If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Continous sending of WM_PAINT message

Hi all,
I have a win32 application,in that user can draw different shapes on the screen by selecting different tool bar buttons with mouse ie,user can select a toolbar button,then i will change the cursor shape based on button clicked,after that when user clicking on the client area,that shape will print there.
My problem is after printing(drawing) 15 or 20 shapes(same or different),application getting hang,I tried to trace out the problem,i found that after a drawing a 15 or 20 shapes,system continously sending WM_PAINT message.In my code for each printing time(Clicking on the screen)i am invalidating the client area,so every time (Clicking mouse on the client area)system will send WM_PAINT message and drawing the shape on client area.What may be the reason for a continous WM_PAINT message sending without getting clicked on the screen

Re: Continous sending of WM_PAINT message

Originally Posted by manjut19

In my code for each printing time(Clicking on the screen)i am invalidating the client area,so every time (Clicking mouse on the client area)system will send WM_PAINT message and drawing the shape on client area.

That's not correct. All that invalidating the client area does, is tell the window to repaint itself the next time the message queue becomes empty. It doesn't send a WM_PAINT message directly.

Originally Posted by manjut19

What may be the reason for a continous WM_PAINT message sending without getting clicked on the screen

Well, you did something wrong. Maybe you are sending WM_PAINT messages yourself or calling UpdateWindow or invalidating in your WM_PAINT message handler. Hard to tell without seeing your code.

Cheers, D Drmmr

Please put [code][/code] tags around your code to preserve indentation and make it more readable.

As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Re: Continous sending of WM_PAINT message

i removed that line now,But my problem not yet solved.I have a doubt about WM_PAINT Message.Whenever the application message que empty system will send WM_PAINT message or only if we did an invalidation\validation of client area?

Re: Continous sending of WM_PAINT message

Well if you "have a doubt about WM_PAINT Message" why don't you read the documentation?
From MSDN WM_PAINT message:

The WM_PAINT message is sent when the system or another application makes a request to paint a portion of an application's window. The message is sent when the UpdateWindow or RedrawWindow function is called, or by the DispatchMessage function when the application obtains a WM_PAINT message by using the GetMessage or PeekMessage function.
...

Re: Continous sending of WM_PAINT message

Originally Posted by VictorN

Do you mean the BeginPaint() function returns NULL?
In such a case only GetLastError can tell you the exact reason!

The program runs fine for several hundreds of frames.Then randomly freezes. On failure, the call to BeginPaint() reurns NULL. Once it fails the first time, it never recovers,ie application hang (unless terminated and restarted). Calling GetLastError() immediately after BeginPaint fails return a invalid Dc handle

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.