005
24.12.2003, 19:29 Uhr
Guybrush Threepwood
Gefürchteter Pirat (Operator)
|
Unter Windows könntet man es so machen:
C++: |
#include <windows.h>
LRESULT CALLBACK MainProc(HWND,UINT,WPARAM,LPARAM);
void HalloWelt();
struct GLOBALS { HWND hMainWindow; }g_={NULL};
APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) { MSG Msg; WNDCLASS wc;
memset(&wc,0,sizeof(WNDCLASS)); wc.hbrBackground = (HBRUSH) COLOR_WINDOWFRAME; wc.hCursor = LoadCursor(0,IDC_ARROW); wc.hInstance = hInstance; wc.lpfnWndProc = MainProc; wc.lpszClassName = "HalloWelt"; wc.style = CS_BYTEALIGNCLIENT;
if (!RegisterClass(&wc)) return false;
g_.hMainWindow = CreateWindow("HalloWelt","Hallo Welt", WS_OVERLAPPEDWINDOW, 300,300, 350,200, GetDesktopWindow(),0, hInstance,0); ShowWindow(g_.hMainWindow,nCmdShow); UpdateWindow(g_.hMainWindow);
HalloWelt();
while(GetMessage(&Msg,0,0,0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
LRESULT CALLBACK MainProc(HWND hWnd,UINT Msg,WPARAM wParam, LPARAM lParam) { switch(Msg) { case WM_DESTROY: { PostQuitMessage(0); return 0; } case WM_ACTIVATE: { HalloWelt(); return 0; } default: return DefWindowProc(hWnd,Msg,wParam,lParam); } }
void HalloWelt() { HDC hDC = GetDC(g_.hMainWindow); TextOut(hDC,50,20,"Hallo Welt!",11); ReleaseDC(g_.hMainWindow,hDC); }
|
PS: Frohe Wihnachten an alle |