Saturday, May 3, 2008

MS Access: Changing the Color Scheme programmatically

Microsoft Access Microsoft Office 2007/2010 comes with 3 colour (color) schemes. Users can easily change it but when you deploy an Access application under the Runtime your users have no way to set the colour scheme as the application’s options are not available.
(Article and Code Updated 31MAY2011.)

Luckily for us, Office 2007 stores the global colour scheme setting in the registry under:
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\Theme
and Office 2010 in:
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Common\Theme

The values being stored under that key are:

  1. Blue scheme
  2. Silver scheme
  3. Black scheme

With this information, we can easily both read and set the colour scheme. The only caveat is that I could not find a way to notify Access to reload the setting automatically once it is changed, so users will have to restart the application before the change becomes active. A small price to pay but if anyone has a better idea, please let me know.

To write the new value to the registry I use a set of WIN 32 APIs that are more flexible than the default ones provided in VBA.

Office 2007 Colour Schemes

You can download the sample database as it contains all necessary files, including the definition for the Win32 API functions.

DownloadDownload the ColorSchemeV1.3.zip (31KB) containing the ACCDB database.

The sample also contains some code to restart the database. This is the subject of another post: Restarting and compacting the database programmatically.

Improvements/uses:

  • Find a way for Access to reload the settings without having to restart the application.
  • Use the knowledge about the current scheme to change the other colour settings in the application (or even adapt the form’s theme).

Updates:

  • 31MAY2011: added support for Office 2010.

References:

8 comments   |   Filed under :  Database,MSAccess,Programming

Thursday, May 1, 2008

MS Access: Modal Dialogs with Transparent Backgrounds (redux)

Microsoft Access Microsoft Access Team made an interesting post and a follow-up on how to add a transparent layer that cover the screen to focus the attention of the user to a login form or other important popup window.

The trick is to use some WIN 32 API calls to modify the transparency of a standard MS Access form made to cover the screen.

The effect is quite neat and I thought I would try it and make a sample database for others to tinker with it.
My version allows you to chose between covering the whole screen or just the main Access window and it will test if it’s running under a Remote Desktop Terminal and disable the layer in that case.

The transparent layer covering the main Window onlyThe transparent layer covering the full screen

Update 07MAY2008

Following Rob’s improvements I made another sample database that incorporates his code with a few improvements:

  • I added the LightBoxForm.LayerToFullScreen property so users can choose explicitly how they want the layer to be shown.
  • I moved the code to hide the layer into a Hide() sub so you can just show/hide the layer using LightboxForm.Show and LightboxForm.Hide.
  • I changed the Form’s Resize event code in the LightBoxForm class to avoid flickering: resizing the form within its Resize event actually trigger the Resize event again a second time which causes flickering.
    I simply modified the code to make the form totally transparent (opacity of 0) the first time the event is fired and assign it the expected opacity when the event handler in re-entered.

Samples

There are now 2 sample databases. Ech zip contains a Microsoft Access 2007 ACCDB file and its conversion to Access 20001 and Access 2002-2003 MDB but please note that I have not been been able to test those in older version of Access and that form transparency doesn’t work in Operating Systems older than Windows 2000.

DownloadDownload TransparentLayer02b.zip (138KB), recommended version
(improved, more flexible version, based on Rob’s updated article).

DownloadDownload TransparentLayer01b.zip (122KB), original version
(simple code, based Rob’s original article).

Troubleshooting

  • If you are getting security warnings: make sure that you open the database from a Trusted Location or you will receive a security prompt. If you don’t know how to do that, check these steps.
  • If the layer appears on top of the login form instead of behind: make sure that the top-most form has ist Modal properties set to Yes and the frmLightBox form has its modal property set to No.
    If you improve on it, please let me know and I’ll post it here for all to find.

  1. A specific version for Access 2000 now included in the archive (updated 25JUL2008). 

19 comments   |   Filed under :  Database,MSAccess,Programming

Sunday, April 13, 2008

“Apple’s OS Edge Is a Threat to Microsoft”. Really?

BusinessBusiness Week has a recent article where the author foresee the demise of Windows in favour of Apple’s OS.
Reading it, I couldn’t help thinking I was reading one of these overenthusiastic 1925 popular-science article promising us that within just a few years we would all use our own flying car to get to work.
Yeah, right, mine is parked right under my window.

The basic premise of the article is that Apple will attack the corporate market through the back-door, using the iPhone and its forthcoming development platform.
The author contend that development to the iPhone will drive interest in the Mac and allow Apple to displace Windows by offering more business-related applications that would eventually not require Microsoft’s OS running side-by-side in your Mac, freeing you of the dominance of the evil empire.
Please read the article first. Done?
Hmmm…
Ok, let’s see…

First, let’s be nice: if Apple want to eat at Microsoft’s dominance of the OS market, then all the better: more competition will drive innovation and choice, which is always nice.
There is certainly some truth to the idea that Apple could offer some useful tools and technologies to the corporate world.

The problem is that author of the article was a bit too much of a Mc Fanboy(TM) to make his arguments compelling.

Let’s start direct quotes from the article.

Speaking of the ability of the Mac to quickly switch from a Windows application to a Mac by using a keyboard shortcut:

“Windows users, in the very near future, will be free to switch to Apple computers and mobile devices, drawn by a widening array of Mac software, without suffering the pain of giving up critical Windows-based applications right away.”

Useful as it may be, it’s forgetting one thing: if you need to be able to run your windows application under a Mac, you will need to give Microsoft money for the Windows license, making the newly found convenience of running the two OS together seamlessly a fairly expensive one, both in terms of computer resources and money.
While it will interest a lot of people and they may use their windows apps on Apple hardware is this really compelling enough to make it a viable migration path?

About the new Mac OS kernel:

“That kernel has proved easily adaptable across the entire Apple product line, from highly complex servers all the way down to the relatively simple iPod Touch. Such modularity allows Apple to add whatever functions are necessary for each product environment—all while maintaining cross-product compatibility.
By contrast, Microsoft has held on to an OS tethered to the 1980s, piling additions upon additions with each upgrade to Windows. With last year’s arrival of Vista, Windows has swollen to 1 billion bytes (a gigabyte) or more of software code. The “Mach” kernel of the Mac OS X, however, requires less than 1 million bytes (a megabyte) of data in its smallest configuration, expanding modestly with the sophistication of the application.”

All this is so silly and skewed that I wonder where to start.
First, kernel size is irrelevant: a basic kernel functionality does not make an operating system. Additionally, I doubt that we’re comparing the same functionality and for desktop or server applications this is utterly irrelevant.
For small devices Windows has its own flavours and they can quickly be deployed to almost any hardware with minimal effort.
Applications built for Windows built for mobile devices can be ported to Windows without too much trouble, and vice versa. Whatever platform you’re developing on, applications for small hardware are always an exercise in compromise: there is no way that you can just recompile an app for a different target and have it just work beautifully in any device. A mobile app must take care of power requirements, limited screen estate, memory and CPU limitations and specific usability issues like the presence of a touch-screen instead of a keyboard and mouse.
The point is that you have to take the platform into consideration when crafting software. Besides, using .Net makes it fairly easy to develop applications for any flavour of Windows. Additionally, whether the OS under the XBox is different or not from the desktop version of Windows is also irrelevant: you can develop games under the XNA platform that compile and work just the same under Windows as they do on the Xbox.

Now, for the argument regarding the “additions upon additions” made upon Windows that contribute to its bloat, it’s an easy shot to make and an unfair one: Apple has had no regards for its legacy applications and since its primary market was consumers, it could get away with making each of its major OS release incompatible with the previous one.
We can argue whether it was a good thing for Microsoft to keep all the quirks from previous releases of its operating system alive but we must not forget that in the corporate world, Windows has close to 100% market share on the desktop.
What that means is that Microsoft could not afford not supporting business applications across versions. it would have been suicidal to even envisage dropping compatibility.
If Apple ever get into that corporate market above a few percent it will have to guarantee compatibility between versions of its OS and programming tools if it wants to have any chance at being taken seriously at all.
When companies spend money developing an application that is critical to their business, they don’t want to hear about its supporting OS becoming incompatible every couple of years.
Apple would have to support and maintain compatibility for at least 10 years for every major OS version. So far Apple hasn’t shown that it was capable of that type of commitment.

Amipro 3.1 on my computerA small digression.
A couple of weeks ago I found some old files of mine on a floppy.
They were Ami Pro files, made at a time when Ami Pro 3.1 was the best word processor around.
Problem was that I could not safely open these files any longer: filters for various word processors would mangle the complex layout of the pages, making them un-usable. Out of curiosity, I found a full version of the original Amipro 3.1.
I had no expectations of being able to run that setup package. After all, Ami Pro 3.1 came out in 1994, before Windows 95 was even released!
Well, I clicked on that setup.exe file and watched the installation process go through… Everything went fine.
Surely, I thought, there is no way this is going to run under Windows XP. It’s going to crash for sure.
I double-clicked on the 16 colour icon and lo and behold, the whole thing actually ran! Flawlessly!
I was able to open my old files without any issue, save them under another format. Everything worked, miraculously.
That application was written at a time the Internet didn’t even exist yet I was able to install and run it without problem on a current operating system.
Back to our regular schedule.

“Despite Apple’s relative scarcity on corporate desktops, Mac laptops are already well accepted within the enterprise, with a market share of more than 20% and growing. For business travellers, the new MacBook Air, some three pounds lighter than comparable Windows-based laptops, already offers one huge advantage.”

First, Apple has a almost 20% market share on overall laptops sales only, not corporate sales.
Second, that figure is for the US only. Apple’s laptop market share in the world is certainly not bad, but it’s a quarter of that figure, making adoption of Apple laptops outside the US very small indeed.
Third, while Apple laptops are certainly sexy, they bring their own issues to businesses: lack of in-house serviceable parts, issues with making them fit into a complex infrastructure, hardware and software compatibility problems.
Bringing Macs into your organisation can be painful. Of course, it’s never impossible, but beyond simple setups, it takes time, energy and money to make stuff work seamlessly.
So I contend that, unless you have a serious commitment to Apple, most of the Macs getting into companies are for simple usage: fetching emails, browsing, making presentations and maybe Photoshop, although it seems that the application that was once the sole reason for some to use macs is now going to switch side, at least for a little while.
For Macs to become a first-class corporate platform would require that Apple makes a very serious commitment to cross-platform development to make applications work on Windows as well.
I seriously don’t think that the ability of Macs to run Windows side-by-side will do much: as mentioned above, the expense incurred offers no real benefit to businesses and having to support both platforms would increase the cost of ownership because of the upfront cost of buying and installing multiple OS, 15% higher average cost of Apple laptops compared to other similarly specified laptops and the cost of maintaining and supporting multiple hardware and OS stacks.
Slickness can only get you so far I suppose.

“While Mac desktops offer a growing number of superior features over Windows desktops”

Seriously dude, what superior features?

“Apple’s recently introduced Leopard servers compete in a market of unhappy Vista server buyers where Microsoft’s market share is only 40%. Leopard has a decent chance to expand from its small beachhead.”

Huh? Vista servers?
WTF is that?
You can’t be talking about Windows 2003 because it’s actually a rock-solid platform and there isn’t much to complain about.
Windows 2008 is just coming out and it looks just as promising.
Apple has some seriously nice server hardware, it’s so beautiful to look at all this engineering that it gets me all hot and bothered.
Seriously though, on the server side, Leopard would not be in competition with Windows but with *nix.
Server-side applications like ASP, Exchange, Sharepoint, SQL Server and the myriad other Microsoft-only server software will only work on Windows.
Apple is not going to compete as a platform for hosting these which means it will host services traditionally found on Linux/Unix/BSD systems.
In that *nix camp Apple would certainly be a good contender, although it would have to prove that it can compete with the low license and hardware cost of its competitors and offer more.

One more thing to remember: Apple is in the hardware business: it uses software to lock people into its hardware business.
I’m all for competition but at least using Linux or Microsoft products doesn’t lock me into a single hardware/software platform pair: I have orders of magnitude more choices when it comes to my servers, desktops and laptops than what Apple can offer me.
Apple products may be slick and beautifully engineered but they certainly don’t offer more freedom: chose an iPhone and get stuck with a single network provider, buy an iPod and get stuck with iTune, buy a mac and get stuck with Apple, limited software offerings, no serious games and limited hardware support.

One other thing to keep in mind is that Microsoft has acquired a huge weight in terms of software development power: new technologies have been pouring out of Redmond at a pace that is impossible to follow.
The number of developers and companies able to develop software for Windows platforms is wayyy above what Apple can dream of at the moment (we’re talking about millions of developer making a living off Windows).
Apple will need to make serious efforts to woo the huge amounts of developers it needs to bring enough business and non-business applications to its platforms before it can become a serious competitor to Windows in the corporate world.
Whether Apple has the capacity and will to do that instead of remaining a consumer-oriented company remains to be seen.

That being said I wouldn’t mind developing software for Apple platforms. I would love to be able to use a generic “surface laptop”, a sort of larger iPhone that could be used by sales people for taking orders and showing off new products.

Anyway, the point of all this was simply to offer a modest reality-check to an article that should have been a bit more measured and balanced in its fanboy-ish enthusiasm.

1 comment   |   Filed under :  Business,Reviews,sysadmin

Sunday, February 10, 2008

WPF and Silverlight: it will take a while…

technology01.pngDecoupling the User Interface from the underlying code has been one of the holy grails of application development. Layers of indirection and new patterns have been invented over time to try to separate what the user does from the back-end data. It’s been a long and difficult journey but WPF is the last attempt at completely separating the user interface from the gut of an application, leaving graphic designer do what they do best and programmers do what they do best.
I think this disconnect has actually hindered the adoption of WPF to a great extent.
I also believe that Silverlight, while showing great promises, is going to take a long time to get off the ground.

SilverlightGood graphic designers who work on User Interfaces are too few and far between, and large organisations will take time to get staff with a sufficient level of expertise to be useful in developing meaningful WPF/Silverlight applications.
Until now, the bulk of the development effort was done by developers. Most ISV only have developers onboard.

As far as I can tell, it seems that main reason behind this slow adoption is that WPF/Silverlight has only been noticed by developers and they don’t know what to make with it.
WPF/Silverlight are not really developer-friendly: the development infrastructure is there but we’re left with a blank canvas and nothing to drag and drop onto it.

There will be a great gap, probably lasting a few years, before there are enough experiments in these new user interfaces that some useful lowest common denominator can be exploited by non-designers.
We’ll have to wait for tool vendors to provide the bulk of user interface blocks and for a few new patterns to appear before all the designer-challenged developers like me can make decent interfaces without requiring a professional graphic designer in their midst.
In the mean time, we’ll probably have useless, but pretty, applications, some useful, but ugly ones and a lot of people scratching their head trying to couple the designers and the developers in a working relationship.

2 comments   |   Filed under :  Musing,Programming

Wednesday, January 30, 2008

MS SQL Server Express: a good choice?

technology02.pngMicrosoft SQL Server comes in many editions, ranging from completely free to use and distribute to versions costing tens of thousands of dollars.
For small businesses, or when you can live with the limits imposed, the Express edition is one option to consider.

SQL Server logoHere are some reasons why SQL Server Express may be a good choice:

You’re upsizing an Access database

SQL Server is the natural extension of upsizing an existing Access database. It work automagically with minimum effort providing that you followed some simple good-design rules from the start.

You’re future-proofing your needs

Because SQL Server comes in many flavours, you know you -or your customers- can upgrade to a more capable (albeit more expensive) version in the future if needed.

Very flexible

As usual with a lot of Microsoft development tools, SQL Server will happily let you shoot yourself in the foot by providing you with a fairly easy way to treat your database as a complete development platform.
It’s good in the sense that you have interesting tools and capabilities included in the server, and it’s bad for the exact same reasons.
I tend to prefer database servers to be just that: data repositories, and I’m not too fond of relying on specific, non-standard features of a particular database system, but what do I know.

Excellent out-of-the-box development support

Deep integration with .Net and Visual Studio, without any effort, Microsoft saw to that of course.
In some cases, such as LINQ to SQL, it’s almost the only real choice, although the other database vendors are working hard at the necessary providers, so that lead should be short-lived.
There is something to be said about developer productivity: you have to give credit to Microsoft for making their tools well integrated and usable from each-other. What it means is that for small developer shops there is much to gain in surrendering to this “ease of the default”.
Of course, it’s a double-edged sword, but having a complete development infrastructure work out of the box is certainly a big help, and if you don’t like it, you’re still free to chose something else.

Lots of tools

With SQL Server Advanced Services, you also get Server Management and Reporting Services. These are great tools made available for free.
The only missing one for SQL Server is the Reporting designer. While the reporting service means that you can use existing reports, only SQL Server Standard and Enterprise have it.
There is an option for developers though: the (nearly free) SQL Server Developer edition is in fact the same as SQL Server Enterprise, without the license to use in non-developer or tester environment. This means that as a developer, you can create and distribute your reports to be used by your customers who will be using SQL Server Express.

Did I mention it’s free?

db_status.pngAll this is free, as in beer, not as in liberty though.
For commercial applications targeted at small businesses, SQL Server Express is a really good choice: you can distribute it without problem, the customer gets all the tools, can easily find outside support, and they can always migrate to a more beefy version if their needs grow, all that without having to depend on you.
So it sort of offers customers a kind of freedom that they wouldn’t have with other choices.

Of course you can get that with other database systems, although you have to be careful which Open Source one you choose: I recently decided not to use MySQL any longer for the simple reason that it’s too expensive and restrictive in a business environment, at least for the kind of work I do.

Why would you not want to use SQL Server Express?

You don’t want to depend on Microsoft

That can be a good reason enough sometimes. There is nothing preventing Microsoft from crippling SQL Server Express in the future to force users to move to a paying version early.
I suppose that whatever database system you use, even Open Source ones, there is always the possibility that the company supporting its development goes bankrupt, the Open Source projects goes dead or decides to go in a direction that doesn’t suit you..

It’s only supported on Microsoft OS

True, and that’s a good reason to chose something else.
There is a hidden cost in SQL Server Express: it needs to run on a Windows machine, and that’s not free, although SQL Server will work on older Windows 2000 machines and Windows XP which are arguably not expensive.

Your database needs will exceed SQL Server Express specifications

If you think any of your databases will grow beyond 4GB or that it will get busy and you need all the RAM and CPU you can get, then SQL Server Express is probably not for you as it will only use 1 CPU and 1GB of RAM at most.
If your needs go beyond that, then you’ll have to move to a paying version.

Upgrading can be expensive

It’s true that moving to the next cheapest upgrade of SQL Server Workgroup will cost you about US$700 for a 5 user license. The limits imposed on the database are much higher (2 processors, 3GB RAM and no size limit) but if you need more clients / or higher limits, then the expense will grow quite fast, and you’ll have to manage those hateful client access licenses.

Your needs are more modest

We haven’t talked here about single-file/single-user database systems. These databases don’t user resident services and are usually meant for more limited needs, sometimes allowing only a single user to be connected.
The footprint of these non-server databases is a lot smaller, typically only requiring a single dll or a handful of files to be installed.
They are extremely useful for desktop application that do not really require multi-user support or advanced security features.
Here again, Microsoft offers SQL Server Compact, which, despite the name, doesn’t have much to do with the other SQL Server editions. This one is also free, but has a limited feature set and only allow single-user access as it is meant to be a lightweight database and works well in limited memory environments such as those found on mobile devices.
SQLite logoOf course, here again there is a lot of competition: Thunderbird, SQLite, MS Access and VistaDB (for embedding into .Net applications, not free) to name a few.

These are pretty good times when it comes to databases: we get more choices now than we ever had.
As usual, choosing a database as a back-end for your products isn’t easy: you need to consider cost, licensing, support and the future.
There isn’t a single database system that will meet everyone’s needs for all types of use, so choose carefully.
SQL Server Express is a very good contender in that market. It should not be dismissed out of hand because it’s from Microsoft, in the same way that PostgreSQL shouldn’t be dismissed because it’s Open Source.
Just use the tool that best answers your needs for your particular circumstances.

References:

Add comment   |   Filed under :  .Net,Database,Programming

Next Posts Previous Posts


about

Renaud Bompuis
This is a simple technical weblog where I dump thoughts and experiences from my computer-related world.
It is mostly focused on software development but I also have wider interests and dabble in architecture, business and system administration.
More About me…

My Google+ Profile
Follow me on Google+

My StackOverflow Profile
My (sporadically active)
StackOVerflow account

Most Recent Posts

Categories

Links

Feeds