checkparametersbeforecreateform
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| checkparametersbeforecreateform [2025/04/18 03:25] – jwan | checkparametersbeforecreateform [2025/10/10 10:15] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 111: | Line 111: | ||
| + | Another is to create different form base on the parameter: | ||
| + | |||
| + | < | ||
| + | program Project1; | ||
| + | |||
| + | uses | ||
| + | Forms, Dialogs, SysUtils, Unit1 in ' | ||
| + | |||
| + | {$R *.RES} | ||
| + | |||
| + | const | ||
| + | ProgramVersion = ' | ||
| + | |||
| + | begin | ||
| + | Application.Initialize; | ||
| + | |||
| + | // Check for command-line parameters | ||
| + | if ParamCount > 0 then | ||
| + | begin | ||
| + | if SameText(ParamStr(1), | ||
| + | begin | ||
| + | // If the parameter is "/ | ||
| + | Application.CreateForm(TScanForm, | ||
| + | Application.Run; | ||
| + | Exit; | ||
| + | end | ||
| + | else if SameText(ParamStr(1), | ||
| + | begin | ||
| + | // If the parameter is "/ | ||
| + | MessageBox(0, | ||
| + | ' | ||
| + | '/scan - Run scan mode (no default form).' | ||
| + | '/help - Display this help message.' | ||
| + | ' | ||
| + | Halt; // Terminate the program | ||
| + | end; | ||
| + | end; | ||
| + | |||
| + | // If no parameters or unrecognized parameter, create and display TForm1 | ||
| + | Application.CreateForm(TForm1, | ||
| + | Application.Run; | ||
| + | end. | ||
| + | </ | ||
| + | |||
| + | NOTE: just make sure each of the form will have: | ||
| + | |||
| + | < | ||
| + | |||
| + | public | ||
| + | { Public declarations } | ||
| + | constructor Create(AOwner: | ||
| + | | ||
| + | constructor Tformmain.Create(AOwner: | ||
| + | begin | ||
| + | | ||
| + | end; | ||
| + | </ | ||
checkparametersbeforecreateform.1744946752.txt.gz · Last modified: (external edit)
