Thread: A problem with a modal dialog box

  1. #1
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186

    A problem with a modal dialog box

    Hi guys. I'm having a problem with a modal dialog box.
    The procedure of the dialog is declared in GameEngine class as so :
    Code:
    private:
       //Modal dialog box window procedure. Enables the player to select a color
       //after throwing either wild or wild four
       BOOL CALLBACK ColorSelector(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
    when I call it through GameEngine class like so:
    Code:
    DialogBox(m_AppInst, "Color Selector", m_Wnd, ColorSelector);

    i get this error:
    error C3867: 'GameEngine::ColorSelector': function call missing argument list; use '&GameEngine::ColorSelector' to create a pointer to member

    The fourth parameter is a pointer to the dialog box procedure, isn't it??
    how come?

    I did what the compiler suggested: &GameEngine::ColorSelector, but i got this error:
    error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'BOOL (__stdcall GameEngine::* )(HWND,UINT,WPARAM,LPARAM)' to 'DLGPROC'

    any one can help ?
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    That's because your callback is a member function of your class - you can not do that, it has to be a free or static function [that is, it must be a function that doesn't expect a hidden "this" pointer passed along to the function]. You would need to find some other way to inform the function which object you are working on.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    i thought of another idea, yet simpler for choosing a color. I will just put some rectangles for the user to click then determine the color

    thanks for your reply
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dialog Box error
    By JJFMJR in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2007, 07:51 AM
  2. Parent of a BrowseForFolder dialog box
    By @nthony in forum Windows Programming
    Replies: 4
    Last Post: 01-08-2007, 02:54 PM
  3. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  4. edit control in dialog box problems
    By Bajanine in forum Windows Programming
    Replies: 11
    Last Post: 11-11-2002, 06:55 PM
  5. Dialog Box Problem....
    By minime6696 in forum Windows Programming
    Replies: 2
    Last Post: 01-08-2002, 08:24 PM