$PBExportHeader$n_svc_window.sru $PBExportComments$Window service forward global type n_svc_window from n_svc_base end type end forward global type n_svc_window from n_svc_base end type global n_svc_window n_svc_window type prototypes FUNCTION ulong GetSystemMetrics(ulong nIndex) LIBRARY "user32.dll" end prototypes type variables private: CONSTANT long ZERO = 0 CONSTANT string DL = "," end variables forward prototypes public subroutine of_position (readonly window aw_parent, readonly window aw_window, readonly integer ai_windowpos, readonly long al_padx, readonly long al_pady) public subroutine of_position (readonly window aw_window, readonly integer ai_windowpos) public subroutine of_position (readonly window aw_parent, readonly window aw_window, readonly integer ai_windowpos) public subroutine of_position (readonly window aw_window, readonly integer ai_windowpos, readonly long al_padx, readonly long al_pady) public function long of_setmax (ref n_svc_mgr anv_svcman, readonly long al_minmaxinfo, readonly long al_minx, readonly long al_miny) public function long of_setmin (ref n_svc_mgr anv_svcman, readonly long al_minmaxinfo, readonly long al_minx, readonly long al_miny) public function window of_getparentwindow (readonly powerobject apo, readonly boolean ab_immediate) public function window of_getparentwindow (readonly powerobject apo) public function string of_getsettings (readonly window aw) public subroutine of_applysettings (ref n_svc_mgr anv_svc, readonly window aw, readonly string as_settings) public subroutine of_makeresizable (ref n_svc_mgr anv_svc, readonly w_base aw_response) public subroutine of_triggerbutton (ref n_svc_mgr anv_svc, readonly w_base aw, readonly string as_buttonname) end prototypes public subroutine of_position (readonly window aw_parent, readonly window aw_window, readonly integer ai_windowpos, readonly long al_padx, readonly long al_pady);long llx, lly, llsw, llsh environment lenv IF NOT ISVALID(aw_parent) THEN of_position(aw_window, ai_windowpos) RETURN END IF CHOOSE CASE ai_windowpos CASE CWindowpos.TopLeft llx = al_padx; lly = al_pady CASE CWindowpos.TopCenter llx = ((aw_parent.width - aw_window.width) / 2) + al_padx ; lly = al_pady CASE CWindowpos.TopRight llx = aw_parent.width - (aw_window.width + al_padx); lly = al_pady CASE CWindowpos.LeftCenter llx = al_padx; lly = ((aw_parent.height - aw_window.height) / 2) + al_pady CASE CWindowpos.Center llx = ((aw_parent.width - aw_window.width) / 2) + al_padx; lly = ((aw_parent.height - aw_window.height) / 2) + al_pady CASE CWindowpos.RightCenter llx = aw_parent.width - (aw_window.width + al_padx); lly = ((aw_parent.height - aw_window.height) / 2) + al_pady CASE CWindowpos.BottomLeft llx = al_padx; lly = aw_parent.height - (aw_window.height + al_pady) CASE CWindowpos.BottomCenter llx = ((aw_parent.width - aw_window.width) / 2) + al_padx; lly = aw_parent.height - (aw_window.height + al_pady) CASE CWindowpos.BottomRight llx = aw_parent.width - (aw_window.width + al_padx); lly = aw_parent.height - (aw_window.height + al_pady) CASE CWindowpos.Cascade //cascade effect on parent llx = PixelsToUnits(GetSystemMetrics(CWin32.SM_CXSIZE) + GetSystemMetrics(CWin32.SM_CXICON), XpixelsToUnits!) lly = PixelsToUnits(GetSystemMetrics(CWin32.SM_CYSIZE) + GetSystemMetrics(CWin32.SM_CYICON), YPixelsToUnits!) END CHOOSE llx += aw_parent.X lly += aw_parent.Y //prevent the window from being cut-off from the screen GetEnvironment(lenv) llsw = PixelsToUnits(lenv.screenwidth, XPixelsToUnits!) llsh = PixelsToUnits(lenv.screenheight, YPixelsToUnits!) IF llx <= 0 THEN llx = al_padx ELSEIF llx + aw_window.width > llsw THEN llx -= (llx + aw_window.width - llsw + al_padx) END IF IF lly <= 0 THEN lly = al_pady ELSEIF lly + aw_window.height > llsh THEN lly -= (lly + aw_window.height - llsh + al_pady) END IF aw_window.Move(llx, lly) end subroutine public subroutine of_position (readonly window aw_window, readonly integer ai_windowpos);of_position(aw_window, ai_windowpos, 0, 0) end subroutine public subroutine of_position (readonly window aw_parent, readonly window aw_window, readonly integer ai_windowpos);of_position(aw_parent, aw_window, ai_windowpos, 0, 0) end subroutine public subroutine of_position (readonly window aw_window, readonly integer ai_windowpos, readonly long al_padx, readonly long al_pady);long llx, lly, llsw, llsh CONSTANT long TWO = 2 environment le GetEnvironment(le) llsw = PixelsToUnits(le.ScreenWidth, XPixelsToUnits!) llsh = PixelsToUnits(le.ScreenHeight, YPixelsToUnits!) CHOOSE CASE ai_windowpos CASE CWindowpos.TopLeft, CWindowpos.Cascade //cascade not supported without parent llx = ZERO; lly = ZERO CASE CWindowpos.TopCenter llx = (llsw - aw_window.width) / TWO; lly = ZERO CASE CWindowpos.TopRight llx = llsw - aw_window.width; lly = ZERO CASE CWindowpos.LeftCenter llx = ZERO; lly = (llsh - aw_window.height) / TWO CASE CWindowpos.Center llx = (llsw - aw_window.width) / TWO; lly = (llsh - aw_window.height) / TWO CASE CWindowpos.RightCenter llx = llsw - aw_window.width; lly = (llsh - aw_window.height) / TWO CASE CWindowpos.BottomLeft llx = ZERO; lly = llsh - aw_window.height CASE CWindowpos.BottomCenter llx = (llsw - aw_window.width) / TWO; lly = llsh - aw_window.height CASE CWindowpos.BottomRight llx = llsw - aw_window.width; lly = llsh - aw_window.height END CHOOSE aw_window.Move(llx + al_padx, lly + al_pady) end subroutine public function long of_setmax (ref n_svc_mgr anv_svcman, readonly long al_minmaxinfo, readonly long al_minx, readonly long al_miny);minmaxinfo lMinMaxInfo n_svc_win32 lnw n_svc_sizeof lnz long ll_size //load service anv_svcman.of_loadsvc(lnw, CSvc.WIN32) anv_svcman.of_loadsvc(lnz, CSvc.SIZEOF) //get size of struct ll_size = lnz.sizeof(lMinMaxInfo) //Copy the data, pointed by the argument al_MinMaxInfo, to our lMinMaxInfo structure lnw.GetMinMaxInfo(lMinMaxInfo, al_MinMaxInfo, ll_size) //Set the maximum size for our window lMinMaxInfo.ptMaxTrackSize.px = al_MinX lMinMaxInfo.ptMaxTrackSize.py = al_MinY //Copy the structure back into memory at the same place lnw.SetMinMaxInfo(al_MinMaxInfo, lMinMaxInfo, ll_size) //Important, according to the MS API, GetMinMax event must return 0 Return CRet.NO_ACTION end function public function long of_setmin (ref n_svc_mgr anv_svcman, readonly long al_minmaxinfo, readonly long al_minx, readonly long al_miny);minmaxinfo lMinMaxInfo n_svc_win32 lnw n_svc_sizeof lnz long ll_size //load service anv_svcman.of_loadsvc(lnw, CSvc.WIN32) anv_svcman.of_loadsvc(lnz, CSvc.SIZEOF) //get size of struct ll_size = lnz.sizeof(lMinMaxInfo) //Copy the data, pointed by the argument al_MinMaxInfo, to our lMinMaxInfo structure lnw.GetMinMaxInfo(lMinMaxInfo, al_MinMaxInfo, ll_size) //Set the minimal size for our window lMinMaxInfo.ptMinTrackSize.px = al_MinX lMinMaxInfo.ptMinTrackSize.py = al_MinY //Copy the structure back into memory at the same place lnw.SetMinMaxInfo(al_MinMaxInfo, lMinMaxInfo, ll_size) //Important, according to the MS API, GetMinMax event must return 0 Return CRet.NO_ACTION end function public function window of_getparentwindow (readonly powerobject apo, readonly boolean ab_immediate);window w powerobject lpo lpo = apo.GetParent() DO IF ISVALID(lpo) THEN IF lpo.TypeOf() = window! THEN w = lpo IF ISVALID(w.ParentWindow()) AND NOT ab_immediate THEN lpo = w.ParentWindow() ELSE RETURN w END IF ELSE lpo = lpo.GetParent() END IF ELSE EXIT END IF LOOP WHILE 1 = 1 end function public function window of_getparentwindow (readonly powerobject apo);RETURN of_getparentwindow(apo, FALSE) end function public function string of_getsettings (readonly window aw);string ls windowstate lws lws = aw.WindowState aw.windowstate = Normal! ls = STRING(aw.X) ls += DL + STRING(aw.Y) ls += DL + STRING(aw.width) ls += DL + STRING(aw.height) CHOOSE CASE lws CASE Minimized!, Normal! ls += DL + "N" CASE Maximized! ls += DL + "M" END CHOOSE RETURN ls end function public subroutine of_applysettings (ref n_svc_mgr anv_svc, readonly window aw, readonly string as_settings);string ls[] n_svc_string lns anv_svc.of_LoadSvc(lns, CSvc.STRING) lns.of_ParseToArray(as_settings, DL, ls) IF LONG(ls[1]) < 0 THEN ls[1] = "0" IF LONG(ls[2]) < 0 THEN ls[2] = "0" aw.Move(LONG(ls[1]), LONG(ls[2])) aw.Resize(LONG(ls[3]), LONG(ls[4])) IF ls[5] = "M" THEN aw.WindowState = Maximized! end subroutine public subroutine of_makeresizable (ref n_svc_mgr anv_svc, readonly w_base aw_response);n_svc_win32 lnv_w ulong lls anv_svc.of_loadsvc(lnv_w, CSvc.WIN32) lls = lnv_w.GetWindowLong(handle(aw_response), CWin32.GWL_STYLE) IF lls <> 0 THEN IF lnv_w.SetWindowLong(handle(aw_response), & CWin32.GWL_STYLE, & lls + CWin32.WS_THICKFRAME + CWin32.WS_SYSMENU) <> 0 THEN ULong hMenu, hWnd hWnd = Handle( aw_response ) hMenu = lnv_w.GetSystemMenu(hWnd, FALSE ) IF hMenu > 0 THEN // removing the menu items from the system menu lnv_w.DeleteMenu( hMenu, CWin32.SC_MINIMIZE , CWin32.MF_BYCOMMAND) lnv_w.DeleteMenu( hMenu, CWin32.SC_MAXIMIZE , CWin32.MF_BYCOMMAND) lnv_w.DeleteMenu( hMenu, CWin32.SC_RESTORE , CWin32.MF_BYCOMMAND) // Force immediate menu update lnv_w.DrawMenuBar( hWnd ) END IF END IF END IF end subroutine public subroutine of_triggerbutton (ref n_svc_mgr anv_svc, readonly w_base aw, readonly string as_buttonname);IF NOT ISVALID(aw) THEN RETURN n_svc_isempty lnv_check long ll_count, n CommandButton cb anv_svc.of_LoadSvc(lnv_check, CSvc.ISEMPTY) IF lnv_check.of_IsEmpty(as_buttonname) THEN RETURN ll_count = UPPERBOUND(aw.Control) FOR n = 1 to ll_count IF aw.Control[n].TypeOf() = CommandButton! THEN cb = aw.Control[n] IF cb.ClassName() = as_buttonname THEN IF cb.Enabled THEN cb.SetFocus() cb.TriggerEvent(clicked!) EXIT END IF END IF END IF NEXT end subroutine on n_svc_window.create call super::create end on on n_svc_window.destroy call super::destroy end on
- Sources
- Kodigo
- OpenExplorer
- n_svc_window.sru
File: n_svc_window.sru
Size: 10309
Date: Mon, 07 Apr 2008 21:31:29 +0200
Size: 10309
Date: Mon, 07 Apr 2008 21:31:29 +0200
- n_svc_base n_svc_window(sru)
- of_applysettings (ref n_svc_mgr anv_svc, readonly window aw, readonly string as_settings)
- of_getparentwindow (readonly powerobject apo) returns window
- of_getparentwindow (readonly powerobject apo, readonly boolean ab_immediate) returns window
- of_getsettings (readonly window aw) returns string
- of_makeresizable (ref n_svc_mgr anv_svc, readonly w_base aw_response)
- of_position (readonly window aw_parent, readonly window aw_window, readonly integer ai_windowpos)
- of_position (readonly window aw_parent, readonly window aw_window, readonly integer ai_windowpos, readonly long al_padx, readonly long al_pady)
- of_position (readonly window aw_window, readonly integer ai_windowpos)
- of_position (readonly window aw_window, readonly integer ai_windowpos, readonly long al_padx, readonly long al_pady)
- of_setmax (ref n_svc_mgr anv_svcman, readonly long al_minmaxinfo, readonly long al_minx, readonly long al_miny) returns long
- of_setmin (ref n_svc_mgr anv_svcman, readonly long al_minmaxinfo, readonly long al_minx, readonly long al_miny) returns long
- of_triggerbutton (ref n_svc_mgr anv_svc, readonly w_base aw, readonly string as_buttonname)