下面的代码通过编译,但为什么不能正常运行?请高手指教.
下面的代码通过编译,但为什么不能把“richedit"显示出来的?请高手指教.
还有就是如何才能支持unicode?要用sdk的。
#include <windows.h>
#include <richedit.h>
#include <commctrl.h>
HANDLE hRTFLib;
HINSTANCE hInst;
HWND hWndRichEdit;
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
InitCommonControls();
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
if(!RegisterClassEx(&wincl)) return 0;
hwnd = CreateWindowEx(
0,
szClassName,
"Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
544,
375,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);
hInst = hThisInstance;
ShowWindow(hwnd, nFunsterStil);
hRTFLib = LoadLibrary("riched20.dll");
while(GetMessage(&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
hWndRichEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
"RichEdit",
"HELLO!",
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_SAVESEL | WS_HSCROLL | WS_VSCROLL,
0,
0,
200,
200,
hwnd,
NULL,
hInst,
NULL);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}