Hello, this one is really ridiculous one. There are no problems at all with compilation but there is still a problem with functions.
I have no idea why does not the programme call my function but the code is right (I hope) if I copy the code straight to the WM_PAINT command it works normally. But if I try to call a function with the same content as before it suddenly fails to work...
Can you chceck please the code?
MS VC++Code:#include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { TCHAR szAppName[] = TEXT("Default window"); // Header HWND hWnd; MSG msg; WNDCLASSEX wc; wc.cbSize = sizeof(wc); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // Ico wc.hIconSm = NULL; // Ico_sm wc.hCursor = (HCURSOR)LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+0); // Background wc.lpszMenuName = NULL; wc.lpszClassName = szAppName; RegisterClassEx(&wc); hWnd = CreateWindowEx(0,szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, // Margin from left CW_USEDEFAULT, // Margin from top CW_USEDEFAULT, // Widht CW_USEDEFAULT, // Height NULL, NULL, hInstance,NULL); ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } void OnWM_PAINT() { HWND hWnd; HDC hDC; PAINTSTRUCT ps; RECT rect; GetClientRect(hWnd, &rect); hDC = BeginPaint(hWnd, &ps); DrawText(hDC, "Text text", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint(hWnd, &ps); } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_PAINT: OnWM_PAINT(); break; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, message, wParam, lParam); }
Dev-C++
Thank you for support



LinkBack URL
About LinkBacks




