| Код | #include <stdio.h> #include <windows.h> #include "resource.h"
HWND hWnd, hWndTextL, hWndTextP, hWndItemB; HINSTANCE hInstance; const char g_szClassName[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
DWORD WINAPI updateLP(char *l, char *p);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wc; MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); //wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) return 0;
hWnd = CreateWindowEx(0, g_szClassName, ("test"), WS_VISIBLE | WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, 300, 200, 198, 140, NULL, NULL, hInstance, NULL);
if(hWnd == NULL) return 0;
ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); }
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
char *var_l = (char*)malloc(64); char *var_p = (char*)malloc(64); //for Thread HANDLE hThread; DWORD IDThread;
HFONT hFont = CreateFont(-11, 0, 0, 0, 0, FALSE, FALSE, FALSE, 1, 0, 0, 0, 0, ("Ms Shell Dlg 2"));
switch(uMsg) { case WM_CREATE: hWndTextL = CreateWindowEx(0, "STATIC", ("test:"), WS_VISIBLE | WS_CHILD | SS_LEFT, 12, 13, 90, 13, hWnd, (HMENU)IDC_STATIC_L, hInstance, 0); //36->90 SendMessage(hWndTextL, WM_SETFONT, (WPARAM)hFont, FALSE); hWndTextP = CreateWindowEx(0, "STATIC", ("test2:"), WS_VISIBLE | WS_CHILD | SS_LEFT, 5, 39, 200, 13, hWnd, (HMENU)IDC_STATIC_P, hInstance, 0); //42->200 SendMessage(hWndTextP, WM_SETFONT, (WPARAM)hFont, FALSE); hWndItemB = CreateWindowEx(0, "BUTTON", ("go"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 110, 86, 78, 23, hWnd, (HMENU)IDC_BUTTON_C, hInstance, 0); SendMessage(hWndItemB, WM_SETFONT, (WPARAM)hFont, FALSE); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BUTTON_C: hThread = CreateThread(NULL, 0, updateLP, "sss"|"sss2", 0, &IDThread); WaitForSingleObject(hThread, INFINITE); CloseHandle(hThread); } break; } break; case WM_CLOSE: DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0;
}
DWORD WINAPI ClosePptp(char *l, char *p) { SendMessage(GetDlgItem(hWnd, IDC_STATIC_L), WM_SETTEXT, 0, (LPARAM)l); SendMessage(GetDlgItem(hWnd, IDC_STATIC_P), WM_SETTEXT, 0, (LPARAM)p); return 0; }
|
Программа почемута виснет подскажите где ошибся, собираю под mingw |