Observe with SPY ++:
This is an MDI program. The window name of the outermost MDI main framework is known-"MDIMainFrame" ---
Then, there is a Class Name: MDIClient window ----------- B
Next, there is a window titled "hSDIClient" ------------ C
Then, there is a Class Name: AfxFrameOrView70 window ------- D
Then, there is a window under the Class Name: SysListView32 --------- E
HTemp = finddomainwex (getdomaintopwindow (), 0, "MDIMainFrame ","");
HTemp = find1_wex (hTemp, 0, "MDIClient ","");
HTemp = find1_wex (hTemp, 0, NULL, "hSDIClient ");
HTemp = find1_wex (hTemp, 0, "AfxFrameOrView70 ","");
HTemp = find1_wex (hTemp, 0, "SysListView32 ","");
In VB6, how does one automatically obtain the "Save as" dialog box handle?
Private Declare Function FindWindow Lib "user32" Alias "find0000wa" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, byVal wFlags As Long) As Long
Private Const HWND_BOTTOM = 1
Private Const SWP_SHOWWINDOW = & H40
Private Const SWP_HIDEWINDOW = & H80
Private Sub commandementclick ()
Dim h1, h2, Point As Long
Shell "NotePad", vbNormalFocus 'open NotePad
H1 = FindWindow ("Notepad", "untitled-Notepad ")
'Showwindow h1, 0' hide notepad window
SetWindowPos h1, HWND_BOTTOM,-100,-100, 0, 0, SWP_HIDEWINDOW
SendKeys "PowerBASIC China", true' type some characters
SendKeys "% FA", True 'Open the Save As dialog box
H2 = FindWindow ("#32770", "Save as") 'to get the handle of the Save As dialog box
'Showwindow h2, 0' hide and save as dialog box
SetWindowPos h2, HWND_BOTTOM,-100,-100, 0, 0, SWP_HIDEWINDOW
SendKeys "C: \ PowerBASIC.txt", true' input file name
SendKeys "{TAB}", true': Focus on the Save button
SendKeys "{ENTER}", true' press ENTER
SendKeys "% (FX)", true' exit notepad
MsgBox "your file has been saved to C: \ PowerBASIC.txt! "
End Sub
Q: sendmessage requires a dialog box handle, but the dialog box does not have a title and is hidden. The handle cannot be obtained using Findwindow. How can I obtain the handle of this dialog box?
; Wn) Gb! S o! B {0 answer: Water Conservancy blog, yW] s H *[
* {H t] 0 | U5W @ 0 find title = "" dialog box> water conservancy blog ~ I uk) Aaf 'd3y
(X}: A [B/v0 [(o. p, \ (T0 //////////////////////////////////////
M "S5TB8N (a' + M4 [0 water conservancy blog X * YPKh7} iSw
How to obtain text in a dialog box, handle with the button, and send a click action to the button. Water Conservancy blog; B '] $ X, t2N (e, {# OC e
Water conservancy blog 9D] m'9fo
Public Declare Function GetDlgItem Lib "user32" Alias "GetDlgItem" (ByVal hDlg As Long, ByVal nIDDlgItem As Long) As Long
'S I, x1cCD0 {0 water conservancy blog 1 ^: '/| ~ O
This function retrieves the control handle in the specified dialog box.
/} 4EM5Ul. b0 water conservancy blog gW .? 7 bxSG + |
If the function call is successful, the return value is the window handle of the given control. If the function call fails, the return value is NULL, indicating an invalid dialog box handle or a non-existent control. To obtain more error information, call the GetLastError function. Water conservancy blog gRY % g {; B
Mi? Ih "U? HYL0o) W0hDlg: identifies a dialog box containing controls.
Qx % E, w8f; S [_ r0nlDDlgltem: ID of the control to be retrieved.
) Bu! Du # J7N? 0 water conservancy blog 5iTJ1 'd4n8g6x)] * S
You can use the GetDlgltem function by using any parent-child window pair, not just a dialog box. As long as the hDlg parameter specifies a parent window and the Child Window has an independent identifier (as specified by the hMenu parameter in CreateWindow or createmediawex of the Child Window ), getDlgltem returns a valid handle to the subwindow. Water conservancy blog I & fj_q * g
R? LpM
/// // Blog ba | q & TN8 [6e
How does B5Tw0zU5 \ 7'vv0 obtain the handle of the current active dialog box? Water conservancy blog H tUK-Jb
Water conservancy blog c8Y & a' aBRl
Water conservancy blog) I + [\ 4lN7d @
GetActiveWindow () is used to obtain the window in which the current thread processes messages.
? B & K/rE ^ 3gua [[BGx0GetForegroundWindow () to obtain the global input focus window. The window in which the character you typed appears.
The 'd2dw) Cc \ I * L] 0 dialog box is also a window, the same way. Water conservancy blog 6ye # whUVAD
Water conservancy blog FoXQ! V0' V
///////////////////////////////////
P (Lx7Yq8Q0
QL-s & I6tA % hx0 knows the handle of an edit control in a dialog box. What can I do if I want to know the handle of this dialog box?
Mcx5chla0 water conservancy blog! Hp3XS # J E8YT1p7i
This dialog box is used to obtain the handle of the GW_OWNER window of the edit Control Using GetWindow. However, the parent window of the edit Control is NULL.
Zo '@ 9e + BSz0 is there any other method? Water conservancy blog e-X ~ F'cc $ B} E
Ud "I" z, TV0N6B0U0
) R9t $ h | NZ # B7 {n0 this dialog box is a dialog box-based MFC program created through the wizard, and then drag and drop several EDIT
Q5T3VjzKD s '0 water conservancy blog u t $ N; {^ mq;] s )? B
Control. Nothing else. Water conservancy blog. U] N "Vv '-zxI
Water conservancy blog: qI cdi
Using spy ++, we found that the dialog box has two subwindows, namely the "OK" and "CANCEL" Buttons automatically created by the system, and I drag and drop the water conservancy blog % T6b (Y ~ [Iu :_
Water conservancy blog-uT U # x & c; XI
The removed EDIT control does not become a subwindow of the dialog box.
QF e. J: H0 water conservancy blog 1I} 7 ~ {: {DQ !?
Is there any way to get the handle of the dialog box?
M # EPze # a] 0 water conservancy blog q * p F | 7WkH
Water conservancy blog/h dMx-h # kM) EG
That is to say, is there a way to get the dlg from ITEM, like GetDlgItem?
-B! O4p6tu0tv PZ0 water conservancy blog U # H 'f * Q' I
DEH0fO Z0GetParent
~ M: _ G % k "V) CQ; B0 water conservancy blog; h/aw + [G \. @ VH
CWnd * wnd = (CWnd *) m_edit1.GetParent ();
% S ^ + U (] 5Q0wnd-> m_hWnd // handle
-D x. V3i # YSaD [0 water conservancy blog 9c' T $ o % ?! XJ
//////////////////////////////////////// /// // The water conservancy blog @ kK-@;] CM * m a & N/wf
H2V D2zg? P0
! Fq j) X9f & Ye % Yk "'0