Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to subclass a CWnd window?

130 views
Skip to first unread message

Igor Jarm

unread,
Dec 19, 2002, 5:54:51 PM12/19/02
to
Hi all,

I would like to subclass (or Attach) a CWnd owned window to my CWnd derived
class.
So far I was able to crash consistently due to
ASSERT(FromHandlePermanent(hWndNew) == NULL);
related problem.

Is there a way for two CWnd objects to coexist on one window handle?
It has to be done this way because of a rather large library so rewriting it
isn't an option.

Thanks in advance.

Igor

Ajay Kalra

unread,
Dec 19, 2002, 7:11:42 PM12/19/02
to
Thats a MFC limitation. Unforturnately you cannot do it. However, the
popular CSubClassWnd by Paul Dilascia will do what you want. You can search
for it in back issues of MSJ: www.microsoft.com/msj. Following example in
MSJ uses it:

http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0199/c++/c++0199.htm

--
Ajay Kalra [MVP - VC++]
ajay...@yahoo.com


"Igor Jarm" <NOigor....@siol.net> wrote in message
news:O2EemG7pCHA.2460@TK2MSFTNGP12...

Igor Jarm

unread,
Dec 20, 2002, 8:16:17 AM12/20/02
to
"Ajay Kalra" <ajay...@yahoo.com> wrote in message
news:eLTbyt7pCHA.2460@TK2MSFTNGP12...

> Thats a MFC limitation. Unforturnately you cannot do it. However, the
> popular CSubClassWnd by Paul Dilascia will do what you want. You can
search
> for it in back issues of MSJ: www.microsoft.com/msj. Following example in
> MSJ uses it:
>
>
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0199/c++/c++0199.htm
>
> --
> Ajay Kalra [MVP - VC++]
> ajay...@yahoo.com

Thanks a lot Ajay, this works fine and is a good substitute for
CWnd::SubclassWindow.
Is there an easy way to transfer CWnd message mapping to CSubClassWnd or is
it better to just rewrite it?

Thanks again.

Igor Jarm

Ajay Kalra

unread,
Dec 22, 2002, 3:46:04 AM12/22/02
to
Actually you will get all the messages before the CWnd object gets it. You
dont have to rewrite anything. Just capture the messages you want in your
own window procedure. Example I mentioned shows how to do it.

--
Ajay Kalra [MVP - VC++]
ajay...@yahoo.com

"Igor Jarm" <NOigor....@siol.net> wrote in message

news:OHhLAoCqCHA.1636@TK2MSFTNGP10...

0 new messages