Vraag : Wor met inidossier


Met:
met TINIFile.Create (ExtractPath (Form1.caption) + ' .ini')
ik zou willen werken in:
procedure TForm1.FormClose (Afzender: TObject; var Actie: TCloseAction);
procedure TForm1.FormCreate (Afzender: TObject);

ik moet weg krijgen waar de initialisering van mijn vorm wordt opgeslagen. En ik krijg het van de titel van de Vorm.

Voorbeeld:  myform wordt het archief gevestigd in: C:\myform
1:
2:
3:
4:
5:
6:
7:
Functie TForm1.ExtractPath (Streptokok: Koord): Koord;
Var
 P: Geheel;
begin
 P: =Pos („: \“, Streptokok);
 als P>0 toen Resultaat: =Copy (Streptokok, p-1, Lengte (Streptokok)) Anders Resultaat: = '';
eind;

Antwoord : Wor met inidossier

Ik begrijp veel niet van wat u wilt doen, maar ik heb een uitgebreide hulpmiddeleenheid/sparen componenten & vormeneigenschappen (titels, gecontroleerde status, etc…) in dossiers te laden Ini.

Zelfs als u niet het wilt gebruiken aangezien het is, ben ik zeker u veel ideeën hier zult vinden.
Wanneer u deze eenheid in een project dat omvat, initialiseert het automatisch een dossier Ini na de toepassing of dll de naam wordt genoemd die het gebruiken.

Allen u moet doen moet roepen
IniSaveComponnents
en
IniLoadComponnents

met een serie van componenten of vormen die u wilt beheren:

procedure TForm1.FormCreate (Afzender: TObject);
begin
 IniLoadComponnents ([Zelf, edtParam1, chkOption1]); // => bewaart de vorm, en 2 componenten
eind;

procedure TForm1.FormDestroy (Afzender: TObject);
begin
 IniSaveComponnents ([Zelf, edtParam1, chkOption1]); // => bewaart de vorm, en 2 componenten
eind;


U kunt een extra sectieparameter toevoegen die aan de automatische gecre�ërde sectie zal worden toegevoegd Ini. Dat moet helpen een beetje hergroeperen zeer belangrijk/de waarden in Ini, indien gebruikt in vele vormen, maar dat beïnvloedt wat niet werkelijk wordt opgeslagen. U kunt een parameter TextOnly van Boole ook toevoegen om slechts/sparen de titels, niet de waarden (voor een eenvoudig taalbeheer) te laden
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
eenheid IniOptions;

interface

De Vormen van het gebruik, klassen, IniFiles, StdCtrls, ExtCtrls, Knopen, Netten, Controles, Dialogen, Grafiek, ComCtrls, Menu's, Rotatie;

Type
 TStringListOption= (slUpperCase);
 TStringListOptions=set van TStringListOption;

procedure IniOpenFile (FileName: String= ''; FilePath: String= ''); overbelasting;
procedure IniOpenFile (Instantie: Geheel; FilePath: String= ''); overbelasting;
procedure IniCloseFile;

procedure IniSaveQuotedCaption (Sectie, Param, Gebrek: Koord);
functie IniLoadQuotedCaption (Sectie, Param, Gebrek: Koord): Koord;

functie IniLoadSaveDefaultString (Sectie, Param, Gebrek: Koord): Koord;
functie IniLoadSaveDefault (Sectie, Param, Gebrek: Koord): Koord; overbelasting;
functie IniLoadSaveDefault (Sectie, Param: Koord; Gebrek: Geheel): Geheel; overbelasting;
functie IniLoadSaveDefault (Sectie, Param: Koord; Gebrek: Van Boole): Van Boole; overbelasting;
procedure IniLoadSaveDefaultStringList (Sectie, Param: Koord; Lijst: TStringList; Opteer: TStringListOptions= []);

procedure IniLoadMenu (M: TMenu);
procedure IniSaveMenu (M: TMenu);
procedure IniLoadListView (L: TListView);
procedure IniSaveListView (L: TListView);
procedure IniLoadFormPosAndSize (frm: TCustomForm);
procedure IniSaveFormPosAndSize (frm: TCustomForm);
procedure IniLoadCheckBox (chk: TCheckBox);
procedure IniSaveCheckBox (chk: TCheckBox);
procedure IniLoadRadioButton (Rb: TRadioButton);
procedure IniSaveRadioButton (Rb: TRadioButton);
procedure IniLoadCaption (lbl: TLabel);
procedure IniSaveCaption (lbl: TLabel);
procedure IniLoadText (edt: TCustomEdit);
procedure IniSaveText (edt: TCustomEdit);
procedure IniLoadRadioGroup (rg: TRadioGroup);
procedure IniSaveRadioGroup (rg: TRadioGroup);
procedure IniLoadGroupBox (GB: TGroupBox);
procedure IniSaveGroupBox (GB: TGroupBox);
procedure IniLoadComboBox (cb: TComboBox);
procedure IniSaveComboBox (cb: TComboBox);
{
procedure IniLoadSpinEdit (edt: TSpinEdit);
procedure IniSaveSpinEdit (edt: TSpinEdit);
}
procedure IniLoadButton (BTN: TButton);
procedure IniSaveButton (BTN: TButton);
procedure IniLoadSpeedButton (BTN: TSpeedButton);
procedure IniSaveSpeedButton (BTN: TSpeedButton);
procedure IniLoadFormCaption (frm: TForm);
procedure IniSaveFormCaption (frm: TForm);
procedure IniSavePanel (pnl: TPanel);
procedure IniLoadPanel (pnl: TPanel);
procedure IniSaveFrame (pnl: TFrame);
procedure IniLoadFrame (pnl: TFrame);
procedure IniLoadStringGrid (net: TStringGrid);
procedure IniSaveStringGrid (net: TStringGrid);
procedure IniLoadShape (shp: TShape);
procedure IniLoadImage (img: TImage);
procedure IniSaveShape (shp: TShape);
procedure IniSaveImage (img: TImage);
procedure IniSaveControl (c: TControl);
procedure IniLoadControl (c: TControl);
procedure IniLoadOpenDialog (dlg: TOpenDialog);
procedure IniSaveOpenDialog (dlg: TOpenDialog);
procedure IniLoadMemo (memorandum: TMemo);
procedure IniSaveMemo (memorandum: TMemo);

procedure SetExtendedSection (S: Koord);
functie  GetExtendedSection: Koord;
functie  GetTextOnly: Van Boole;
procedure SetTextOnly (B: Van Boole);
functie TranslateFormat2Text (S: Koord): Koord;
functie TranslateText2Format (S: Koord): Koord;

procedure IniSaveComponnents (Lijst: Serie van TObject; Ext_Section: String= ''; TextOnly: Boolean=False);
procedure IniLoadComponnents (Lijst: Serie van TObject; Ext_Section: String= ''; TextOnly: Boolean=False);

Var
 IniFile: TIniFile;

implementatie

Gebruik SysUtils, untUtils, FileCtrl;

Var
 _ExtSection: String= '';
 _TextOnly: Boolean=False;

procedure SetExtendedSection (S: Koord);
begin
 _ExtSection: =S;
eind;

functie  GetExtendedSection: Koord;
begin
 Resultaat: =_ExtSection;
eind;

functie  GetTextOnly: Van Boole;
begin
 Resultaat: =_TextOnly;
eind;

procedure SetTextOnly (B: Van Boole);
begin
 _TextOnly: =b;
eind;

functie TranslateFormat2Text (S: Koord): Koord;
begin
 Resultaat: =StringReplace (S, „% \“, #13#10, [rfReplaceAll]);
eind;

functie TranslateText2Format (S: Koord): Koord;
begin
 Resultaat: =StringReplace (S, #13#10, „% \“, [rfReplaceAll]);
eind;

procedure IniOpenFile (Instantie: Geheel; FilePath: String= '');
begin
 IniOpenFile (ChangeFileExt (GetModuleName (hInstance), „.INI“), FilePath);
eind;

procedure IniOpenFile (FileName: String= ''; FilePath: String= '');
begin
 IniCloseFile;
 als FileName van FileName= '' toen: =ChangeFileExt (GetModuleName (hInstance), „.INI“); /ChangeFileExt (ParamStr (0), „.INI“);
 als (FilePath<> '') Dan
  begin
   FilePath: =IncludeTrailingBackslash (FilePath);
   als (FilePath) toen FileName DirectoryExists: =FilePath+FileName;
  eind;
 IniFile: =TIniFile.Create (FileName);
eind;

procedure IniCloseFile;
begin
 FreeAndNil (IniFile);
eind;

functie IniLoadSaveDefaultString (Sectie, Param, Gebrek: Koord): Koord;
begin
 Resultaat: =IniLoadSaveDefault (Sectie, Param, Gebrek);
eind;

procedure IniLoadSaveDefaultStringList (Sectie, Param: Koord; Lijst: TStringList; Opteer: TStringListOptions= []);
Var
 i: geheel;
begin
 Sectie: =_ExtSection+Section;
 List.CommaText: =IniFile.ReadString (Sectie, Param, List.CommaText);
 als slUpperCase in Opt toen
  begin
   List.Sorted: =False;
   voor I: =0 aan List.Count-1 do Lijst [I]: =UpperCase (Lijst [I]);
   List.Sorted: =True;
  eind;
 IniFile.WriteString (Sectie, Param, List.CommaText);
eind;

functie IniLoadSaveDefault (Sectie, Param, Gebrek: Koord): Koord; overbelasting;
begin
 Sectie: =_ExtSection+Section;
 Resultaat: =IniFile.ReadString (Sectie, Param, Gebrek);
 IniFile.WriteString (Sectie, Param, Resultaat);
eind;

functie IniLoadSaveDefault (Sectie, Param: Koord; Gebrek: Geheel): Geheel; overbelasting;
begin
 Sectie: =_ExtSection+Section;
 Resultaat: =IniFile.ReadInteger (Sectie, Param, Gebrek);
 IniFile.WriteInteger (Sectie, Param, Resultaat);
eind;

functie IniLoadSaveDefault (Sectie, Param: Koord; Gebrek: Van Boole): Van Boole; overbelasting;
begin
 Sectie: =_ExtSection+Section;
 Resultaat: =IniFile.ReadBool (Sectie, Param, Gebrek);
 IniFile.WriteBool (Sectie, Param, Resultaat);
eind;

procedure IniSaveQuotedCaption (Sectie, Param, Gebrek: Koord);
begin
 het Gebrek als van de Versiering (Gebrek<>) dan in gebreke blijft: =AnsiQuotedStr (Gebrek, „„“);
 IniFile.WriteString (_ExtSection+Section, Param, Gebrek);
eind;

functie IniLoadQuotedCaption (Sectie, Param, Gebrek: Koord): Koord;
Var
 P: PChar;
begin
 Resultaat: =IniFile.ReadString (_ExtSection+Section, Param, Gebrek);
 als (Lengte (Resultaat) >=2) en (Resultaat [1] = ' „') toen
  begin
   P: =PChar (Resultaat);
   Resultaat: =AnsiExtractQuotedStr (P, „„“);
  eind;
eind;

procedure IniLoadFormPosAndSize (frm: TCustomForm);
Var
 Sectie: Koord;
begin
 Sectie: =_ExtSection+frm.Name;
 frm. Titel: =IniFile.ReadString (Sectie, „TITEL“, frm. Titel);
 als niet _TextOnly toen
  begin
   als frm TForm toen TForm is (frm). Positie: =poDesigned;
   frm. Breedte: =IniFile.ReadInteger (Sectie, „BREEDTE“, frm. Breedte);
   frm. Hoogte: =IniFile.ReadInteger (Sectie, „HOOGTE“, frm. Hoogte);
   frm. Bovenkant: =IniFile.ReadInteger (Sectie, „BOVENKANT“, frm. Bovenkant);
   frm. Linkerzijde: =IniFile.ReadInteger (Sectie, „WEGGEGAAN“, frm. Linker);
   frm.WindowState: =TWindowState (IniFile.ReadInteger (Sectie, „STAAT“, Geheel (frm.WindowState)));
  eind;
eind;

procedure IniSaveFormPosAndSize (frm: TCustomForm);
Var
 Sectie: Koord;
begin
 Sectie: =_ExtSection+frm.Name;
 IniFile.WriteString (Sectie, „TITEL“, frm. Titel);
 als niet _TextOnly toen
  begin
   IniFile.WriteInteger (Sectie, „STAAT“, Geheel (frm.WindowState));
   IniFile.WriteInteger (Sectie, „BREEDTE“, frm. Breedte);
   IniFile.WriteInteger (Sectie, „HOOGTE“, frm. Hoogte);
   IniFile.WriteInteger (Sectie, „BOVENKANT“, frm. Bovenkant);
   IniFile.WriteInteger (Sectie, „WEGGEGAAN“, frm. Linker);
  eind;
eind;

procedure IniLoadMemo (memorandum: TMemo);
begin
 memorandum. Tekst: =TranslateFormat2Text (IniFile.ReadString (_ExtSection+memo.Name, „TEKST“, TranslateText2Format (memorandum. Tekst)));
eind;

procedure IniSaveMemo (memorandum: TMemo);
begin
 IniFile.WriteString (_ExtSection+memo.Name, „TEKST“, TranslateText2Format (memorandum. Tekst));
eind;

procedure IniLoadCheckBox (chk: TCheckBox);
begin
 chk. Titel: =IniLoadQuotedCaption (chk. Naam, „TITEL“, chk. Titel);
 als niet _TextOnly toen chk. Gecontroleerd: =IniFile.ReadBool (_ExtSection+chk.Name, „GECONTROLEERD“, chk. Controleerde);
eind;

procedure IniSaveCheckBox (chk: TCheckBox);
begin
 IniSaveQuotedCaption (chk. Naam, „TITEL“, chk. Titel);
 als niet _TextOnly toen IniFile.WriteBool (_ExtSection+chk.Name, „GECONTROLEERD“, chk. Controleerde);
eind;

procedure IniLoadShape (shp: TShape);
Var
 Sectie: Koord;
begin
 met shp 
  begin
   Sectie: =_ExtSection+Name;
   Zichtbaar: =IniFile.ReadBool (ZICHTBAAR“, Zichtbare Sectie, „);
   Pen.Color: =StringToColor (IniFile.ReadString (Sectie, „PEN_COLOR“, ColorToString (Pen.Color)));
   Brush.Color: =StringToColor (IniFile.ReadString (Sectie, „BRUSH_COLOR“, ColorToString (Brush.Color)));
  eind;
eind;

procedure IniLoadImage (img: TImage);
Var
 F: Koord;
 Sectie: Koord;
begin
 Met img 
  probeer
   Sectie: =_ExtSection+Name;
   Zichtbaar: =IniFile.ReadBool (ZICHTBAAR“, Zichtbare Sectie, „);
   Transparant: =IniFile.ReadBool (TRANSPARANT“, Transparante Sectie, „);
   Rek: =IniFile.ReadBool (Sectie, „REK“, Rek);
   F: =IniFile.ReadString (Sectie, „DOSSIER“, '');
   als FileExists (F) Dan Picture.LoadFromFile (F);
  behalve
  eind;
eind;

procedure IniSaveShape (shp: TShape);
Var
 Sectie: Koord;
begin
 met shp 
  begin
   Sectie: =_ExtSection+Name;
   IniFile.WriteBool (ZICHTBAAR“, Zichtbare Sectie, „);
   IniFile.WriteString (Sectie, „PEN_COLOR“, ColorToString (Pen.Color));
   IniFile.WriteString (Sectie, „BRUSH_COLOR“, ColorToString (Brush.Color));
  eind;
eind;

procedure IniSaveImage (img: TImage);
Var
 Sectie: Koord;
begin
 Met img 
  begin
   Sectie: =_ExtSection+Name;
   IniFile.WriteBool (ZICHTBAAR“, Zichtbare Sectie, „);
   IniFile.WriteBool (TRANSPARANT“, Transparante Sectie, „);
   IniFile.WriteBool (Sectie, „REK“, Rek);
  eind;
eind;

procedure IniLoadRadioButton (Rb: TRadioButton);
begin
 Rb. Titel: =IniLoadQuotedCaption (Rb. Naam, „TITEL“, Rb. Titel);
 als niet _TextOnly toen Rb. Gecontroleerd: =IniFile.ReadBool (_ExtSection+rb.Name, „GECONTROLEERD“, Rb. Controleerde);
eind;

procedure IniSaveRadioButton (Rb: TRadioButton);
begin
 IniSaveQuotedCaption (Rb. Naam, „TITEL“, Rb. Titel);
 als niet _TextOnly toen IniFile.WriteBool (_ExtSection+rb.Name, „GECONTROLEERD“, Rb. Controleerde);
eind;

procedure IniLoadText (edt: TCustomEdit);
begin
 edt. Tekst: =IniLoadQuotedCaption (edt. Naam, „TEKST“, edt. Tekst);
eind;

procedure IniSaveText (edt: TCustomEdit);
begin
 IniSaveQuotedCaption (edt. Naam, „TEKST“, edt. Tekst);
eind;

procedure IniLoadCaption (lbl: TLabel);
begin
 lbl. Titel: =IniLoadQuotedCaption (lbl. Naam, „TITEL“, lbl. Titel);
eind;

procedure IniSaveCaption (lbl: TLabel);
begin
 IniSaveQuotedCaption (lbl. Naam, „TITEL“, lbl. Titel);
eind;

procedure IniLoadFormCaption (frm: TForm);
begin
 frm. Titel: =IniLoadQuotedCaption (frm. Naam, „TITEL“, frm. Titel);
eind;

procedure IniSaveFormCaption (frm: TForm);
begin
 IniSaveQuotedCaption (frm. Naam, „TITEL“, frm. Titel);
eind;

procedure IniLoadButton (BTN: TButton);
begin
 BTN. Titel: =IniLoadQuotedCaption (BTN. Naam, „TITEL“, BTN. Titel);
eind;

procedure IniSaveButton (BTN: TButton);
begin
 IniSaveQuotedCaption (BTN. Naam, „TITEL“, BTN. Titel);
eind;

procedure IniLoadBitButton (BTN: TBitBtn);
begin
 BTN. Titel: =IniLoadQuotedCaption (BTN. Naam, „TITEL“, BTN. Titel);
eind;

procedure IniSaveBitButton (BTN: TBitBtn);
begin
 IniSaveQuotedCaption (BTN. Naam, „TITEL“, BTN. Titel);
eind;

procedure IniLoadSpeedButton (BTN: TSpeedButton);
begin
 BTN. Titel: =IniLoadQuotedCaption (BTN. Naam, „TITEL“, BTN. Titel);
eind;

procedure IniSaveSpeedButton (BTN: TSpeedButton);
begin
 IniSaveQuotedCaption (BTN. Naam, „TITEL“, BTN. Titel);
eind;

procedure IniLoadRadioGroup (rg: TRadioGroup);
begin
 rg. Titel: =IniLoadQuotedCaption (rg. Naam, „TITEL“, rg. Titel);
 als niet _TextOnly toen rg.ItemIndex: =IniFile.ReadInteger (_ExtSection+rg.Name, „INDEX“, rg.ItemIndex);
eind;

procedure IniSaveRadioGroup (rg: TRadioGroup);
begin
 IniSaveQuotedCaption (rg. Naam, „TITEL“, rg. Titel);
 als niet _TextOnly toen IniFile.WriteInteger (_ExtSection+rg.Name, „INDEX“, rg.ItemIndex);
eind;

procedure IniLoadGroupBox (GB: TGroupBox);
begin
 GB. Titel: =IniLoadQuotedCaption (GB. Naam, „TITEL“, GB. Titel);
 als niet _TextOnly toen IniLoadControl (GB);
eind;

procedure IniSaveGroupBox (GB: TGroupBox);
begin
 IniSaveQuotedCaption (GB. Naam, „TITEL“, GB. Titel);
 als niet _TextOnly toen IniSaveControl (GB);
eind;

procedure IniLoadComboBox (cb: TComboBox);
Var
 Streptokok: Koord;
begin
 Streptokok: =IniLoadQuotedCaption (cb. Naam, „TEKST“, cb. Tekst);
 als cb. Style=csDropDownList toen
  begin
   als Streptokok<> '' toen cb.ItemIndex: =cb. Items.IndexOf (Streptokok) Anders cb.ItemIndex: =IniFile.ReadInteger (_ExtSection+cb.Name, „INDEX“, cb.ItemIndex);
  eind Anders cb. Tekst: =Str;
eind;

procedure IniSaveComboBox (cb: TComboBox);
begin
 IniSaveQuotedCaption (cb. Naam, „TEKST“, cb. Tekst);
 IniFile.WriteInteger (_ExtSection+cb.Name, „INDEX“, cb.ItemIndex);
eind;

{$ifdef USE_SPIN_EDT}
procedure IniLoadSpinEdit (edt: TSpinEdit);
begin
 edt. Waarde: =IniFile.ReadInteger (_ExtSection+edt.Name, „VALUE“, edt. Waarde);
eind;

procedure IniSaveSpinEdit (edt: TSpinEdit);
begin
 IniFile.WriteInteger (_ExtSection+edt.Name, „VALUE“, edt. Waarde);
eind;
{$endif}

procedure IniSavePanel (pnl: TPanel);
begin
 IniFile.WriteInteger (_ExtSection+pnl.Name, „BREEDTE“, pnl. Breedte);
 IniFile.WriteInteger (_ExtSection+pnl.Name, „HOOGTE“, pnl. Hoogte);
eind;

procedure IniLoadPanel (pnl: TPanel);
begin
 pnl. Breedte: =IniFile.ReadInteger (_ExtSection+pnl.Name, „BREEDTE“, pnl. Breedte);
 pnl. Hoogte: =IniFile.ReadInteger (_ExtSection+pnl.Name, „HOOGTE“, pnl. Hoogte);
eind;

procedure IniSaveFrame (pnl: TFrame);
begin
 IniFile.WriteInteger (_ExtSection+pnl.Name, „BREEDTE“, pnl. Breedte);
 IniFile.WriteInteger (_ExtSection+pnl.Name, „HOOGTE“, pnl. Hoogte);
eind;

procedure IniLoadFrame (pnl: TFrame);
begin
 pnl. Breedte: =IniFile.ReadInteger (_ExtSection+pnl.Name, „BREEDTE“, pnl. Breedte);
 pnl. Hoogte: =IniFile.ReadInteger (_ExtSection+pnl.Name, „HOOGTE“, pnl. Hoogte);
eind;

procedure IniLoadStringGrid (net: TStringGrid);
Var
 i: geheel;
 Sectie: Koord;
begin
 Met net 
  begin
   Sectie: =_ExtSection+Name;
   grid.ColCount: =IniFile.ReadInteger (Sectie, „COL_COUNT“, grid.ColCount);
   voor I: =0 aan grid.ColCount-1 
    begin
     grid.ColWidths [I]: =IniFile.ReadInteger (Sectie, Formaat („COL_%d_WIDTH“, [I]), grid.ColWidths [I]);
     net. Cellen [I, 0]: =IniFile.ReadString (Sectie, Formaat („COL_%d_TEXT“, [I]), net. Cellen [I, 0]);
    eind;
  eind;
eind;

procedure IniSaveStringGrid (net: TStringGrid);
Var
 i: geheel;
 Sectie: Koord;
begin
 Met net 
  begin
   Sectie: =_ExtSection+Name;
   IniFile.WriteInteger (Sectie, „COL_COUNT“, grid.ColCount);
   voor I: =0 aan grid.ColCount-1 
    begin
     IniFile.WriteInteger (Sectie, Formaat („COL_%d_WIDTH“, [I]), grid.ColWidths [I]);
     IniFile.WriteString (Sectie, Formaat („COL_%d_TEXT“, [I]), net. Cellen [I, 0]);
    eind;
  eind;
eind;

procedure IniLoadOpenDialog (dlg: TOpenDialog);
begin
 dlg.InitialDir: =IniLoadQuotedCaption (dlg. Naam, „INITIAL_DIR“, dlg.InitialDir);
eind;

procedure IniSaveOpenDialog (dlg: TOpenDialog);
begin
 IniSaveQuotedCaption (dlg. Naam, „INITIAL_DIR“, dlg.InitialDir);
eind;

procedure IniSaveControl (c: TControl);
begin
 IniFile.WriteInteger (_ExtSection+c.Name, „BREEDTE“, c.Width);
 IniFile.WriteInteger (_ExtSection+c.Name, „HOOGTE“, c.Height);
eind;

procedure IniLoadControl (c: TControl);
begin
 c.Width: =IniFile.ReadInteger (_ExtSection+c.Name, „BREEDTE“, c.Width);
 c.Height: =IniFile.ReadInteger (_ExtSection+c.Name, „HOOGTE“, c.Height);
eind;

procedure IniLoadListView (L: TListView);
Var
 Sectie: Koord;
 i: geheel;
begin
 Met L 
  begin
   Sectie: =_ExtSection+Name;
   voor I: = 0 aan Columns.Count - 1 doet Kolommen [I]. Titel: =IniFile.ReadString (Sectie, Formaat („COLUMN_%d“, [I]), Kolommen [I]. Titel);
  eind;
eind;

procedure IniSaveListView (L: TListView);
Var
 Sectie: Koord;
 i: geheel;
begin
 Met L 
  begin
   Sectie: =_ExtSection+Name;
   voor I: = 0 aan Columns.Count - 1 doet IniFile.WriteString (Sectie, Formaat („COLUMN_%d“, [I]), Kolommen [I]. Titel);
  eind;
eind;

procedure IniLoadMenu (M: TMenu);
Var
 Sectie: Koord;
 i: geheel;

 procedure IniLoadMenuItem (M: TMenuItem; Sekte: Koord);
 Var
  i: geheel;
 begin
  Sekte: =Sect+'. '+M.Name;
  voor I: = 0 aan M.Count - 1 doet als M.Items [I]. Caption'-<> 'toen
   begin
    M.Items [I]. Titel: =IniFile.ReadString (Sekte, M.Items [I]. Naam, M.Items [I]. Titel);
    als M.Items [I]. Count>0 toen IniLoadMenuItem (M.Items [I], Sekte);
   eind;
 eind;
begin
 Met M 
  begin
   Sectie: =_ExtSection+Name;
   voor I: = 0 aan M.Items.Count - 1 doet als Punten [I]. Caption'-<> 'toen
    begin
     Punten [I]. Titel: =IniFile.ReadString (Sectie, Punten [I]. Naam, Punten [I]. Titel);
    eind;
  eind;
eind;

procedure IniSaveMenu (M: TMenu);
Var
 Sectie: Koord;
 i: geheel;
 procedure IniSaveMenuItem (M: TMenuItem; Sekte: Koord);
 Var
  i: geheel;
 begin
  Sekte: =Sect+'. '+M.Name;
  voor I: = 0 aan M.Count - 1 doet als M.Items [I]. Caption'-<> 'toen
   begin
    IniFile.WriteString (Sekte, M.Items [I]. Naam, M.Items [I]. Titel);
    als M.Items [I]. Count>0 toen IniSaveMenuItem (M.Items [I], Sekte);
   eind;
 eind;
begin
 Met M 
  begin
   Sectie: =_ExtSection+Name;
   voor I: = 0 aan M.Items.Count - 1 doet als Punten [I]. Caption'-<> 'toen
    begin
     IniFile.WriteString (Sectie, Punten [I]. Naam, Punten [I]. Titel);
     als Punten [I]. Count>0 toen IniSaveMenuItem (Punten [I], _ExtSection);
    eind;
  eind;
eind;

procedure IniSaveComponnents (Lijst: Serie van TObject; Ext_Section: String= ''; TextOnly: Boolean=False);
var
 i: geheel;
 SaveExtSect: Koord;
 SaveTextOnly: Van Boole;
begin
 SaveExtSect: =_ExtSection;
 _ExtSection: =Ext_Section;
 SaveTextOnly: =_TextOnly;
 _TextOnly: =TextOnly;
 voor I: =Low (Lijst) aan Hoogte (Lijst) doe indien dan Toegewezen (Lijst [I])
  probeer
   als de Lijst [I] TMemo toen        IniSaveMemo (          TMemo (        Lijst [I])) is Anders
   als de Lijst [I] TListView toen    IniSaveListView (      TListView (    Lijst [I])) is Anders
   als de Lijst [I] TMenu toen        IniSaveMenu (          TMenu (        Lijst [I])) is Anders
   als de Lijst [I] TCustomForm toen  IniSaveFormPosAndSize (TCustomForm (  Lijst [I])) is Anders
   als de Lijst [I] TRadioGroup toen  IniSaveRadioGroup (    TRadioGroup (  Lijst [I])) is Anders
   als de Lijst [I] TRadioButton toen IniSaveRadioButton (   TRadioButton (Lijst [I])) is Anders
   als de Lijst [I] TCustomEdit toen  IniSaveText (          TCustomEdit (  Lijst [I])) is Anders
   als de Lijst [I] TCheckBox toen    IniSaveCheckBox (      TCheckBox (    Lijst [I])) is Anders
   als de Lijst [I] TComboBox toen    IniSaveComboBox (      TComboBox (    Lijst [I])) is Anders
{$ifdef USE_SPIN_EDT}
   als de Lijst [I] TSpinEdit toen    IniSaveSpinEdit (  	TSpinEdit (    Lijst [I])) is Anders
{$endif}
   als de Lijst [I] TLabel toen       IniSaveCaption (  	TLabel (       Lijst [I])) is Anders
   als de Lijst [I] TBitBtn toen      IniSaveBitButton (  	TBitBtn (      Lijst [I])) is Anders
   als de Lijst [I] TButton toen      IniSaveButton (  	TButton (      Lijst [I])) is Anders
   als de Lijst [I] TSpeedButton toen IniSaveSpeedButton (  	TSpeedButton (Lijst [I])) is Anders
   als de Lijst [I] TPanel toen       IniSavePanel ( 	TPanel (       Lijst [I])) is Anders
   als de Lijst [I] TFrame toen       IniSaveFrame ( 	TFrame (       Lijst [I])) is Anders
   als de Lijst [I] TStringGrid toen  IniSaveStringGrid (    TStringGrid (  Lijst [I])) is Anders
   als de Lijst [I] TOpenDialog toen  IniSaveOpenDialog (    TOpenDialog (  Lijst [I])) is Anders
   als de Lijst [I] TShape toen       IniSaveShape (         TShape (       Lijst [I])) is Anders
   als de Lijst [I] TImage toen       IniSaveImage (         TImage (       Lijst [I])) is Anders
   als de Lijst [I] TGroupBox toen    IniSaveGroupBox (      TGroupBox (    Lijst [I])) is Anders
   als de Lijst [I] TControl toen     IniSaveControl (       TControl (     Lijst [I])) is Anders
   als de Lijst [I] TComponent toen   ShowMessage ('is Erreur sparen „+TComponent (Lijst [I]). Name+“: '+List [I] .ClassName)
    Anders ShowMessage ('Erreur bewaart '+List [I] .ClassName);
  behalve
   op E: Exception do ShowMessage (Formaat (de „Besparing van de Fout %s: %s'#13'% s“, [TComponent (Lijst [I]). Naam, E.ClassName, E.Message]));
  eind;
 _ExtSection: =SaveExtSect;
 _TextOnly: =SaveTextOnly;
eind;

procedure IniLoadComponnents (Lijst: Serie van TObject; Ext_Section: String= ''; TextOnly: Boolean=False);
var
 i: geheel;
 SaveExtSect: Koord;
 SaveTextOnly: Van Boole;
begin
 SaveExtSect: =_ExtSection;
 _ExtSection: =Ext_Section;
 SaveTextOnly: =_TextOnly;
 _TextOnly: =TextOnly;
 voor I: =Low (Lijst) aan Hoogte (Lijst) doe indien dan Toegewezen (Lijst [I])
  probeer
   als de Lijst [I] TMemo toen        IniLoadMemo (          TMemo (        Lijst [I])) is Anders
   als de Lijst [I] TListView toen    IniLoadListView (      TListView (    Lijst [I])) is Anders
   als de Lijst [I] TMenu toen        IniLoadMenu (          TMenu (        Lijst [I])) is Anders
   als de Lijst [I] TCustomForm toen  IniLoadFormPosAndSize (TCustomForm (  Lijst [I])) is Anders
   als de Lijst [I] TRadioGroup toen  IniLoadRadioGroup (    TRadioGroup (  Lijst [I])) is Anders
   als de Lijst [I] TRadioButton toen IniLoadRadioButton (   TRadioButton (Lijst [I])) is Anders
   als de Lijst [I] TCustomEdit toen  IniLoadText (          TCustomEdit (  Lijst [I])) is Anders
   als de Lijst [I] TCheckBox toen    IniLoadCheckBox (      TCheckBox (    Lijst [I])) is Anders
   als de Lijst [I] TComboBox toen    IniLoadComboBox (      TComboBox (    Lijst [I])) is Anders
{$ifdef USE_SPIN_EDT}
   als de Lijst [I] TSpinEdit toen    IniLoadSpinEdit (  	TSpinEdit (    Lijst [I])) is Anders
{$endif}
   als de Lijst [I] TLabel toen       IniLoadCaption (  	TLabel (       Lijst [I])) is Anders
   als de Lijst [I] TBitBtn toen      IniLoadBitButton (  	TBitBtn (      Lijst [I])) is Anders
   als de Lijst [I] TButton toen      IniLoadButton (  	TButton (      Lijst [I])) is Anders
   als de Lijst [I] TSpeedButton toen IniLoadSpeedButton (  	TSpeedButton (Lijst [I])) is Anders
   als de Lijst [I] TPanel toen       IniLoadPanel ( 	TPanel (       Lijst [I])) is Anders
   als de Lijst [I] TFrame toen       IniLoadFrame ( 	TFrame (       Lijst [I])) is Anders
   als de Lijst [I] TStringGrid toen  IniLoadStringGrid (    TStringGrid (  Lijst [I])) is Anders
   als de Lijst [I] TOpenDialog toen  IniLoadOpenDialog (    TOpenDialog (  Lijst [I])) is Anders
   als de Lijst [I] TShape toen       IniLoadShape (         TShape (       Lijst [I])) is Anders
   als de Lijst [I] TImage toen       IniLoadImage (         TImage (       Lijst [I])) is Anders
   als de Lijst [I] TGroupBox toen    IniLoadGroupBox (      TGroupBox (    Lijst [I])) is Anders
   als de Lijst [I] TControl toen     IniLoadControl (       TControl (     Lijst [I])) is Anders
   als de Lijst [I] TComponent toen   ShowMessage ('is Erreur Lading „+TComponent (Lijst [I]). Name+“: '+List [I] .ClassName) anders
    ShowMessage ('Erreur Lading '+List [I] .ClassName);
  behalve
   op E: Exception do ShowMessage (Formaat (de „Lading van de Fout %s: %s'#13'% s“, [TComponent (Lijst [I]). Naam, E.ClassName, E.Message]));
  eind;
 _ExtSection: =SaveExtSect;
 _TextOnly: =SaveTextOnly;
eind;

initialisering
 IniFile: =nil;
 IniOpenFile;
voltooiing
 IniCloseFile;
eind.
Andere oplossingen  
 
programming4us programming4us