vdfsplat / AppSrc / FindWindows.pkg
History | View | Annotate | Download (4.46 KB)
1 | 53 | wil | //TH-Header |
---|---|---|---|
2 | //***************************************************************************************** |
||
3 | // Copyright (c) 2016 Antwise Solutions |
||
4 | // All rights reserved. |
||
5 | // |
||
6 | // $FileName : VdfGuidance\VdfSplat\AppSrc\FindWindows.pkg |
||
7 | // $ProjectName : VdfSplat DataFlex Debugger |
||
8 | // $Authors : Wil van Antwerpen |
||
9 | // $Created : 10.26.2016 19:15 |
||
10 | // $Type : GPL v2 |
||
11 | // |
||
12 | // Contents: |
||
13 | // |
||
14 | //***************************************************************************************** |
||
15 | //TH-RevisionStart |
||
16 | //TH-RevisionEnd |
||
17 | 19 | wil | |
18 | 53 | wil | |
19 | |||
20 | |||
21 | |||
22 | 19 | wil | External_function GetDlgItem "GetDlgItem" User32.dll ; |
23 | Handle hWnd ; |
||
24 | Integer nIDDlgItem ; |
||
25 | Returns Handle |
||
26 | |||
27 | // Find the handle to a window whose class name and window name match |
||
28 | // the specified strings. The Function searches child windows, |
||
29 | // beginning with the one following the specified child window. |
||
30 | External_function FindWindowEx "FindWindowExA" User32.dll ; |
||
31 | Handle hWndParent ; |
||
32 | Handle hWndChildAfter ; |
||
33 | Pointer lpszClass ; |
||
34 | Pointer lpszWindow ; |
||
35 | Returns Handle |
||
36 | |||
37 | External_function GetClassName "GetClassNameA" user32.dll ; |
||
38 | Handle hWnd ; |
||
39 | Pointer lpClassName ; |
||
40 | Integer nMaxCount ; |
||
41 | Returns Integer |
||
42 | |||
43 | |||
44 | |||
45 | //Showln "Print some text" // this creates the output window |
||
46 | |||
47 | // Finds the next windows child object given by parent window hWnd |
||
48 | // for class sClass |
||
49 | // The search is case insensitive |
||
50 | // If hWndChild = 0 the first child is returned. |
||
51 | // Returns: The windows handle of the child object if found |
||
52 | Function FindNextChildWindowByClass Handle hWnd Handle hWndChild String sClass Returns Handle |
||
53 | String sClassName |
||
54 | Handle lpsClassName |
||
55 | Integer nChar |
||
56 | Boolean bStop |
||
57 | |||
58 | //Move (Left(Lowercase(sClass),10)) To sClass |
||
59 | Move (Lowercase(sClass)) To sClass |
||
60 | |||
61 | Move (False) To bStop |
||
62 | While Not (bStop) |
||
63 | //Showln "PARENT = " (IntToHex(hWnd)) |
||
64 | Move (FindWindowEx(hWnd,hWndChild,'','')) To hWndChild |
||
65 | //Showln "FindWindowEx " (IntToHex(hWndChild)) |
||
66 | If (hWndChild=0) Begin |
||
67 | // No Childs found, stop here |
||
68 | Move (True) To bStop |
||
69 | End |
||
70 | Else Begin |
||
71 | Move (Repeat(Character(0),80)) To sClassName |
||
72 | GetAddress Of sClassName To lpsClassName |
||
73 | Move (GetClassName(hWndChild,lpsClassName,40)) To nChar |
||
74 | If (nChar<>0) Begin |
||
75 | Move (Left(Lowercase(Cstring(sClassName)),nChar)) To sClassName |
||
76 | If (sClass=sClassName) Begin |
||
77 | Move (True) To bStop |
||
78 | End |
||
79 | End |
||
80 | End |
||
81 | Loop |
||
82 | Function_Return (hWndChild) |
||
83 | End_Function // FindNextChildWindowByClass |
||
84 | |||
85 | 53 | wil | // Finds the first windows child object given by parent window hWnd |
86 | // |
||
87 | // If hWndChild = 0 the first child is returned. |
||
88 | // Returns: The windows handle of the child object if found |
||
89 | Function FindFirstChildWindowHandle Handle hWnd Returns Handle |
||
90 | Handle hWndChild |
||
91 | Move (FindWindowEx(hWnd,0,'','')) To hWndChild |
||
92 | Function_Return hWndChild |
||
93 | End_Function // FindFirstChildWindowHandle |
||
94 | |||
95 | |||
96 | // Finds the next windows child object given by parent window hWnd |
||
97 | // |
||
98 | // Returns: The windows handle of the child object if found |
||
99 | Function FindNextChildWindowHandle Handle hWnd Handle hWndChild Returns Handle |
||
100 | Handle hWndNextChild |
||
101 | Move (FindWindowEx(hWnd,hWndChild,'','')) To hWndNextChild |
||
102 | Function_Return hWndNextChild |
||
103 | End_Function // FindNextChildWindowHandle |
||
104 | |||
105 | Function WindowsClassnameForWindowsHandle Integer hWnd Returns String |
||
106 | String sClassName |
||
107 | Handle lpsClassName |
||
108 | Integer nChar |
||
109 | |||
110 | Move "" To sClassName |
||
111 | If (hWnd<>0) Begin |
||
112 | ZeroString 120 To sClassName |
||
113 | GetAddress Of sClassName To lpsClassName |
||
114 | Move (GetClassName(hWnd,lpsClassName,119)) To nChar |
||
115 | If (nChar<>0) Begin |
||
116 | Move (Left(CString(sClassName),nChar)) To sClassName |
||
117 | End |
||
118 | Else Move "" To sClassname |
||
119 | End |
||
120 | Function_Return sClassName |
||
121 | End_Function // WindowsClassnameForWindowsHandle |
||
122 | |||
123 | |||
124 | |||
125 | 19 | wil | Function WindowsClassname Integer hObject Returns String |
126 | String sClassName |
||
127 | Handle lpsClassName |
||
128 | Handle hWnd |
||
129 | Integer nChar |
||
130 | |||
131 | Move "" To sClassName |
||
132 | If (hObject) Begin |
||
133 | Move (Window_Handle(hObject)) To hWnd |
||
134 | If (hWnd<>0) Begin |
||
135 | Move (Repeat(Character(0),40)) To sClassName |
||
136 | GetAddress Of sClassName To lpsClassName |
||
137 | Move (GetClassName(hWnd,lpsClassName,30)) To nChar |
||
138 | If (nChar<>0) Begin |
||
139 | Move (Left(Lowercase(CString(sClassName)),nChar)) To sClassName |
||
140 | End |
||
141 | Else Move "" To sClassname |
||
142 | End |
||
143 | Else Move "" To sClassname |
||
144 | End |
||
145 | Function_Return sClassName |
||
146 | End_Function // WindowsClassname |