|
|
Bankey Khandelwal wrote: i want to run c++ program on linux platform...
Which makes no sense at all. Machines don't care what high-level language you used to create the application. As long as the binary matches the target platform, you're good to go. Now if you wanted to compile C++ code on a Linux box, that's a different animal altogether.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I developed a VC++ application and now I need to support UNICODE to show Hebrew strings into a CListCtrl. I added the declaration:
#define _UNICODE
but now I obtain several error during the compilation process:
error C2664: 'int ATL::CStringT<basetype,stringtraits>::Find(ATL::CSimpleStringT<basetype,t_bmfcdll>::XCHAR,int) throw() const' : cannot convert parameter 1 from 'const char [11]' to 'ATL::CSimpleStringT<basetype,t_bmfcdll>::XCHAR'
with
[
BaseType=wchar_t,
StringTraits=StrTraitMFC_DLL<wchar_t>,
t_bMFCDLL=true
]
and
[
BaseType=wchar_t,
t_bMFCDLL=true
]
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
This is because I used string constants without the _T("..."); prefix.
In my application there are several strings without _T prefix so I wanted to know if exist a workaround to use UNICODE without the intoruduction of _T prefix.
Remember that I need to display Hebrew strings.
Thank you
|
|
|
|
|
wollet wrote: In my application there are several strings without _T prefix so I wanted to know if exist a workaround to use UNICODE without the intoruduction of _T prefix.
I think you have to replace all strings without _T(...) with _T(...), it is one good way to avoid any future problems too.
Actually its a good practice for UNICODE aware program to always include the strings in _T() macro.
-Prakash
|
|
|
|
|
Firstly defining just "_UNICODE" is not enough - You need to define both "UNICODE" and "_UNICODE". "UNICODE" effects the Windows headers and "_UNICODE" the C runtime library. Make sure you "undefine" (remove) any "MBCS" defines. It would be best to make these definitions by altering the project settings and not be putting "#define"s in your code. Other peoples comments on the use the the "_T" or "_TEXT" macros apply.
Steve
|
|
|
|
|
How to place a ToolBar created by CreateWindowEx() in a particular position on Dialog. I tried by placing a static control & then...see code
WINDOWPLACEMENT w;
::GetWindowPlacement(::GetDlgItem(m_hWnd, IDC_STATIC_TOOL), &w);
::SetWindowPlacement(hToolBarHandle, &w);
But the ToolBar displayed bit lower than the position of static control.
When I tested using MFC it placed exactly sample place that of static text
::GetWindowPlacement(::GetDlgItem(m_hWnd, IDC_STATIC_TOOL), &w);
m_Toolbar.CreateEx(this,WS_CHILD | CCS_NOPARENTALIGN|TBSTYLE_FLAT);
m_Toolbar.LoadToolBar(IDR_TOOLBAR);
::SetWindowPlacement(m_Toolbar.m_hWnd, &w);
Also in MFC the width of toolbar is same as the toolbar resource/static control where we place the toolbar. But in SDK the displayed toolbar width is higher. How to set/fix size of tool bar in SDK. What could be the trouble in Win32 SDK way? any suggestions???
|
|
|
|
|
Hello
I need a complete education refrence in kernel mode programming in web.
thanks
Agh
|
|
|
|
|
By this question, i clearly mean to say that "My application needs to be Unicode-Aware". Just adding the 'UNICODE' directive is enough? (I did that but when I pasted unicode text in one edit box of my app, it showed ??? and not the unicode text)
What are the necessary steps (Linker directives, etc) that I should take to make sure that my app works fine with Unicode and is completely Unicode-Aware?
I know I should use all "W" functions and should place literal strings within _T.
Any pointers or help in this direction is highly appreciated.
Thanks and regards,
Aljechin Alexander
|
|
|
|
|
Aljechin wrote: I pasted unicode text in one edit box of my app, it showed ??? and not the unicode text
did you install appropriate language packs in your machine?
-Prakash
|
|
|
|
|
Without installing appropriate language packs how do I take Unicode text from some other app to paste here?
|
|
|
|
|
add _UNICODE to project settings.
-Prakash
|
|
|
|
|
Mr.Prakash wrote: add _UNICODE to project settings.
5/5
That's it dude! Heartfelt Thanks.
Best Regards and Thanks,
Aljechin Alexander
|
|
|
|
|
also add UNICODE
never say die
|
|
|
|
|
Sir,
What is the significance of adding UNICODE / _UNICODE? It's actually now I removed _UNICODE and added UNICODE, the app still understands unicode. I kept both UNICODE AND _UNICODE, the app still works with unicode. I don't understand this. Can someone explain me in detail? I went through The msdn documentation regarding the same, but didn't get it. (In all the cases I had to define an entry point by myself i.e. entry:wBlah, otherwise the compiler gave a bitter error complaining _WinMain@16 is an unresolved external symbol!)
Thanks,
Aljechin Alexander
![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
the two macros exist, but not manages the same places. so, the best way to handle unicode fully is to define the 2 macros this way (in stdafx.h for instance) :
<font color=green>
<font color=blue>#define</font> _UNICODE
<font color=blue>#define</font> UNICODE
<font color=green>
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
-- modified at 5:54 Monday 9th January, 2006
|
|
|
|
|
yes and this need to put preferablely in stdafx.h or any common header file that is included in all the files so that the project is compiled uniformly or add it to the project settings.
-Prakash
-- modified at 5:46 Monday 9th January, 2006
|
|
|
|
|
_UNICODE for C like wsprintf
UNICODE for Microsoft Function/API
never say die
|
|
|
|
|
Aljechin wrote: Just adding the 'UNICODE' directive is enough?
It's best to define both UNICODE and _UNICODE .
Aljechin wrote: I know I should use all "W" functions...
It might be easier to just use the macros defined in tchar.h like _tcscpy() and _tcslen() .
Aljechin wrote: I know I should...place literal strings within _T.
Correct.
Aljechin wrote: ...but when I pasted unicode text in one edit box of my app, it showed ??? and not the unicode text)...
Did you assign a Unicode font to the edit control?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Sir,
I will tell you in sequence what happened. First I added 'UNICODE' ( in project-settings ). The app was unaware of unicode (displayed ???). I added _UNICODE and suddenly the compiler gave me a bitter error that _WinMain@16 is an unresolved external symbol. I had to give my entry, i.e. entry:"wWinMainCRTStartup". I really dont know why I had to do this, but after this only it compiled, and the program worked with unicode. I did not assign any unicode font also, to the edit control. What is the significance of this "wWinMainCRTStartup"? and is that if i assign a unicode font to the edit control it can still go ahead to be unicode aware without defining _UNICODE and my own entry point "wWinMaainblahblah"?
Thanks and Regards,
Aljechin Alexander
![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
Aljechin wrote: What is the significance of this "wWinMainCRTStartup"?
It's the entry point for Unicode MFC applications.
Aljechin wrote: ...if i assign a unicode font to the edit control it can still go ahead to be unicode aware without defining _UNICODE and my own entry point "wWinMaainblahblah"?
The best way to answer "What happens if..." questions is to just try it and see.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Is there a way to convert RTF string to plain text?
Putting a string into CRichEditCtrl using Callback StreamIn and then getting it out using CRichEditCtrl::GetWindowText seems overly complicated and doesn't work in my case, since GetWindowText returns null unless you've displayed the string (UpdateData(FALSE)) and it doesn't support unicode (or at least I've been unable to get it working).
Just stripping RTF codes wouln't do since unicode rtf uses some strange character encoding.
If you know how to do it I'd really appreciate. (I think I've read something about coping it into clipboard and then getting plain text, but can't find it..)
Maciej Lisiewski
|
|
|
|
|
Maciej Lisiewski wrote: (I think I've read something about coping it into clipboard and then getting plain text, but can't find it..
Copy it to the Clipboard then get the CF_TEXT(?) format and use that. Should work.
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
|
Every bit of code I found/wrote in order to put CStringW into clipboard caused program crash (no exception thrown).
.. help?
-- modified at 8:25 Monday 9th January, 2006
|
|
|
|
|
Maciej Lisiewski wrote: Is there a way to convert RTF string to plain text?
After you stream it into the Rich Edit control you can always stream it out.
Reference:
CRichEditCtrl::StreamOut[^]
ZeePain! wrote: This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
thedailywtf.com[^]
|
|
|
|
|
For some reason it doesn't work.
I'm using this StreamIn/StreamOut:
<code>
static DWORD CALLBACK StreamOut( DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb )
{
// Setting up temp buffer
char* buff;
buff = new char[ cb + 1 ];
buff[ cb ] = ( char ) 0;
strncpy( buff, ( LPCSTR ) pbBuff, cb );
int max = strlen( buff );
CString* str = ( CString* ) dwCookie;
#ifdef _UNICODE
// We want to convert the buff to wide chars
int length = ::MultiByteToWideChar( CP_UTF8, 0, buff, max, NULL, 0 );
if( length )
{
TCHAR* wBuff = new TCHAR[ length ];
::MultiByteToWideChar( CP_UTF8, 0, buff, max, wBuff, length );
*str += wBuff;
delete[] wBuff;
}
#else
*str += buff;
#endif
delete[] buff;
*pcb = max;
return 0;
}
static DWORD CALLBACK StreamIn( DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb )
{
CString* str = ( ( CString* ) dwCookie );
#ifdef _UNICODE
// Unicode is only supported for SF_TEXT, so we need
// to convert
LPCTSTR ptr = str->GetBuffer( (*str).GetLength() );
int length = ::WideCharToMultiByte( CP_UTF8, 0, ptr, -1, NULL, 0, NULL, NULL );
int max = min( cb, length );
if( length )
{
char* buff = new char[ length ];
::WideCharToMultiByte( CP_UTF8, 0, ptr, -1, buff, length + 1, NULL, NULL );
strncpy( (LPSTR) pbBuff, buff, max );
delete[] buff;
}
str->ReleaseBuffer();
#else
int max = min( cb, (*str).GetLength() );
strncpy( ( LPSTR ) pbBuff, (*str) , max );
#endif
(*str) = (*str).Right( (*str).GetLength() - max );
*pcb = max;
return 0;
}
</code>
If I StreamIn with SF_RTF and StreamOut with SF_TEXT I end up with an empty string or one far too long, but containing the desired data.
-- modified at 8:25 Monday 9th January, 2006
|
|
|
|