|
Hi all,
I have a MFC application, This application has a dialog which contains a
richedit control and an edit control, it likes chat dialog in Yahoo
Messenger. I type unicode string in edit control and I want to display it
in rich edit control after user typing enter key. To display the string in
rich edit control I used ReplaceSel function. After I call this function the
string that displays in rich edit control is not correct.
The chinese and japanese text shows as ????
Please show me how to display correctly this string in rich edit control.
Thank In Advance
|
|
|
|
|
1. Which version of Visual Studio are you using?
2. You are successfully able to type Unicode in edit control in the same window, but the problem is only with RichEdit?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
I am using Visual Studio. net 2005
Yes I am able to type it in Edit control and the problem is with RichEdit only.
|
|
|
|
|
Hmm... I faced this problem with earlier versions of VS. Can't believe they hadn't fixed it even on 2005.
This worked for me: Close the project, create a backup of your .RC file, open the .RC file with notepad and replace all instances of the word RICHEDIT with RICHEDIT20W . Save and close the .RC file.
Now build and run your app and let me know if that worked.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Thanks a lot it worked.
U r Genius. Hats off to you.
|
|
|
|
|
Dhiraj kumar Saini wrote: U r Genius. Hats off to you.
OK - I'm flattered.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
No its not flattery. Actually its b'coz of you all that our worked is eased out so I am thankful to you.
|
|
|
|
|
You're welcome.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: I'm flattered.
No, U r Genius!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you very much. I find this finally.... 
|
|
|
|
|
You're welcome!
This is why I like message boards. An answer given on the board helps someone years after.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Hi guys,
I want to display the content of an array of type unsigned char which contains ascii caracters in a Windows form textbox. After hours of trying to do this, I am asking for some help. I am using Visual C++ Express 2008.
The array is filled by a function who reads data from the serial port.
I get a pointer to that array of unsigned char from a defined function.
something like this :
unsigned char *RxBuffer; // Filled by a function reading COM port.
I want to Display it in a Textbox, something like this :
textBox1->Text = RxBuffer.ToString();
When I do this, it diyplays the decimal value of my ascii code.
For example if the first ascii code in my array is 0x41, I would like "A" to be displayed in the textbox. But instead it displays "51" which is the decimal value.
Any advice? Thx in advance.
|
|
|
|
|
you may try the following code, i am not sure that it works , but i think this is one of the ways to solve ur problem , try it !
CString str;
str.Format("%s %x",str, RxBuffer);
now str contains converted data
i think now you can display str in your text box
|
|
|
|
|
kapardhi wrote: CString str;
str.Format("%s %x",str, RxBuffer);
now str contains converted data
Nope. Can you spot the problem in your code?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
My code looks like this :
cRxBuff1 is the array which I want to diplay in the textbox.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
CUart ComPort;
ComPort.InitComPort(0x0F);
DWORD dwBytesRead1;
unsigned char cRxBuff1[EVAL_READ_BUFFER_LEN];
if(ReadFile(ComPort.MyHandleCOM1,cRxBuff1,EVAL_READ_BUFFER_LEN,&dwBytesRead1,NULL))
{
if(dwBytesRead1 > 0)
{
textBox1->Text= ???;
}
}
|
|
|
|
|
...
if(dwBytesRead1 > 0)
{
int i;
Byte b;
for (i=0; i<dwbytesread;> {
b = cRxBuff1[i];
textBox1->Text += b.ToString("x02");
}
}
...
Anyway, if you choose the right forum [^] then you'll have the chance of better answers.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Almost there, but it is still not diplaying text.
Like this it diplay the Hexadecimal value. 0x41 when I would like 'A' displayed.
If I change
textBox1->Text += b.ToString("x02");
to
textBox1->Text += b.ToString("s");
I get an unhandled exception error due to invalid format.
Sorry if it is not in the good forum, I thought this was related to Visual C++ problem, because my problem is I am not able to display text in a windows form textbox.
What could be the good forum in your opinion?
|
|
|
|
|
textBox1->Text += (Char) cRxBuff1[i];
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks a lot, it is working now.
I was sure to have tried this already.
In fact I tried the following just to test if I can display a caracter
textBox1->Text = (Char) cRxBuff1[0];
How come we can do
textBox1->Text += (Char) cRxBuff1[i];
but not
textBox1->Text = (Char) cRxBuff1[i];
??
|
|
|
|
|
Because a string is a sequence of characters.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
which header file do I need to include to use CString?
|
|
|
|
|
|
Nah it hasn't. That is why I was wondering how this can work. I saw some examples with stuff like this. At least the compiler accept it. I tried to do some thins like this too :
textBox1->Text = ToString(RxBuffer);
But its not working either.
I am not used to manipulate strings, I do mostly C code, and I have no clue how to do this.
|
|
|
|
|
Hi !!
My application is related with Smart card readers.
I actually use CreateFile() to create a handle to the port to which the reader is connected.
I use WriteFile () to send data to reader & receive response from reader using ReadFile ().
I compare the response sent by a reader, to detect whether it is a valid Reader or not
now my problem is if i donot connect a reader to the port, and use ReadFile (), it executes successfully, although there is no reader connected to the port.
So is there a function to detect whether a reader is connected to the port or not?
|
|
|
|
|
I will suggest you to send some basic command to reader.
If reader responds reader is there. Else you can time out and say no reader is connected.
Regards,
Sandip.
|
|
|
|