🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.windows.ms.programmer
2 messages
2 total messages Started by Khun So Tue, 18 Aug 1992 15:59
MFC and Custom Controls / WM_NCPAINT
#483
Author: Khun So
Date: Tue, 18 Aug 1992 15:59
24 lines
1486 bytes

    I have a couple of questions on Windows developement using C/C++ 7.0.
    Any insights on the subjects will be greatly appreciated.


        1. How does one extend MFC to support custom controls
           and other window classes?  Specifically I would like
           to derive a class from CWnd for the custom controls
           I had developed.  Many of my controls use extra bytes
           per window instance (cbWndExtra!=0 in WNDCLASS data
           structure).  The current AfxRegisterWndClass always
           sets cbWndExtra=cbClsExtra=0.  Is there a simple way
           to do this without modifying MFC source?


        2. In processing WM_PAINT, BeginPaint() API is called
           and an invalidated region of the window is returned.
           What about WM_NCPAINT?  Is there a way to detect only
           the invalidated area in the non-client area for
           painting?  Or do I have to paint the entire non-client
           area everytime?

    Thanks in advance.
Re: MFC and Custom Controls / WM_NCPAINT
#485
Author: Steven Sinofsky
Date: Thu, 20 Aug 1992 20:21
62 lines
2741 bytes
In article <8304@ncratl.AtlantaGA.NCR.COM> kso@ncratl.AtlantaGA.NCR.COM (Khun So) writes:
>
>
>    I have a couple of questions on Windows developement using C/C++ 7.0.
>    Any insights on the subjects will be greatly appreciated.
>
>
>        1. How does one extend MFC to support custom controls
>           and other window classes?  Specifically I would like
>           to derive a class from CWnd for the custom controls
>           I had developed.  Many of my controls use extra bytes
>           per window instance (cbWndExtra!=0 in WNDCLASS data
>           structure).  The current AfxRegisterWndClass always
>           sets cbWndExtra=cbClsExtra=0.  Is there a simple way
>           to do this without modifying MFC source?
Let's say you have a Window class called "MYCLASS", then all you
need to do to have a C++ class is the following:

class CMyClass : public CWnd
{
public:
	BOOL Create(LPCSTR lpszWindowName, DWORD dwExtraStyles, 
			const RECT& rect, CWnd* pParentWnd)
		{
			static char BASED_CODE szMyClass[] = "MYCLASS";
			return CWnd::Create(szMyClass, lpszWindowName,
				dwStyles, rect, pParentWnd);
		}

	// add additional member functions to support custome WM_
	// SendMessages here


	DECLARE_MESSAGE_MAP() // use this to handle messages as
				// you would expect
};

You don't even need to derive your own class if you don't plan
on customizing the Window at all, since CWnd::Create will
allow you to pass a Window class name.  The window will still then be
part of the normal MFC message routing.	
			
>
>        2. In processing WM_PAINT, BeginPaint() API is called
>           and an invalidated region of the window is returned.
>           What about WM_NCPAINT?  Is there a way to detect only
>           the invalidated area in the non-client area for
>           painting?  Or do I have to paint the entire non-client
>           area everytime?
>
>    Thanks in advance.

Painting in the non-client area of a Window is "not recommended" (from
page 475 of the Programmers Reference v2).  If you must, then
you retrieve a DC via CWnd::GetWindowDC.  In your code you should
paint everything.


-- 
Steven Sinofsky
stevesi@microsoft.com
Disclaimer: I don't speak for Microsoft, BillG does that.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads