Posts

Showing posts from December, 2006

Conversion macros\inline functions

sometimes you might need to convert (safely) between different Windows data types. for example, consider this: you have a dialog window procedure and you want to handle WM_CTLCOLOREDIT message to change the background color of the edit control. BOOL CALLBACK DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) { case WM_CTLCOLOREDIT: return (BOOL)(GetStockObject(DKGRAY_BRUSH)); } } I followed the instructions from MSDN for WM_CTLCOLOREDIT: "If a dialog box procedure handles this message, it should cast the desired return value to a BOOL and return the value directly." the problem is it works but it gives a warning: Compiler Warning (level 1) C4311. "This warning detects 64-bit portability issues. For example, if code is compiled on a 64-bit platform, the value of a pointer (64 bits) will be truncated if it is assigned to an int (32 bits). This warning is only issued when /Wp64 is used. " I am using VisualC++ 2003 compiler so it seems /w

Using photoshop to create & edit ICO files

To edit & create icons in Photoshop you need an ICO plugin: http://www.telegraphics.com.au/sw/info/icoformat.html After installing the plugin file in the Photoshop directory (installing means just copy the ICOFormat.8bi file into the Photoshop plugin directory so it can load it at startup; mine is: C:\Program Files\Adobe\Adobe Photoshop CS\Plug-Ins\File Formats\ICOFormat.8bi) to create an icon in Photoshop: 1. select your object which you want to appear in your icon with the Magic Wand tool (selection). you might want to adjust the Tolerance factor. 2. go to Selection menu and choose save selection and name the layer Alpha (it can have any name). 3. go to Save menu and now you should have in the list the ICO format available. Remeber 2 things: The alpha channel you created must look like this: you should see the object silhouette in black and the background in white. The icon cannot have in size more than 255x255 pixels (Windows fil

guest book

Although I created this blog just as a place where to keep my programming thoughts so I can review them anytime, since it's a public blog people might come in and want to say something, like Hello. If you have any general feedback regading this blog, you are encouraged to reply it here.

what's this blog for

Hello, I wanted a place where I can place programming things I encounter along my humble programming job I have. It is meant for helping me to save different ideas I should remember but memory is not my strongest point. In fact I dont like to remember things just beacause it is needed so. I prefer to write them down. Physical memory is valuable.

CAtlRegExp Match access violation

if the string you want to match (not the regular expression string) contains characters with code >= 128 then CAtlRegExp::Match() method fails. Here is the fix suggested here: http://groups-beta.google.com/group/microsoft.public.vc.atl/msg/b525c84477676c4f Hi, I was running in the same problem with german umlauts. The algorithm seems to be buggy. To word around that, copy the file C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlrx.h to your project path and make the following changes and include it in your cpp: Line 637 New code: unsigned char* usz = (unsigned char *) sz; size_t u = (size_t) *usz; instead of Old code: size_t u = (size_t) *sz; and Line 1181 New code: unsigned char uchStart = chStart; unsigned char uchEnd = chEnd; for (int i=uchStart; i<=uchEnd; i++) instead of Old code: for (int i=chStart; i<=chEnd; i++) With these changes everthing should work fine. Good luck! Michael