============================== JF Software VB Modules By Joshua Foster - JF Software http://www.jfsoftware.net joshua_70448@ureach.com June 14, 2001 ============================== Tasks class module ================== Description: Procedures that work with tasks and windows. Procedures: =========== ----------- CloseWindow ----------- Syntax: CloseWindow(lngHandle As Long) Description: "Asks" a window to close. Parameters: lngHandle - Handle of the window to close. Example: -------- Private cTasks As Tasks 'Define a Tasks object Private Sub Form_Load() Set cTasks = New Tasks 'Load the cTasks object 'Close a window Call cTasks.CloseWindow(wndhnd) End Sub ------- FindAll ------- Syntax: FindAll(ByVal frmStartFrom As Form, strTaskTitleList() As String, lngTaskHandleList() As Long) As Integer Description: Finds every window's title and handle. (default) Return Value: Returns the number of windows found. Parameters: frmStartFrom - Form to start from (usually Me) strTaskTitleList() - String array to pass window titles to. lngTaskHandleList() - Long array to pass window handles to. Example: -------- 'MsgBox the title of the last task found Dim titlearray() As String Dim handlearray() As Long Dim numwindows As Integer numwindows = cTasks.FindAll(Me, titlearray(), handlearray()) MsgBox titlearray(numwindows) ------------ FindWithText ------------ Syntax: FindWithText(ByVal frmStartFrom As Form, strSearchText As String) As Long Description: Finds a window's handle whose title contains the specified text. Return Value: Returns the handle of the window found, or 0 if none found. Parameters: frmStartFrom - Form to start from (usually Me) strSearchText - Text to search window titles for. Example: -------- 'MsgBox the handle of the window whose title contains "Notepad" MsgBox cTasks.FindWithText(Me, "Notepad") ----------- MakeTopMost ----------- Syntax: MakeTopMost(frmTarget As Form) As Boolean Description: Makes a form ***in your program*** topmost. Return Value: Returns true if successful, false if an error occured. Parameters: frmTarget - Form to make topmost. Example: -------- 'Make the current form topmost Call cTasks.MakeTopMost(Me) ---------- MoveWindow ---------- Syntax: MoveWindow(lngHandle As Long, x As Long, y As Long, [width As Long], [height As Long]) As Boolean Description: Moves a window. ***NOTE***: All measurements are done in pixels. Return Value: Returns true if successful, false if an error occured. Parameters: lngHandle - Handle of the window to move. x - Left coordinate to move to (in pixels) y - Top coordinate to move to (in pixels) [width] - Width to resize window to (in pixels) (optional; if not specified, original width is used) [height] - Height to resize window to (in pixels) (optional; if not specified, original height is used) Example: -------- 'Move a window to (100,100), and resize it to 200x200 pixels. Call cTasks.MoveWindow(wndhnd, 100, 100, 200, 200) ---------- OffTopMost ---------- Syntax: OffTopMost(frmTarget As Form) As Boolean Description: Turns off topmost on a form ***in your program***. Return Value: Returns true if successful, false if an error occured. Parameters: frmTarget - Form to turn off topmost. Example: -------- 'Turn off topmost on the current form Call cTasks.OffTopMost(Me)