#include #include #include LRESULT CALLBACK MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam) { static HWND hwndButton = 0; static HWND hEdit=0; HDC hdc;/* A device context used for drawing */ PAINTSTRUCT ps;/* Also used during window drawing */ RECT rc;/* A rectangle used during drawing */ switch (nMsg) { case WM_CREATE: { /* Now create the button */ hwndButton = CreateWindow ("button","Vajuta", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 100, 100, 30, hwnd,(HMENU) 1,((LPCREATESTRUCT) lParam)->hInstance,NULL); hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL , 0, 0, 100, 30, hwnd, (HMENU)2, GetModuleHandle(NULL), NULL); return 0; break; } case WM_DESTROY: PostQuitMessage (0); return 0; break; case WM_COMMAND: if (LOWORD(wParam) == 1 && HIWORD(wParam) == BN_CLICKED && (HWND) lParam == hwndButton) { int tekstipikkus=GetWindowTextLength(hEdit); LPSTR tekst=LPSTR(GlobalAlloc(GPTR, tekstipikkus+1)); GetWindowText(hEdit, tekst, tekstipikkus+1); MessageBox(hwnd, tekst, "Teade", MB_OK); } return 0; break; } return DefWindowProc (hwnd, nMsg, wParam, lParam); } int STDCALL WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) { HWND hwndMain;/* Handle for the main window. */ MSG msg;/* A Win32 message structure. */ WNDCLASSEX wndclass;/* A window class structure. */ char*szMainWndClass = "WinTestWin"; memset (&wndclass, 0, sizeof(WNDCLASSEX)); wndclass.lpszClassName = szMainWndClass; wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = MainWndProc; wndclass.hInstance = hInst; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION); wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); RegisterClassEx (&wndclass); hwndMain = CreateWindow ( szMainWndClass, "Hello", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, NULL ); ShowWindow (hwndMain, nShow); UpdateWindow (hwndMain); while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); } return msg.wParam; }