\Win32 API
simple_demo.c
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int iShow) { HWND hWnd; HWND hWndChat; MSG msg; WNDCLASS wc; TCHAR tcClassName[] = TEXT("MsnPacket"); wc.lpszClassName = tcClassName; wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbClsExtra = 0; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpfnWndProc = WndProc; wc.lpszMenuName = 0; wc.hInstance = hInst; wc.hbrBackground = (HBRUSH)CreateSolidBrush(WND_COLOR); if(!RegisterClass(&wc)) { MessageBox(NULL, TEXT("Could not register class"), TEXT("Error"), MB_ICONERROR | MB_OK); return 0; } hWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), 0, NULL); ShowWindow(hWnd, iShow); while(GetMessage(&msg, NULL, 0, 0)) { if(!IsDialogMessage(hWnd, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return 0; } LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { TCHAR cBuffer[1024]; HDC hdcStatic; int iIndex; switch(msg) { case WM_PAINT: \* Paint stuff here */ return 0; case WM_CLOSE: case WM_DESTROY: PostQuitMessage(0); return 0; case WM_CTLCOLORSTATIC: hdcStatic = (HDC)wParam; SetTextColor(hdcStatic, TXT_COLOR); SetBkMode(hdcStatic, TRANSPARENT); return (LONG)ghBrush; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_LIST1: break; case IDC_EXIT: SendMessage(hWnd, WM_DESTROY, 0, 0); return 0; } return 0; } return DefWindowProc(hWnd, msg, wParam, lParam); }