Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nervo

Win32 API Rich Edit Control questions

This topic is 5359 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is actually two issues I have. To use a rich edit control from the api I did:
LoadLibrary("Riched32.dll")

	hwnd_edit = CreateWindow(TEXT("RICHEDIT"),NULL,ES_AUTOVSCROLL | ES_LEFT|
		ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_VSCROLL,
		20,20,660,450,hwnd,NULL,NULL,NULL)

...which works fine, but initially I did a LoadLibrary("Riched20.dll") and subsequently called CreateWindow() which gave an error Invalid Handle. I'm not sure why. Second issue (bigger one) : I am trying now change the foreground color of the text to green. This does not work at all. To see whether I was on the right path, I changed some other arbitrary attribute such as italic text, and this did work. But changing the color does not. I really have no idea why!
   
CHARFORMAT edit_properties;

	edit_properties.cbSize = sizeof(CHARFORMAT);
	edit_properties.dwMask = CFM_COLOR;
	edit_properties.crTextColor = RGB(0,255,0);

	SendMessage(hwnd_edit,EM_SETCHARFORMAT,(WPARAM) SCF_ALL,(LPARAM)&edit_properties)
It seems trivial enough, but I'm just out of ideas. Thanks again in advance. EDIT: Additionally, when I did call riched20.dll I also specified TEXT("RICHEDIT_CLASS") as the type. [edited by - nervo on April 15, 2004 11:15:21 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
TEXT("RICHEDIT" should be the numeric constant RICHEDIT or with no TEXT(" ". This constant is defined in the richedit.h header file.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
TEXT("RICHEDIT" should be the numeric constant RICHEDIT or with no TEXT(" ". This constant is defined in the richedit.h header file.


Ah. I found that what you''ve said is very much correct when declaring RICHEDIT_CLASS (Rich Edit 2.0 and greater)...But it does require TEXT("RichEdit") for the Rich Edit 1.0 specification.

One down, one to go..

Share this post


Link to post
Share on other sites
I solved my problem, but I''d love for someone here seasoned in win32 programming to tell me why I had to change the CFM_COLOR preprocessor macro to its hex value of 0x40000000 literally in the struct in order for it to work? Is my compiler crazy? Am I crazy? Both? The compiler should succesfully be able to switch out the macro to its #define value, but I did it explicitly...please tell me if this is some vs quirk. Visual Studio 7.0

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!