WM_PAINT

WM_PAINT

Post by Bart Hul » Fri, 18 Sep 1998 04:00:00



Hi,

HAs anyone an example how to handle to act on the WM_PAINT message

Greetings,

Bart Huls

 
 
 

WM_PAINT

Post by Michael Warn » Fri, 18 Sep 1998 04:00:00




Quote:>HAs anyone an example how to handle to act on the WM_PAINT message

A window gets that msg when any part of it is exposed. VCL controls
repaint themselves, but any painting you do yourself on a TCanvas
(e.g. in a TForm or TPaintBox or in your own control) must be done
again.

 
 
 

WM_PAINT

Post by Bart Hul » Fri, 18 Sep 1998 04:00:00


Hi,

I want to catch this message because I want must do someting when the
form is being maximized, Or is there an other way?

Thanks,

Bart Huls

 
 
 

WM_PAINT

Post by Colin Attwel » Fri, 18 Sep 1998 04:00:00



> Hi,

> I want to catch this message because I want must do someting when the
> form is being maximized, Or is there an other way?

> Thanks,

> Bart Huls

If I understand your question correctly, you want to "catch" the
WM_PAINT message and call your own function. This can easily be done,
but may not really be what you want !

In the class header for your form put the following code:-

class TMyForm : public TForm
{
  ...
private:        // User declarations
  void __fastcall MyPaint(TMessage* Message);
  BEGIN_MESSAGE_MAP
    MESSAGE_HANDLER(WM_PAINT, TMessage*, MyPaint)
  END_MESSAGE_MAP(TForm)
  ...

Quote:};

Then in the form module, write the necessary code that you need to do:-

void __fastcall TMyForm::MyPaint(TMessage *Message)
{
  ...

Quote:}

Now the bad news ! Remember that by depriving the form of it's regular
supply of WM_PAINT messages, you'll have to take care of updating the
form yourself ! (calling Show() won't work since Show throws WM_PAINT
messages which will wind you up !).

Perhaps trapping the WM_SIZE message would be more fruitful. You'll have
to check the wParam part of the message (Message->wParam) to see if the
form has Maximized (wParam==2), Minimized (wParam==1) or Restored
(wParam==0)

Page 8-4 in the BCB 1.0 Component Writer's Guide gives more details.

Good luck !

 
 
 

WM_PAINT

Post by Michael Warn » Sat, 19 Sep 1998 04:00:00




Quote:>I want to catch this message because I want must do someting when the
>form is being maximized, Or is there an other way?

When a form is maxed your resize handler will be called, and you can
look at WindowState to see if the form is now maxed, minned or normal.
That might be more suitable.
 
 
 

WM_PAINT

Post by Bart Hul » Sat, 19 Sep 1998 04:00:00


Hi Colin,

I tried to use the WM_SIZE message but when I catch the message it
seems that the corrupts the getting of the WM_GETMINMAX message.
Maybe I'm doing something wrong, but I don't have enough documentation
about this. can you tell me  what the Message parameters are?

Thanks,

Bart Huls

 
 
 

WM_PAINT

Post by Team » Sat, 19 Sep 1998 04:00:00


Quote:>>I tried to use the WM_SIZE message but when I catch the message it

seems that the corrupts the getting of the WM_GETMINMAX message.

Be sure you call DefaultHandler(&Message) or TForm::Dispatch(&Message) in
your message handler.

--
Kent (TeamB and TurboPower Software)

 
 
 

WM_PAINT

Post by Bart Hul » Tue, 22 Sep 1998 04:00:00


Hallo Kent,

Calling TForm::Dispatch(&Message) results in a Stackoverflow calling
the defaulthandler results in a vertical scrollbar. When I click the
vertical scrollbar, The form doesn't move and the scrollbar disappear.
I don't know what is wrong?

Greetings,

Bart Huls

 
 
 

WM_PAINT

Post by Harold Howe [TeamB » Wed, 23 Sep 1998 04:00:00


Quote:>Calling TForm::Dispatch(&Message) results in a Stackoverflow

How did you trap WM_PAINT? With a message map, or by overriding the WndProc
function. If you overrode WndProc, call the base class WndProc instead of
calling Dispatch. Dispatch should work from a message map.

If your base class is not TForm, make sure that you replace TForm with the
correct base class.

Harold Howe (TeamB)
http://www.bcbdev.com

 
 
 

WM_PAINT

Post by Bart Hul » Fri, 25 Sep 1998 04:00:00


Hello Harold,

Quote:

> >Calling TForm::Dispatch(&Message) results in a Stackoverflow

> How did you trap WM_PAINT? With a message map, or by overriding the WndProc

I'm catching the WM_SIZE command in the message map

BEGIN_MESSAGE_MAP
   MESSAGE_HANDLER(WM_SIZE         ,TWMSize           ,WMSize         );
END_MESSAGE_MAP(TForm)

Quote:};

And in the source:

void __fastcall TfrmRadarPresentatie::WMSize(TWMSize &Message)
{
  TfrmRadarPresentatie::Dispatch(&Message);

Quote:}

It creates a stack-overflow. When I'm not calling the default-handler
there is a scrollbar on my form.

Regards,

Bart Huls

 
 
 

WM_PAINT

Post by Colin Attwel » Fri, 25 Sep 1998 04:00:00



> > >Calling TForm::Dispatch(&Message) results in a Stackoverflow
> void __fastcall TfrmRadarPresentatie::WMSize(TWMSize &Message)
> {
>   TfrmRadarPresentatie::Dispatch(&Message);
> }

> It creates a stack-overflow. When I'm not calling the default-handler
> there is a scrollbar on my form.

Stack overflow not surprizing! When you get the WMSize message, you send
it to yourself then repeat until you die!
 
 
 

WM_PAINT

Post by Team » Fri, 25 Sep 1998 04:00:00


void __fastcall TfrmRadarPresentatie::WMSize(TWMSize &Message)
{
  TfrmRadarPresentatie::Dispatch(&Message);

Quote:}

Oops. Try:

  TForm::Dispatch(&Message);

--
Kent (TeamB and TurboPower Software)

 
 
 

1. Swapbuffers() without WM_PAINT msg

Hi,

I'm delopping an OpenGL wrapper for Tcl / Tk
(http://sourceforge.net/projects/om2t) that works fine under Linux but
still
have some problems under Windows. The main one is that I can't swap
buffers
of a double-buffered window if a WM_PAINT message hasn't been
triggered
before. As a simplified example, this function... :

    void repaint() {
        DoPaintingStuff();
        SwapBuffers();
    }

...works when called by the WM_PAINT handler but has no effect on
screen when called anywhere else. Note that I have no problem when
flushing
simple-buffered windows. The temporary solution I've adopted is
something like that... :

void

tempNote also that I've tried to call

Any Idea?

Thanx.

2. u ::[OT]my online portfolio|visual

3. OpenGL & WM_PAINT

4. "Circular" graphics

5. too many WM_PAINTs freeze my interface

6. MS PaintBrush Help!!

7. WM_PAINT and BeginPaint()

8. Handling X Expose / WM_PAINT events

9. MDI and WM_PAINT ? (VB6.0)

10. Paint event -vs- WM_PAINT message

11. Subclassing WM_PAINT is not working, help!

12. Subclassing WM_PAINT