locked
how to get a window handle (HWND)? RRS feed

  • Question

  • hi everyone,

     i develop a app in win32 c++ for windows mobile 6. but,in my app, a dialog has not title bar ,so i do not know how to use FindWindow to found it HANDLE(HWND) .
     How can i get this dialog handle(HWND) ?

    thanks so much.


    best
    Friday, September 18, 2009 7:02 AM

Answers

  • OK I am  trying understand your question
    if your app has to tittle bar , you should have  handle  right (CWnd/HWND)
    you can share in other objects, ( after load the window)

    could please you explain your logic..




     Please mark as answer and vote if my post help to fix your issue.
    Friday, September 18, 2009 8:12 AM
  • If the dialog is in your application, you typically don't need FindWindow() to know its HWND. First off, the window procedure of the dialog receives the HWND on every callback. If the dialog is non-modal, the CreateDialog() function returns the HWND. If the dialog is modal, then all activity outside of its window procedure is frozen out anyway (save for other threads), so the HWND may only be needed down the call stack from the window proc. If you have to, you may cache the HWND in a global/static variable in the WM_INITDIALOG handler. But make sure to clear (reset to 0) the variable in the WM_DESTROY handler, since the HWND won't be valid anymore.
    Saturday, September 19, 2009 2:40 AM

All replies

  • OK I am  trying understand your question
    if your app has to tittle bar , you should have  handle  right (CWnd/HWND)
    you can share in other objects, ( after load the window)

    could please you explain your logic..




     Please mark as answer and vote if my post help to fix your issue.
    Friday, September 18, 2009 8:12 AM
  • If the dialog is in your application, you typically don't need FindWindow() to know its HWND. First off, the window procedure of the dialog receives the HWND on every callback. If the dialog is non-modal, the CreateDialog() function returns the HWND. If the dialog is modal, then all activity outside of its window procedure is frozen out anyway (save for other threads), so the HWND may only be needed down the call stack from the window proc. If you have to, you may cache the HWND in a global/static variable in the WM_INITDIALOG handler. But make sure to clear (reset to 0) the variable in the WM_DESTROY handler, since the HWND won't be valid anymore.
    Saturday, September 19, 2009 2:40 AM