Thread: ChooseColor

  1. #1
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    California, US


    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
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    I see you took Salem's advise.

    You should mention that you're using Windows ME. Perhaps it works under other versions of Windows.


    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Newport, South Wales, UK
    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.
    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:-
    ZeroMemory(&choosecolor, sizeof(choosecolor));
    choosecolor.lStructSize = sizeof(choosecolor);
    For a working example of the Choose Color Dialog, please read this.
    Last edited by SMurf; 11-21-2005 at 02:44 PM. Reason: D'oh, it's lStructSize, not cbSize. Why can't M$ be consistent...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ChooseColor()
    By Elyubarov in forum Windows Programming
    Replies: 1
    Last Post: 04-08-2005, 11:23 AM