Click to See Complete Forum and Search --> : 'SETTEXTEX' : undeclared identifier message - How can it be fixed?


deivakumar
January 16th, 2007, 04:42 AM
I am trying to use a RichEdit control in my code. I am able to bring up the window with the RichEdit control. I would like to populate the RichEdit dialog with some text using SendDlgItemMessage() but keep getting the error as follows:

D:\Test\Test.cpp(198) : error C2065: 'SETTEXTEX' : undeclared identifier
D:\Test\Test.cpp(198) : error C2146: syntax error : missing ';' before identifier 'setTextEx'
D:\Test\Test.cpp(198) : error C2065: 'setTextEx' : undeclared identifier
D:\Test\Test.cpp(199) : error C2228: left of '.codepage' must have class/struct/union type
D:\Test\Test.cpp(200) : error C2228: left of '.flags' must have class/struct/union type
D:\Test\Test.cpp(200) : error C2065: 'ST_DEFAULT' : undeclared identifier
D:\Test\Test.cpp(201) : error C2065: 'EM_SETTEXTEX' : undeclared identifier

I understand that I can get the text to be displayed on the RichEdit control by using Edit_SetText() but the thing that I would like to do is to be able to display special characters like the "TM" (trademark) and copyright (the circle with the 'c' in it). I found that if I use Edit_SetText(), I only see a '|" in the place of the special character in the RichEdit control. After reading in many sources, I found that I have to use SendDlgItemMessage(), which in turn needs SETTEXTEX.

When I looked at the richedit.h file, I found that SETTEXTEX was not in the header file.

I am attaching my project as a zip file. The RichEdit control can be found in the About dialog box, by clicking on the About menu item.

Could anyone help me please. If it is not too much to ask, it would be appreciated if you could edit my codes and send it to me (Sorry, I dun mean to be too demanding in any way but I am new to all of this. So any help would be most appreciated).

p.s. I am using MS Visual C++ 6.0. And I do not want to use MFC.

ovidiucucu
January 16th, 2007, 07:10 AM
If you are still using VC6.0 and some stuff is missing from your SDK header files, then it's time to download and install a newer Windows Platform SDK from Microsoft site.
As for example, one that can be found HERE (http://www.microsoft.com/downloads/details.aspx?familyid=484269E2-3B89-47E3-8EB7-1F2BE6D7123A&displaylang=en).

However, until accomplishing that, just as a temporary fast patch solution, try by adding these definitions:
#define ST_DEFAULT 0
#define ST_KEEPUNDO 1
#define ST_SELECTION 2
#define ST_NEWCHARS 4

typedef struct _settextex
{
DWORD flags;
UINT codepage;
} SETTEXTEX;

#define EM_SETTEXTEX (WM_USER + 97)

Aside note: the other solution is to get rid of old VC6.0 and step into XXI century, by acquiring and installing VC2005. [;)]
FYI, one free (which you can use as long as you don't need, don't want, or do hate MFC) can be found here: Microsoft Express Editions (http://msdn.microsoft.com/vstudio/express/).

deivakumar
January 16th, 2007, 09:36 AM
Thanks for that. I tired it and the compiling can be done without error.

However... here comes the bad news...

When I pass in a string with the 'TM' (trademark) symbol to the RichEdit control, it does not get displayed as 'TM'. Instead, it is displayed as | (the pipe symbol). The same applies to the copyright symbol.

How can I overcome this problem of displaying these symbols as they are, instead of the pipe symbol?