News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Static with WS_BORDER style on the fly vs. .RC?

Started by hotrod, December 11, 2009, 10:47:50 PM

Previous topic - Next topic

hotrod

If I create a static with the WS_BORDER style on the fly, it is flat; if I create it in an .RC file, it is sunken. Can anyone elaborate on this issue?. I would like to be able to create the controls in an .RC file and save space in the .asm files, but the flat effect has me baffled. Thanks...

hutch--

Depending on the OS version you are using the default style may be being supressed by the theme you are using. I keep classic Win200, Classic XP and Vista blck profiles so I can check what various interface components look like on digfferent versions.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MichaelW

What is the style value specified in the resource definition?
eschew obfuscation

dedndave

i don't understand how you do that Hutch - what - are they files you have saved ?

rags

God made Man, but the monkey applied the glue -DEVO

hutch--

Dave,

3 different profiles under XP SP3. One has the default lolly shop XP, another has the "classic" old style Windows interface and I have a profile that has an aftermarket theme for Vista Aero Black and its handy to be able to swap between profiles to see what something looks like on all 3.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

hotrod

How does this explain the same value (equ 1) working differently on the fly and in an .RC? No matter how the window is loaded, it is using the same style.

MichaelW

Instead of leaving us to guess what you are doing, post the relevant code.

eschew obfuscation

hotrod

This is the simplest I could come up with. Note also that these 2 controls have x, nWidth and nHeight set to the same values. Thanks...

MichaelW

I would guess that the reason is something hidden in the dialog box style or class, and I don't have time to run it down right now. You should be able to get the same (or at least very close to the same) appearance by eliminating the WS_BORDER style and adding the WS_EX_CLIENTEDGE extended style:


invoke CreateWindowEx, WS_EX_CLIENTEDGE, addr szStaticClass, addr szCaption, \
  WS_CHILD or WS_VISIBLE or SS_LEFT or SS_NOTIFY, \
  10, 10, 80, 30, hWin, 1001 , hInstance, NULL

eschew obfuscation

hotrod

I appreciate your response MichaelW. WS_EX_CLIENTEDGE results in the sunken effect for both statics, but defeats the purpose of the WS_BORDER effect and does not explain why the size is different. Starting to look like another M$ mystery.

MichaelW

The reason that the two static controls are not the same size and not in the same relative position is that the coordinates and width and height values are in dialog template units in the resource definition, and in pixels in the call to CreateWindowEx.

Dialog Box Measurements

Also, you can use the WS_BORDER style with WS_EX_CLIENTEDGE, but on my Window 2000 system this did not duplicate the appearance of the control specified in the resource definition.
eschew obfuscation

hotrod

I think some of the answers are starting to surface. No matter what the Windows style is, the OS is going to change it. I have tried several combinations and the styles have to be created on the fly in order to get Windows to ignore the OS styles. It apparently has to do with the JIT compliler. My OS is XP Pro SP 3 and it will not display a rectangle around a flat static with the .RC file.

RadASM seems to read its' property sheet rather than the .RC file once a control has been created using the Dialog Editor. The control must be deleted from the editor and manually entered in the .RC to get it to work. I have posted this comment on KetilO's website and waiting for a reply. This seems to be one of the problems I was having with sizing the control since I went into the .RC and made changes.

Anyway, thanks MichaelW and if anyone comes up with a way to get the WS_BORDER effect to work on a XP Pro SP 3 machine using the .RC file, I sure would like to see it.

MichaelW

#13
What do you mean by "get the WS_BORDER effect to work"? Per the Microsoft documentation, WS_BORDER "creates a window that has a thin-line border", with no mention of sunken. Now that I check I cannot find anything in the dialog class or style to explain the difference. If I comment out the CLASS statement in the resource definition, and in the source comment out all of the WNDCLASSEX-related code to force the use of the standard dialog class, and then in the window procedure comment out these lines:

;invoke DefWindowProc,hWin,uMsg,wParam,lParam
;ret

So the application will run, then I still get the same difference between the static controls. So it still is not clear to me what is causing the difference, but there is at least one way to work around it.

I also tried a different resource compiler (GoRC) and it did not change the results.
eschew obfuscation

hotrod

Yep, that is the problem - M$ documentation. Apparently they don't put a lot of store in resource compiler, or they have made changes to the library, or possibly version 6.14 of ml.exe is not uptodate with the newer ones. Back to the work around-->>