Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to get HWND for Dialog Window?

jms51jms51 Member Posts: 14
[b][red]This message was edited by jms51 at 2002-10-21 4:11:40[/red][/b][hr]
I am developing a dialog application that has several classes that
are not children of CWnd (they are separate functions that do various data manipulations). In one of the classes I need to fill an
edit control in the dialog window. To do this, I need (I think) to execute "UpdateWindow(HWND hWnd)" after the statement to write to the edit control. I have used "HWND m_hWnd = FindWindow( "class", NULL ); and lots of variations to get the dialog window handle to pass to UpdateWindow but my code will never update the edit control until the entire program execution is complete - i.e., after I return out of the function back to ...Dlg and end program execution. What am I doing wrong? Am I taking a completely wrong approach to this? Thanks for helping me out!


Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : [b][red]This message was edited by jms51 at 2002-10-21 4:11:40[/red][/b][hr]
    : I am developing a dialog application that has several classes that
    : are not children of CWnd (they are separate functions that do various data manipulations). In one of the classes I need to fill an
    : edit control in the dialog window. To do this, I need (I think) to execute "UpdateWindow(HWND hWnd)" after the statement to write to the edit control. I have used "HWND m_hWnd = FindWindow( "class", NULL ); and lots of variations to get the dialog window handle to pass to UpdateWindow but my code will never update the edit control until the entire program execution is complete - i.e., after I return out of the function back to ...Dlg and end program execution. What am I doing wrong? Am I taking a completely wrong approach to this? Thanks for helping me out!
    :
    :
    :
    [blue]1. [b]UpdateWindow()[/b] has no effect without [b]InvalidateRect()[/b].
    2. To update an edit box - you should call these functions for HWND of edit control, not the HWND of a dialog.

    3. You always have an HWND for a dialog - use [b]m_hWnd[/b].[/blue]

  • jms51jms51 Member Posts: 14
    : : [b][red]This message was edited by jms51 at 2002-10-21 4:11:40[/red][/b][hr]
    : : I am developing a dialog application that has several classes that
    : : are not children of CWnd (they are separate functions that do various data manipulations). In one of the classes I need to fill an
    : : edit control in the dialog window. To do this, I need (I think) to execute "UpdateWindow(HWND hWnd)" after the statement to write to the edit control. I have used "HWND m_hWnd = FindWindow( "class", NULL ); and lots of variations to get the dialog window handle to pass to UpdateWindow but my code will never update the edit control until the entire program execution is complete - i.e., after I return out of the function back to ...Dlg and end program execution. What am I doing wrong? Am I taking a completely wrong approach to this? Thanks for helping me out!
    : :
    Thanks for the info. I understand your suggestion but am not sure how to determine the HWND of the edit control. Can you help me further?
    : :
    : :
    : [blue]1. [b]UpdateWindow()[/b] has no effect without [b]InvalidateRect()[/b].
    : 2. To update an edit box - you should call these functions for HWND of edit control, not the HWND of a dialog.
    :
    : 3. You always have an HWND for a dialog - use [b]m_hWnd[/b].[/blue]
    :
    :

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [b][red]This message was edited by AsmGuru62 at 2002-10-22 6:56:36[/red][/b][hr]
    : : : [b][red]This message was edited by jms51 at 2002-10-21 4:11:40[/red][/b][hr]
    : : : I am developing a dialog application that has several classes that
    : : : are not children of CWnd (they are separate functions that do various data manipulations). In one of the classes I need to fill an
    : : : edit control in the dialog window. To do this, I need (I think) to execute "UpdateWindow(HWND hWnd)" after the statement to write to the edit control. I have used "HWND m_hWnd = FindWindow( "class", NULL ); and lots of variations to get the dialog window handle to pass to UpdateWindow but my code will never update the edit control until the entire program execution is complete - i.e., after I return out of the function back to ...Dlg and end program execution. What am I doing wrong? Am I taking a completely wrong approach to this? Thanks for helping me out!
    : : :
    : Thanks for the info. I understand your suggestion but am not sure how to determine the HWND of the edit control. Can you help me further?
    : : :
    : : :
    : : [blue]1. [b]UpdateWindow()[/b] has no effect without [b]InvalidateRect()[/b].
    : : 2. To update an edit box - you should call these functions for HWND of edit control, not the HWND of a dialog.
    : :
    : : 3. You always have an HWND for a dialog - use [b]m_hWnd[/b].[/blue]
    : :
    : :
    :
    :
    [blue]To update any control (id=IDC_CONTROL):[/blue][code]
    CWnd* pControl = GetDlgItem (IDC_CONTROL);
    HWND hwndControl = pControl->m_hWnd;

    pControl->InvalidateRect (NULL);
    pControl->UpdateWindow ();
    [/code]


  • jms51jms51 Member Posts: 14
    : [b][red]This message was edited by AsmGuru62 at 2002-10-22 6:56:36[/red][/b][hr]
    : : : : [b][red]This message was edited by jms51 at 2002-10-21 4:11:40[/red][/b][hr]
    : : : : I am developing a dialog application that has several classes that
    : : : : are not children of CWnd (they are separate functions that do various data manipulations). In one of the classes I need to fill an
    : : : : edit control in the dialog window. To do this, I need (I think) to execute "UpdateWindow(HWND hWnd)" after the statement to write to the edit control. I have used "HWND m_hWnd = FindWindow( "class", NULL ); and lots of variations to get the dialog window handle to pass to UpdateWindow but my code will never update the edit control until the entire program execution is complete - i.e., after I return out of the function back to ...Dlg and end program execution. What am I doing wrong? Am I taking a completely wrong approach to this? Thanks for helping me out!
    : : : :
    : : Thanks for the info. I understand your suggestion but am not sure how to determine the HWND of the edit control. Can you help me further?
    : : : :
    : : : :
    : : : [blue]1. [b]UpdateWindow()[/b] has no effect without [b]InvalidateRect()[/b].
    : : : 2. To update an edit box - you should call these functions for HWND of edit control, not the HWND of a dialog.
    : : :
    : : : 3. You always have an HWND for a dialog - use [b]m_hWnd[/b].[/blue]
    : : :
    : : :
    : :
    : :
    : [blue]To update any control (id=IDC_CONTROL):[/blue][code]
    : CWnd* pControl = GetDlgItem (IDC_CONTROL);
    : HWND hwndControl = pControl->m_hWnd;
    :
    : pControl->InvalidateRect (NULL);
    : pControl->UpdateWindow ();
    : [/code]
    :
    : Thanks again - I wasn't having any luck. I'll try your additional information.

  • jms51jms51 Member Posts: 14
    : : [b][red]This message was edited by AsmGuru62 at 2002-10-22 6:56:36[/red][/b][hr]
    : : : : : [b][red]This message was edited by jms51 at 2002-10-21 4:11:40[/red][/b][hr]
    : : : : : I am developing a dialog application that has several classes that
    : : : : : are not children of CWnd (they are separate functions that do various data manipulations). In one of the classes I need to fill an
    : : : : : edit control in the dialog window. To do this, I need (I think) to execute "UpdateWindow(HWND hWnd)" after the statement to write to the edit control. I have used "HWND m_hWnd = FindWindow( "class", NULL ); and lots of variations to get the dialog window handle to pass to UpdateWindow but my code will never update the edit control until the entire program execution is complete - i.e., after I return out of the function back to ...Dlg and end program execution. What am I doing wrong? Am I taking a completely wrong approach to this? Thanks for helping me out!
    : : : : :
    : : : Thanks for the info. I understand your suggestion but am not sure how to determine the HWND of the edit control. Can you help me further?
    : : : : :
    : : : : :
    : : : : [blue]1. [b]UpdateWindow()[/b] has no effect without [b]InvalidateRect()[/b].
    : : : : 2. To update an edit box - you should call these functions for HWND of edit control, not the HWND of a dialog.
    : : : :
    : : : : 3. You always have an HWND for a dialog - use [b]m_hWnd[/b].[/blue]
    : : : :
    : : : :
    : : :
    : : :
    : : [blue]To update any control (id=IDC_CONTROL):[/blue][code]
    : : CWnd* pControl = GetDlgItem (IDC_CONTROL);
    : : HWND hwndControl = pControl->m_hWnd;
    : :
    : : pControl->InvalidateRect (NULL);
    : : pControl->UpdateWindow ();
    : : [/code]
    : :
    : : Thanks again - I wasn't having any luck. I'll try your additional information.
    :
    : The above code doesn't work because the function within which I want to update the Edit Control isn't a subclass of ***Dlg. Consequently, the problem is that the call to GetDlgItem has two parameters (HWND hWnd, IDC_CONTROL). I cannot seem to get/find the correct HWND hWnd handle for the control so that the remainder of the code, e.g., GetDlgItem, will work. What is interesting to me is that from within this same function, List Boxes are updated and Progress Control is updated. I pass CEdit * m_CProgress_Label to the function just as I pass the others, e.g., CListBox * m_Status, and CProgress_Ctrl * m_CProgress. They all work fine, but the Edit Control won't. Still stymied. But, thanks for your persistence.

  • jms51jms51 Member Posts: 14
    : : : [b][red]This message was edited by AsmGuru62 at 2002-10-22 6:56:36[/red][/b][hr]
    : : : : : : [b][red]This message was edited by jms51 at 2002-10-21 4:11:40[/red][/b][hr]
    : : : : : : I am developing a dialog application that has several classes that
    : : : : : : are not children of CWnd (they are separate functions that do various data manipulations). In one of the classes I need to fill an
    : : : : : : edit control in the dialog window. To do this, I need (I think) to execute "UpdateWindow(HWND hWnd)" after the statement to write to the edit control. I have used "HWND m_hWnd = FindWindow( "class", NULL ); and lots of variations to get the dialog window handle to pass to UpdateWindow but my code will never update the edit control until the entire program execution is complete - i.e., after I return out of the function back to ...Dlg and end program execution. What am I doing wrong? Am I taking a completely wrong approach to this? Thanks for helping me out!
    : : : : : :
    : : : : Thanks for the info. I understand your suggestion but am not sure how to determine the HWND of the edit control. Can you help me further?
    : : : : : :
    : : : : : :
    : : : : : [blue]1. [b]UpdateWindow()[/b] has no effect without [b]InvalidateRect()[/b].
    : : : : : 2. To update an edit box - you should call these functions for HWND of edit control, not the HWND of a dialog.
    : : : : :
    : : : : : 3. You always have an HWND for a dialog - use [b]m_hWnd[/b].[/blue]
    : : : : :
    : : : : :
    : : : :
    : : : :
    : : : [blue]To update any control (id=IDC_CONTROL):[/blue][code]
    : : : CWnd* pControl = GetDlgItem (IDC_CONTROL);
    : : : HWND hwndControl = pControl->m_hWnd;
    : : :
    : : : pControl->InvalidateRect (NULL);
    : : : pControl->UpdateWindow ();
    : : : [/code]
    : : :
    : : : Thanks again - I wasn't having any luck. I'll try your additional information.
    : :
    : : The above code doesn't work because the function within which I want to update the Edit Control isn't a subclass of ***Dlg. Consequently, the problem is that the call to GetDlgItem has two parameters (HWND hWnd, IDC_CONTROL). I cannot seem to get/find the correct HWND hWnd handle for the control so that the remainder of the code, e.g., GetDlgItem, will work. What is interesting to me is that from within this same function, List Boxes are updated and Progress Control is updated. I pass CEdit * m_CProgress_Label to the function just as I pass the others, e.g., CListBox * m_Status, and CProgress_Ctrl * m_CProgress. They all work fine, but the Edit Control won't. Still stymied. But, thanks for your persistence.
    :
    : !!!I figured it out, thanks to your help. I created a global variable in my "globals.h" that is HWND hWnd_Progress_Label. Then in the main dialog I do CWnd* pControl = GetDlgItem( IDC_PROGRESS_LABEL ); then hWnd_Progress_Label = pControl->m_hWnd;. Now in the function I do m_CProgress_Label->SetWindowText( "some stuff" ); and then UpdateWindow(hWnd_Progress_Label); and it works fine! I think I'm beginning to better understand the relationship between a code window and a Window's window. Thanks again.

  • Justin BibJustin Bib USAMember Posts: 0

    // http://forcoder.org // free video tutorials and ebooks about [ Assembly MATLAB JavaScript Visual Basic .NET Ruby Scratch PL/SQL Objective-C C Python Go C# PHP Visual Basic Java Swift R C++ Perl Delphi Julia ML VBScript Alice Erlang Transact-SQL SAS Prolog F# Ada Clojure Awk Logo Kotlin Scala Fortran Scheme Rust Apex Bash Lua Lisp Crystal LabVIEW Dart D COBOL Hack ABAP FoxPro ] __________

Sign In or Register to comment.