Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2003.05.01;
Download: [xml.tar.bz2];

Down

Implementing a button click event in a dynamically created window Find similar branches


R   (2003-04-18 01:58) [0]

Here is an example of the function from the Delphi source, how to implement it
mechanism without closing this modal window click on the button and
run on this click for example beep?
function InputQuery (const ACaption, APrompt: string;
var Value: string): Boolean;
was
Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
begin
Result: = False;
Form: = TForm.Create (Application);
with form do
try
Canvas.Font: = Font;
DialogUnits: = GetAveCharSize (Canvas);
BorderStyle: = bsDialog;
Caption: = ACaption;
ClientWidth: = MulDiv (180, DialogUnits.X, 4);
ClientHeight: = MulDiv (63, DialogUnits.Y, 8);
Position: = poScreenCenter;
Prompt: = TLabel.Create (Form);
with Prompt do
begin
Parent: = Form;
AutoSize: = True;
Left: = MulDiv (8, DialogUnits.X, 4);
Top: = MulDiv (8, DialogUnits.Y, 8);
Caption: = APrompt;
end;
Edit: = TEdit.Create (Form);
with Edit do
begin
Parent: = Form;
Left: = Prompt.Left;
Top: = MulDiv (19, DialogUnits.Y, 8);
Width: = MulDiv (164, DialogUnits.X, 4);
MaxLength: = 255;
Text: = Value;
SelectAll;
end;
ButtonTop: = MulDiv (41, DialogUnits.Y, 8);
ButtonWidth: = MulDiv (50, DialogUnits.X, 4);
ButtonHeight: = MulDiv (14, DialogUnits.Y, 8);
with TButton.Create (Form) do
begin
Parent: = Form;
Caption: = SMsgDlgOK;
ModalResult: = mrOk;
Default: = True;
SetBounds (MulDiv (38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create (Form) do
begin
Parent: = Form;
Caption: = SMsgDlgCancel;
ModalResult: = mrCancel;
Cancel: = True;
SetBounds (MulDiv (92, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
if ShowModal = mrOk then
begin
Value: = Edit.Text;
Result: = True;
end;
finally
Form.Free;
end;
end;



DJ_Sedoy   (2003-04-18 05:15) [1]

It is logical to assume that remove MedalResult: = true?
If I understand the question correctly



Palladin   (2003-04-18 07:16) [2]

the most obvious is to assign sv-in onclick to the desired TButton



R   (2003-04-18 08:11) [3]

> Palladin ©
And how to assign it because the form is created dynamically and buttons too.
I understand the question of lamer but nevertheless how. Give an example.



Palladin   (2003-04-18 08:17) [4]

you have an example under the nose ...
in the main form file ...

Create a button visually and assign an OnClick handler to it and see what was added to the project and how it is designed, and then consider that the events for the components are properties that you can assign ...



R   (2003-04-18 08:51) [5]

I still do not understand how to do it dynamically. Give an example code.



Skier   (2003-04-18 09:23) [6]

> R
http://www.delphimaster.ru/cgi-bin/faq.pl?look=1&id=988625051&n=19



Palladin   (2003-04-18 09:27) [7]

go to help and see
property OnClick: TNotifyEvent;
go ahead, see:
type TNotifyEvent = procedure (Sender: TObject) ofobject;
we think, we think more (just in case)
guessed and write in the main form

procedure OnMyButtonClick (Sender: TObject);
then
we describe it

procedure TForm1.OnMyButtonClick (Sender: TObject);
begin
Application.ShowMessage ("Where was my head before?!", "Eureka!);
end;

in the code for the creation of your form din write (to get to the class TForm1, we put your creation procedure in the module with the main form)

with TButton.Create (Form) do
begin
Parent: = Form;
Caption: = SMsgDlgOK;
ModalResult: = mrOk;
Default: = True;
SetBounds (MulDiv (38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
OnClick: = TForm1.OnMyButtonClick;
end;



R   (2003-04-18 09:38) [8]

Thanks for the help.



Pages: 1 whole branch

Forum: "Main";
Current archive: 2003.05.01;
Download: [xml.tar.bz2];

Top









Memory: 0.58 MB
Time: 0.024 c
We answer immediately.
Tytus
2003-04-18 14:43
2003.05.01
Button


We answer immediately.
Alibaba
2003-04-15 11:53
2003.05.01
Hacker in prison


We answer immediately.
Ivan L
2003-04-13 22:39
2003.05.01
Component Palette


We answer immediately.
_MAX_
2003-04-14 11:08
2003.05.01
RecNo in Oracle?


We answer immediately.
neodiX
2003-03-04 15:52
2003.05.01
BitBlt - sometimes when copying the screen in bmp it turns out





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish