LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetPanelEventRect differs from GetPanelAttributes(.. size..)?

I want to add a EVENT_PANEL_SIZING handler that redraws my controls as the panel resizes (like most other natives MS windows work). 
 
It should be easy to do this using GetPanelEventRect with EVENT_PANEL_SIZING, but the rectangle I get from GetPanelEventRect seems to be the outter window edge (+title bar + frame thickness) whereas GetPanelAttribute return only the interior sizes.  Is there some other CVI function I can use to get the inner panel area that matches the area size returned from GetPanelAttribute(..ATTR_HEIGHT..), etc.?  (I don't want to / should have to use the SDK functions)
 
Why doesn't the GetPanelEventRect return the same panel size references as the panel attribute? 
 
Greg
0 Kudos
Message 1 of 3
(3,158 Views)
Hello Greg,
 
Yes, it's true that the size passed to the event callback corresponds to the outer size of the window whereas GetPanelAttribute returns the inner size. The reason for the inconsistency is because with the default Windows setting of "Show window contents while dragging" enabled, if you call GetPanelAttribute from within the EVENT_PANEL_SIZING event, you can get the updated interior size of the panel. So the fact that eventData2 gives you the outer size provides you with some additional information that you can use, if for example, you wanted to limit the sizing based on screen constraints. Also, this is the size that the user is directly controlling during the sizing operation, so it makes more sense for it to be associated with the event.
 
But I acknowledge that it's inconsistent, and I definitely acknowledge that the documentation for the event does not mention this, which is a problem. The help needs to state this explicitly.
 
If you can't use GetPanelAttribute to obtain the updated interior size in the callback (because "Show window contents while dragging" is disabled?), then your only solution, short of calling an SDK function, is to note the difference between the two dimensions the first  time that the event is sent to the callback. You can assume that these height and width offsets are the same throughout the life of the panel, in which case you can simply subtract them from the sizes returned by GetPanelEventRect.
 
Unfortunately there is no good programmatic way in CVI of getting the titlebar height and the frame thickness of top-level panels. The ATTR_TITLEBAR_THICKNESS and ATTR_FRAME_THICKNESS attributes are only valid for child panels. We will be addressing this in a future version of CVI. Thanks for the useful suggestion!
 
Luis
Message 2 of 3
(3,148 Views)

Thanks Luis,

GetPanelAttribute does work inside a SIZING event with the "show contents on resize" Windows setting turned on.  As it turns out, the redraw of the panel is much too slow anyway with only one graph and 2 controls.  So I'm ditching the resize on SIZING option.  Adding a short note to the documentation on GetPanelEventRect would be great. 


Greg

0 Kudos
Message 3 of 3
(3,141 Views)