Article View: comp.os.ms-windows.programmer.misc
Article #2314Subclassing dialog controls
From: Richard Janssen
Date: Mon, 25 Jan 1993 12:37
Date: Mon, 25 Jan 1993 12:37
74 lines
2995 bytes
2995 bytes
Hello, I posted this problem a week ago and got
some answers, but none solved the problem.
That's why I decided to repost and once again
ask if one of you people can help me out.
This is a short description of the problem:
I try to "subclass" controls in a dialog (created from a .DLG template)
by replacing there Window procedure by my own. I do this by calling
SetWindowLong(..) in the handling of the WM_INITDIALOG message in the
Dialog Procedure.
The old Window procedure of the control (returned by SetWindowLong())
is stored. The new Window procedure of the control is set up to call
the old Window Procedure for all messages that are not processed.
Here is what my code looks like:
(The variable oldWindowProc is part of a C++ class for the
control, so appropriate storage space the old Window Procedure is
arranged.)
/* DIALOG PROCEDURE */
... DialogProc (...., WORD wParam, ...)
switch (wParam)
{
case WM_INITDIALOG:
oldWindowProc = SetWindowLong(GetDlgItem(hDlg,ID_CONTROL),
MakeProcInstance(hInst,NewWinProc));
break;
...
}
/* NEW WINDOW PROCEDURE */
... NewWinProc (HWND hWin, WORD wMsg, WORD wParam, LONG lParam)
{
switch (wMsg)
{
...
default:
return CallWindowProc(oldWindowProc, wMsg, wParam, lParam);
break;
}
}
The actual problem? As soon as the dialog displays the subclassed control
is not displayed!! The Window is created though, which is shown by
Borlands' WinSight (Borland version of Spy).
In fact if the control is a button, it does display if i click my left
mouse button over it. If i release the mouse button outside the button,
the button stays visble! But now comes the strange part: Firt i drag the
dialog box, so that the button is off the screen. After releasing the
mouse button i again drag the dialog box, moving the button position
back onto the screen. The button is not drawn, it is invisble !!!
Pressing the left mouse button over it displays it again, which
means the window is still there.
I have tried lots of things like calling ShowWindow() and EnableWindow()
after calling SetWindowLong(), it just doesn't work!!!
Can anybody please help me out !! I'm starting to get desperate !!
Mail to me at: R.H.P.Janssen@research.ptt.nl
Thanks ahead, Richard Janssen
PTT Research, The Netherlands
Technical Details
Message-ID:
<1993Jan25.123715.27106@spider.research.ptt.nl>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!spider.research.ptt.nl!sun032!janssenShow Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!spider.research.ptt.nl!sun032!janssen From: janssen@sun032.research.ptt.nl (Richard Janssen) Subject: Subclassing dialog controls Message-ID: <1993Jan25.123715.27106@spider.research.ptt.nl> Sender: usenet@spider.research.ptt.nl (USEnet News) Nntp-Posting-Host: sun032.research.ptt.nl Organization: PTT Research, Groningen, the Netherlands Distribution: comp.os.ms-windows.programmer.misc Date: Mon, 25 Jan 1993 12:37:15 GMT Lines: 77