Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. small ques about handles

small ques about handles

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    r i s h a b h s
    wrote on last edited by
    #1

    dear all, how can i get the handles of controls present in my dialog. :confused: thanx

    _ 1 Reply Last reply
    0
    • R r i s h a b h s

      dear all, how can i get the handles of controls present in my dialog. :confused: thanx

      _ Offline
      _ Offline
      _crs_
      wrote on last edited by
      #2

      hello, I don't know exactly what you want but: 1. if you are programming MFC and you need a CWnd pointer to an edit box(his resource id is for example IDC_EDIT1) or any other control in your dialog (dialog1) : dialog1.GetDlgItem(IDC_EDIT1); 2. in old windows programming style GetDlgItem(dialog1, IDC_EDIT1); where dialog1 is a handle to your dialog and IDC_EDIT1 is the resource id of the control for both functions the return value is what you want....

      R 1 Reply Last reply
      0
      • _ _crs_

        hello, I don't know exactly what you want but: 1. if you are programming MFC and you need a CWnd pointer to an edit box(his resource id is for example IDC_EDIT1) or any other control in your dialog (dialog1) : dialog1.GetDlgItem(IDC_EDIT1); 2. in old windows programming style GetDlgItem(dialog1, IDC_EDIT1); where dialog1 is a handle to your dialog and IDC_EDIT1 is the resource id of the control for both functions the return value is what you want....

        R Offline
        R Offline
        r i s h a b h s
        wrote on last edited by
        #3

        thanx a lot _crs_ thats exactly what i was asking for, but how do i get the handle of dialog box (dialog1 in ur example)

        D _ 2 Replies Last reply
        0
        • R r i s h a b h s

          thanx a lot _crs_ thats exactly what i was asking for, but how do i get the handle of dialog box (dialog1 in ur example)

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Use CWnd::GetSafeHwnd() for any window.

          1 Reply Last reply
          0
          • R r i s h a b h s

            thanx a lot _crs_ thats exactly what i was asking for, but how do i get the handle of dialog box (dialog1 in ur example)

            _ Offline
            _ Offline
            _crs_
            wrote on last edited by
            #5

            ... if you are in DialogProc - it looks like this LRESULT CALLBACK DialogPROC(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); handle to the dialog is "hDlg" your first parameter when you create a dialog ... DialogBox(hInst, (LPCTSTR)IDD_DIALOG1, hWnd, (DLGPROC)DialogPROC); where "hInst" is the application instance, "hWnd" is a handle to parent dialog window in your case will be main window "IDD_DIALOG1" is the dialog resource id and "DialogPROC" is the dialog callback procedure (like WndProc for your main window) if you use MFC look at the other answer ....

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups