Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 |
TCHAR fontname[] = TEXT ("ownfont"); HFONT hfont = CreateFont(22,10,0,0,700,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_MODERN,fontname); |
C-/C++-Quelltext |
|
1 2 3 4 |
for(i=0;i<4;i++) { SendMessage(hwndButton[i],WM_SETFONT,(WPARAM)hfont,MAKELPARAM(TRUE,0)); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 |
if(!bFlag) { //Font erstellen //... bFlag = true; } |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static RECT rect; static int cxChar, cyChar; //Schrift erstellen static TCHAR fontname[] = TEXT ("ownfont"); static HFONT hfont = CreateFont(22,10,0,0,700,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_MODERN,fontname); HDC hdc, hwndDC; PAINTSTRUCT ps; int i = 0; TCHAR t_frage_1[] = TEXT("Wie groß ist Europa?"); BUTTON button[4]; button[0].szText = TEXT(" 7.345.000 km²"); button[1].szText = TEXT("10.532.000 km²"); button[2].szText = TEXT("22.489.000 km²"); button[3].szText = TEXT("31.157.000 km²"); switch(message) { case WM_CREATE: { //Schrift zuweisen for(i=0;i<4;i++) { SendMessage(hwndButton[i],WM_SETFONT,(WPARAM)hfont,MAKELPARAM(TRUE,0)); } cxChar = LOWORD (GetDialogBaseUnits()); cyChar = HIWORD (GetDialogBaseUnits()); button[0].x = cxChar * 3; button[1].x = cxChar * 3 + 165; button[2].x = cxChar * 3; button[3].x = cxChar * 3 + 165; button[0].y = cyChar * 7; button[1].y = cyChar * 7; button[2].y = cyChar * 7 + 35; button[3].y = cyChar * 7 + 35; for (i=0;i<4;i++) { hwndButton[i] = CreateWindow (TEXT("Button"), button[i].szText, BS_PUSHBUTTON | WS_CHILD| WS_VISIBLE |BS_MULTILINE | BS_TEXT, button[i].x, button[i].y, 20 * cxChar, 7 * cyChar / 4, hwnd, (HMENU) i, ((LPCREATESTRUCT) lParam)->hInstance, NULL); } i = 0; return 0; } case WM_PAINT: { InvalidateRect(hwnd, &rect, TRUE); //Begin des Zeichenvorgangs hdc =BeginPaint (hwnd, &ps); //Hintergrund zeichnen HBITMAP hBackground = (HBITMAP)LoadImage(NULL, "euroquiz_bk_2.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE); HDC hDCBackground = CreateCompatibleDC(0); SelectObject(hDCBackground, hBackground); RECT rc; GetClientRect(hwnd, &rc); HDC hDChWnd = GetDC(hwnd); BitBlt(hDChWnd,0,0,rc.right,rc.bottom,hDCBackground,0,0,SRCCOPY); ReleaseDC(hwnd, hDChWnd); //Textrechteck festlegen GetClientRect(hwnd,&rect); rect.top = 45; //Schrift einsetzen SelectObject(hdc,hfont); //Text ausgeben SetBkMode(hdc,TRANSPARENT); DrawText(hdc,t_frage_1,strlen(t_frage_1),&rect,DT_CENTER); //Ende des Zeichenvorgangs EndPaint(hwnd, &ps); return 0; } case WM_DESTROY: DeleteObject(hfont); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); } |
Werbeanzeige