Thread: window differentianting problem

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    9

    window differentianting problem

    Hi. I'm making a program that is initalized by a Dialogue box:
    Code:
      DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN_DLG),
                  hWnd, reinterpret_cast<DLGPROC>(DlgProc));
    Once I receive all the input from the user, I want to open another DialogBox and print the results in there.
    The problem is, once I open the new DialogBox inside of the other Dialogbox like this:
    Code:
    HWND hWndResults = GetDlgItem(hWndDlg, IDC_RESULTS);
    DialogBox(0, MAKEINTRESOURCE(IDD_RESULTS_DLG), hWndResults, reinterpret_cast<DLGPROC>(DlgProc));
    I need to be able to compare in the WM_INITDIALOG: whether this is the parent window or this is the window spawned inside the parent window (idd_results_dlg). What I eventually want to do is sprintf information into the results in real-time while the program is working. If there is a way I can make this work or an easier way to implement this, please let me know.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Just use SendMessage() or PostMessage() to send the data to the dialog which displays the data. This would solve your problem of displaying the results in real-time.

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    It's more usual to use separate dialog procedures for each dialog and I'd advise you do this. This immediately eliminates the problem of dialog box identification.

    But, to answer your question of:

    >>I need to be able to compare in the WM_INITDIALOG: whether this is the parent window or this is the window spawned inside the parent window<<

    here are a couple of suggestions for how you may be able to do this:
    • Use GetDlgCtrlID to retrieve the id of the dialog box based on the handle passed to your WM_INITDIALOG handler in your dialog procedure.
    • Use DialogBoxParam to create your modal dialog boxes and use the lParam parameter to pass information to identify each dialog - this value will be passed as the lParam parameter to your WM_INITDIALOG handler.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Also, if you want the message loops of both dialogs to be running at the same time, you will have to make the second dialog box modeless or call DialogBox[Param]() in a seperate thread.

    gg

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    9
    Thanks for all of the suggestions. I tried making a second dialogue procedure, but I could not get the syntax of it correct. My compiler (C++BuilderX) kept rejecting the name of the second dialogue procedure.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Just name the two dialog procs DialogProc1 and DialogProc2. The names of the procedures shouldn't matter here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  2. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 06:57 AM
  3. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. How to change window style at runtime?
    By Mr. Bitmap in forum Windows Programming
    Replies: 5
    Last Post: 06-09-2002, 04:49 PM