Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Message Queue - Invalidate

Posted on 1998-09-10
14
Medium Priority
?
844 Views
Last Modified: 2013-11-20
Ok when i call invalidate it places the message at the end of the message queue and even when i send more messages Invalidate is the last thing it does..
So my question is how would you invalidate a window and force it to invalidate first with out processing all the other messages first?

thanks in advance Mr Ramsay
0
Comment
Question by:ramsay
  • 6
  • 3
  • 2
  • +3
14 Comments
 
LVL 2

Expert Comment

by:jstolan
ID: 1322031
UpdateWindow()
0
 
LVL 2

Expert Comment

by:jstolan
ID: 1322032
Actually to elaborate a little, if you want to repaint immediately first you Invalidate, then call UpdateWindow.  Note that you can also update smaller portions of the window by calling InvalidateRect or InvalidateRgn instead of Invalidate.  The call will look something like this

Invalidate();
UpdateWindow();

If you don't invalidate something first (the update region is empty), then UpdateWindow does nothing.
0
 
LVL 1

Expert Comment

by:plebel
ID: 1322033
UpdateWindow Also call directly the WM_PAINT message
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:ramsay
ID: 1322034
ok this is the code below..
unfortunatly your suggestion doesnt work.

the window updates then
runs the function below
then invalidates.

so possibly another way would be to insert some kind of pause between the two blocks of code to allow the window to fully invalidate before it goes on.. any other suggestions?



   Invalidate();    
    UpdateWindow();  
   
    //need to insert a pause here.

    CPoint oldpt,newpt;
    oldpt = GetScrollPosition();
    newpt.Offset(GetTotalSize());
    if (newpt != oldpt) {
        ScrollToPosition(newpt);
    }
0
 
LVL 1

Expert Comment

by:Bridge
ID: 1322035
RedrawWindow()
0
 
LVL 2

Expert Comment

by:jstolan
ID: 1322036
I'm not sure I understand what you're trying to do.  Your idea of the pause to allow the window to fully invalidate won't work.  Invalidate fully invalidates the window immediately.  UpdateWindow sends an immediate WM_PAINT, bypassing the message queu, which then draws the window and validates it.

When you say "Invalidate" do you mean to draw the results immediately as you said in your original question.  If so, my suggestion will work, you simply have to put it in the right place.  Try moving the Invalidate, UpdateWindow() pair after you've done your ScrollToPosition call.

If by Invalidate you mean something else, please try to clarify a little more.
0
 
LVL 1

Author Comment

by:ramsay
ID: 1322037
Well we can always try a different approach.. ill tell you the whole thing of what i am trying to do.

First of all I have a function called drawstring which adds a line of text to an array of CStrings.  After this is written the invalidate() is called to redraw the window and then I want to adjust the scroll so it alwasy points to the bottom of the screen.

Unfortunatly I have processes which call drawstring in quick succession so that the window only gets invalidated at the end and so the scrolling doesnt take place as it does this BEFORE the invalidate() message gets through.

(Invalidate() is programmed to only execute after all other messages are taken care of)

Now with the update window it doesnt do as good a job as invalidate().

To explain what happens with the pair is as follows:

If a portion of my code executes 3 draw strings here is what happens
1) updatewindow()  -> scroll to bottom()
2) updatewindow()  -> scroll to bottom()
3) updatewindow()  -> scroll to bottom() -> invalidate()
as the invalidatemessage is ALWAYS the last to execute.

Now if updatewindow() did a good job this would not be a problem unfortunatly it paints the screen very poorly.. (the text seems like it has been adjusted to the left about 8 characters.. so it causes a vary bad flicker especially on long operations as invlaidate is always the last message to get sent.)
The big problem is that I have a function that lasts 20 seconds and that whole time the text is adjusted too far to the left(so that the sentences are cut in half).  but Invalidate() does a good job but is executed last so the scrolling doesnt work.

Oh yea sorry bout the rejection but the autograder aparently cuts you off very quickly.

Hope this clarifys the question a bit more.




0
 
LVL 1

Author Comment

by:ramsay
ID: 1322038
Can someone answer?
0
 
LVL 1

Expert Comment

by:Bridge
ID: 1322039
Did you try CWnd::RedrawWindow() ??
0
 
LVL 1

Author Comment

by:ramsay
ID: 1322040
Yes it profuced the same result...

A bit more info..
The reason i need to invalidate the window is because i have an array of strings in the diocument file and it is used to store the messages.  
I need to invalidate the window so i can see those messages..

if you have any other suggestions on how to implement scrolling properly i would appriciate it.

0
 
LVL 1

Author Comment

by:ramsay
ID: 1322041
points increased
0
 
LVL 1

Expert Comment

by:VAM345
ID: 1322042
Try this
Change you code
//need to insert a pause here.
With this

      MSG msg;
      // Îáðàáîòâàò ñå âñè÷êè ñúîáùåíèÿ ÷àêàùè â îïàøêàòà.
      while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE))
            if(!AfxGetThread()->PumpMessage( ) )
            {      
                  ::PostQuitMessage(0);
                  break;
            }


0
 
LVL 1

Accepted Solution

by:
polimetla earned 300 total points
ID: 1322043
Dear brother/sister,

Please try the following statement.
It will force the app. to invalidate.

SendMessage( WM_PAINT, 0, 0 );

any doubts, send mail to me.

with love,
Bhavani P Polimetla
bhavani_73@hotmail.com
0
 
LVL 1

Author Comment

by:ramsay
ID: 1322044
I lockedupdate then did all the drawing stuff then unlocked the update.. stopped all the smeg being shown.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question