★ 3个问题,请高手相助!十分感谢!!! !!!!!★

yunxp 2003-05-14 09:36:48


问题1:
请问,如果我已经知道了一个窗口的句柄为 2176窗口的类型为ComboBox,我想实现:一旦发现满足上述条件(即发现这个窗口出现),就立即自动把焦点聚在ComboBox上,并且在这个ComboBox上keybd_event模拟键盘打入字符"F"?

问题2:
我想编程实现对资源管理器窗口的刷新,(就是资源管理器右半边的SysListView32). 如果能实现右键里刷新的效果也可以的.我想操作注册表应该可以实现的.请问谁知道在哪里能够有相关的键值??我曾试过注册表内的一个资源管理器自动刷新的选项,但是不管用.


问题3:
我发现MkDir只能创建一级目录,如 MkDir "c:\aaa",请问如果我想创建二级目录,如MkDir "c:\aaa\bbb",该怎样做呢?有一个朋友给了我一个很复杂很复杂的例子,用了大量的自定义函数。我看了一下午还是没看懂。呵呵。

-----------------------------------------------------------------------
我是大连的编程菜鸟,My QQ:9227066 My Tel:0411-2113485
...全文
8 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
rainstormmaster 2003-05-14
'问题1
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SETTEXT = &HC
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function SetFocusAPI Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Private Const KEYEVENTF_KEYUP = &H2
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Const VK_H = 72
Const VK_E = 69
Const VK_L = 76
Const VK_O = 79
Private Sub Command1_Click()
'用SendMessage发送WM_SETTEXT消息的方式实现
Dim chwnd As Long, str1 As String * 256
chwnd = GetClassName(Me.Combo1.hwnd, str1, 256)
Dim bwnd As Long
bwnd = FindWindowEx(Me.hwnd, ByVal 0&, Trim(str1), vbNullString)
'以上是查找combo句柄的语句,要视你的情况改写
Dim str2 As String
str2 = "this is text"
SendMessage bwnd, WM_SETTEXT, 0, ByVal str2
End Sub

Private Sub Command2_Click()
'用keybd_event发送仿真击键方式的实现
Dim chwnd As Long, str1 As String * 256
chwnd = GetClassName(Me.Combo1.hwnd, str1, 256)
Dim bwnd As Long
bwnd = FindWindowEx(Me.hwnd, ByVal 0&, Trim(str1), vbNullString)
'以上是查找combo句柄的语句,要视你的情况改写
SetFocusAPI bwnd
keybd_event VK_H, 0, 0, 0 '按下H键
keybd_event VK_H, 0, KEYEVENTF_KEYUP, 0 '松开H键
keybd_event VK_E, 0, 0, 0
keybd_event VK_E, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_L, 0, 0, 0
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_L, 0, 0, 0
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_O, 0, 0, 0
keybd_event VK_O, 0, KEYEVENTF_KEYUP, 0
End Sub

Private Sub Form_Load()
Dim i As Integer
For i = 1 To 100
Combo1.AddItem CStr(i)
Next
End Sub
回复
道素 2003-05-14
1,Combo1.SetFocus
SendKeys vbKeyDown

2。HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\UPDATE,修改 "UPDATEMODE"值,由"1"改为"0",这样窗口就能做到自动刷新了。
3如果你不想用api那就循环用mkdir
把要建的路径存到数组中
回复
yunxp 2003-05-14
晕死~
回复
yunxp 2003-05-14
拜托啊!大哥们!
回复
yunxp 2003-05-14
没。。。没人理我?
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7489

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2003-05-14 09:36
社区公告
暂无公告