|
If you call GetWindowText from an external application you would not be able to get the text. You can inject code into the external application using hooks and then try to use GetWindowText on the control.
For the mouse movement, there is an API called SetCursorPos to move the mouse cursor. Or you could try sending the WM_MOUSEMOVE message with the button states and the new position.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Regarding the hooks. Due to somesecurity issues with the application and and the vendor..I will stay away from it for now unless I am really stuck I will use hooking.
Ok..I am able to set the mouse to the starting point of the text.
What you suggesting I have tried. Without releasing the button I moved it to the new position I wanted but the text is not hilighting. Not sure because of the moving the button gets released.
Here is the actual Code I used...
GetCursorPos CurMouse
SetCursorPos LongX, LongY
mouse_event MOUSEEVENTF_LEFTDOWN 0&, 0&, 0&, 0&
SetCursorPos CurMouse.X, CurMouse.Y
at this point I wanted the text highlighted but it is not.
|
|
|
|
|
In that case, I guess you would need to try and send the WM_MOUSEMOVE message.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yeah..However If I can get some help on my bitmap issue. this will not be required.
trying hard to get this going it was one of the main reasons I moved to C++. Was strugling with it in VB for the last3 to 4 months and I think I might have this solved with a little more help.
Thanks a million. I do appreciate all the help from everyone here.
|
|
|
|
|
Hello all... I've Win32 application in which i extract data from database and put into some file..Say notepad.. I'm facing problem in extracting chinese fonts..
For ex if the entry in database is "Abc (Some chinese stuff)" after extraction it comes "Abc ???????" in buffer...
How do i properly extract chinese character in VC++ ??
Thanks all...
|
|
|
|
|
You probably need to use unicode.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
This is what i'm doing...
_bstr_t bstrString_Ini;
_bstr_t bstrString_Tag;
_bstr_t bstrString_Dest;
char sqlQuery[2 * MAX_PATH] = "";
sprintf(sqlQuery, "SELECT IniSection,TagName,DestinationValue FROM %s WHERE FileName = '%s'" , szTableName, szstr);
_bstr_t sqlQueryText(sqlQuery);
try
{
ADODB::_CommandPtr m_objCmdSearch;
ADODB::_RecordsetPtr m_cpRecordsetSearch;
HRESULT hr = m_objCmdSearch.CreateInstance("ADODB.Command");
if(SUCCEEDED(hr))
{
m_objCmdSearch->ActiveConnection = m_cpConnection;
m_objCmdSearch->CommandType = ADODB::adCmdText;
m_objCmdSearch->CommandText = sqlQueryText;
m_cpRecordsetSearch = m_objCmdSearch->Execute(NULL, NULL, ADODB::adCmdText);
if(m_cpRecordsetSearch != NULL)
{
if(!m_cpRecordsetSearch->GetEndOfFile())
{
char szstr[MAX_PATH];
char szstr1[MAX_PATH];
m_cpRecordsetSearch->MoveFirst();
while(!m_cpRecordsetSearch->EndOfFile)
{
bstrString_Ini = m_cpRecordsetSearch->Fields->GetItem("IniSection")->GetValue().bstrVal;
bstrString_Tag = m_cpRecordsetSearch->Fields->GetItem("TagName")->GetValue().bstrVal;
bstrString_Dest = m_cpRecordsetSearch->Fields->GetItem("DestinationValue")->GetValue().bstrVal;
m_cpRecordsetSearch->MoveNext();
}
rVal = TRUE;
}
if((m_cpRecordsetSearch->State & ADODB::adStateOpen) != 0)
{
m_cpRecordsetSearch->Close();
m_cpRecordsetSearch = NULL;
}
}
m_objCmdSearch->PutRefActiveConnection(NULL);
}
}
And i get "Abc ????" in bstrString_Dest... Which is defined as _bstr_t...
bstrString_Dest = cpRecordsetSearch->Fields->GetItem("DestinationValue")->GetValue().bstrVal;
What else do i need to do.. I've enabled unicode in my project..
|
|
|
|
|
How did you determine what is in that variable (traced it out, pointed at it and checked the tooltip in VS, ...)? Are you sure the database correctly contains the chinese chars?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Yes i'm sure that database correctly contain chinese char (I saw it).. And i can see the value of that variable in tooltip only.. Other int values comes out perfect but this chinese stuff which is in last field, it only shows "????"..
Am i missing some setting or do i need to use other data type ?
Thanks
|
|
|
|
|
I'm not sure but i suspect that the tooltip simply doesn't handle the chinese chars...try to save the string into a txt file for example and then open it in word or such and see if it displays the chinese chars or not (you might need to select the right charset to actually see something usefull).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I tried.. I printed all the results into text file but result remains same.. some text in English followed by question mark...
I even tried putting in MS-Word file..But same result..
|
|
|
|
|
What happens if you retrieve the string into CString instead of _bstr_t ? Btw if you check out the string as a byte array, what do you get at the place of questionmarks? Can you maybe upload that text file somewhere for me so i can take a peak?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I can't use CString ... Not using MFC ..
Is there any subsitute of CString in Win32 ???
Thanks..
|
|
|
|
|
Hmm, am not sure...how about std:string ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Try outputting the string and check whether it is really some junk characters or you were just unable to view it properly.
You could do this.
MessageBox(0, (wchar_t*)bstrvariable, 0, 0);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
That give some hope..When i use MessageBoxW it doesn't give "????" , rather that it give some junk character (Might be chinese which is not supported in messagebox).. Trying to print into notepad..
|
|
|
|
|
I believe the characters are encoded in the multi-byte character set.
So you should first extract the characters into a char array instead of wchar_t array or string variable instead of wstring variable or you can explicitly use CStringA instead of CString .
After getting it into the variable, convert the multi-byte characters into wide characters using the MultiByteToWideChar API.
Now use that in a MessageBoxW function.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I just did this to print data on file...
(char *)(wchar_t*)bstrString_Dest
And it's printing chinese character... That was just a blind try..how did it work..Can someone explain?
|
|
|
|
|
I did this...
bstrString_Dest = m_cpRecordsetSearch->Fields->GetItem("DestinationValue")->GetValue().bstrVal;
Extracted the character in char array..
strncpy(bstrString_Dest_Char,(char*)bstrString_Dest, sizeof(bstrString_Dest_Char));
Converted using MultiByteToWideChar..
TCHAR wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, bstrString_Dest_Char, -1,
(wchar_t*)wsz, MAX_PATH);
Printed using Messagebox
MessageBoxW(0, (wchar_t*)wsz, 0, 0);
But same result
|
|
|
|
|
Use wchar_t instead of TCHAR
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
<quote>Use wchar_t instead of TCHAR
Changed it to this
wchar_t wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, bstrString_Dest_Char, -1,wsz, MAX_PATH);
MessageBoxW(0, wsz, 0, 0);
and this..
wchar_t wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, bstrString_Dest_Char, -1,(wchar_t*)wsz, MAX_PATH);
MessageBoxW(0, wsz, 0, 0);
But Same result...Gossh what am i doing wrong?
|
|
|
|
|
|
My final try.
Try CP_UTF8 instead of CP_ACP .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Sadly that didn't work either.. Anyways thanks for your help..
|
|
|
|
|
MessageBox(0, (wchar_t*)bstrvariable, 0, 0);
I guess this is giving me right data...
How do i print this to file.. Notepad??
Thanks..
|
|
|
|