Einzelnen Beitrag anzeigen

ZelltoD

Registriert seit: 1. Jul 2008
40 Beiträge
 
RAD-Studio 2009 Arc
 
#13

Re: -> SingleInstance - Parameter an Form1 übergeben

  Alt 12. Okt 2008, 19:18
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, jpeg, ComCtrls, LMDCustomComponent, SingleInstance, FileCtrl, FunktionReaddir,
  ShellAPI, Menus, CoolTrayIcon, Clipbrd, Printers;

type
  TForm1 = class(TForm)

    Button1: TButton;
    SaveDialog1: TSaveDialog;
    Suchfeld: TEdit;
    Hauptliste: TListBox;
    Button2: TButton;
    Benutzerliste: TListBox;
    Testimage: TImage;
    BildControlLogo: TImage;
    BildSteuerleiste: TImage;
    BildLeiste1: TImage;
    Button3: TButton;
    Eingabefeld: TEdit;
    BildLinkAnnehmen: TImage;
    BildLinkAbbrechen: TImage;
    StatusBar: TStatusBar;
    Button4: TButton;
    ColorDialog1: TColorDialog;
    Button6: TButton;
    Zusatzliste: TListBox;
    OrdnerListe: TListBox;
    Button7: TButton;
    Button8: TButton;
    OpenDialog1: TOpenDialog;
    Button9: TButton;
    mmoClipbrdContents: TMemo;
    Button5: TButton;
    Button10: TButton;
    Button11: TButton;
    CoolTrayIcon1: TCoolTrayIcon;
    PopupMenu1: TPopupMenu;
    Eintrag1: TMenuItem;
    Programmwiederherstellen1: TMenuItem;
    Programmminimieren1: TMenuItem;
    Beenden1: TMenuItem;
    CheckBox1: TCheckBox;
    Button12: TButton;
    PrintDialog1: TPrintDialog;
    Button13: TButton;
    Button14: TButton;
    Button15: TButton;
    Button16: TButton;

procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure SuchfeldKeyPress(Sender: TObject; var Key: Char);
    procedure BenutzerlisteDrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure SuchfeldClick(Sender: TObject);
    procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure Button3Click(Sender: TObject);
    procedure BildLinkAbbrechenMouseEnter(Sender: TObject);
    procedure BildLinkAbbrechenMouseLeave(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure EingabefeldClick(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
   procedure Programmbeenden1Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormHide(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button11Click(Sender: TObject);
    procedure CoolTrayIcon1Click(Sender: TObject);
    procedure CoolTrayIcon1DblClick(Sender: TObject);
    procedure mmoClipbrdContentsChange(Sender: TObject);
    procedure Programmwiederherstellen1Click(Sender: TObject);
    procedure Programmminimieren1Click(Sender: TObject);
    procedure Beenden1Click(Sender: TObject);
    procedure Eintrag1Click(Sender: TObject);
    procedure Button12Click(Sender: TObject);
    procedure Button13Click(Sender: TObject);
    procedure Button14Click(Sender: TObject);
    procedure Button15Click(Sender: TObject);
    procedure Button16Click(Sender: TObject);

 private
  FNextViewer: THandle;
  FClpBrd: TClipboard;
   function LastErrorMsgStr: String;
   procedure WMDROPFILES(var Msg: TMessage); Message WM_DROPFILES;
   procedure AttachToClipboard;
   procedure DetachFromClipboard;
 procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
       { Private-Deklarationen }

   protected
    {geschützte-Deklarationen}
    procedure WMChangeCBChain(var Msg: TWMChangeCBChain); message WM_CHANGECBCHAIN;
    procedure WMDrawClipboard(var Msg: TWMDrawClipboard); message WM_DRAWCLIPBOARD;
  public
      Memo1: TMemo;
    procedure ShowParams(Params: TStringList);
   
 { Public-Deklarationen }

 end;
var
  Form1: TForm;
  minimiert:boolean;
implementation

{$R *.dfm}

procedure TForm1.ShowParams(Params: TStringList);
begin
  Application.Minimize;
  Application.Restore;

  Memo1.Text := Params.Text;

end;

// [...]

Im OnCreate-ereignis der Form is dann noch
parametername:=(extractfilename(ParamStr(1))); //Parametername ermitteln und in String schreiben...
memo1.lines.add(parametername);

[...]
Die komplette Unit 1 hat 700 Zeilen, aber das ist so eigendlich das einzige was mit den Parametern zu tun hat.
  Mit Zitat antworten Zitat