Problem with Dialog not showing

This is a discussion on Problem with Dialog not showing within the Windows Programming forums, part of the Platform Specific Boards category; Hi guys. Just this tiny prog I just did to calculate my pay for my job and for some reason ...

  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
    Attached Files Attached Files
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  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);
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  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)
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  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 03: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:
    Attached Files Attached Files
    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?
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  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?
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  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
    Attached Files Attached Files
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  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.
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21