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 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 |
class cTest1 { public: void SetChecked(bool p1); private: bool Checked; } void cTest1::SetChecked(bool p1) { Checked = p1; } class cTest2 { public: cTest1 GetKlasse1(); private: cTest1 Klasse1; } cTest1 cTest2::GetKlasse1() { return Klasse1; } int main() { cTest2 Klasse2; Klasse2.GetKlasse1().SetChecked(true); return (0); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
/**
Once you are done trying to ‘optimize’ this routine,
and have realized what a terrible mistake that was,
please increment the following counter as a warning
to the next guy:
total_hours_wasted_here = 11
*/
|
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
/**
Once you are done trying to ‘optimize’ this routine,
and have realized what a terrible mistake that was,
please increment the following counter as a warning
to the next guy:
total_hours_wasted_here = 11
*/
|
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
/**
Once you are done trying to ‘optimize’ this routine,
and have realized what a terrible mistake that was,
please increment the following counter as a warning
to the next guy:
total_hours_wasted_here = 11
*/
|
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
/**
Once you are done trying to ‘optimize’ this routine,
and have realized what a terrible mistake that was,
please increment the following counter as a warning
to the next guy:
total_hours_wasted_here = 11
*/
|
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 |
class BitmapButton { public: HWND CreateButton(HWND hWnd, HINSTANCE hInstance, int id, int x_pos, int y_pos,LPCSTR up, LPCSTR hover, LPCSTR down); void PaintButton(); int GetButtonState(); //Konstruktor BitmapButton(); //Destruktor ~BitmapButton(); private: void SetButtonBitmapPressed(); void SetButtonBitmapHighlight(); void SetButtonBitmapNormal(); bool CheckMouseOver(); HBITMAP ButtonNormal; HBITMAP ButtonPressed; HBITMAP ButtonMouseOver; HWND hWnd; bool pressed; //BitmapStates 0=Up, 1=Hover, 2=Down int BitmapState; }; |
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
#include "Buttons.h" BitmapButton::BitmapButton() { BitmapState=5; } BitmapButton::~BitmapButton() { DestroyWindow(hWnd); DeleteObject(ButtonNormal); DeleteObject(ButtonPressed); DeleteObject(ButtonMouseOver); DeleteObject(hWnd); } bool BitmapButton::CheckMouseOver() { POINT MausPos; RECT Rect; GetWindowRect(hWnd,&Rect); GetCursorPos(&MausPos); if(hWnd != NULL) { if(MausPos.x >Rect.left && MausPos.x < Rect.right && MausPos.y < Rect.bottom && MausPos.y > Rect.top) return true; else return false; } else return false; } void BitmapButton::SetButtonBitmapPressed() { SendMessage(hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)ButtonPressed); } void BitmapButton::SetButtonBitmapHighlight() { SendMessage(hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)ButtonMouseOver); } void BitmapButton::SetButtonBitmapNormal() { SendMessage(hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)ButtonNormal); } HWND BitmapButton::CreateButton(HWND hWindow, HINSTANCE hInstance, int id, int x_pos, int y_pos,LPCSTR up, LPCSTR hover, LPCSTR down) { this->ButtonNormal = LoadBitmap(GetModuleHandle(NULL), up); this->ButtonPressed = LoadBitmap(GetModuleHandle(NULL), down); this->ButtonMouseOver = LoadBitmap(GetModuleHandle(NULL), hover); this->hWnd = CreateWindow ("STATIC",NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP, x_pos, y_pos, 1, 1, hWindow, (HMENU)id, hInstance, NULL); this->SetButtonBitmapNormal(); return hWindow; } void BitmapButton::PaintButton() { if(CheckMouseOver()) { if(GetAsyncKeyState (VK_LBUTTON) & 0x8000) { if(BitmapState != 2) { SetButtonBitmapPressed(); } BitmapState = 2; } else if(BitmapState == 2) { SetButtonBitmapHighlight(); BitmapState = 1; } else { if(BitmapState != 1) { SetButtonBitmapHighlight(); BitmapState = 1; } } } else { if(BitmapState != 0) { SetButtonBitmapNormal(); BitmapState = 0; } } } int BitmapButton::GetButtonState() { if(CheckMouseOver()) { if(GetAsyncKeyState (VK_LBUTTON) & 0x8000) { pressed = true; return (0); } else if(pressed == true) { pressed = false; return (1); } else { return (2); } } else return (0); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
/**
Once you are done trying to ‘optimize’ this routine,
and have realized what a terrible mistake that was,
please increment the following counter as a warning
to the next guy:
total_hours_wasted_here = 11
*/
|
Werbeanzeige