CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2012
    Posts
    12

    Dialog wait...Help me

    i am making dialog " please wait ... " :

    When i click BUTTON to connect server example :HOSTING ----->show dialog please wait...
    and when finish connected auto close dialog.

    I maked with Multi thread as in this forum ,but show 2 icon on a program,

    and i use ShowWindow to start( has updateWindow,...) ,DestroyWindo to end(close) dialog wait -But error display dialog not normal.

    You can help me?

    please help me, send me your code example about your dialog wait's .

    Thanks so much,

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Dialog wait...Help me

    Please, post your code causing the problems. Please, don't forget to use Code tags around code snippets.
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2012
    Posts
    12

    Re: Dialog wait...Help me

    Code:
           CWaitDlg *wDlg = new CWaitDlg(); //CWaitDlg : Class of Dialog IDD_WAITDLG
    	wDlg->m_Text = _T("Please Wait...");  // m_text is type edit text of Dialog IDD_WAITDLG
    	wDlg->Create(IDD_WAITDLG,this);
    	wDlg->CenterWindow();
    	wDlg->ShowWindow(SW_NORMAL);
            wDlg->UpdateWindow();
    
            Sleep(2000); // ****//
    
           wDlg->DestroyWindow();
    When i insert " Sleep(2000) // ****// ", i can not move this dialog wait, after 2s ,i can move this window. And when i connect to hostting,it's empty as "not responding",

    i think reason is my program,not win system .

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Dialog wait...Help me

    It sure is your program that cause the issue. When you enter Sleep from the GUI thread you effectively prevent the message loop from executing.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Mar 2012
    Posts
    12

    Re: Dialog wait...Help me

    Sleep() only example that i insert to test, my code connect to server is in Sleep().

    When connect to server ,need a few time to finished (have not Sleep() )->but window dialog can't move and show not normal . It' s the same as Sleep.

    Have you any way to create other Dialog Wait ?

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Dialog wait...Help me

    Well, your thread is busy executing what you have in that "Sleep" block, so it has no time for displaying the dialog.
    You could however, move this block into another thread...
    Victor Nijegorodov

  7. #7
    Join Date
    Mar 2012
    Posts
    12

    Re: Dialog wait...Help me

    thanks, i am trying make it by thread ,

  8. #8
    Join Date
    Oct 2010
    Posts
    19

    Re: Dialog wait...Help me

    Have you considered using SetTimer / OnTimer?

  9. #9
    Join Date
    Jun 2001
    Location
    USA
    Posts
    298

    Re: Dialog wait...Help me

    The way I normally do this is to create a modeless dialog box with the "Please Wait" message, and display it before doing the task. Then when the task is finished, terminate the modeless dialog.

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

Featured