I'm trying to convert old TASM-code to MASM, but i've run across this very weird bug: I'm trying to create a window whose size, as reported by GetClientRect, is 800 by 600. So the width and height of the window must to be 6 and 25 pixels larger to compensate for the borders and title bar. This works in TASM, but not in MASM: for a reason I cannot understand, the borders in MASM are 2 pixels wider in every direction (so the width and height are 4 pixels off)
I've disassembled both binaries with OlyyDBG, and the parameters are exactly the same. The style is WS_VISIBLE OR WS_POPUP OR WS_CAPTION OR WS_MINIMIZEBOX (90C20000 hex in both cases), and the extended style is WS_EX_OVERLAPPEDWINDOW (300 hex in both cases).

There are differences in the parameters I use for TASM and MASM (debug info, object format etc) but I don't understand that this would make a difference. Anybody knows what could be the cause??
Posted on 2002-05-06 15:03:07 by james
With WS_THICKFRAME off you get a thinner border (Style).

Posted on 2002-05-06 16:46:11 by sch.jnn
I?m not sure if this is what you?re doing but here?s my advice?

Use this

; Adjust the x and y coordinates to include the border and title bar
invoke AdjustWindowRectEx, (addr of a rect scruct), (dwStyle flags), FALSE, (dwExStyle flags)

It works great for me when I want the client area to be exactly the dimensions I specify.
Posted on 2002-05-06 19:24:52 by nikadeemus27
Does your version of TLINK32 have a /V switch for setting the subsystem version? There are subtle differences between 3.x subsystems and 4.x (and 5.x) subsystems.

You can also try setting the subsystem version in MASM with the /SUBSYSTEM switch. For instance, if you want your program to display 3.1 behavior, you use /subsystem:windows,3.10 as part of your linker options.
Posted on 2002-05-07 02:54:36 by tenkey
You shouldn't use "6" and "25" constants directly, as titlebar and
border size may vary (themes, even worse after XP arrived).
AdjustWindowRectEx is nice :)
Posted on 2002-05-07 04:25:32 by f0dder
Thanks Tenkey, using subsystem:windows,3.10 solved the problem :) Is there some place I can read more about the difference between those subsystems? I guess they can cause some *really* obscure bugs if you don't know this...

To the others: thanks for the suggestions, I was looking for an explanation for the strange behaviour rather than for a workaround, but I suppose using that AdjustWindowRectExt method will be more robust so I'll use it in my new code.
Posted on 2002-05-07 12:23:42 by james
Posted on 2002-05-07 15:28:12 by tenkey