BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OnKeyDown handler inside messagedialog form

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Mike McWhinney
Guest





PostPosted: Mon Feb 23, 2004 7:33 pm    Post subject: OnKeyDown handler inside messagedialog form Reply with quote



Hello,

I have a custom form/dialog created at runtime which is a custom form
based on CreateMessageDialog.

I am trying to use the OnKeyDown event to create an event when the
pgup key is pressed. However I am having problems implementing it. On
compiling the statement: OnkeyDown:=YNFormKeyDown I get an error message:

Incompatible types: method pointer and regular procedure

How can this procedure set up a keydown handler so that keypresses can be
trapped?

Thanks in advance.
Mike


Procedure GetYNDialog(S:String; Var Yes:Boolean);
Var
Res:Word;
YNForm:TForm;
btn:TButton;
tlab:TLabel;

procedure YNFormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If key=VK_PRIOR then Begin
YNForm.ModalResult:=mrCancel;
showmessage('pgup pressed');
Key:=0;
End;
end;




Begin



YNForm:=CreateMessageDialog(S,mtConfirmation,
[mbYes,mbNo,mbCancel]);
YNForm.Caption:='';
YNForm.borderstyle:=bsdialog;

YNForm.BorderIcons:=[];
YNForm.Color:=$0086B9BB;
YNForm.Font.Name:='Arial';
YNForm.Font.Size:=16;
YNForm.Height:=340;
YNForm.Width:=360;
tlab:=TLabel(YNForm.Components[1]);
tlab.width:=250;

With YNForm do Begin

BorderIcons:=BorderIcons-[biSystemMenu];
If Yes then
activecontrol:=TButton(Components[2])
else
activecontrol:=TButton(Components[3]);
btn:=TButton(Components[2]);
btn.left:=50;
btn.top:=145;
btn.width:=85;
btn.height:=85;
btn:=TButton(Components[3]);
btn.left:=200;
btn.top:=145;
btn.width:=85;
btn.height:=85;
btn:=TButton(Components[4]);
btn.visible:=FALSE;
keypreview:=TRUE;
OnKeyDown:=YNFormKeyDown;

End;
Res:=YNForm.ShowModal;
Yes:=(Res=mrYes);


End;
Back to top
Jamie
Guest





PostPosted: Tue Feb 24, 2004 10:30 am    Post subject: Re: OnKeyDown handler inside messagedialog form Reply with quote



create a method procedure.
it must be the same type of OnKeyDown event object that you
nornally would see if done via the IDE method..
this procedure proto type (header) will have an entry in the
object of the public settion.
then you create the actuall event procedure in code like this.
mydialogExxxxxx.OnKeyOPress(Sender:TObject, and the rest of the
expected params.).
---


Mike McWhinney wrote:

Quote:
Hello,

I have a custom form/dialog created at runtime which is a custom form
based on CreateMessageDialog.

I am trying to use the OnKeyDown event to create an event when the
pgup key is pressed. However I am having problems implementing it. On
compiling the statement: OnkeyDown:=YNFormKeyDown I get an error message:

Incompatible types: method pointer and regular procedure

How can this procedure set up a keydown handler so that keypresses can be
trapped?

Thanks in advance.
Mike


Procedure GetYNDialog(S:String; Var Yes:Boolean);
Var
Res:Word;
YNForm:TForm;
btn:TButton;
tlab:TLabel;

procedure YNFormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If key=VK_PRIOR then Begin
YNForm.ModalResult:=mrCancel;
showmessage('pgup pressed');
Key:=0;
End;
end;




Begin



YNForm:=CreateMessageDialog(S,mtConfirmation,
[mbYes,mbNo,mbCancel]);
YNForm.Caption:='';
YNForm.borderstyle:=bsdialog;

YNForm.BorderIcons:=[];
YNForm.Color:=$0086B9BB;
YNForm.Font.Name:='Arial';
YNForm.Font.Size:=16;
YNForm.Height:=340;
YNForm.Width:=360;
tlab:=TLabel(YNForm.Components[1]);
tlab.width:=250;

With YNForm do Begin

BorderIcons:=BorderIcons-[biSystemMenu];
If Yes then
activecontrol:=TButton(Components[2])
else
activecontrol:=TButton(Components[3]);
btn:=TButton(Components[2]);
btn.left:=50;
btn.top:=145;
btn.width:=85;
btn.height:=85;
btn:=TButton(Components[3]);
btn.left:=200;
btn.top:=145;
btn.width:=85;
btn.height:=85;
btn:=TButton(Components[4]);
btn.visible:=FALSE;
keypreview:=TRUE;
OnKeyDown:=YNFormKeyDown;

End;
Res:=YNForm.ShowModal;
Yes:=(Res=mrYes);


End;


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.