[comp.lang.pascal] Question on method name in TPW

F0O@psuvm.psu.edu (06/19/91)

   HI!

   In TPW, in the Windows Programmers Guide, step 6: Automatically re-
displaying graphics, I notice they use procedures:
   TMyWindow.WMLButtonDown
   TMyWindow.MouseMove
   TMyWindow.Paint

   Why isn't the Paint method called WMPaint?  That's what the actual
Windows message is called.  I used a WMPaint method in one of my programs
and it worked ok.  What's going on here folks?

                                                     Thanks in Advance

                                                              [Tim]

dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (06/20/91)

In article <91170.083555F0O@psuvm.psu.edu> F0O@psuvm.psu.edu writes:
>
>   HI!
>
>   In TPW, in the Windows Programmers Guide, step 6: Automatically re-
>displaying graphics, I notice they use procedures:
>   TMyWindow.WMLButtonDown
>   TMyWindow.MouseMove
>   TMyWindow.Paint
>
>   Why isn't the Paint method called WMPaint?  That's what the actual
>Windows message is called.  I used a WMPaint method in one of my programs

As I read the online docs on the two, Paint is a procedure to paint the
window, while WMPaint is a procedure to service the WMPaint message.  The
distinction is that WMPaint calls BeginView, Paint, then EndView to 
communicate with the scrollers.

Duncan Murdoch
dmurdoch@watstat.waterloo.edu

chard@borland.com (Richard Nelson) (06/21/91)

In article <1991Jun19.201012.29349@maytag.waterloo.edu> dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:
>>   In TPW, in the Windows Programmers Guide, step 6: Automatically re-
>>displaying graphics, I notice they use procedures:
>>   TMyWindow.WMLButtonDown
>>   TMyWindow.MouseMove
>>   TMyWindow.Paint
>>
>>   Why isn't the Paint method called WMPaint?  That's what the actual
>>Windows message is called.  I used a WMPaint method in one of my programs
>
>As I read the online docs on the two, Paint is a procedure to paint the
>window, while WMPaint is a procedure to service the WMPaint message.  The
>distinction is that WMPaint calls BeginView, Paint, then EndView to 
>communicate with the scrollers.

That's basically it. The reason you'd normally override Paint instead of
WMPaint is that rewriting WMPaint would require assigning a display
context, adjusting the scroller, etc.  WMPaint will handle all of that
in a standard way, then call Paint.

Once Paint is called, you've already got a DC (PaintDC), so it's quite
easy to just write the painting parts and not have to worry about all
the "administrative overhead."

Hence the designations in the docs:  WMPaint is "Override: Seldom,"
while Paint is "Override: Often."

The alternate answer, of course, is that I suppose you might want to
call Paint in response to something other than a wm_Paint message
(though I can't think of a reason off the top of my head).  There are
a number of places in ObjectWindows where a message-response method
simply calls another method, precisely because you might want to have
other ways of producing the same response (such as with a menu command).
Thus, you might have a message-response method WMFoo and a command-
response method CMFoo that both produce the same action, calling a
method Foo.

Hope this helps some.

-- 
=======================================================================
   Richard Nelson, Languages Development Unit, Borland International
       Internet: chard@borland.com  |  MCIMail: RNELSON/BORLAND
 Had this been Borland's opinion, I would have written it in a manual.