The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: hotrod on December 11, 2009, 10:47:50 PM

Title: Static with WS_BORDER style on the fly vs. .RC?
Post by: hotrod on December 11, 2009, 10:47:50 PM
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...
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: hutch-- on December 12, 2009, 12:54:20 AM
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.
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: MichaelW on December 12, 2009, 01:08:59 AM
What is the style value specified in the resource definition?
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: dedndave on December 12, 2009, 01:09:48 AM
i don't understand how you do that Hutch - what - are they files you have saved ?
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: rags on December 12, 2009, 01:20:46 AM
probably "themes" Dave
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: hutch-- on December 12, 2009, 03:40:37 AM
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.
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: hotrod on December 12, 2009, 10:33:10 AM
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.
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: MichaelW on December 12, 2009, 01:37:46 PM
Instead of leaving us to guess what you are doing, post the relevant code.

Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: hotrod on December 12, 2009, 05:50:31 PM
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...
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: MichaelW on December 12, 2009, 07:23:16 PM
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

Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: hotrod on December 12, 2009, 09:01:13 PM
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.
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: MichaelW on December 13, 2009, 12:17:01 PM
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 (http://msdn.microsoft.com/en-us/library/ms644994(VS.85).aspx#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.
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: hotrod on December 13, 2009, 04:02:51 PM
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.
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: MichaelW on December 13, 2009, 07:51:28 PM
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.
Title: Re: Static with WS_BORDER style on the fly vs. .RC?
Post by: hotrod on December 13, 2009, 08:58:11 PM
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-->>