$PBExportHeader$n_resizable_response.sru forward global type n_resizable_response from nonvisualobject end type end forward global type n_resizable_response from nonvisualobject autoinstantiate end type type prototypes Function boolean DrawMenuBar ( & long hWnd & ) Library "user32.dll" Function long GetSystemMenu ( & long hWnd, & boolean bRevert & ) Library "user32.dll" Function integer GetSystemMetrics ( & integer nIndex & ) Library "user32.dll" Function ulong GetWindowLong ( & long hWnd, & integer nIndex & ) Library "user32.dll" Alias For "GetWindowLongA" Function boolean InsertMenu ( & long hMenu, & uint uPosition, & uint uFlags, & uint uIDNewItem, & string lpNewItem & ) Library "user32.dll" Alias For "InsertMenuA" Function ulong SetWindowLong ( & long hWnd, & integer nIndex, & ulong dwNewLong & ) Library "user32.dll" Alias For "SetWindowLongA" end prototypes type variables Private: Constant Integer GWL_STYLE = -16 Constant ULong WS_THICKFRAME = 262144 Constant ULong WS_MINIMIZEBOX = 65536 Constant UInt MF_BYCOMMAND = 0 Constant UInt MF_BYPOSITION = 1024 Constant UInt MF_STRING = 0 Constant UInt SC_RESTORE = 61728 Constant UInt SC_MAXIMIZE = 61488 Constant UInt SC_MINIMIZE = 61472 Constant UInt SC_SIZE = 61440 Constant Integer SM_CXSIZEFRAME = 32 Constant Integer SM_CYSIZEFRAME = 33 Constant Integer SM_CYCAPTION = 4 Public: Boolean IsResizable Integer iOrigXPixels Integer iOrigYPixels end variables forward prototypes public subroutine of_setresizable (window aw_response) end prototypes public subroutine of_setresizable (window aw_response);// ----------------------------------------------------------------------------- // SCRIPT: n_resizeable_response.of_SetResizable // // PURPOSE: This function makes the passed response window resizable. The // function is called from the window open event passing 'this'. // The window should also implement the GetMinMaxInfo event so // that it can set original size to be the minimum size. // // The code is based on examples/discussion between Bruce Armstrong // and Dan Cooperstock on the SAP PowerBuilder forum: // http://scn.sap.com/thread/3266956 // // ARGUMENTS: aw_response - The response window // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 01/11/2015 RolandS Initial Coding // ----------------------------------------------------------------------------- Long ll_hWnd, ll_hMenu ULong lul_style, lul_newstyle Integer li_XSize, li_YSize, li_Title Integer li_NewWidth, li_NewHeight aw_response.SetRedraw(False) ll_hWnd = Handle(aw_response) // Get size of the window borders li_XSize = PixelsToUnits(GetSystemMetrics(SM_CXSIZEFRAME), XPixelsToUnits!) li_YSize = PixelsToUnits(GetSystemMetrics(SM_CYSIZEFRAME), YPixelsToUnits!) li_Title = PixelsToUnits(GetSystemMetrics(SM_CYCAPTION), YPixelsToUnits!) // calculate Width/Height to allow the window body to remain the same size li_NewWidth = aw_response.WorkSpaceWidth() + (li_XSize * 2) li_NewHeight = aw_response.WorkSpaceHeight() + (li_YSize * 2) + li_Title // this is only needed for PB8. Delete if migrating to PB9. li_NewWidth = li_NewWidth + 20 li_NewHeight = li_NewHeight + 20 // Save original size of window in pixels for minimum size event iOrigXPixels = UnitsToPixels(li_NewWidth, XUnitsToPixels!) iOrigYPixels = UnitsToPixels(li_NewHeight, YUnitsToPixels!) // Get the current window style lul_style = GetWindowLong(ll_hWnd, GWL_STYLE) If aw_response.ControlMenu Then // You have to include MINIMIZEBOX for the controls to show lul_newstyle = lul_style + WS_THICKFRAME + WS_MINIMIZEBOX Else lul_newstyle = lul_style + WS_THICKFRAME End If If lul_style <> 0 Then If SetWindowLong(ll_hWnd, GWL_STYLE, lul_newstyle) <> 0 Then If aw_response.ControlMenu Then // Add items to the system menu ll_hMenu = GetSystemMenu(ll_hWnd, False) If ll_hMenu > 0 Then InsertMenu(ll_hMenu, 1, MF_BYPOSITION + MF_STRING, & SC_MAXIMIZE, "Maximize") InsertMenu(ll_hMenu, 1, MF_BYPOSITION + MF_STRING, & SC_RESTORE, "Restore") InsertMenu(ll_hMenu, 1, MF_BYPOSITION + MF_STRING, & SC_SIZE, "Size") DrawMenuBar(ll_hWnd) End If End If // Return to original size aw_response.Resize(li_NewWidth, li_NewHeight) IsResizable = True End If End If aw_response.SetRedraw(True) end subroutine on n_resizable_response.create call super::create TriggerEvent( this, "constructor" ) end on on n_resizable_response.destroy TriggerEvent( this, "destructor" ) call super::destroy end on
- Sources
- TopWiz
- resize_response
- PB8
- n_resizable_response.sru
File: n_resizable_response.sru
Size: 4790
Date: Mon, 31 Dec 2018 21:14:39 +0100
Size: 4790
Date: Mon, 31 Dec 2018 21:14:39 +0100
- nonvisualobject autoinstantiate n_resizable_response(sru)