$PBExportHeader$n_appobject.sru forward global type n_appobject from nonvisualobject end type type filetime from structure within n_appobject end type type win32_find_data from structure within n_appobject end type end forward type filetime from structure unsignedlong dwlowdatetime unsignedlong dwhighdatetime end type type win32_find_data from structure unsignedlong dwfileattributes filetime ftcreationtime filetime ftlastaccesstime filetime ftlastwritetime unsignedlong nfilesizehigh unsignedlong nfilesizelow unsignedlong dwreserved0 unsignedlong dwreserved1 character cfilename[260] character calternatefilename[14] end type global type n_appobject from nonvisualobject autoinstantiate end type type prototypes Function long SHGetFolderPath ( & long hwndOwner, & long nFolder, & long hToken, & long dwFlags, & Ref string pszPath & ) Library "shell32.dll" Alias For "SHGetFolderPathW" Function int GetTempPath ( & int nBufferLength, & Ref string lpBuffer & ) Library "kernel32.dll" Alias For "GetTempPathW" Function boolean ShowWindow ( & long handle, & integer ncmdshow & ) Library "user32.dll" Function long FindFirstFile ( & Ref string filename, & Ref win32_find_data findfiledata & ) Library "kernel32.dll" Alias For "FindFirstFileW" Function boolean FindClose ( & ulong handle & ) Library "kernel32.dll" Alias For "FindClose" Function integer GetSystemMetrics ( & integer nIndex & ) Library "user32.dll" Function boolean SetFileAttributes ( & string lpFileName, & long dwFileAttributes & ) Library "kernel32.dll" Alias For "SetFileAttributesW" Function boolean PathIsURL ( & string pszPath & ) Library "shlwapi.dll" Alias For "PathIsURLW" Subroutine DebugMsg ( & string lpOutputString & ) Library "kernel32.dll" Alias For "OutputDebugStringW" Function long MonitorFromWindow ( & long hwnd, & ulong dwFlags & ) Library "user32.dll" end prototypes type variables Constant String REGISTRYKEY = "HKEY_CURRENT_USER\Software\TopWiz\PBEditor" String is_findstr Integer ii_replaced Boolean ib_MatchCase Boolean ib_WholeWord Boolean ib_WordStart Boolean ib_RegEx Boolean ib_Backwards Boolean ib_IgnoreComment end variables forward prototypes public function string of_getfolderpath (string as_folder) public function string of_gettemppath () public subroutine of_showwindow (window aw_window, windowstate ae_state) public function string of_getreg (string as_subkey, string as_valuename, string as_default) public function string of_getreg (string as_valuename, string as_default) public subroutine of_setreg (string as_subkey, string as_valuename, string as_value) public subroutine of_setreg (string as_valuename, string as_value) public function boolean of_checkbit (long al_number, unsignedinteger ai_bit) public function integer of_getfileattributes (string as_filename, ref boolean ab_readonly, ref boolean ab_hidden, ref boolean ab_system, ref boolean ab_subdir, ref boolean ab_archive) public function boolean of_isfilereadonly (string as_filename) public function integer of_winborderwidth () public function integer of_winborderheight () public function integer of_titlebaroffset () public subroutine of_delregkey (string as_subkey) public subroutine of_setreadonly (string as_filename, boolean ab_readonly) public subroutine of_webbrowse (string as_urlstring) public function boolean of_isonmonitor (window aw_window) end prototypes public function string of_getfolderpath (string as_folder);// ----------------------------------------------------------------------------- // SCRIPT: of_GetFolderPath // // PURPOSE: This function returns the path to a shell folder. // // ARGUMENTS: as_folder - Name of the shell folder // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 10/13/2006 RolandS Initial Coding // ----------------------------------------------------------------------------- Constant Long SHGFP_TYPE_CURRENT = 0 Constant Long CSIDL_DESKTOP = 0 Constant Long CSIDL_PROGRAMS = 2 Constant Long CSIDL_PERSONAL = 5 Constant Long CSIDL_FAVORITES = 6 Constant Long CSIDL_STARTUP = 7 Constant Long CSIDL_RECENT = 8 Constant Long CSIDL_BITBUCKET = 10 Constant Long CSIDL_APPDATA = 26 String ls_path Long ll_rc, ll_hWnd, ll_csidl // set the CSIDL choose case Upper(as_folder) case "DESKTOP" ll_csidl = CSIDL_DESKTOP case "PROGRAMS" ll_csidl = CSIDL_PROGRAMS case "PERSONAL" ll_csidl = CSIDL_PERSONAL case "FAVORITES" ll_csidl = CSIDL_FAVORITES case "STARTUP" ll_csidl = CSIDL_STARTUP case "RECENT" ll_csidl = CSIDL_RECENT case "BITBUCKET" ll_csidl = CSIDL_BITBUCKET case "APPDATA" ll_csidl = CSIDL_APPDATA case else Return "" end choose ll_hWnd = Handle(this) ls_path = Space(256) ll_rc = SHGetFolderPath(ll_hWnd, ll_csidl, & 0, SHGFP_TYPE_CURRENT, ls_path) Return ls_path end function public function string of_gettemppath ();// ----------------------------------------------------------------------------- // SCRIPT: of_GetTempPath // // PURPOSE: This function returns the system temporary file directory. // // RETURN: Temp directory // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 10/13/2006 RolandS Initial Coding // ----------------------------------------------------------------------------- String ls_path Integer li_buflen li_buflen = 260 ls_path = Space(li_buflen) GetTempPath(li_buflen, ls_path) Return ls_path end function public subroutine of_showwindow (window aw_window, windowstate ae_state);// this function sets the windowstate Integer li_cmdshow CHOOSE CASE ae_state CASE Maximized! li_cmdshow = 3 CASE Minimized! li_cmdshow = 2 CASE Normal! li_cmdshow = 1 END CHOOSE ShowWindow(Handle(aw_window), li_cmdshow) aw_window.SetFocus() end subroutine public function string of_getreg (string as_subkey, string as_valuename, string as_default);// ----------------------------------------------------------------------------- // SCRIPT: of_GetReg // // PURPOSE: This function returns a string value from the registry. // // ARGUMENTS: as_subkey - Optional subkey under the base key // as_valuename - Name of the value // as_default - Default to return if not found // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 10/13/2006 RolandS Initial Coding // ----------------------------------------------------------------------------- String ls_regkey, ls_value If as_subkey = "" Then ls_regkey = REGISTRYKEY Else ls_regkey = REGISTRYKEY + "\" + as_subkey End If RegistryGet(ls_regkey, as_valuename, RegString!, ls_value) If IsNull(ls_value) Or ls_value = "" Then Return as_default Else Return ls_value End If end function public function string of_getreg (string as_valuename, string as_default);// ----------------------------------------------------------------------------- // SCRIPT: of_GetReg // // PURPOSE: This function returns a string value from the registry. // // ARGUMENTS: as_valuename - Name of the value // as_default - Default to return if not found // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 10/13/2006 RolandS Initial Coding // ----------------------------------------------------------------------------- Return of_getreg("", as_valuename, as_default) end function public subroutine of_setreg (string as_subkey, string as_valuename, string as_value);// ----------------------------------------------------------------------------- // SCRIPT: of_SetReg // // PURPOSE: This function saves string values in the registry. // // ARGUMENTS: as_subkey - Optional subkey under the base key // as_valuename - Name of the value // as_value - The value to save // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 10/13/2006 RolandS Initial Coding // ----------------------------------------------------------------------------- String ls_regkey, ls_value If as_subkey = "" Then ls_regkey = REGISTRYKEY Else ls_regkey = REGISTRYKEY + "\" + as_subkey End If RegistrySet(ls_regkey, as_valuename, RegString!, as_value) end subroutine public subroutine of_setreg (string as_valuename, string as_value);// ----------------------------------------------------------------------------- // SCRIPT: of_SetReg // // PURPOSE: This function saves string values in the registry. // // ARGUMENTS: as_valuename - Name of the value // as_value - The value to save // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 10/13/2006 RolandS Initial Coding // ----------------------------------------------------------------------------- of_SetReg("", as_valuename, as_value) end subroutine public function boolean of_checkbit (long al_number, unsignedinteger ai_bit);// ----------------------------------------------------------------------------- // SCRIPT: of_Checkbit // // PURPOSE: This function determines if a certain bit is on or off within // the number. // // ARGUMENTS: al_number - Number to check bits // ai_bit - Bit number ( starting at 1 ) // // RETURN: True = On, False = Off // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 04/22/2005 RolandS Initial Coding // ----------------------------------------------------------------------------- If Int(Mod(al_number / (2 ^(ai_bit - 1)), 2)) > 0 Then Return True End If Return False end function public function integer of_getfileattributes (string as_filename, ref boolean ab_readonly, ref boolean ab_hidden, ref boolean ab_system, ref boolean ab_subdir, ref boolean ab_archive);// ----------------------------------------------------------------------------- // SCRIPT: of_GetFileAttributes // // PURPOSE: This function returns attributes of the specified file. // // ARGUMENTS: as_filename - Name of the file // ab_readonly - Read Only attribute (By Ref) // ab_hidden - Hidden attribute (By Ref) // ab_system - System attribute (By Ref) // ab_subdir - Subdirectory attribute (By Ref) // ab_archive - Archive attribute (By Ref) // // RETURN: 1 = Success, -1 = Error // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 04/22/2005 RolandS Initial Coding // ----------------------------------------------------------------------------- Long lul_Handle win32_find_data lstr_fd // Find the file lul_Handle = FindFirstFile(as_filename, lstr_fd) If lul_Handle <= 0 Then Return -1 FindClose(lul_Handle) // Return file attributes in by reference arguments ab_ReadOnly = this.of_checkbit(lstr_fd.dwFileAttributes, 1) ab_Hidden = this.of_checkbit(lstr_fd.dwFileAttributes, 2) ab_System = this.of_checkbit(lstr_fd.dwFileAttributes, 3) ab_SubDir = this.of_checkbit(lstr_fd.dwFileAttributes, 5) ab_Archive = this.of_checkbit(lstr_fd.dwFileAttributes, 6) Return 1 end function public function boolean of_isfilereadonly (string as_filename);// ----------------------------------------------------------------------------- // SCRIPT: of_IsFileReadOnly // // PURPOSE: This function determines if file is read only. // // ARGUMENTS: as_filename - Full path and name of the file. // // RETURN: True=Read Only, False=Not Read Only // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 04/27/2009 RolandS Initial Coding // ----------------------------------------------------------------------------- Boolean lb_ReadOnly, lb_Hidden, lb_System, lb_Subdirectory, lb_Archive // Get the current attribute values If this.of_GetFileAttributes(as_FileName, lb_ReadOnly, lb_Hidden, & lb_System, lb_Subdirectory, lb_Archive) = -1 Then Return False End If Return lb_ReadOnly end function public function integer of_winborderwidth ();// ----------------------------------------------------------------------------- // FUNCTION: of_WinBorderWidth // // PURPOSE: This function returns width of a window border. // // RETURN: Width of border // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 11/06/2010 RolandS Initial coding // ----------------------------------------------------------------------------- CONSTANT Integer SM_CXSIZEFRAME = 32 Integer li_pixels, li_pbunits li_pixels = GetSystemMetrics(SM_CXSIZEFRAME) li_pbunits = PixelsToUnits(li_pixels, XPixelsToUnits!) Return li_pbunits end function public function integer of_winborderheight ();// ----------------------------------------------------------------------------- // FUNCTION: of_WinBorderHeight // // PURPOSE: This function returns height of a window border. // // RETURN: Height of border // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 11/06/2010 RolandS Initial coding // ----------------------------------------------------------------------------- CONSTANT Integer SM_CYSIZEFRAME = 33 Integer li_pixels, li_pbunits li_pixels = GetSystemMetrics(SM_CYSIZEFRAME) li_pbunits = PixelsToUnits(li_pixels, YPixelsToUnits!) Return li_pbunits end function public function integer of_titlebaroffset ();// ----------------------------------------------------------------------------- // FUNCTION: of_TitlebarOffset // // PURPOSE: This function returns the difference between the current // titlebar size and the standard 'Windows Classic' size. // // RETURN: Offset ( difference ) // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 06/25/2008 RolandS Initial coding // ----------------------------------------------------------------------------- CONSTANT Integer SM_CYCAPTION = 4 Integer li_pixels, li_pbunits, li_offset li_pixels = GetSystemMetrics(SM_CYCAPTION) li_pbunits = PixelsToUnits(li_pixels, YPixelsToUnits!) li_offset = li_pbunits - 76 Return li_offset end function public subroutine of_delregkey (string as_subkey);// ----------------------------------------------------------------------------- // SCRIPT: of_DelRegKey // // PURPOSE: This function deletes a subkey from the registry. // // ARGUMENTS: as_subkey - Optional subkey under the base key // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 08/28/2016 RolandS Initial Coding // ----------------------------------------------------------------------------- String ls_regkey If as_subkey = "" Then ls_regkey = REGISTRYKEY Else ls_regkey = REGISTRYKEY + "\" + as_subkey End If RegistryDelete(ls_regkey, "") end subroutine public subroutine of_setreadonly (string as_filename, boolean ab_readonly);// ----------------------------------------------------------------------------- // SCRIPT: of_SetReadOnly // // PURPOSE: This function sets the read-only flag on/off. // // ARGUMENTS: as_filename - Full path and name of the file. // ab_ReadOnly - True=Read Only, False=Not Read Only // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 04/27/2009 RolandS Initial Coding // ----------------------------------------------------------------------------- If ab_ReadOnly Then SetFileAttributes(as_filename, 1) Else SetFileAttributes(as_filename, 0) End If end subroutine public subroutine of_webbrowse (string as_urlstring);// ----------------------------------------------------------------------------- // SCRIPT: of_WebBrowse // // PURPOSE: This function runs the default browser passing the URL. // // ARGUMENTS: as_urlstring - The URL to open in the browser // // Passing "? " followed by a string will cause the browser // to use it's default web search to search for the string. // // Example: of_WebBrowse("? " + ls_searchterm) // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 12/27/2016 RolandS Initial Coding // ----------------------------------------------------------------------------- String ls_regkey, ls_value, ls_command Long ll_pos // get the default browser ls_regkey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\" + & "Associations\UrlAssociations\http\UserChoice" RegistryGet(ls_regkey, "Progid", RegString!, ls_value) // get the browser command line ls_regkey = "HKEY_CLASSES_ROOT\" + ls_value + "\shell\open\command" RegistryGet(ls_regkey, "", RegString!, ls_value) // append the passed URL string to the browser exe ll_pos = LastPos(ls_value, ".exe") + 4 ls_command = Left(ls_value, ll_pos) + ' "' + as_urlstring + '"' Run(ls_command) end subroutine public function boolean of_isonmonitor (window aw_window);// ----------------------------------------------------------------------------- // SCRIPT: of_IsOnMonitor // // PURPOSE: This function determines if the window is currently visible // on one of the monitors. // // ARGUMENTS: aw_window - Window to check the location // // DATE PROG/ID DESCRIPTION OF CHANGE / REASON // ---------- -------- ----------------------------------------------------- // 05/10/2019 RolandS Initial Coding // ----------------------------------------------------------------------------- Constant ULong MONITOR_DEFAULTTONULL = 0 Long ll_hWnd ULong lul_handle ll_hWnd = Handle(aw_window) lul_handle = MonitorFromWindow(ll_hWnd, MONITOR_DEFAULTTONULL) If lul_handle = 0 Then Return False End If Return True end function on n_appobject.create call super::create TriggerEvent( this, "constructor" ) end on on n_appobject.destroy TriggerEvent( this, "destructor" ) call super::destroy end on
File: n_appobject.sru
Size: 18934
Date: Wed, 17 Aug 2022 03:26:52 +0200
Size: 18934
Date: Wed, 17 Aug 2022 03:26:52 +0200
- nonvisualobject autoinstantiate n_appobject(sru)
- of_checkbit (long al_number, unsignedinteger ai_bit) returns boolean
- of_delregkey (string as_subkey)
- of_getfileattributes (string as_filename, ref boolean ab_readonly, ref boolean ab_hidden, ref boolean ab_system, ref boolean ab_subdir, ref boolean ab_archive) returns integer
- of_getfolderpath (string as_folder) returns string
- of_getreg (string as_subkey, string as_valuename, string as_default) returns string
- of_getreg (string as_valuename, string as_default) returns string
- of_gettemppath () returns string
- of_isfilereadonly (string as_filename) returns boolean
- of_isonmonitor (window aw_window) returns boolean
- of_setreadonly (string as_filename, boolean ab_readonly)
- of_setreg (string as_subkey, string as_valuename, string as_value)
- of_setreg (string as_valuename, string as_value)
- of_showwindow (window aw_window, windowstate ae_state)
- of_titlebaroffset () returns integer
- of_webbrowse (string as_urlstring)
- of_winborderheight () returns integer
- of_winborderwidth () returns integer