[DUG] Pasting components from code
Alister Christie
alister at salespartner.co.nz
Fri Sep 17 13:15:01 NZST 2010
Or Frames for that matter, or custom components.
Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington
On 17/09/2010 12:48 p.m., Jeremy North wrote:
> Why not form inheritence?
>
> Are you declaring the events in the correct spot for the form?
>
> BTW, you really want your Label font to be different to the Edit font?
>
>
> On Fri, Sep 17, 2010 at 10:39 AM, John Bird<johnkbird at paradise.net.nz> wrote:
>> I have a source generation program to speed creating of sets of labels and
>> edit boxes on a form - which gives output like examples below.
>>
>> I paste the code that goes in the DFM onto the form, and it creates all the
>> components - a neat Delphi trick for those who might not know.
>>
>> My problem is that the OnEnter and OnExit events seem to disappear from
>> these components and I have to add them back manually, even though the code
>> was already in the unit when the paste was done. My detective work so far
>> seems to show that it depends on where the forward (first) declaration of
>> the event code is placed whether it is recognised or not - seems it has to
>> be above the {private} and {public} sections for the form
>>
>> What are the rules for where such event code has to be declared? - I am
>> vague on this. I have heard others use generated code too, I am wondering
>> if they have tips or pitfalls like this to avoid.
>>
>> (Aside - Personally I favour source generation like this a lot. It is cool
>> to do, ends up as fast as hand written code, and most importantly saves time
>> and introduces standard code structure that is easy to understand.)
>> (Further aside - this is code generated by the program for a new part of
>> itself. Its cool when a program can write its own code).
>>
>> example of output from the code generation....
>>
>> // Forward declaration
>> procedure edtSOURCEINPUTEnter(Sender: TObject);
>> procedure edtSOURCEINPUTExit(Sender: TObject);
>>
>>
>> //Implementation ------- edit enter and exit events for editing this
>> record --------
>> procedure Tform1.edtSOURCEINPUTEnter(Sender: TObject);
>> begin
>> (some code here)
>> end;
>>
>> procedure Tform1.edtSOURCEINPUTExit(Sender: TObject);
>> begin
>> (some code here)
>> end;
>>
>> And:
>>
>> //Paste onto form
>>
>> object lblSrcInpPath: TLabel
>> Left = 300
>> Top = 51
>> Width = 142
>> Height = 13
>> Caption = 'Path'
>> Font.Charset = DEFAULT_CHARSET
>> Font.Color = clBlack
>> Font.Height = -11
>> Font.Name = 'MS Sans Serif'
>> Font.Style = []
>> ParentFont = False
>> end
>> object edtSrcInpPath: TEdit
>> Left = 420
>> Top = 48
>> Width = 121
>> Height = 21
>> Font.Charset = DEFAULT_CHARSET
>> Font.Color = clNavy
>> Font.Height = -11
>> Font.Name = 'Tahoma'
>> Font.Style = [fsBold]
>> ParentFont = False
>> TabOrder = 1
>> Text = ''
>> Enabled = True
>> OnEnter = edtSOURCEINPUTEnter
>> OnExit = edtSOURCEINPUTExit
>> end
>> object lblSrcInpFileIn: TLabel
>> Left = 300
>> Top = 75
>> Width = 142
>> Height = 13
>> Caption = 'Filename without path'
>> Font.Charset = DEFAULT_CHARSET
>> Font.Color = clBlack
>> Font.Height = -11
>> Font.Name = 'MS Sans Serif'
>> Font.Style = []
>> ParentFont = False
>> end
>> object edtSrcInpFileIn: TEdit
>> Left = 420
>> Top = 72
>> Width = 121
>> Height = 21
>> Font.Charset = DEFAULT_CHARSET
>> Font.Color = clNavy
>> Font.Height = -11
>> Font.Name = 'Tahoma'
>> Font.Style = [fsBold]
>> ParentFont = False
>> TabOrder = 2
>> Text = ''
>> Enabled = True
>> OnEnter = edtSOURCEINPUTEnter
>> OnExit = edtSOURCEINPUTExit
>> end
>>
>> etc....
>>
>>
>> John
>>
>>
>> _______________________________________________
>> NZ Borland Developers Group - Delphi mailing list
>> Post: delphi at delphi.org.nz
>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>> Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject: unsubscribe
>>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject: unsubscribe
>
More information about the Delphi
mailing list