Archived

This topic is now archived and is closed to further replies.

Hang time ... delayed program response

This topic is 5666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, so I just barely started coding a graphical little nothing using the windows API (eg: BitBlt and such), and I have the little app blit an image from memDC #1 to memDC #2, then I have a rect placed at the mouse''s position on memDC #2 as well. I blit memDC #2 to the window''s DC, but for some reason, all the interactions are delayed by about 4-5 seconds... for example, I move the mouse, and the rect doesn''t move the way the mouse moved for about 4-5 seconds... I have no clue why this would be. I''m not sure if it''s something that others have run into in the past or if it''s something code-specific. If it may be code-specific, I''ll gladly post the code I have, but I figured I''d wait to post the code unless you all think it''s code-specific. Thanks

Share this post


Link to post
Share on other sites
Yes, it should. Also you should probably be using the PeekMessage() function rather than GetMessage(). Just put the PeekMessage() inside your main loop.
If you wanted, instead of using a loop you could put a test in your callback processing function for the WM_MOUSEMOVE message, and just update the rect and call UpdateWindow() from there.

Twilight Dragon
www.freewebz.com/j-world

Share this post


Link to post
Share on other sites
I wouldn''t put it in your main loop but rather after you''ve updated the positions and are ready to draw.

ie. The mouse moves and now you''ve updated the rect''s values and you want the screen to change, that is when you call UpdateWindow().

As a person said, call the function when you are ready to draw the screen, not right after you have (do not use this function in the WM_PAINT message)



I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm

Share this post


Link to post
Share on other sites
Excuse me? Um, last I heard, checking the messages, updating the positions, and drawing are all part of the main loop!!! Here is what a main loop generally looks like for the wapi:

while(!exit)
{
GetInput();
UpdatePositions();
DrawEverything();
PeekMessage(parameters);
}

Invader X: Perhaps you're confusing the whole main loop with the updating functions, a part of the main loop. In other words, if Mattman57 didn't put his draw functions in the main loop, the drawing would only happen once at the start of the program. Savvy?

Twilight Dragon
www.freewebz.com/j-world

[edited by - TDragon on June 5, 2002 12:00:15 AM]

Share this post


Link to post
Share on other sites
Update functions dont HAVE to be in the main loop. He described his app as a "graphical little nothing" and so I did not assume he has a loop as you have

while(!exit)
{
GetInput();
UpdatePositions();
DrawEverything();
PeekMessage(...);
}

Perhaps he is using WinProc as the loop, instead of PeekMessage() maybe he is using GetMessage()

while (GetMessage(...))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}



I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm

Share this post


Link to post
Share on other sites
Okay, I guess I misunderstood you. If you read my earlier posting, you would have seen that I had said
"If you wanted, instead of using a loop you could put a test in your callback processing function for the WM_MOUSEMOVE message, and just update the rect and call UpdateWindow() from there."
And yes, that GetMessage() loop is the standard method for Win32 programs (it''s the one I use when I make a non-real-time program); since Mattman57 asked a question about the main loop, I guessed that he meant a main loop other than what you mentioned. My apologies.

Twilight Dragon
www.freewebz.com/j-world

Share this post


Link to post
Share on other sites