Discussion:
Modify WNDCLASS of existing windows?
(too old to reply)
Pix
2005-06-21 08:51:25 UTC
Permalink
Is it possible to modify the WNDCLASS of an existing standard dialog?
I have tried several things but it all comes down to changing
properties of a class which affects all dialogs and this is not what I
want.

What I really need is to apply CS_HREDRAW|CS_VREDRAW to a particular
dialog instance. I have tried registering a new class and applying it
to the window (with SetClassWord) in both WM_NCCREATE and WM_CREATE
but it didn't work.

Is there any known way of changing some class properties of a
particular window instance, after it is created. I am particularly
interested in dialogs (as created by CreateDialog and friends).

Pix
Jeff Partch [MVP]
2005-06-21 11:39:23 UTC
Permalink
Post by Pix
Is it possible to modify the WNDCLASS of an existing standard dialog?
I have tried several things but it all comes down to changing
properties of a class which affects all dialogs and this is not what I
want.
What I really need is to apply CS_HREDRAW|CS_VREDRAW to a particular
dialog instance. I have tried registering a new class and applying it
to the window (with SetClassWord) in both WM_NCCREATE and WM_CREATE
but it didn't work.
Is there any known way of changing some class properties of a
particular window instance, after it is created. I am particularly
interested in dialogs (as created by CreateDialog and friends).
Not after it's created. You can GetClassInfo and RegisterClass a modified
WNDCLASS and Create a dialog of that class by using the CLASS statement in
your DIALOG template resource.
--
Jeff Partch [VC++ MVP]
Pix
2005-06-21 19:11:34 UTC
Permalink
Post by Jeff Partch [MVP]
Not after it's created. You can GetClassInfo and RegisterClass a modified
WNDCLASS and Create a dialog of that class by using the CLASS statement in
your DIALOG template resource.
Thanks! This is exactly what I needed!

Pix
Dr.Sai
2005-07-05 09:35:03 UTC
Permalink
Hi,
I am giving you a sample code that worked for me.
BOOL CSDIDrawView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default

long lnStyle;
lnStyle = WS_CHILD;
static int s = 0;
if(!s)
{
SetClassLong(m_hWnd,GCL_STYLE,lnStyle);
SetClassLong(GetParent()->m_hWnd,GCL_STYLE,lnStyle);

s =1;
}
return CView::OnEraseBkgnd(pDC);
}

The static int will make sure the code executes once,
what you are doing is using the API too early.
Dr.Sai
Post by Pix
Is it possible to modify the WNDCLASS of an existing standard dialog?
I have tried several things but it all comes down to changing
properties of a class which affects all dialogs and this is not what I
want.
What I really need is to apply CS_HREDRAW|CS_VREDRAW to a particular
dialog instance. I have tried registering a new class and applying it
to the window (with SetClassWord) in both WM_NCCREATE and WM_CREATE
but it didn't work.
Is there any known way of changing some class properties of a
particular window instance, after it is created. I am particularly
interested in dialogs (as created by CreateDialog and friends).
Pix
Michael K. O'Neill
2005-07-06 01:47:53 UTC
Permalink
SetClassLong (and SetClassLongPtr), with a parameter of GCL_STYLE, will
alter class styles, such as CS_HREDRAW and other CS-prefixed class styles.

But in your code you're using it to alter a window style (WS_CHILD), so it's
unclear what the result (if any) will be.

I'm not an expert here, so this is a real question. Did you see any
difference in this code? Note that WS_CHILD id #define'd to 0x40000000L,
whereas all the CS-styles are #define'd to values of 0x4000 or below, so
it's possible that the code does nothing? Or maybe it un-sets some common
styles like CS_DBLCLKS (#define'd to 0x0008)?
Post by Dr.Sai
Hi,
I am giving you a sample code that worked for me.
BOOL CSDIDrawView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
long lnStyle;
lnStyle = WS_CHILD;
static int s = 0;
if(!s)
{
SetClassLong(m_hWnd,GCL_STYLE,lnStyle);
SetClassLong(GetParent()->m_hWnd,GCL_STYLE,lnStyle);
s =1;
}
return CView::OnEraseBkgnd(pDC);
}
The static int will make sure the code executes once,
what you are doing is using the API too early.
Dr.Sai
Post by Pix
Is it possible to modify the WNDCLASS of an existing standard dialog?
I have tried several things but it all comes down to changing
properties of a class which affects all dialogs and this is not what I
want.
What I really need is to apply CS_HREDRAW|CS_VREDRAW to a particular
dialog instance. I have tried registering a new class and applying it
to the window (with SetClassWord) in both WM_NCCREATE and WM_CREATE
but it didn't work.
Is there any known way of changing some class properties of a
particular window instance, after it is created. I am particularly
interested in dialogs (as created by CreateDialog and friends).
Pix
Loading...