
Strange behavior when subclassing a static control in modal dialog
Not surprising. Do you know what "static" means? It means "DOES NOT RESPOND TO USER
INPUT". Now, in later versions of Windows that has been modified somewhat; you can set the
SS_NOTIFY flag. So that should solve your problem.
You should not need SubclassDlgItem at all. Just create a member variable of your subclass
in your modal dialog. If you already have
CStatic c_MySpecialControl;
then jjust hand-edit it to be
CMyStatic c_MySpecialControl;
read my essay on avoiding GetDlgItem. The same techniques apply here.
Quote:
>I have written a MFC program which uses a modal dialog window.
>There is a static control in the dialog window. In order to
>paint on this static control, I subclassed it by using
>CMyStatic::SubclassDlgItem() and defined a OnPaint() in
>CMyStatic. (CMyStatic is derived from CStatic.) This works
>fine. But when I want this subclassed static control to do
>something special when it is clicked, I add a OnLButtonDown()
>in CMyStatic. To my surprise, CMyStatic::OnLButtonDown() is not
>called when I clicked on the static control. Instead, the
>CMyDialog::OnLButtonDown() is called. Why?
>Anybody can explain this for me?
Joseph M. Newcomer [MVP]
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm