Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 11 to 20 of 27 total |
Threads when opening a form and data |
Tue, Mar 22 2011 3:38 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Adam
>It's a pitty I can't get to the Melbourne conference - would have been >good to see the talks on threads and see how they can be used in desktop >applications. Do you know anyone attending who has a camcorder? Or could the organisers be persuaded to video it? Roy Lambert . |
Tue, Mar 22 2011 3:43 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
>SaveToStream/LoadFromStream With each bit wrapped in a criticalsection. Roy Lambert |
Tue, Mar 22 2011 6:03 PM | Permanent Link |
Adam H. | >
>> It's a pitty I can't get to the Melbourne conference - would have been >> good to see the talks on threads and see how they can be used in desktop >> applications. > > Do you know anyone attending who has a camcorder? Or could the organisers be persuaded to video it? That's a good thought! Cheers mate Adam |
Thu, Mar 24 2011 2:07 AM | Permanent Link |
Adam H. | Hi Roy,
Sorry to bug you again, but you're a wealth of information. > I'm guessing that you have some sort of tabbed controls with wadges of controls on each page all of which has to be loaded and sized when the form is opened. If so a better approach is to use frames or (as I do) parented forms and only create the bit needed for a page when it is viewed. I need to add another Tab on one of my forms, and I remembered 'Hey - Roy told me something about this only a few days ago... I better go check it out' I was hoping you could help me with a couple of questions. 1) TFrame vs Inherited TForm. Any reason to go for the form over the frame. (I actually tried playing with a Frame in the IDE and got an Access Violation as soon as I tried adding the Frame to a form, so at this stage I'm very wary of Frames anyway), but thought I'd ask none the less. 2) I'm guessing if I went with a frame, I'd still need to create it Dynamically when required to get the performance boost? 3) One of the things I've tried is to Destroy Tabsheet's handles on the forms create event to free up resources (and let Delphi automatically create them again when they need to be viewed. I do this after creating the form, but before the form becomes visible. The code is simple: Form1.Tabsheet2.visible := false; Form1.Tabsheet2.free; Form1.Tabsheet3.visible := false; Form1.Tabsheet3.free; I have found that this does increase the performance of the application (especially when showing the form). I'm not sure if it's best to continue with this approach, or whether I should look at inherited forms anyway. 4) Playing with TForms, I've played with the following code on the TPageControls OnChange event handler. Just wondering if you see any issues with it or if there's something else I should watch out for? procedure TForm1.PageControl1Change(Sender: TObject); begin if not assigned(Form2) then application.createform(TForm2, Form2); Form2.parent := TabSheet2; Form2.Align := alclient; Form2.BorderStyle := bsnone; Form2.Visible := true; end; Cheers again for your help! Adam. |
Thu, Mar 24 2011 5:13 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Adam
>Sorry to bug you again, but you're a wealth of information. Remember I'm just a hobbyist. If you really want to see a mine of information look at Peter Below's posts on the CodeGear forums. >1) TFrame vs Inherited TForm. Any reason to go for the form over the frame. TFrame is a bit lighter than TForm but I prefer a TForm. There is little real difference. When you parent a form / frame onto another control certain events don't fire (eg activate) and these are missing from a TFrame. Essentially I see the advantage of a frame being that you can drop one onto another component easily at design time but not a form. However, the advantage of a form is that it can be displayed independently as well as being embedded, but it does need creating and parenting at runtime. I use both embedded forms and frames and have some frames on a form that is embedded. >(I actually tried playing with a Frame in the IDE and got an Access >Violation as soon as I tried adding the Frame to a form, so at this >stage I'm very wary of Frames anyway), but thought I'd ask none the less. No real idea, but the most likely cause is you have an event that isn't fired so some component isn't created. >2) I'm guessing if I went with a frame, I'd still need to create it >Dynamically when required to get the performance boost? I think so, and if that's the case I'd use TForm - easier for debugging since you can do it independently. >3) One of the things I've tried is to Destroy Tabsheet's handles on the >forms create event to free up resources (and let Delphi automatically >create them again when they need to be viewed. > >I do this after creating the form, but before the form becomes visible. >The code is simple: > >Form1.Tabsheet2.visible := false; >Form1.Tabsheet2.free; >Form1.Tabsheet3.visible := false; >Form1.Tabsheet3.free; > >I have found that this does increase the performance of the application >(especially when showing the form). I'm not sure if it's best to >continue with this approach, or whether I should look at inherited forms >anyway. I've never tried it but that scare's me a bit, mainly because I don't understand what's going on. One thing I do know is that you're unlikely to get the same Windows handle when a tabsheet is recreated. > >4) Playing with TForms, I've played with the following code on the >TPageControls OnChange event handler. Just wondering if you see any >issues with it or if there's something else I should watch out for? > >procedure TForm1.PageControl1Change(Sender: TObject); >begin >if not assigned(Form2) then > application.createform(TForm2, Form2); >Form2.parent := TabSheet2; >Form2.Align := alclient; >Form2.BorderStyle := bsnone; >Form2.Visible := true; >end; This is what I use for the primary forms (ie those for which a tab is created with the main form and is always there) procedure TMainForm.LoadPrimaryForm(FormTag: integer; PageMoveNeeded: boolean; InitialAutoLoad: boolean = False); procedure MakeForm(Archetype: TFormClass; Location: TAdvOfficePage); var tmpForm: TForm; begin LastFormKey := FormTag; Application.CreateForm(Archetype, tmpForm); tmpForm.BorderIcons := []; tmpForm.BorderStyle := Forms.bsNone; tmpForm.Parent := Location; frmHndl[FormTag] := tmpForm.Handle; tmpForm.Show; IsCreated[FormTag] := True; tmpForm.Align := alClient; tmpForm.Visible := True; SendMessage(tmpForm.Handle, FakeFormActivate, 0, 0); SendMessage(tmpForm.Handle, DoLocalColours, 0, 0); end; begin if (not InitialAutoLoad) and GetCfgBool(cfg_DisplayOpening, True) then begin DisplayStatusMessage('Opening ' + FormController.AdvPages[FormTag].Caption); end else Update; if not IsCreated[FormTag] then begin case FormTag of tagProject: MakeForm(TProjectForm, doProject); tagCompanies: MakeForm(TCompaniesForm, doCompanies); tagContacts: MakeForm(TContactsForm, doContacts); tagIntroductions: MakeForm(TIntroductionsForm, doIntroductions); tagOrderBook: MakeForm(TOrdersForm, doOrderbook); tagEMails: begin CmnString1 := doStandardEMail; CmnString2 := EMailTable; MakeForm(TEMailsForm, doEMails); end; tagAlarms: begin MakeForm(TProjectForm, doAlarms); SendMessage(frmHndl[tagAlarms], ConfigureProjectPage, 0, 0); end; tagCallBacks: begin MakeForm(TProjectForm, doCallbacks); SendMessage(frmHndl[tagCallbacks], ConfigureProjectPage, 0, 0); end; tagLTC: MakeForm(TLTCForm, doLTC); end; Update; end; if PageMoveNeeded then FormController.ActivePageIndex := FormTag; ResetCloseButton; if (not InitialAutoLoad) and GetCfgBool(cfg_DisplayOpening, True) then HideSplashScreen; end; and this is what I use for forms where I dynamically create and destroy the tab function TMainForm.MakeSuplementaryForm(Archetype: TFormClass; TabCaption: string = ''): HWND; var tmpForm: TForm; NewPageNo: integer; begin Update; if GetCfgBool(cfg_DisplayOpening, True) then DisplayStatusMessage('Opening: ' + TabCaption); Application.CreateForm(Archetype, tmpForm); tmpForm.Tag := -1; tmpForm.BorderIcons := []; tmpForm.BorderStyle := Forms.bsNone; NewPageNo := FormController.AddAdvPage(TabCaption); FormController.ButtonSettings.CloseButtonPicture.LoadFromStream(BtnClosePicture); FormController.ButtonSettings.CloseButtonHint := 'Close'; LastFormKey := GetTickCount; tmpForm.Tag := LastFormKey; FormController.AdvPages[NewPageNo].Tag := GetTickCount; tmpForm.Parent := FormController.AdvPages[NewPageNo]; FormController.ActivePageIndex := NewPageNo; FormController.Tag := 1; tmpForm.Show; tmpForm.Align := alClient; tmpForm.Visible := True; SendMessage(tmpForm.Handle, FakeFormActivate, 0, 0); SendMessage(tmpForm.Handle, DoLocalColours, 0, 0); Result := tmpForm.Handle; HideSplashScreen; end; The other important thing is I set Action to caFree in the forms OnClose event Roy Lambert [Team Elevate] |
Thu, Mar 24 2011 6:20 PM | Permanent Link |
Adam H. | Hi Roy,
Thanks for your reply again mate. Really appreciate it. >> (I actually tried playing with a Frame in the IDE and got an Access >> Violation as soon as I tried adding the Frame to a form, so at this >> stage I'm very wary of Frames anyway), but thought I'd ask none the less. > > No real idea, but the most likely cause is you have an event that isn't fired so some component isn't created. Sorry - should have explained better. The AV occurs at Designtime in the IDE. I don't think it matters. For what I want to do I think I'll stick with Forms anyway. As you mention, it will give me greater flexibility if I want the form by itself at a later date. I'll keep on playing then - appreciate the info! Have a great weekend Adam. |
Fri, Mar 25 2011 4:46 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Adam
>Sorry - should have explained better. The AV occurs at Designtime in the >IDE. I don't think it matters. For what I want to do I think I'll stick >with Forms anyway. As you mention, it will give me greater flexibility >if I want the form by itself at a later date. Sorry I should have explained better. When you drop the frame onto a control the frame will (I think) run through whatever its equivalent of the OnCreate event and something isn't right there. Its a problem with writing your own component - you can't really debug in the IDE. What you need to do is set up a test bed with a button that creates the frame that way you can get to the bit that bombs. Roy Lambert [Team Elevate] |
Sun, Mar 27 2011 5:45 PM | Permanent Link |
Adam H. | Morning Roy,
I hope you had a great weekend mate! >> Sorry - should have explained better. The AV occurs at Designtime in the >> IDE. I don't think it matters. For what I want to do I think I'll stick >> with Forms anyway. As you mention, it will give me greater flexibility >> if I want the form by itself at a later date. > > Sorry I should have explained better. When you drop the frame onto a control the frame will (I think) run through whatever its equivalent of the OnCreate event and something isn't right there. Its a problem with writing your own component - you can't really debug in the IDE. What you need to do is set up a test bed with a button that creates the frame that way you can get to the bit that bombs. Thanks for that. Seems like a lot of trouble for something I can do with embedded TForms without the AV. I think that pretty much nails the way I'll go with this. Have a great week! Adam. |
Tue, Mar 29 2011 12:07 PM | Permanent Link |
Adam Brett Orixa Systems | Hi Adam
>>procedure TForm1.PageControl1Change(Sender: TObject); >>begin >>if not assigned(Form2) then >> application.createform(TForm2, Form2); >>Form2.parent := TabSheet2; >>Form2.Align := alclient; >>Form2.BorderStyle := bsnone; >>Form2.Visible := true; >>end; I use the above method to create elements of an App GUI on the fly all the time & it definitely works, seems reasonably quick etc., so I would recommend it. I don't touch frames as there don't seem to be many advantages over forms, and they seem to have extra complexities. I know they are more light-weight, but I don't think that's critical anymore. Another plus on Forms is that you can always "Pop-out" ... i.e. I have a TForm Descendent with a built in PopupMenu containing the Items "Pop Out" & "Pop In" ... if the user selects Pop Out the Align, BorderStyle & Parent properties are changed so that the form becomes modal / dialogue. On the TForm Descendent I include a "ParentDummy" property: Form2.PopOut begin ParentDummy:= Parent; Parent:= nil; end; Form2.PopOut begin Parent:= ParentDummy; end; From memory I think that ParentDummy has to be of type TWinControl ... but I can't remember for sure. |
Wed, Mar 30 2011 11:02 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Adam,
<< It's a pitty I can't get to the Melbourne conference - would have been good to see the talks on threads and see how they can be used in desktop applications. >> I would have just loved to go to Melbourne again. I'm sure that Primoz's presentation was very interesting, though. -- Tim Young Elevate Software www.elevatesoft.com |
« Previous Page | Page 2 of 3 | Next Page » |
Jump to Page: 1 2 3 |
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |