CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Guest

    urgent:refreshing dialog

    i have written a dialog based application
    if i open another program (eg. WORD) over my program while it is running,and then close WORD again, my program doesnt re-paint.

    Q. How can i get my program to refresh when the focus isnt on it but it is in view?

    thanks in advance
    J


  2. #2
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: urgent:refreshing dialog

    Normally I would expect your dialog to re-draw, but it may not do so under certain circumstances. Are you doing processing work in your main application thread, as doing so would not allowed qued messages like WM_PAINT (WM_PAINT messages seem to be given low priority by windows) to not be executed until your code stops what it is doing and enteres the idle loop.
    If this is the case, I would recommend adding a Peek and Dispatch message loop to your running code to allow other messages to be processed.
    An example of this code is :

    MSG msg ;
    while (::PeekMessage(&msg, NULL, 0, 0, PM_NOYIELD | PM_REMOVE))
    {
    ::TranslateMessage(&msg) ;
    :ispatchMessage(&msg) ;
    }




    HTH


    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  3. #3
    Guest

    Re: urgent:refreshing dialog

    Thanks for that, yes processing takes place in the main thread (there was no way around this). where should i put the

    MSG msg ;
    while (::PeekMessage(&msg, NULL, 0, 0, PM_NOYIELD | PM_REMOVE))
    {
    ::TranslateMessage(&msg) ;
    :ispatchMessage(&msg) ;
    }
    code?, i tried putting it in an OnShowWindow(BOOL bShow, UINT nStatus)
    function, im not sure wher to go from here and dont know what code i should add to the above segment.

    help?
    J


  4. #4
    Join Date
    May 1999
    Location
    Farnborough, Hants, England
    Posts
    710

    Re: urgent:refreshing dialog

    The code should go in the middle of your processing which is taking up the time - because your intense processing is preventing messages from being processed, it also prevents WM_SHOWWINDOW from getting through (and all other messages), which is why it still doesn't work. Basically, what we are attempting to do here is get your intense processing to ease up every now and then and allow some messages through.

    --
    Jason Teagle
    [email protected]

  5. #5
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: urgent:refreshing dialog

    A word of warning :

    When you put this in your main processing loop, if the main processing was set off by a menu item selection, then it can be selected again and you could have multiple instances of the same procedure running, so you may have to disable certain menu items in your application at the start of your main processing algorithm to stop this from happening.

    Good luck....




    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  6. #6
    Guest

    Re: urgent:refreshing dialog

    I have the menu disabled.

    would it be alright to call this code in multiple places?, because there are a few area's of the main process algorthim that could cause a delay that could cause the problem.

    thanks
    J


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