Dobrze. Program już się kompluje bez żadnych błędów, lecz nadal nie reaguje na naciśnięcie Entera...
Zamieszczam tutaj mocno okrojony kod programu (usunąłem tu wszystko, co nie jest związane z moim problemem):
Kopiuj
#include <windows.h>
#include <richedit.h>
#include <commctrl.h>
HWND hSearchControl, hButton, hText, hWnd;
HFONT hFontButton;
CHAR szClassName[] = "MainWindow";
HINSTANCE* hInst;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lStart, INT nShow)
{
LoadLibrary("RICHED32.DLL");
hInst = &hInstance;
WNDCLASSEX wc;
wc.hInstance = *hInst;
wc.lpszClassName = szClassName;
wc.lpfnWndProc = WndProc;
wc.style = 0;
wc.cbSize = sizeof(WNDCLASSEX);
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hIconSm = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.lpszMenuName = "Menu";
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
if(!RegisterClassEx(&wc))
return 0;
hWnd = CreateWindowEx(0, szClassName, "Co jest nie tak?", WS_OVERLAPPEDWINDOW, 20, 20, 680, 480, 0, 0, *hInst, 0);
ShowWindow(hWnd, nShow);
MSG msgs;
while(GetMessage(&msgs, 0, 0, 0))
{
TranslateMessage(&msgs);
DispatchMessage(&msgs);
}
return msgs.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wPar, LPARAM lPar)
{
switch(msg)
{
case WM_CREATE:
hSearchControl = CreateWindowEx(WS_EX_CLIENTEDGE, "richedit", 0, WS_CHILD|WS_VISIBLE, 10, 110, 570, 25, hwnd, 0, *hInst, 0);
hButton = CreateWindowEx(0, WC_BUTTON, "Szukaj", WS_CHILD|WS_VISIBLE, 590, 110, 70, 25, hwnd, (HMENU)0, *hInst, 0);
hFontButton = CreateFont(16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial CE");
SendMessage(hButton, WM_SETFONT, (WPARAM)hFontButton, 1);
hText = CreateWindowEx(WS_EX_CLIENTEDGE, "richedit", 0, WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|WS_VSCROLL|ES_READONLY, 10, 145, 650, 270, hwnd, (HMENU)0, *hInst, 0);
SendMessage(hSearchControl, EM_SETEVENTMASK, 0, ENM_KEYEVENTS);
break;
case WM_NOTIFY:
if(((MSGFILTER*)lPar) -> msg == VK_RETURN)
MessageBox(0, "Naciśnięto Enter", "", MB_ICONINFORMATION);
break;
case WM_COMMAND:
if(wPar == 0)
MessageBox(0, "Naciśnięto przycisk Szukaj", "", MB_ICONINFORMATION);
break;
case WM_DESTROY:
DestroyWindow(hSearchControl);
DestroyWindow(hButton);
DestroyWindow(hText);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wPar, lPar);
}
return 0;
}