01-14-2009 07:23 AM
Hi,
I have just realized that the GUI I have built with CVI 9.0 looks different depending on the Windows display style: lab style buttons that have some space between them in the XP style stick together in classic style; I didn't investigate if the buttons grow or move, but actually I feel that the button size and placement should be the same whatever style the end user is applying. Did I miss something?
Thanks,
Wolfgang
Solved! Go to Solution.
01-14-2009 01:37 PM
Hi Wolfgang,
Lab-style and classic style buttons should have the same physical width. So if you set the width of a button to 40, for example, then the actual and apparent width of the button should be 40 pixels, regardless of whether you're using lab-style or classic style buttons.
I'm attaching an image of two buttons next to each other, one classic and the other lab-style, both 40 pixels wide, that illustrate this.
Can you attach an image of what you're seeing on your end?
Thanks
Luis
01-14-2009 06:21 PM - edited 01-14-2009 06:22 PM
I think you may be refering to the visual difference between Windows-style and non-Windows-style buttons, like in the attached picture. The buttons are technically the same size. They respond to mouse input in exactly the same region, and if you select them in the UI editor, you may notice that the selection outline is exactly the same. The difference is just in how they are drawn, which is up to the Windows API that we call to draw them into a given rectangle. The Windows-style buttons draw a 1-pixel border within the bounds of the control. That, along with the rounded corners can result in pretty significant visual spacing when you line them right next to each other, but is usually not noticable.
Mert A.
National Instruments
01-15-2009 01:38 AM
Hi Luis, hi Mert,
sorry for my unclear description, indeed Mert addressed my question correctly. I attach two screenshots showing basically the same phenomen as outlined by Mert.
The difference looks more pronounced on a dislay with lower resolution.
The difficulty is that if I align my controls in one style, they might be misaligned in another. At least good to know 🙂 May be, it could be added somewhere in the documentation?
Btw, is there a possibility to check what kind of style is set on a display?
Thanks, Wolfgang
01-15-2009 01:40 AM
oops, I forgot the figures...
01-15-2009 10:58 AM
I understand that the controls are visually "misaligned," but I think that aspect needs to be accepted as characteristic of that visual style. The alternative would be to try to visually align the controls, but that would require overlapping the controls (in the true, position/height/width sense) by two pixels on each side. Depending on which controls were on top in the z-plane order, you could appear to be clicking the very edge of one control, but it would actually press the button next to it. Also, there's no guarantee that Windows 7 (or some other future version) won't change their button's visual style to something that does go all the way to the edge of the control. The best way is just to think, "Windows XP/Vista style buttons have border spacing built into them."
The way to determine whether Windows visual styles are being used on a UI is to first check the ATTR_CONFORM_TO_SYSTEM_THEME panel attribute (GetPanelAttribute). This indicates that controls on that panel are being drawn the "Windows way". However, individual controls may override this setting with the ATTR_DISABLE_PANEL_THEME control attribute (GetCtrlAttribute), so you may need to check that attribute to be sure.
Mert A.
National Instruments
01-15-2009 11:43 AM
Hi Mert,
thanks. I understand that this is a MS Windows feature... 🙂
What I was looking for in my last email was a possiblity to find out, probably via a WIN32 call, if the Windows XP style or the Windows classic style is in effect, so building panels programmatically one could adjust for this extra pixel.
Wolfgang
01-15-2009 11:55 AM
A quick Google search turned up the GetCurrentThemeName function, which looks like it should do what you need. You'll have to have to include Uxtheme.h and link against Uxtheme.lib.
Hopefully this will work for you.
Mert A.
National Instruments