// RDSPanelSizeLoc package // Sets the guisize and guilocation of the application. // Usage: Put a "Use RDSPanelSizeLoc.pkg" before End_Object in the Main panel object, // and Send DoSetPanelSize and pass parameters: // 1. Menubar object id (Or 0 if not used) // 2. Toolbar object id (Or 0 if not used) // 3. A Toolbar Button object id (Or 0 if toolbar not used) // 4. View object id // 5. Statusbar object id (Or 0 if not used) // Register functions here in case a toolbar object hasn't been defined in the program: Register_Function piBorderVert Returns Integer // Property in cToolbar class. Register_Function pbList Returns Integer // Property in cToolbar class. Register_Function piButtonHeight Returns Integer // Property in cToolbar class. Register_Function pbNoDivider Returns Integer // Property in cToolbar class. Register_Object oFindRebarBand // Rebar first band. // Uncomment the "#REPLACE DEGUG$$MODE ON" line if you want to see debug // values for this code. Used by procedure DoCheckCurrentClient. // The purpose is for you (and me) to check that this package is working properly... //#Replace DEBUG$$MODE ON //#COMMAND xSHOWLN // #IFSAME DEBUG$$Mode ON // Showln !1 !2 !3 !4 !5 !6 !7 !8 !9 // #ENDIF //#ENDCOMMAND // PARAMETERS: // hoToolbar = The object id of the toolbar. Can be zero. // hoMenu = The object id of the menubar. Can be zero. // hoView = The view object id. Mandatory // hoStatbar = The object id of the status bar. Can be zero. Procedure DoSetPanelSize Handle hoMenu Handle hoToolbar Handle hoButton Handle hoView Handle hoStatbar Handle hoMain ho hoBand Integer iCaptionVert iToolbarVert iViewSize iStatusBarVert iAppVert iAppHori iAppSize Integer iBorderVert iFrameVert iFrameHori iMenuVert iState Move (Self) To hoMain If Not hoView Begin Send Stop_Box "The view object id was not passed to the DoSetPanelSize procedure." Procedure_Return End // If Not hoView Begin If (hoToolbar And Not(hoButton)) Begin Send Stop_Box "The object id of a toolbar button was not passed to the DoSetPanelSize procedure." Procedure_Return End // If (hoToolbar And Not(hoButton)) Begin // Horizontal and Vertical borders: Move (GetSystemMetrics(SM_CYFRAME) * 2 + 3) To iFrameHori // Where does these extra pixels come from? Move (GetSystemMetrics(SM_CXFRAME) * 2 + 3) To iFrameVert // Where does these extra pixels come from? // Caption bar: If (Caption_Bar(hoMain)) Begin Move (GetSystemMetrics(SM_CYCAPTION)) To iCaptionVert // SM_CYSMCAPTION was used before.SM_CYCAPTION End // If (Caption_Bar(hoMain)) Begin // Menubar: If hoMenu Begin Move (GetSystemMetrics(SM_CYMENU)) To iMenuVert End // If hoMenu Begin // Toolbar: If hoToolbar Begin Get piButtonHeight Of hoToolBar To iToolbarVert // Toolbar button height. Get pbNoDivider Of hoToolBar To iState If Not iState Move (iToolbarVert + 2) To iToolbarVert // Graphical line above the toolbar. If (pbList(hoToolbar)) ; Move (iToolbarVert - 7) To iToolbarVert // Where does these extra pixels come from? Else Move (iToolbarVert + 7) To iToolbarVert // Where does these extra pixels come from? If hoButton Begin If (pbAutoSize(hoButton)) ; Move (piBorderVert(hoToolbar) * 2) To iBorderVert End // If hoButton Begin // REBAR: If (oFindRebarBand(hoToolbar)) Begin Move 48 To iToolbarVert Move 0 To iBorderVert End // If (oFindRebarBand(hoToolbar)) Begin End // If ho Begin // View: Get GuiSize Of hoView To iViewSize Set GuiLocation Of hoView To 0 0 // Statusbar: If hoStatbar Begin Move (Hi(GuiSize(hoStatbar))) To iStatusBarVert End // If hoStatbar Begin // Set the new application size: Set GuiSize Of hoMain To (iCaptionVert + iToolbarVert + iBorderVert + iMenuVert + Hi(iViewSize) + iStatusBarVert + iFrameHori) ; (Low(iViewSize) + iFrameVert) Move (GetSystemMetrics(SM_CXSCREEN)) To iAppHori // The screen width. Move (Hi(GUIScreen_Size(1))) To iAppVert // The screen height adjusted for Windows taskbar. Get GuiSize Of hoMain To iAppSize // Application size. // Set the new application location: (centered on screen) Set Guilocation Of hoMain To ((iAppVert / 2) - (Hi(iAppSize) / 2)) ((iAppHori / 2) - ((Low(iAppSize)) / 2)) Send Adjust_Logicals End_Procedure // DoSetPanelSize