Click here to Skip to main content
15,912,578 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Check for Unicode Pin
Dominik Reichl8-Jun-03 5:15
Dominik Reichl8-Jun-03 5:15 
GeneralRe: Check for Unicode Pin
PJ Arends8-Jun-03 9:29
professionalPJ Arends8-Jun-03 9:29 
GeneralRe: Check for Unicode Pin
Dominik Reichl8-Jun-03 21:01
Dominik Reichl8-Jun-03 21:01 
GeneralRichedit control in Win32 C++ Pin
tareqsiraj7-Jun-03 19:49
tareqsiraj7-Jun-03 19:49 
GeneralRe: Richedit control in Win32 C++ Pin
Michael Dunn7-Jun-03 20:17
sitebuilderMichael Dunn7-Jun-03 20:17 
GeneralRe: Richedit control in Win32 C++ Pin
tareqsiraj7-Jun-03 22:26
tareqsiraj7-Jun-03 22:26 
GeneralRe: Richedit control in Win32 C++ Pin
Ryan Binns8-Jun-03 4:45
Ryan Binns8-Jun-03 4:45 
GeneralRe: Richedit control in Win32 C++ Pin
tareqsiraj8-Jun-03 5:49
tareqsiraj8-Jun-03 5:49 
Here is the code ...

#define WIN32_LEAN_AND_MEAN
#include < windows.h >
#include < stdlib.h >
#include < richedit.h >
#include < commctrl.h >

HWND _rich;
HMODULE _hRich;
char className[14];

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_CREATE:
		_rich = CreateWindowEx(WS_EX_CLIENTEDGE,
							className,
							"Sample Text",
							WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_BORDER | WS_VSCROLL,
							10, 10,
							200, 200,
							hWnd,
							0,
							GetModuleHandle(0),
							0);
		
		LPVOID lpMsgBuf;	
		FormatMessage( 		
			FORMAT_MESSAGE_ALLOCATE_BUFFER | 		
			FORMAT_MESSAGE_FROM_SYSTEM | 		
			FORMAT_MESSAGE_IGNORE_INSERTS,		
			NULL,		
			GetLastError(),		
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language		
			(LPTSTR) &lpMsgBuf,		
			0,		
			NULL );	
		MessageBox( 
			NULL, 
			(LPCTSTR)lpMsgBuf, 
			"Error", 
			MB_OK | MB_ICONINFORMATION 
			);	
		LocalFree( lpMsgBuf );
		break;

	case WM_CLOSE:
		DestroyWindow(hWnd);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX wc;
	HWND _hWnd;

	ZeroMemory(className, 14);
	InitCommonControls();

	_hRich = LoadLibrary("RICHED20.DLL");
	if (!_hRich)
	{
		_hRich = LoadLibrary("RICHED32.DLL");
		if (!_hRich)
		{
			MessageBox(0, "Richedit control not loaded!", "Error", MB_ICONERROR);
			exit(0);
		}
		else
		{
			strcpy(className, "RichEdit");
		}
	}
	else
	{
		strcpy(className, "RICHEDIT_CLASS");
	}

	wc.cbClsExtra = 0;
	wc.cbSize = sizeof(WNDCLASSEX);
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
	wc.hCursor = 0;
	wc.hIcon = 0;
	wc.hIconSm = 0;
	wc.hInstance = hInstance;
	wc.lpfnWndProc = (WNDPROC)WndProc;
	wc.lpszClassName = "MainWindowClass";
	wc.lpszMenuName = 0;
	wc.style = 0;

	if (!RegisterClassEx(&wc))
	{
		MessageBox(0, "Error", "", MB_ICONERROR);
		exit(0);
	}

	_hWnd = CreateWindowEx(WS_EX_WINDOWEDGE,
					"MainWindowClass",
					"",
					WS_OVERLAPPEDWINDOW,
					0, 0,
					300, 300,
					0, 0,
					hInstance, 0);

	ShowWindow(_hWnd, SW_SHOW);
	UpdateWindow(_hWnd);

	MSG msg;

	while (GetMessage(&msg, 0, 0, 0) > 0)
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return msg.wParam;
}


-Tareq
GeneralRe: Richedit control in Win32 C++ Pin
Ryan Binns8-Jun-03 15:54
Ryan Binns8-Jun-03 15:54 
GeneralRe: Richedit control in Win32 C++ Pin
tareqsiraj9-Jun-03 8:30
tareqsiraj9-Jun-03 8:30 
GeneralRe: Richedit control in Win32 C++ Pin
ashxly7-Jun-03 22:21
ashxly7-Jun-03 22:21 
GeneralRe: Richedit control in Win32 C++ Pin
tareqsiraj7-Jun-03 22:28
tareqsiraj7-Jun-03 22:28 
GeneralRe: Richedit control in Win32 C++ Pin
ashxly7-Jun-03 22:33
ashxly7-Jun-03 22:33 
GeneralRe: Richedit control in Win32 C++ Pin
tareqsiraj7-Jun-03 22:44
tareqsiraj7-Jun-03 22:44 
GeneralRe: Richedit control in Win32 C++ Pin
ashxly7-Jun-03 22:52
ashxly7-Jun-03 22:52 
GeneralRe: Richedit control in Win32 C++ Pin
tareqsiraj7-Jun-03 22:57
tareqsiraj7-Jun-03 22:57 
Generaldebugging embedded C in MFC Pin
willTuck7-Jun-03 19:32
willTuck7-Jun-03 19:32 
GeneralRe: debugging embedded C in MFC Pin
ashxly7-Jun-03 22:26
ashxly7-Jun-03 22:26 
Generaleditbox question... Pin
JoeSox7-Jun-03 18:50
JoeSox7-Jun-03 18:50 
GeneralRe: editbox question... Pin
Weiye Chen7-Jun-03 19:05
Weiye Chen7-Jun-03 19:05 
GeneralRe: editbox question... Pin
JoeSox8-Jun-03 7:43
JoeSox8-Jun-03 7:43 
GeneralRe: editbox question... Pin
ashxly7-Jun-03 22:30
ashxly7-Jun-03 22:30 
GeneralRe: editbox question... Pin
JoeSox8-Jun-03 7:44
JoeSox8-Jun-03 7:44 
QuestionHow can a CPropertySheet instance be added to a CPropertySheet as a CPropertyPage Pin
FlyingDancer7-Jun-03 15:50
FlyingDancer7-Jun-03 15:50 
AnswerRe: How can a CPropertySheet instance be added to a CPropertySheet as a CPropertyPage Pin
Weiye Chen7-Jun-03 19:11
Weiye Chen7-Jun-03 19:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.