LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Panel width value incorrect?

I am trying to "dock" one panel to another, which means that when a panel is moved in a way that it almost borders (within 25 pixels) to another panel, that it exactly borders (lines up) to the other panel.

The way I did this was Panel2.left = Panel1.left + Panel1.width
However, this resulted in Panel2 being placed slightly over Panel1 (see the jpg in the attached zip file). I resolved the problem by adding 7 to the value and now it works correctly, but why is this needed?
Exactly how is the panel width calculated?

The plot area of a graph is one pixel off when calculating the XY value (see this post), is the panel width value a few pixels off as well? And what is the philosophy behind it? What do the returned values mean, why not return the actual values in the first place? There's probably a reason, I don't think NI deliberately changes these values to tease programmers 😉

Regards,

Erwin Timmerman
0 Kudos
Message 1 of 3
(3,038 Views)
I think that you are struggling with panel frames. Look at the on-line help for ATTR_LEFT panel attribute:

Description: The horizontal offset (in pixels) of the panel relative to the origin of the screen (for top-level windows) or the parent panel (for child panels).

The screen origin (0,0) is the upper-left corner of the screen.

The origin of a parent panel is the upper-left corner of the panel below the title bar and to the right of the panel frame.


That is, when you set panel position you are setting the first addressable pixel of the panel, to the interior of the panel frame.

You may retrieve the panel frame thickness using SDK function
fw = GetSystemMetrics (SM_CXFIXEDFRAME);

On my system it is 3 pixels that explain the 7 pixels separation tou have added to your code to plave panels side-by-side.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(3,032 Views)
That's it, thanks.

I saw in the SDK that I can choose between the following parameters:

SM_CXBORDER, SM_CXEDGE, SM_CXFIXEDFRAME, SM_CXFRAME

It's not really clear to me what the differences are (the SDK help doesn't really explain the differences), but on my system the values of them are 1, 2, 3 and 4. The last value (CXFRAME) seems to do the trick, however I distract one pixel (to 7), otherwise the 3d-groove between the 2 windows becomes to deep and too apparent.

Thanks for your help!
0 Kudos
Message 3 of 3
(3,008 Views)