How to Get the Size of the Client Area in the CodeJock Era?
by
, 26-Oct-2010 at 11:44 AM (5187 Views)
A typical Visual DataFlex Windows application is an MDI application. The MDI contains of a panel with a menu bar, one or more tool bars, a status bar and a gray area called the client area. It is the client area that provides support for MDI children, the (db)Views, (db)ReportViews.
Prior to Visual DataFlex 12.1 when we introduced the use of CodeJock Commandbars you could retrieve the size of the client area via the GuiSize built-in function call used for the oClientArea object. A number of developers used that to position extra objects like a Outlook Bar. With the introduction of the CodeJock CommandBars the client area is under control by the CodeJock controls and one should no longer try to get the size via GuiSize or try to change the size with Visual DataFlex functions. Instead you should ask CodeJock what the size is.
Note that the size of the client area will change as soon as a commandbar is added, repositioned (like dragging from the top to the left or right side).
The size is returned by a method named ComGetClientRect. The method takes 4 ByRef parameters for returning the position of the top left and bottom right corners and from that you can determine the size. The method is defined inside the cCJCommandBarSystem class.
So we can write:Code:Send ComGetClientRect Left iTop Right Bottom
As you noticed the above code does not use 4 variables but instead uses a struct variable with 4 members. The struct is defined as:Code:Function BarClientSize Returns tBarSize Boolean bComObjectCreated tBarSize BarSize Get IsComObjectCreated to bComObjectCreated If (bComObjectCreated) Begin Send ComGetClientRect (&BarSize.iLeft) (&BarSize.iTop) (&BarSize.iRight) (&BarSize.iBottom) End Function_Return BarSize End_Function
You can also use this function when you want to have menu and tool bar(s) in a (db)View. The size returned can be used to position and relocate objects in the dialog. Use the OnComResize event of the cCJCommandBarSystem object as in:Code:Struct tBarSize Integer iLeft Integer iTop Integer iRight Integer iBottom End_Struct
Code:Procedure OnComResize Send ResizeViewContents End_Procedure Procedure ResizeViewContents tBarSize BarSize Handle hoDataView Get phoDataView to hoDataView Get BarClientSize of oViewCommandBarSystem to BarSize Set GuiSize Of hoDataView To (BarSize.iBottom - BarSize.iTop) 3 End_Procedure