|
I'd highly recommend you read these two articles:
These should answer your question and will be invaluable for the future, however make sure to read part I first as part II relies on knowledge obtained there.
|
|
|
|
|
A _bstr_t should certainly hold Chinese characters (it's effectively a managed wchar_t) - what's the problem that you're seeing?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
_bstr_t did hold chinese character.. But when i see the data using watch or print to any file it shows "????" only... Chinese fonts are definately installed in my system..As i'm reading from database and i can vivdly see chinese character in database.
Do i further need to typecast it??
Thanks..
|
|
|
|
|
How are you writing it to a file?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Now using this..
(char *)(wchar_t*)bstrString_Dest
|
|
|
|
|
As I asked before, "How are you writing it to a file?"
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm writing in ini file..Also i'm displaying in messagebox..Say the data is "Abc(Some chinese character)"
MessageBoxW(0, (wchar_t*)bstrString_Dest, 0, 0);
The messagebox prints "Abc(square brackets)".
WritePrivateProfileString(pszSection,pszKey,(char *)(wchar_t*)bstrString_Dest,
pszinipath);
And this prints "A" only...
|
|
|
|
|
gothic_coder wrote: The messagebox prints "Abc(square brackets)".
It's probably using non-Unicode font? The following code prints the expected ideaographs with Visual Studio 2008 and Windows 7
MessageBoxW(L"丁丂七", L"Test", MB_OK);
gothic_coder wrote: WritePrivateProfileString(pszSection,pszKey,(char *)(wchar_t*)bstrString_Dest,
pszinipath);
That's the ANSI call, so it's no surprise that you can't write Unicode successfully with that call. However, I don't think WritePrivateProfileString will write Unicode anyway.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Alright..
when i copy
MessageBoxW(L"丁丂七", L"Test", MB_OK);
It comes as
MessageBoxW(L"???", L"Test", MB_OK);
So it has something to do with my VC 6 setting..Isn't it..
Can someone throw light on it..
And please Stuart tell me how do i write the data on file (Notepad)???
Thanks
|
|
|
|
|
Well
MessageBoxW(0, (wchar_t *)bstrString_Dest, 0, 0);
giving me right data... Now the problem is how do i print this data to file?? Notepad??
Thanks..
|
|
|
|
|
Hello all,
I have a application where the file properties dialog is inadequate for the task so I want to use mine. There is an API for the application but there is no event for that particular dialog box so I am looking into windows hooks.
What I want to do is to capture this specific dialog box opeing so that I can shut it down and display my own.
I ideally want to do this in c# but from reading some articles, I understand that there is a certain amount i'll have to do in c++...Does anyone have any sample code that will achieve this or know of some good articles that will help? All I can seem to find are articles on keyboard and mouse hooks, I cannot find any articles that help with capturing dialog boxes let along specific dialog boxes of specific applications.
Any help will be appreciated.
Thanks
|
|
|
|
|
If you really want to hook, I believe you would need the WH_SHELL hook.
This should give you a notification when any window/dialog is going to be activated.
You have to find some method of identifying if it is right dialog.
If the file properties dialog is a standard windows properties dialog, I would recommend extending it rather than replacing it. You could use shell extensions for this.
Read these wonderful articles of shell extensions by Michael Dunn[^]
The Complete Idiot's Guide to Writing Shell Extensions - Index[^]
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I am trying to capture text from an external application that has it's textedit control set to readonly and keeps scrolling based on certain market conditions. Using Getwindowtext returns me a null string and so do other functions. I am trying to stay away from hooking as much as possible.
Since I am getting NULL string back. I could be wrong, but hooking won't work either, am I right?
The question I have is:
I can set my mouse at the location I want e.g
Point.x = 288;
Point.y = 15;
I can keep the Lbutton Clicked.
///
This is where I need help
How do I now move the mouse cursor to
Point.x = 350;
Point.y = 30;
and highlight the text uderneath it.
///
Or the next option is to capture the area as a bitmap. The captured area will always be text. Is it possible to convert this bitmap easily into text without comparing to findout what pixel is on and off.
If it is possible doing it the second way. Can you please direct me to some reading material. I have tried doing a search..All results I get are in Visual Basic. I am trying to get away from Visual Basic if I can and start using c++.
In the mean time help with the first option will be appreciated too.
|
|
|
|
|
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. <
|
|
|
|