|
I am using VC++ and want to display UNICODE String on a Dialog box
Doing it like this :
CString str="Name";
wchar_t buf[255];
strcpy(pc_char1,str);
mbstowcs(buf,pc_char1,str.GetLength()+1);
SetDlgItemTextW(hWnd,IDC_VIEW,buf);
and HWND hWnd is declared in .h File
The problem is even though code compiles fine but nothing gets displayed.
|
|
|
|
|
CString str=_T("name");<br />
<br />
SetDlgItemText(IDC_BTN_RESET,str);
works fine
does that solve it?
|
|
|
|
|
Thanx
yaa , it has but what is the problem with the above code.
still figuring this out ...
in case of any suggestions , do reply
|
|
|
|
|
sonsam wrote: CString str=_T("name");
no. this instead :
CString str = L"Name";
|
|
|
|
|
I guess UNICODE is not defined else
Suneet.03 wrote: CString str="Name";
will not compile.
|
|
|
|
|
spsharma wrote: CString str="Name";
will not compile
sure it will, and it does !
but it doesn't work properly if UNICODE and _UNICODE are not defined...
|
|
|
|
|
In fact it will not compile if UNICODE is defined.
|
|
|
|
|
Suneet.03 wrote: CString str="Name";
wchar_t buf[255];
strcpy(pc_char1,str);
mbstowcs(buf,pc_char1,str.GetLength()+1);
SetDlgItemTextW(hWnd,IDC_VIEW,buf);
CString , strcpy() are not handling unicode...
use CStringW and wcscpy_s() instead, and of course, when using literals, type them with a prepending L
|
|
|
|
|
The data is not Unicode until the call to mbstowcs(...) at which point buf (a Unicode/wide character buffer) should contain Unicode data. At that point, the CString and strcpy(...) are no longer involved.
Most ANSI/MBCS applications are capable of handling Unicode data and vice-versa simpy by using/omitting the L prefix on strings to indicate a wide/narrow string and using the appropriate W /A suffix on the Win32 API. Your application configuration (UNICODE #define d or not) mostly indicates the default character width and version of the Win32 API to link with.
There is something else going on...
Peace!
-- modified at 7:49 Monday 16th July, 2007
(Posted before complete...)
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Assuming that pc_char is a suitable char buffer, the conversion to Unicode looks OK from here.
I would try a few things...
1: Remove the CString usage - it is not necessary and only adds time and another point for exception handling.
LPCTSTR pcData = "Name";
wchar_t wcaBuf[255];
::mbstowcs( wcaBuf, cpData, ::_tcslen( cpData ) );
::SetDlgItemTextW( hWnd, IDC_VIEW , wcaBuf );
<code>
2: Make sure that the conversion to Unicode was successful by checking the return value from mbstowcs(...)
3: Check the return value of SetDlgItemTextW(...) , and maybe try using SetWindowTextW(...) by first obtaining the HWND of the IDC_VIEW control.
4: This may be a stupid question, but are you sure that IDC_VIEW is a "text-able" control (edit, button, static/label, drop-list combobox)?
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Wow. Alot of discussion and 1-voting on this thread
Isn't this sufficient?
CStringW str=L"Name";
SetDlgItemTextW(hWnd,IDC_VIEW,str);
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
or this
CStringW str("Name");
SetDlgItemTextW(hWnd,IDC_VIEW,str);
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Or this:
SetDlgItemTextW( hWnd, IDC_VIEW, L"Name" ); :P
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Thanx guys for such quick replies.
One more thing , is UTF-8 conversion same as UNICODE conversion?
i think its same ...
|
|
|
|
|
Can anyone tell me how to change the caption of the button in a file dialog to
a cutomized one.....
thanx'n'advance
|
|
|
|
|
arshadkc wrote: Can anyone tell me how to change the caption of the button in a file dialog to
you have to subclass that CFileDialog class, and OnInitDialog of that function you can perform your required function!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
Send the button a WM_SETTEXT message.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Send the button a WM_SETTEXT message.
just wondering how to send message to filedialog when filedialog is running in modal state!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
This can be done in the dialog's OnInitDialog() method (if using MFC), or in response to the WM_INITDIALOG message.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: This can be done in the dialog's OnInitDialog() method (if using MFC), or in response to the WM_INITDIALOG message.
yeah you have subclass to achieve desired result
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
I agree with ThatsAlok subclass is easy you need to id of buttons of File Dialog.
|
|
|
|
|
I try to add lzh header and lzh extend header before a file in order to make a lzh file manually. According to lzh format, I use "-ld0-" and level 0x01 so i can avoid to write compress codes. But after i add this header to a file, there is wrong when i open it with winrar. The Message is that file was damanged. I think the problem maybe take place in two ways:
1. I don't know hwo to get the checksum in lzh header.
2. CRC-16 maybe is wrong, i just copy the code from internet.
Can someone give me advice in this topic, some demonstrated codes are best.
Thanks.
|
|
|
|
|
I've tested in ActiveX test container which runs very well,when user have register such control,it runs quickly.But when I've use web to automatically register this control,it always represents red x on web.By the way,I use MFC activeX with MFC share DLL and open all the access right for activex control,meanwhile, I've add the server ip to trusted zone.Can somebody give me a help?
Later buggers harm more.
|
|
|
|
|
I think u r using a cab file for downloading the activex.
Is your control getting downloaded, jus check it in
Tools->Internet Options->General->View Objects in ur browser
This is the place your ActiveX once downloaded gets displayed.
UnRegister previous ActiveX registered , u can use regsvr32 -u cmd
|
|
|
|