Autor Beitrag
Jann1k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: Di 01.05.07 16:17 
Also, ich habe ein rundenbasierendes strategiespiel programmiert, welches man derzeit noch über die tastatur steuern muss. Da der PC die Möglichkeit einer Maus bietet, wollte ich die steuerung so erweitern, dass maussteuerung möglich wird.

Das ganze habe ich mir so gedacht, dass ich bei einem Mausklick das onkeydown ereignis meiner Form aufrufe, weil über die die Steuerung funktioniert. Je nachdem ob linke, rechte oder mittlere maustaste gedrückt wird (was für okay, abbruch oder info steht) als key-parameter von onkeydown, die zugehörige taste der tastatur steuerung übergeben.

Hier mal der Beispielquelltext für den aufruf von onkeydown (VK_space=okay-taste):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
     
procedure Tmain.imbackgroundMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if button=mbleft then 
  onkeydown(main,VK_return,shift);
end;


Allerdings gibt mir der compiler folgende fehlermeldung aus:
[Error] mbastiwars.pas(2365): Types of actual and formal var parameters must be identical

die meldung verwirrt mich etwas bzw. weiß ich einfach nicht was am aufruf falsch ist
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: Di 01.05.07 16:55 
Moin,

als Key wird ne Variable erwartet, du übergibst (mit VK_RETURN) allerdings eine Konstante. Mach es so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var Key: Word;
begin
 if Button = mbLeft then begin
  Key := VK_RETURN;
  onKeyDown(Self, Key, Shift);
  end;
end;


Gruß
Jann1k Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: Di 01.05.07 18:04 
danke funktioniert