004
11.11.2004, 17:18 Uhr
xXx
Devil
|
Hi, ich hab die Englische Version von Visual Studio, da heißt das glaub ich mal anders oder?
Hier ist auf jedenfall mal der Code:
C++: |
#include <windows.h> #include <tchar.h>
LRESULT CALLBACK WfFu(HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow) { WNDCLASSEX wc = {0}; wc.cbSize = sizeof(WNDCLASSEX); static TCHAR szAppName[] = _T("Fenster"); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WfFu; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = reinterpret_cast(COLOR_WINDOW + 1); wc.lpszMenuName = NULL; wc.lpszClassName = szAppName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wc);
HWND hWnd = CreateWindowEx( WS_EX_CLIENTEDGE, szAppName, _T("Unser erstes Fenster"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd);
MSG msg; while (GetMessage(&msg,NULL, 0, 0) == TRUE) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
LRESULT CALLBACK WfFu(HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam) { switch (message) { case WM_PAINT: { PAINTSTRUCT paintst; HDC hDC = BeginPaint(hWnd, &paintst); RECT rcClient; GetClientRect(hWnd, &rcClient); int nOldBkMode = SetBkMode(hDC, TRANSPARENT); COLORREF clrOldTextColor = SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); DrawText( hDC, _T("Hier erfolgt die Textausgabe"), -1, &rcClient, DT_SINGLELINE| DT_CENTER| DT_VCENTER ); SetTextColor(hDC, clrOldTextColor); SetBkMode(hDC, nOldBkMode); EndPaint(hWnd, &paintst); return 0; }
case WM_DESTROY: PostQuitMessage(0); return 0;
default: return DefWindowProc(hWnd, message, wParam, lParam); } }
|
|