View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001412 | JEDI VCL | 00 JVCL Components | public | 2004-03-02 12:06 | 2004-04-22 01:10 |
| Reporter | anonymous | Assigned To | user72 | ||
| Priority | normal | Severity | feature | Reproducibility | always |
| Status | closed | Resolution | won't fix | ||
| Product Version | |||||
| Target Version | Fixed in Version | ||||
| Summary | 0001412: Suggestion | ||||
| Description | I use Delphi 5 Pro, JVCL3 BETA1 JvVCLUtils.FindForm function return only the first instance found of TFormClass. But in the same application two or more instances can have the same TFormClass..! FindForm function will be more efficient if modified as below. function FindForm(FormClass: TFormClass; AForm: TForm): Boolean; var F: integer; begin Result := False; if Assigned(AForm) then with Screen do begin for F := 0 to FormCount - 1 do if (Forms[F] is FormClass) and (Forms[F] = AForm) then begin RESULT := TRUE; Break end end end; or for more compatibility function FindForm(FormClass: TFormClass; AForm: TForm = nil): Boolean; var F: integer; begin Result := False; with Screen do begin for F := 0 to FormCount - 1 do if (Forms[F] is FormClass) and ( Assigned(AForm) and (Forms[F] = AForm)) then begin RESULT := TRUE; Break end end end; regards | ||||
| Tags | No tags attached. | ||||
|
|
... or for more compatibility function FindForm(FormClass: TFormClass; AForm: TForm = nil): Boolean; var F: integer; begin Result := False; with Screen do for F := 0 to FormCount - 1 do begin if (Forms[F] is FormClass) then if Assigned(AForm) then Result := Forms[F] = AForm else RESULT := TRUE; If Result then Break end end; edited on: 03-02-04 13:12 |
|
|
I don't quite see the point. If you already have the instance in AForm, why search for it? |
|
|
I create and free some forms dynamically (to save memory in major accounting application) I use Onclose event to free the instance (Action := caFree). In this case “MyForm†is free, removed from memory, but it’s pointer still no Nil. Testing Assigned(Myform) return True.. using MyForm crash the application.. But testing FindForm(TmyForm, MyForm) return False.. I need to create MyForm first…etc...(Very helpful in case where I had more than one instance of the same class Myform1, MyForm2,Myform3) edited on: 03-03-04 19:05 edited on: 03-03-04 19:14 |
|
|
This to me is bad programming. Either do not use the global form instance (recommended - in fact, remove it altogether) or set it to nil in OnClose: Action := caFree; MyForm := nil; |
|
|
Thanks I'll do that |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2004-03-02 12:06 | anonymous | New Issue | |
| 2004-03-02 12:19 | nestor | Note Added: 0003156 | |
| 2004-03-02 13:12 | nestor | Note Edited: 0003156 | |
| 2004-03-03 09:11 |
|
Note Added: 0003161 | |
| 2004-03-03 09:12 |
|
Status | new => feedback |
| 2004-03-03 18:48 | nestor | Note Added: 0003168 | |
| 2004-03-03 19:05 | nestor | Note Edited: 0003168 | |
| 2004-03-03 19:14 | nestor | Note Edited: 0003168 | |
| 2004-03-04 04:41 |
|
Note Added: 0003173 | |
| 2004-03-04 05:19 | nestor | Note Added: 0003175 | |
| 2004-03-04 08:41 |
|
Status | feedback => resolved |
| 2004-03-04 08:41 |
|
Resolution | open => won't fix |
| 2004-03-04 08:41 |
|
Assigned To | => user72 |
| 2004-04-22 01:10 |
|
Status | resolved => closed |