Xref: utzoo comp.windows.ms.programmer:3203 comp.lang.pascal:7231 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!csus.edu!borland.com!chard From: chard@borland.com (Richard Nelson) Newsgroups: comp.windows.ms.programmer,comp.lang.pascal Subject: Re: Question on method name in TPW Summary: Paint vs. WMPaint methods Keywords: Paint WMPaint ObjectWindows TPW Message-ID: <1991Jun20.172458.8147@borland.com> Date: 20 Jun 91 17:24:58 GMT References: <91170.083555F0O@psuvm.psu.edu> <1991Jun19.201012.29349@maytag.waterloo.edu> Organization: Borland International Lines: 44 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.