Autor Beitrag
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Fr 30.01.04 10:38 
Ich bin gerade dabei an einem Programm zu werkeln, bei dem mann die Einstellungen im Programm verändern kann.
Zum Verändern der Einstellungen möchte ich ein Fenster erzeugen in dem mann dies kann und daher meine Frage: Wie kann man ein Fenster dynamisch erzeugen und zwar so, das beim Schließen des Fensters automatisch zum Hauptfenster gewechselt wird? Geht das vielleicht mit Frames?
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Fr 30.01.04 11:18 
Hier ein Beispiel, wie ein Formular dynamisch erzeugt werden kann.
Wenn Du diese Funktion vom Hauptformular aus aufrufst, kommst Du auch automatisch dorthin zurück.

Ich hoffe, das hilft Dir weiter.

Gruß, jjturbo

ausblenden volle Höhe Delphi-Quelltext
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:
{------------------------------------------------------------------------------}
{                             PasswortBox                                      }
{------------------------------------------------------------------------------}
function PasswortBox(const PWCaption, PWPrompt, PWDefault: string): string;
const BtnBreite=100;
var PWForm:TForm;
    OKButton,CancelButton:TButton;
    PWEdit:TEdit;
    PWLabel:TLabel;
begin


  Result := PWDefault;
  PWForm:=TForm.Create(HauptForm);
  with PWForm do begin
    Width:=300;
    Height:=130;
    Left:=Trunc((Screen.Width-Width)/2);
    Top:=Trunc((Screen.Height-Height)/2);
    Caption:=PWCaption;
  end;

  PWLabel:=TLabel.Create(PWForm);
  with PWLabel do begin
    Width:=PWForm.Width-30;
    Height:=20;
    Left:=15;
    Top:=5;
    Caption:=PWPrompt;
    Parent:=PWForm;
  end;

  PWEdit:=TEdit.Create(PWForm);
  with PWEdit do begin
    Width:=PWForm.Width-30;
    Height:=20;
    Left:=15;
    Top:=25;
    Text:='';
    Parent:=PWForm;
    PasswordChar:='*';
    Text:=PWDefault;
  end;

  OKButton:=TButton.Create(PWForm);
  with OKButton do begin
    Width:=BtnBreite;
    Height:=30;
    Left:=PWEdit.Left;
    Top:=PWEdit.Top+PWEdit.Height+20;
    Caption:='OK';
    Parent:=PWForm;
    ModalResult:=mrOk;
    Default:=True;
  end;

  CancelButton:=TButton.Create(PWForm);
  with CancelButton do begin
    Width:=BtnBreite;
    Height:=30;
    Left:=PWEdit.Left+PWEdit.Width-BtnBreite;
    Top:=PWEdit.Top+PWEdit.Height+20;
    Caption:='Abbruch';
    Parent:=PWForm;
    ModalResult:=mrCancel;
    Cancel:=True;
  end;

  if PWForm.ShowModal=mrOK then begin
    Result:=PWEdit.Text;
    PWForm.Close;
  end
  else PWForm.Close;


  PWEdit.Free;
  PWLabel.Free;
  CancelButton.Free;
  OKButton.Free;
  PWForm.Free;

end;


Moderiert von user profile iconMotzi: Delphi-Tags hinzugefügt

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Master_BB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 90



BeitragVerfasst: So 01.02.04 12:26 
hy jjDragon
wie ist das wenn ich einen Button dynamisch erstellen lassn will der auf einen Dialog zugreift?
Den dialog und den button hab ich schon erstellen lassen, jedoch weiß ich nicht wie ich jetzt das OnClick ereignis fülle. damit der dialog geöffnet wird.

Greetz
Master_BB
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: So 01.02.04 15:07 
s.u.

gruß, jjturbo



ausblenden volle Höhe Delphi-Quelltext
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    procedure MyButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

const
  MyPassword='hdt65ak8aj';

var
  Form1: TForm1;

implementation

{$R *.DFM}



{------------------------------------------------------------------------------}
{                             PasswortBox                                      }
{------------------------------------------------------------------------------}
function PasswortBox(const PWCaption, PWPrompt, PWDefault: string): string;
begin
//... ist ja schon bekannt...
end;




procedure TForm1.MyButtonClick(Sender: TObject);
begin
  if PasswortBox('Passwort eingeben','Bitte Passwort für diese Funktion eingeben','') =MyPassword
   then ShowMessage ('Gültiges Passwort');
end;





procedure TForm1.FormCreate(Sender: TObject);
var MyButton:TButton;
begin
  MyButton:=TButton.Create(Form1);
  with MyButton do begin
    Width:=80;
    Height:=30;
    Left:=10;
    Top:=10;
    Caption:='Mein Button';
    Parent:=Form1;
    OnClick:=MyButtonClick;
  end;

end;

end.


Moderiert von user profile iconDeCodeGuru: Delphi-Tags hinzugefügt

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Master_BB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 90



BeitragVerfasst: So 01.02.04 15:56 
aja THX
und wie ist es wenn ich in meinem Dynamischen Fenster
nen Speedbuttom erstellt habe und diesen jetzt mit einem Glyph ausstatten will?
Man kann ja nicht einfach den Pfad des Glyphs angeben da dann das ja nicht ein compiliert wird oder?
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: So 01.02.04 17:26 
@Master_BB:
Da fallen mir jetzt nur zwei Möglichkeiten ein. Entweder du plazierst ein paar nicht sichtbare SpeedButtons im HauptFormular, in denen du die benötigten Glyphs mitlieferst, später kannst Du sie mit MySpeedButton.Glyph:=MitgelieferterSpeedButton.Glyph zuweisen.
Ich meine aber, daß es besser ist, die entsprechenden BMP´s mitzuliefern. Mit einem selbsterstellten Setup(z.B. mit Installshield Express) kannst du sie ja an den entsprechenden Pfad kopieren lassen. Das ist besonders von Vorteil, wenn es sich um viele verschiedene Glyphs handelt.
Hoffe Dir geholfen zu haben.

Gruß, jjturbo

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Tilo Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Do 05.02.04 14:21 
@jjturbo
Ich habe mein gestelltes Problem mit Hilfe von Panelen, welche ich aus und an schalte gelöst.
Trotzdem Danke.
Das fertige Programm das hier:
web73.sso-hosting.de/primzahlgen_1.exe

Ich denke solch ein Program ist kein Novum