Creating a RichEdit Control

I have been trying to create a Richedit window but it doesn't work at all...
Could someone help me?
Thanks
What code do you have ??
My code is something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <windows.h>
#include <richedit.h>


HWND main, re;

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPInst, char* line, int show)
{
	WNDCLASS wc = {CS_VREDRAW|CS_HREDRAW,(WNDPROC)DefWindowProc,0,0,hInstance,LoadIcon(hInstance,MAKEINTRESOURCE(IDI_APPLICATION)),
		LoadCursor(hInstance,MAKEINTRESOURCE(IDC_ARROW)),GetSysColorBrush(COLOR_WINDOW),0,"wndclass"};
	RegisterClass(&wc);
	main=CreateWindowA("wndclass","title",WS_OVERLAPPEDWINDOW,64,64,640,480,0,0,hInstance,0);
	re=CreateWindow("RICHEDIT50W","text",WS_CHILD,10,10,300,300,main,0,hInstance,0);
	ShowWindow(re,show);
	ShowWindow(main,show);

	MSG Msg={0};
	while (GetMessageA(&Msg,0,0,0))
	{
		TranslateMessage(&Msg);
		DispatchMessageA(&Msg);
		
	}
	return 0;
}
Ah, my friend, there is more to this RichEdit Controls than meets the eye.
It didn't work for me either so I went checking.
here is your modified code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
HWND main, re;

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPInst, char* line, int show)
{
	
 LoadLibrary(TEXT("Riched32.dll"));   //notice this
    
    WNDCLASS wc = {CS_VREDRAW|CS_HREDRAW,(WNDPROC)DefWindowProc,0,0,hInstance,LoadIcon(hInstance,MAKEINTRESOURCE(IDI_APPLICATION)),
		LoadCursor(hInstance,MAKEINTRESOURCE(IDC_ARROW)),GetSysColorBrush(COLOR_WINDOW),0,L"wndclass"};
	RegisterClass(&wc);
	main=CreateWindowA("wndclass","title",WS_OVERLAPPEDWINDOW,64,64,640,480,0,0,hInstance,0);
	re=CreateWindowA("RICHEDIT","text",WS_BORDER|WS_CHILD|WS_VISIBLE|ES_MULTILINE,10,10,300,300,main,0,hInstance,0);
	//ShowWindow(re,show);
	ShowWindow(main,show);

	MSG Msg={0};
	while (GetMessageA(&Msg,0,0,0))
	{
		TranslateMessage(&Msg);
		DispatchMessageA(&Msg);
		
	}
	return 0;
}


Notice the LoadLibrary command on line 6.
(ps. I only commented out the showwindow because I used the WS_VISIBLE style);

Here is where I got the information from:
http://msdn.microsoft.com/en-us/library/bb787877(VS.85).aspx

Thanks a lot Guestgulkan!!
New Question:

I'm now able to load a RTF in my RichEdit but I don't know how to load a rtf file with an image in it (I would like to do that without MFC)

Thanks
A quick looks around shows this this is a known problem.

here is an article from CodeProject which gives a possible solution:

http://www.codeproject.com/KB/edit/csexrichtextbox.aspx


P.S
CodeGuru and CodeProject are very useful Windows programming sites:

http://www.codeproject.com
http://www.codeguru.com

Thanks, I had already surfed on those sites but I have the problem that I'm missing some headers (afx-something-.h)
That is because I'm using VC++ and with Express editions those headers don't come, could I skip this problem someway?
Last edited on
Topic archived. No new replies allowed.