-
ChooseColor
When I run the attached program and hit 0 on the numberpad, I get an error saying Project1.exe has caused an error in COMDLG32.dll. Earlier, before I made the CHOOSECOLOR structure global and had it in WndProc, I got the same error with KRNL386.exe. I've made several test programs using the same and different circumstances, and for the most part it just doesn't show up. I have gotten the COMDLG32.dll error again with a test with CHOOSECOLOR global.
- SirCrono6
-
I see you took Salem's advise. :)
You should mention that you're using Windows ME. Perhaps it works under other versions of Windows.
[edit]
http://cboard.cprogramming.com/showthread.php?t=72503
[/edit]
-
It's pretty obvious that this wouldn't (or indeed shouldn't) work on any version of Windows. You can't just pass a CHOOSECOLOR structure without providing any information. You must ensure that at least the first member, the size of the structure, has been set. This member is important as Microsoft may well add members in the future and thus change the size, so older variants of the structure can be easily determined.
Code:
choosecolor.lStructSize = sizeof(choosecolor);
Also, you should clear all the other members just in case they are referenced by the function. So, in all, you need to initialize it like this:-
Code:
ZeroMemory(&choosecolor, sizeof(choosecolor));
choosecolor.lStructSize = sizeof(choosecolor);
For a working example of the Choose Color Dialog, please read this.