Results 1 to 4 of 4

Thread: Confused ? getting the hWnd

  1. #1
    Guest

    Question

    I am making a program for my friend in C++ using MSVC++ 6.0.

    it is not a MFC(he doesnt want runtimes) app.

    how do I get the hWnd of an item in a resource file I have.
    it is called
    res.rc it has an Icon and a Dialog box,

    how would I get the hWnd of this??
    I am pretty sure I can show it using ShowWindow, but I just dont know how to get the hWnd,

    Thanks,
    Dennis Wrenn

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    When you create the window using CreateDialog or equiv., it returns the hWnd of the window. You need to keep this in a global variable of something like that.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    huh?

    what do you mean?

    I made the dialog and added it to a resource file,
    how do I get the hWnd of that and show it?(the window)

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The resource file only stores a template for a window. You have to create a new window for it. MSDN has a full example project, but this is the gist of it: Create a WndProc, with format
    Code:
    BOOL CALLBACK WndProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
    Then, create the dialogue box:
    Code:
    INT_PTR DialogBox(
      HINSTANCE hInstance,  // handle to module
      LPCTSTR lpTemplate,   // dialog box template
      HWND hWndParent,      // handle to owner window
      DLGPROC lpDialogFunc  // dialog box procedure
    );
    For the template, use MAKEINTRESOURCE(IDD_YOUR_DIALOG_ID). Pass the WndProc for the dialogue box procedure.
    Here's a full sample project: http://msdn.microsoft.com/library/de...in_generic.exe
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width