sanjay0288
13 years agoFrequent Contributor
Help Needed in working with windows API
I am working on an application where i need to fetch values for some of the components developed in C++. For example I need to fetch the text which is displayed dynamically on an AFX title bar. I used the following dll method to fetch the text displayed in title bar but was unsuccessful since there is no text in wndcaption.(The below code is just an example)
Sub Call_SendMessage_FromDLL
'Handle = Sys.Process("notepad").Window("Notepad", "sanjay.txt - Notepad", 1).Window("Edit", "", 1).Handle
MessageID = 13 'WM_GETTEXT
MaxTextLen = 1000
' Defines the dll type
Set Def_DLL = DLL.DefineDLL("USER32")
' Registers the function type in TestComplete
Def_DLL.DefineProc "SendMessageA", vt_i4, vt_i4, vt_i4, vt_lpstr, vt_i4
' Creates an alias for SendMessageA
Def_DLL.DefineAlias "SendMessage", "SendMessageA"
Set LpStr = DLL.New("LPSTR", 256)
' Loads the dll
Set Lib = DLL.Load("USER32")
' Calls the function from the DLL
Lib.SendMessage Handle, MessageID, MaxTextLen, LpStr
Log.Message LpStr.Text
End Sub
And when i spoke to the developer they told :The text in the Title bar are drawn using GDI of MFC. The methods such as DrawText are used. Now I dont know which method should I use to fetch the text (which is written using Draw Text Method). Kindly help
Sub Call_SendMessage_FromDLL
'Handle = Sys.Process("notepad").Window("Notepad", "sanjay.txt - Notepad", 1).Window("Edit", "", 1).Handle
MessageID = 13 'WM_GETTEXT
MaxTextLen = 1000
' Defines the dll type
Set Def_DLL = DLL.DefineDLL("USER32")
' Registers the function type in TestComplete
Def_DLL.DefineProc "SendMessageA", vt_i4, vt_i4, vt_i4, vt_lpstr, vt_i4
' Creates an alias for SendMessageA
Def_DLL.DefineAlias "SendMessage", "SendMessageA"
Set LpStr = DLL.New("LPSTR", 256)
' Loads the dll
Set Lib = DLL.Load("USER32")
' Calls the function from the DLL
Lib.SendMessage Handle, MessageID, MaxTextLen, LpStr
Log.Message LpStr.Text
End Sub
And when i spoke to the developer they told :The text in the Title bar are drawn using GDI of MFC. The methods such as DrawText are used. Now I dont know which method should I use to fetch the text (which is written using Draw Text Method). Kindly help