日期:2014-05-20  浏览次数:20925 次

谁能帮我看看SendMessage的代码那里错了?(vb的代码,但是操作对象是.net编译的)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long 
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 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 Const TA_TOP = 0 

Private Sub Command1_Click() 
Dim NavHwnd As Long 
Dim NavName As String 
Dim NavBuffer As String * 256 
Dim TagHwnd As Long 
Dim Tag As Long 
NavHwnd = FindWindow("WindowsForms10.Window.8.app.0.33c0d9d", vbNullString) 
If NavHwnd <> 0 Then 
NavName = GetWindowText(NavHwnd, NavBuffer, 255) 
Text2.Text = Left$(NavBuffer, NavName) 
End If 
Tag = FindWindowEx(NavHwnd, TagHwnd, vbNullString, "Play Route") 
SendMessage TagHwnd, TA_TOP, 0, 0 
End Sub 

 

如图程序主要想激活名为Play Route 的TagPage控件(不知道TagPage的称呼是否正确,好像挺重要,大概影响常量的设定)可

能是donNet Framework里的标准控件,怎么样由hwnd获得相应的winform控件对象,然后调用其方法切换页签 ????

TA_TOP的常量使自己瞎猜的,网上没找到相关资料。 

除了Text2.Text可以正确显示该窗体的标题,运行以后没有反应。 

拜托了,帮顶、每天灌一贴、给链接、给思路。。。。。都欢迎。

>>>> Window < < < < 
Title: NavMan 
Class: WindowsForms10.Window.8.app.0.33c0d9d 
Position: 110, 110 
Size: 217, 410 
Style: 0x16CF0000 
ExStyle: 0x00050100 
Handle: 0x00010BFC 

>>>> Control < < < < 
Class: WindowsForms10.Window.8.app.0.33c0d9d 
Instance: 1 
ClassnameNN: WindowsForms10.Window.8.app.0.33c0d9d1 
Name: tabPage1 
Advanced (Class): [NAME:tabPage1] 
ID: 68618 
Text: Play Route 
Position: 1, 22 
Size: 207, 321 
ControlClick Coords: 28, 1 
Style: 0x56000000 
ExStyle: 0x00010000 
Handle: 0x00010C0A 

>>>> Mouse < < < < 
Position: 33, 46 
Cursor ID: 0 
Color: 0x000000 

补充一下,使用Window Info查到的窗体信息 



------解决方案--------------------
哈哈,不知道是要用PostMessage发TCM_SETCURSEL消息,还是用dotNet自带的方法解决:)