Solved

About component building

Posted on 2002-04-28
5
162 Views
Last Modified: 2010-04-04
I need help on this:
  To build a component with a button on it, when the button is clicked, a dialog style form will be displaying,
on this form:
           1. certain buttons like OK, Add.
           2. when button OK on the form is clicked, the form is closed, an event e.g. OnCancel in the component will be connected to the OK button's OnClick event.
           3. the component will get certain result calculated at the form when OK button is clicked, an event AfterCalc in the component is fired.
 
  my problems: how can I have a component like this with its properties and event handlers that relate to a form that is only create when requied  
0
Comment
Question by:JasBei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6976509
Simply set the ModalResult properties of the buttons on the modal form.
Connecting an OnCancel event is not needed and not (easily) possible.
Move your modal form in Project : Options : Forms to the rigt list.
In the OnClick of the main form button do something like this:
var
  ModRes: Integer;
begin
  ModForm := TModForm.Create(Self);
  ModRes := ModFrom.ShowModal;
  if ModRes = mrOK then
  ...
  ModForm.Free;
0
 

Author Comment

by:JasBei
ID: 6979129
I would like to clarify my problem:
      I tried to use a mordal form just as you have pointed out, but if on the mordal form there is a button I would like to use it to fire an event in my component, and this button is not going to shut the mordal form after all this happening, so I couldn't use ModResult here.
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6979473
You can always call methods of the main form in response to the button click on the modal form.
0
 
LVL 4

Accepted Solution

by:
nestorua earned 100 total points
ID: 6981723
HI,
If I am not mistaken you don't know how to create a component which has a button as a part of it and this "part" has its own event OnClick?
If so do the following (see an example):
TMyPanel=class(TPanel)
private
FButton: TButton;
FOnButtonClick: TNotifyEvent;
...
protected
 procedure MyButtonClick(Sender: TObject)
published
 property OnButtonClick: TNotifyEvent read FOnButtonClick
                                      write FOnButtonClick;
end;
...

constructor TMyPanel.Create(AOwner: TComponent);
begin
  inherited;

   FButton:=TButton.Create(Self);  
   with FButton do
    begin
     Left:=...
     Top:=...
     Parent:=Self;
     OnClick:=MyButtonClick;    
  ...
    end;
end;
procedure TMyPanel.MyButtonClick(Sender: TObject)
begin
  If Assigned(FOnButtonClick)
   then FOnButtonClick(Self);
end;

Sincerely,
Nestorua.
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9004269
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from nestorua

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Multiple image collision 13 108
firemonkey keyboard covers the controls 1 83
DBCtrlGrid, Delphi, Scroll 8 86
How to insert .png images to TClientDataSet .cds file? 2 84
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question