ERLEDIGT
NEIN
NEIN
ANTWORTEN
7
7
ZUGRIFFE
387
387
EMPFEHLEN
-
13.10.09 16:42 #1BLapBluPe Tutorials.de Gastzugang
Hey,
ich habe eine klasse in der es eine funktion gibt die ,die mausklicks eines fensters abfangen soll
diese funktionen gehen außerhalb der klasse ohne probleme jedoch spuckt vc++ mir einen error aus wenn ich sie in einer klasse verwenden will
und zwar kommt es bei nur einem parameter, hier mal der code:
Code :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
class Pong { private: bool MausMove; bool eckemove; bool first; int PongX; int PongY; int PongW; int PongH; int DifX,DifY,DifX2,DifY2; bool eins; public: Pong(){ MausMove=false; eckemove=false; first=true; eins=false; PongX=100; PongY=200; PongW=240; PongH=80; } LONG OldWndProc; LRESULT CALLBACK NewWndProc(HWND Hwnd, UINT Message, WPARAM wParam, LPARAM lParam); DWORD WINAPI Creation(LPVOID); void start(); }; LRESULT CALLBACK Pong::NewWndProc(HWND Hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { if (MouseIsOver(this->PongX, this->PongY,this->PongW, this->PongH)||this->eckemove||this->MausMove) { switch(Message) { case WM_LBUTTONDOWN: return 0; break; case WM_LBUTTONUP: return 0; break; case WM_LBUTTONDBLCLK: return 0; break; } } return CallWindowProc((WNDPROC)OldWndProc, Hwnd, Message, wParam, lParam); } DWORD WINAPI Pong::Creation(LPVOID) { Sleep(2000); HWND hWnd = FindWindow(NULL,"Guild Wars"); HMENU hCurrent = GetMenu(hWnd); //Get the CURRENT menu of the window HMENU hNew = CreateMenu(); //Create a new one AppendMenu(hCurrent, MF_STRING | MF_POPUP, (unsigned int)hNew, "Tutorial"); AppendMenu(hNew, MF_STRING, 2000, "Button"); //2000 is the ID of the button DrawMenuBar(hWnd); //redraw the Menu! OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC,(long)Pong::NewWndProc); //subclass the original window procedure //With our new one //So now all messages sent to the notepad window, are sent to OUR window proc..See above! return TRUE; } void EnemieWindow::start() { // }
das problem liegt hier:
Code :1
OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC,(long)Pong::NewWndProc);
und zwar beim 3.parameter sagt mir vc++ jetzt
Code :1
Fehler 4 error C2440: 'Typumwandlung': 'LRESULT (__stdcall Pong::* )(HWND,UINT,WPARAM,LPARAM)' kann nicht in 'long' konvertiert werden
was meint ihr woran das liegt?
ich grübele heute schon lange daran aber ich weiß nicht wie ich es anders schreiben kann so das es geht....
danke schonmal für eure vorschläge,ideen,lösungen etc.
=)
-
13.10.09 16:49 #2
- Registriert seit
- Jun 2005
- Beiträge
- 8.168
Hi.
Erstmal muß die Methode statisch sein.
Dann solltest du lieber die SetWindowLongPtr Funktion verwenden:
GrußCode cpp:1 2
::SetWindowLongPtr(hWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(&Pong::NewWndProc));
If at first you don't succeed, try again. Then quit. No use being a damn fool about it.
-
13.10.09 17:00 #3BLapBluPe Tutorials.de Gastzugang
danke für deine antwort aber fehler kommt immernoch ~.~
und ich hab noch ne frage: warum ist SetWindowLongPtr besser?
-
14.10.09 08:09 #4
- Registriert seit
- Jun 2005
- Beiträge
- 8.168
Wie sieht der Code aus und wie lautet die Fehlermeldung?
Siehe http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
Bitte halte dich an die Netiquette bezügl. Groß-/Kleinschreibung. Danke.
GrußIf at first you don't succeed, try again. Then quit. No use being a damn fool about it.
-
14.10.09 09:28 #5BLapBluPe Tutorials.de Gastzugang
Hey,
also der Fehlercode ist jetzt folgender:
Code :1
Fehler 4 error C2440: 'reinterpret_cast': 'LRESULT (__stdcall Pong::* )(HWND,UINT,WPARAM,LPARAM)' kann nicht in 'LONG_PTR' konvertiert werden
Danke schonmal für deine Hilfe =)
-
14.10.09 11:47 #6
- Registriert seit
- Jun 2005
- Beiträge
- 8.168
Hast du die Methode auch als statisch deklariert?
If at first you don't succeed, try again. Then quit. No use being a damn fool about it.
-
15.10.09 10:45 #7BLapBluPe Tutorials.de Gastzugang
Ja eig schon...
static DWORD WINAPI Creation(LPVOID);
oder?
-
15.10.09 13:33 #8
- Registriert seit
- Jun 2005
- Beiträge
- 8.168
If at first you don't succeed, try again. Then quit. No use being a damn fool about it.
Ähnliche Themen
-
Innerhalb einer Klasse eine Instanz einer anderen Klasse
Von HackerNeo im Forum VisualStudio & MFCAntworten: 1Letzter Beitrag: 17.11.09, 13:08 -
[C++] Problem mit Zeigern in einer Klasse
Von radazong im Forum C/C++Antworten: 3Letzter Beitrag: 13.12.08, 06:55 -
Problem bei .this Methodenaufruf in einer Klasse
Von X-Color im Forum Javascript & AjaxAntworten: 1Letzter Beitrag: 29.10.07, 22:47 -
Problem mit Include einer PEAR-Klasse
Von firstlord18 im Forum PHPAntworten: 2Letzter Beitrag: 03.01.05, 10:56 -
Problem: das einbinden einer Klasse
Von xyzPainter im Forum Borland CBuilder und VCLAntworten: 1Letzter Beitrag: 23.01.04, 23:11





Zitieren

Login






