Over time I have posted a number of what I call "Windows 101"
tutorials (or detailed explanation) about programming the Windows
API. I decided to search the forums and to put them all into one
thread to make it easier for any who are learning Windows programming
to find them.
Class Styles 101:
There are three sets of styles for use with any window class.
The first is the extended window styles which are predefined in
Windows. The constants start with %WS_EX_
The second and third set of styles are combined to create the
window styles. Windows styles can be a 32 bit value. The two high
bytes of this value (&00010000 to &FFFF0000) are predefined window
styles. These style constants start with %WS_ and are predefined
by windows.
The lower two bytes of the style value are for custom window styles
based on the window class (&H00000001 to &H0000FFFF). These styles
are defined for each window class and are not interchangable between
window classes. For example the button control (or any class based
on the button control) styles start with %BS_ and are defined for
that class. These styles have no meaning for any other window
class.
Windows actually does not recognize the meaning of any of these
custom class styles (the low 2 bytes). Only the window procedure
for the class understands how to make sense of the styles.
When writing your own custom control (even if you superclass),
you should always define your own set of Styles for the class
(lower 2 bytes) and define a prefix and name for the styles.
Let's say I write a custom control called a Turtle Graphics
control. I would define my own window styles for the control
(the lower two bytes) and then prefix them with a prefix that
makes sense, like %TGS_
Additional Notes:
%DS_CONTROL is a pseudo style supported by the Dialog class.
%WS_EX_CONTROLPARENT is the actual extended style that makes a
window handle child windows and tabbing properly.
The dialog class (which DDT uses) doesn't support all the
extended window styles. When the dialog is created (it gets
the WM_CREATE message internally) it will read the styles used
and then convert some of them to actual extended window styles.
The %DS_CONTROL style will be converted to the extended window style
%WS_EX_CONTROLPARENT.
If you are using your own window classes (SDK style code), then
%DS_CONTROL won't work and you must use the extended window
style %WS_EX_CONTROLPARENT !
Windows defines a number of custom styles just for the Dialog
class which all start with the %DS_ prefix. When the dialog is
created, the internal window procedure for the dialog class,
will convert all the %DS_ styles to the appropriate %WS_ or
%WS_EX styles.
Dialogs are a predefined window class in Windows and they don't
work exactly the same as window classes you create yourself.
An interesting tool to use to learn more, is Borje's WinSpy.
You can check to see what styles the dialog actually ends up
with after it is created.
As has been discussed before, the two high bytes of the window
style value are universal window styles that any window class
can use (universal). The two low bytes are custom styles unique
to the window class. The Dialog class has its own set of custom
styles just like controls do. These styles start with the prefix
%DS_ . Now some of these custom styles are features that already
exist in windows in the extended window styles, so the dialog
class converts them to their extended style counter parts.
The extended window styles are also universal for all window
classes. You can only use the extended styles made available by windows.
I should clarify one point.
The dialog class converts %DS_ styles
during the creation of the dialog before its window procedure
gets the %WM_CREATE message.
The reason is that to create a Dialog requires that you use
the Dialog functions in the API, rather than CreateWindowEx.
It is likely that the conversion takes place here, before the
dialog functions call CreateWindowEx.
Windows supports two different dialog
template structures. The default one does not support extended
window styles, which is why the %DS_ styles are needed to be
able to set extended window styles.
to be continued ...
------------------
Chris Boss
Computer Workshop
Developer of "EZGUI"
http://cwsof.com
tutorials (or detailed explanation) about programming the Windows
API. I decided to search the forums and to put them all into one
thread to make it easier for any who are learning Windows programming
to find them.
Class Styles 101:
There are three sets of styles for use with any window class.
The first is the extended window styles which are predefined in
Windows. The constants start with %WS_EX_
The second and third set of styles are combined to create the
window styles. Windows styles can be a 32 bit value. The two high
bytes of this value (&00010000 to &FFFF0000) are predefined window
styles. These style constants start with %WS_ and are predefined
by windows.
The lower two bytes of the style value are for custom window styles
based on the window class (&H00000001 to &H0000FFFF). These styles
are defined for each window class and are not interchangable between
window classes. For example the button control (or any class based
on the button control) styles start with %BS_ and are defined for
that class. These styles have no meaning for any other window
class.
Windows actually does not recognize the meaning of any of these
custom class styles (the low 2 bytes). Only the window procedure
for the class understands how to make sense of the styles.
When writing your own custom control (even if you superclass),
you should always define your own set of Styles for the class
(lower 2 bytes) and define a prefix and name for the styles.
Let's say I write a custom control called a Turtle Graphics
control. I would define my own window styles for the control
(the lower two bytes) and then prefix them with a prefix that
makes sense, like %TGS_
Additional Notes:
%DS_CONTROL is a pseudo style supported by the Dialog class.
%WS_EX_CONTROLPARENT is the actual extended style that makes a
window handle child windows and tabbing properly.
The dialog class (which DDT uses) doesn't support all the
extended window styles. When the dialog is created (it gets
the WM_CREATE message internally) it will read the styles used
and then convert some of them to actual extended window styles.
The %DS_CONTROL style will be converted to the extended window style
%WS_EX_CONTROLPARENT.
If you are using your own window classes (SDK style code), then
%DS_CONTROL won't work and you must use the extended window
style %WS_EX_CONTROLPARENT !
Windows defines a number of custom styles just for the Dialog
class which all start with the %DS_ prefix. When the dialog is
created, the internal window procedure for the dialog class,
will convert all the %DS_ styles to the appropriate %WS_ or
%WS_EX styles.
Dialogs are a predefined window class in Windows and they don't
work exactly the same as window classes you create yourself.
An interesting tool to use to learn more, is Borje's WinSpy.
You can check to see what styles the dialog actually ends up
with after it is created.
As has been discussed before, the two high bytes of the window
style value are universal window styles that any window class
can use (universal). The two low bytes are custom styles unique
to the window class. The Dialog class has its own set of custom
styles just like controls do. These styles start with the prefix
%DS_ . Now some of these custom styles are features that already
exist in windows in the extended window styles, so the dialog
class converts them to their extended style counter parts.
The extended window styles are also universal for all window
classes. You can only use the extended styles made available by windows.
I should clarify one point.
The dialog class converts %DS_ styles
during the creation of the dialog before its window procedure
gets the %WM_CREATE message.
The reason is that to create a Dialog requires that you use
the Dialog functions in the API, rather than CreateWindowEx.
It is likely that the conversion takes place here, before the
dialog functions call CreateWindowEx.
Windows supports two different dialog
template structures. The default one does not support extended
window styles, which is why the %DS_ styles are needed to be
able to set extended window styles.
to be continued ...
------------------
Chris Boss
Computer Workshop
Developer of "EZGUI"
http://cwsof.com
Comment