I just created an interesting tool (well, at least I think so) that lets you play with window styles and see the effects of those styles immediately.
It's a little testbed that lets you select any of the available WS_xxxx styles (using a bunch of checkboxes), and creates a window when you click the "Create window" button. Click it again and it creates a new window, destroying the old one.
Note that you need to check WS_CHILD for this thing to work at all (otherwise the window creation fails). I didn't put any smarts in the program to do this automagically. It's also interesting to see which combinations of styles don't work (there's a popup error message box if it does).
It's especially interesting to see the effects of WS_CLIPSIBLINGS: try creating a window without this style and then moving the window (you need to create a window with a title bar to do this). Finally I'm starting to be able to make some sense of those crazy window styles.
The program also shows my technique for creating bunches of objects (checkbox controls in this case) using a big ol' table driving a small amount of code ...
Have fun and let me know what you think.
:U
i find that if i try to create a window without the WS_CHILD flag set, i get "Error Creating..."
i suspect that is because you pass the main window handle to CreateWindowEx function as the parent (and hMenu = child ID)
you might put a test in there - if they do not set that flag, pass 0 as the hWndParent and hMenu parms
dcc20: mov edx,WindowStyles
mov eax,MainWinHandle
mov ecx,$childID
test edx,WS_CHILD
jnz dcc21
xor eax,eax
xor ecx,ecx
dcc21: INVOKE CreateWindowEx, WS_EX_LEFT, ADDR MainClassName, ADDR ChildTitleText, edx,
$childX, $childY, $childWidth, $childHeight, eax, ecx, InstanceHandle,
NULL
another way to go would be to check the WS_CHILD box and don't let them un-check it :P
one little thing
you must not have included the \masm32\macros\macros.asm file in your version of masm32rt.inc :bg
at program exit, you have a label named "exit"
that conflicts with the name of a masm32 macro
i changed it to "exit1" to build it
the child test above works great - i can create non-child windows, now
Good work. Another change I made was to check for the WS_CHILD checkbox on creation, and to automatically set this one's state to checked:
MOV EAX, BST_UNCHECKED
CMP [EBX + $chkbox.wstyle], WS_CHILD
JNE ccb30
MOV EAX, BST_CHECKED
ccb30: INVOKE CheckDlgButton, MainWinHandle, [EBX + $chkbox.ID], EAX ;Set button state to unchecked (except WS_CHILD).
With your changes, the program has been generalized and should probably be called a "window creation testbed" since you can create non-child windows.
One problem I'm sure you've noticed is that some of the WS_xxxx styles contain multiple style bits (why did Micro$oft do that?), which complicates things. Extra code might be able to detect this and set the state of the other checkboxes that are affected when you set multiple style bits.
You'll notice that the little binary display at lower left shows which bits are set in the style word.
yes - and, probably the biggest one is WS_OVERLAPPEDWINDOW (6 flags i think)
if you had to specify all those flags, you'd need 2 lines :P
Yep:
WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
Plus, to make things even more confusing, WS_TILEDWINDOW is a synonym for WS_OVERLAPPEDWINDOW. (I just left this out of my program altogether.)
Other synonyms:
WS_OVERLAPPED = WS_TILED
WS_CHILD = WS_CHILDWINDOW
WS_SIZEBOX = WS_THICKFRAME (??? WTF ???)
well - may not be obvious, but...
thick frame means you have a sizing frame around the window
if you have a size box, it also means the window is sizable :P
some of the aliases are due to carry-overs from earlier windows versions (like win 3.x or win 9x)
they give them a new name in NT-based OS's, then, to make the old stuff jive, they give you the alias