Thread: Problem with Dialog not showing

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Problem with Dialog not showing

    Hi guys. Just this tiny prog I just did to calculate my pay for my job and for some reason the dialog just wont show up. Can anybody help?

    Thanks

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The 2nd parameter of Dialogproc should be either a string identifier or a string placeholder generated with, for example, the MAKEINTRESOURCE macro. Either enclose the dialog id in quotes in the resource script or, arguably better, use MAKEINTRESOURCE on the short int id value.

    You may have to set the WS_VISIBLE style for the dialog, but I think you might get away with it with this example.

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    I changed it to this but its still not appearing
    Code:
    DialogBox(hInstance, MAKEINTRESOURCE("DLG_MAIN"), NULL, APP_DlgProc);

  4. #4
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    if i understand what you're trying to do (didn't have time to download) take out the quotes from DLG_MAIN

    Code:
    DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, APP_DlgProc);

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The syntax provided by Leeman_s is one of the two ways I was referring to ie use MAKEINTRESOURCE on the short int id value.

    For future reference, resources can be assigned a short int (WORD, 0-65535) id numeric value or a string identifier, not both. If a function, such as DialogBox, requires an 'LPCTSTR' type then you should, as I have previously mentioned, use either MAKEINTRESOURCE on the numeric id to convert it to the required type or just use the neat string identifier.

    Sorry for not being clearer earlier.

  6. #6
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    took out the quotes, still not working. DLG_MAIN is the identifier. I even tried
    Code:
    BOOL b = DialogBox(hInstance, MAKEINTRESOURCE(104), NULL, APP_DlgProc);
    (DLG_MAIN is defined as 104)

  7. #7
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Try setting the WS_VISIBLE style for the dialog. Also, make sure you remove the *.aps file prior to rebuilding. If it still fails after that, ditch the project and create a new one; sometimes msvc just acts like an arsehole, although i'm sure the pro's and more knowledgeable programmers of these board have a more descriptive technical term for that kind of intermittent behaviour.
    Last edited by Ken Fitlike; 12-29-2002 at 04:28 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Since I was bored, here's one that worked for me on win9x/2k:
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Sweet that worked. Thanks. What changes did you make? Just so I know in the future...what mistakes did I make?

  10. #10
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Ok, I tried your program, (just added a couple of things that dont affect anything) and it for some reason crashes when you press 'Calculate' I debugged it and it exited with code 1 which I looked up using ErrorLookup utility and it said that error code 1 meant 'Incorrect Function'. Whats wrong?

  11. #11
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>What changes did you make?<<

    Other than use MAKEINTRESOURCE on the dialog id, nothing. I did create an entirely new project as described above, so I suppose that the problem lay with that particular project and msvc.

  12. #12
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    So...do you know what the other problem is?

    Here's the project

  13. #13
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    oops silly me. Had EndDialog() after Calcualte(). Its all good now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem creating a Dialog Box
    By Dark_Phoenix in forum Windows Programming
    Replies: 1
    Last Post: 05-30-2009, 08:16 AM
  2. Replies: 3
    Last Post: 05-03-2003, 12:04 PM
  3. Problem showing Moduls ...
    By gardenair in forum C Programming
    Replies: 1
    Last Post: 04-14-2003, 02:44 PM
  4. Common Dialog Boxes problem
    By face_master in forum Windows Programming
    Replies: 6
    Last Post: 07-29-2002, 05:01 AM
  5. Dialog Edit box v's WindowsText Problem
    By simham_uk in forum Windows Programming
    Replies: 2
    Last Post: 06-10-2002, 07:28 AM