If you want need a 64-bit version of this module for Google App Engine, or another project, you can run into a couple of issues. Sticking to 32-bit versions of Python and PIL avoids these issues so that may be the best direction for newbies.
The downloads on the PIL site are for 32-bit versions of Python which means that you hit runtime issues as soon as the Python script files attempt to load the 32-bit libraries into 64-bit Python. Annoyingly the installer is unaware of the architecture for the Python installation it finds and will leave you with a broken PIL install. Just uninstall it from Control Panel. My first thought was to try an build from the sources but I figured someone has run into this problem.
After some searching I found a site which offers pre-built versions of many Python modules for 64-bit architectures including PIL. If you are in any way concerned about performance, or security a better solution might be to build from source or use versions from a company offering supported versions.
I downloaded the version for Python 2.5 and then discovered that it would not install. What is interesting is that the 32-bit installer was able to find my 64-bit Python, but the 64-bit installer was unable to find it.
After some more searching it turns out that the installer takes it’s cue from a key in the registry and the Registry virtualization in Windows x64 was confusing it. To resolve the issue I had to export the “HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\2.5” key, remove the “Wow6432Node\” string using a text editor, and re-import the key so that it was at “HKLM\SOFTWARE\Python\PythonCore\2.5”.
After doing this the 64-bit installer for PIL detected my Python installation and I was up and running.
Working with Win32 listbox controls is fairly simple but the code can be quite convoluted and get tedious after a while. I decided to use the WTL library to simplify some listbox handling code but it wasn't initially obvious how to do this. Hopefully this blog post will help someone else understand the basics.
Manual message processing
The majority of Win32 programming involves working with messages of various types that are basically #defines in header files. The Listbox control responds to messages like these:
LB_GETCURSEL (get the selected item)
LB_DELETESTRING (delete a string)
LB_INSERTSTRING (add a string)
..but you also have to make sure you use the correct WPARAM and LPARAMs.
The resulting code for adding an item to a Listbox looks like this:
As you can see this requires a lot of work that I’ve grown tired of with years of C# coding.
Simplifying with WTL
It is best to thinking of simplification here with a view to the long term. You are writing C++ so this is not as straightforward as WinForms or WPF.
First of all you need to create a member variable in your window class. I'm assuming you have installed the WTL AppWizard into Visual Studio and have created a Dialog application, but the steps are similar for other types of window. The code looks something like this:
class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>, public CMessageFilter, public CIdleHandler
{
private:
CListBox m_ListBox;
public:
enum { IDD = IDD_MAINDLG };
....
As you can see we have private called m_ListBox that we can reference elsewhere. Next an instance of CListBox needs to be attached to a Listbox that has been added to your dialog resource file. You do this in the OnInitDialog() method:
The IDC_LIST1 parameter is the name defined in my resource file and messages are now being routed between the instance variable and the actual control.
Now in the event handling code it is possible to call the AddString() method without having to worry about message types:
Microsoft made it very simple to get information about the displays available to Windows with the Screen class in Windows Forms. Using this class you can identify the primary screen, and get properties like size from any display device.
For anyone developing an application which supports multiple monitors the Screen.Bounds property may be useful in finding screen offsets. If you have multiple monitors attached try the Get Current Screen Info button on your secondary display.
Download the C# sample code and binaries to explore further. Like all good API examples I have omitted error handling ;)
Recently I was migrating several Subversion repositories from a Windows server over to a Solaris one and ran into a rather frustrating issue. Actually it's quite an interesting problem, but was frustrating due to the size of the repositories involved, and my fear that repositories were borked.
It all started with my decision to fire up PowerShell rather than cmd.exe to do the initial dump of the repostories. The following code was executed to dump a repository:
svnadmin dump repositorypath > repository.dump
All seems to go to plan but this is where a silent corruption of the dump file occurs. Not suspecting that the dump file was malformed, I copied repository.dump over to the Solaris box. I issued the standard commands to create a new repository and load the dump file:
After executing the second command I got an error from svnadmin complaining about a malformed header on the dump file:
svnadmin: Malformed dumpfile header
My first instinct was to re-copy the dump file and try again, but I thought I should dump and load the repository on my Windows server. Lo and behold this fell over with the same error. At this point I was thinking something was really wrong with my SVN install and repositories, but then I stumbled on this newsgroup discussion.
It turns out that my problems were the result of how Windows PowerShell handles binary data that is piped on the command line. I really want to look into the details of this, but it would appear that the new found ability to pass .NET objects on the command line can mess with old school expectations of how the command line works.
After a very quick install on a Dell XPS M1710 laptop, and a few hours of messing around, I have come to the conclusion that this is going to be the best release of Windows yet. At the same time, it's not very exciting for the alpha geek in me. Perhaps it is good to have regular stable releases and leave the fireworks to user applications?
Before I list some of the things that I like, or didn't as the case may be, I have a tip for anyone trying to get Aero running on the M1710. For some reason, Beta 1 doesn't have drivers in the box for the NVIDIA GeForce 9700M GT. Just download the mobile drivers from the NVIDIA website and install the Vista version using the "Have a disk..." option. Ignore any warnings about compatibility, the Vista drivers are close enough and I would expect NVIDIA to release some beta drivers for Windows 7.
What I liked
Performance improvements
This has been a problem for a large number of Vista users and Microsoft have made big strides according to my unscientific testing. Little things like searching for programs on the Start menu is noticeably quicker than Vista on the same machine. No doubt anti-virus vendors are working on ways to reduce the performance.
System protection
You can now reserve a percentage of disk space to storage of old versions of user and system files (just like Recycle Bin has done since Windows 95). This is something I would want to increase for someone like my Mum.
Task bar application integration
The thumbnails introduced in Vista are now more useful since you view individual tabs in an application like Internet Explorer 8. When you have a long running task like a file copy, the progress is shown directly on the task bar when minimised.
Easier wireless network access
Clicking the network icon in the task notification area now shows a list of network connections. This makes it much easier to connect, and is similar to the experience in Apple OS X.
Notification area grouping
I find the pollution of the task notification area to be a real pain. Every application thinks it belongs there and needs to be visible. With Vista you could force some items to be hidden, in Windows 7 they are grouped under a single icon. It only takes simple stuff to improve the overall experience.
Requires more thought
Taskbar application identification
So is Internet Explorer running, or do you have a shortcut pinned to the task bar? It's hard to see on the task bar, but I can see the rationale for this design decision. It would be nice if there was an option for clearer identification, such as the name of the application appearing on the task bar. I suspect more use of Windows 7 will result in a change in my expectation for this aspect of task bar operation.
IE 8 rendering issues
There is a still a lot of work to do here. I suspect that a lot of people will enable compatibility mode to enable sites to load. One site with problems was GMail (I'm using Google Apps for e-mail).
Almost everyone I know complains about the performance of their computer when an anti-virus (A/V) product has installed, and thinks they need more memory or a faster processor. Wrong! You need to get a faster hard disk, or disable scanning of certain files.
You'll see from Task Manager that memory and other resources are plentiful on a modern computer, but page faults and other disk I/O (hidden by default) are occurring at very high levels. Disk I/O is still slow on modern computers and you'll get better performance gains from improving this aspect.
Most A/V software has settings that let you control:
Scanning inside archives like .zip files. Only files downloaded from the Internet or via other media are major threats. Consider tweaking these settings to avoid scanning too deeply into archives, or only scan in risky locations (external drives or downloads folder).
Directories that excluded from automatic scanning. Real-time protection is valuable for certain users, but there may be files that a user must access very frequently. These include databases or virtual machines. Consider disabling real-time scanning of these files/folders.
Making changes to these settings will benefit performance, and security can still be maintained to a very high level. You are running Windows under a normal user account, aren't you?
Relog.exe isn't some new fad amongst Bloggers - it's a tool from the Windows Resource Kit that helps you convert performance counter logs produced by Performance Monitor (perfmon.exe) into common text formats such as CSV. Earlier today I ran perfmon.exe and forgot to change the logging format from the default binary format to CSV. I searched the Web for a tool to convert to a format acceptable to LogParser and I found Relog. This utility saved me having to redo five hours of monitoring to get the data that I needed to analyse. Cheers to the Resource Kit team!
Syntax: relog input.blg -f CSV -o output.csv
Where can I get it? Download relog.exe for free from the Microsoft Download Center (requires a genuine Windows installation).
When I attended TechEd Europe in July 2002 one of the most interesting sessions was presented by Steve Riley. This was an overflow session presented during lunch, and I thought it would be interesting to check out something I hadn't planned to look at. The session covered use of IPSec, and the presentation style was very engaging. Rather than discuss technology in search of a solution, Steve solicited a number of scenarios from the audience and presented the hidden power of IPSec.
Many years pass, and I spot a blog entry from Jesper Johansson, where he book that is co-authored with Steve. I ordered it almost immediately from Amazon.com and I wasn't let down. This book is a gem for any developer who is trying to understand infrastructure security and the capabilities of the Windows platform. It's a fairly easy read and only delves into the necessary detail, avoiding coverage of mundane technical details that are presented on TechNet. To get the most out of this book you'll want your own test rig set up on virtualised hardware (think VMWare or Virtual Server) with a domain controller, certificate services, ISA Server and the like.
It's really hard to fault this book, maybe it should be available in hardback?
Microsoft have been collecting crash data using a system known as Windows Error Reporting ("Dr Watson") since the release of Windows XP (and possibly earlier). When a usermode error occurs in an application, a minidump and other pertinent is extracted. The user is then prompted as to whether they wish to report this information. After the reboot that follows a kernal mode error (bugcheck) you are prompted to send this information to a secure Microsoft server.
If the information is reported, a back end process does some analysis to see if it matches other error messages and might offer you some feedback. I've certainly benefited from this in the past, as a buggy D-Link driver caused numerous bugchecks (blue screens) and WER pointed me to a source of newer drivers.
I've observed the use of this feature by many people and there seems to be a fairly even split between those that send the crash data and those who cancel out. It appears that many people don't provide feedback because they fear Microsoft getting getting access to private information. This fear is justifiable, but I think that Microsoft could encourage more people to submit bug reports if they improved their UI design and branding.
The current implementation on Windows XP and 2003 has these faults:
The UI is simplistic. Although it offers some information on why you might submit, it fails to reinforce the benefits.
Technical information cannot be easily copied to the clipboard. It would also be good to be able to save this to a file.
There is little help provided to help decipher the technical information provided.
Lack of Windows UI integration. If you are using a shared computer, an administrator cannot see all of the issues which have been submitted to spot problem applications. The settings for crash reporting are hidden away from most users in the system applet.
If you are offline you cannot submit a report.
Thankfully there are some improvements on the way. Windows Vista will include support for centralised crash reporting management, and improved UI. I will post a review of this in Beta 2 soon. Users of Office 2007 will notice that the bug and usage data collector is more advanced, and allows you to submit later. This is enabled when you sign up for the application improvement programme when prompted in the task notification area.