AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Delphi NotifyWindow, dynamisches Fenster in nur einer Prozedur inklusive Events und AA
Thema durchsuchen
Ansicht
Themen-Optionen

NotifyWindow, dynamisches Fenster in nur einer Prozedur inklusive Events und AA

Ein Thema von FarAndBeyond · begonnen am 27. Jul 2015 · letzter Beitrag vom 16. Nov 2015
 
FarAndBeyond
(Gast)

n/a Beiträge
 
#2

AW: NotifyWindow, dynamisches Fenster in nur einer Prozedur inklusive Events und AA

  Alt 28. Jul 2015, 19:06
Hi,
tja, was ich auch mache das klappt bei mir nicht...
Also hab' ich jetzt einfach 'ne Unit daraus gemacht und die ist ja auch sehr praktisch... grins...
Das funzt wenigstens immer...

Wie schon erwähnt... nicht auf das ExceptionHandling achten...

Delphi-Quellcode:
Unit uNotifyWindow;

Interface

 Uses Windows, Forms, Classes, SysUtils, Graphics, Controls, StdCtrls, ExtCtrls;

 Type
  TNotifyWindow = Class
   Class Procedure CloseQuery(Sender: TObject; Var CanClose: Boolean);
   Class Procedure KeyDown(Sender: TObject; Var Key: Word; Shift: TShiftstate);

   Public
    Class Procedure Show(WindowTitle: String; WindowText: String);
  End;

 Var
  form_Notify : TForm;

Implementation


Function GetKey(Keycode: Integer) : Boolean;
 Begin
  Try
   GetKey := GetAsyncKeyState(KeyCode) <> 0;
  Except
   Exit;
  End;
 End;


Function OK_Pressed : Boolean;
 Begin
  Try
   If GetKey(VK_LControl) And GetKey(VK_LMenu) And GetKey(Ord('O')) And GetKey(Ord('K'))
   Then OK_Pressed := True
   Else OK_Pressed := False;
  Except
   Exit;
  End;
 End;


Class Procedure TNotifyWindow.CloseQuery(Sender: TObject; Var CanClose: Boolean);
 Begin
  Try
   If OK_Pressed = True
   Then CanClose := True
   Else CanClose := False;
  Except
   Exit;
  End;
 End;


Class Procedure TNotifyWindow.KeyDown(Sender: TObject; Var Key: Word; Shift: TShiftstate);
 Begin
  Try
   If OK_Pressed = True Then form_Notify.Close;
  Except
   Exit;
  End;
 End;


Class Procedure TNotifyWindow.Show(WindowTitle: String; WindowText: String);
  Var
   panel_BehindMemo : TPanel;
   memo_Text : TMemo;
   label_OKTaste : TLabel;


  Procedure AAFont(ObjFont: TFont);
    Var
     LogFont: TLogFont;
   Begin
    Try
     GetObject(ObjFont.Handle, SizeOf(TLogFont), @LogFont);
     LogFont.lfQuality := ANTIALIASED_QUALITY;
     ObjFont.Handle := CreateFontIndirect(LogFont);
    Except
     Exit;
    End;
   End;

 Begin
  Try
   Try
    form_Notify := TForm.Create(Nil);
    form_Notify.Caption := WindowTitle;
    form_Notify.Height := 374;
    form_Notify.Width := 583;
    form_Notify.BorderStyle := bsSingle;
    form_Notify.BorderIcons := [];
    form_Notify.Color := 898061;
    form_Notify.FormStyle := fsStayOnTop;
    form_Notify.Left := (Screen.Width - form_Notify.Width) Div 2;
    form_Notify.Top := (Screen.Height - form_Notify.Height) Div 2;
    form_Notify.OnCloseQuery := TNotifyWindow.CloseQuery;
    form_Notify.OnKeyDown := TNotifyWindow.KeyDown;

    panel_BehindMemo := TPanel.Create(form_Notify);
    panel_BehindMemo.Borderstyle := bsNone;
    panel_BehindMemo.Color := 898061;
    panel_BehindMemo.Enabled := False;
    panel_BehindMemo.Height := 296;
    panel_BehindMemo.Width := 549;
    panel_BehindMemo.Left := 14;
    panel_BehindMemo.Top := 17;
    panel_BehindMemo.Parent := form_Notify;

    memo_Text := TMemo.Create(form_Notify);
    memo_Text.Alignment := taLeftJustify;
    memo_Text.BorderStyle := bsSingle;
    memo_Text.Color := 898061;
    memo_Text.Font.Color := clBlack;
    memo_Text.Font.Size := 14;
    memo_Text.Font.Name := 'VerdanaB';
    memo_Text.Font.Style := [fsBold];
    memo_Text.Height := 284;
    memo_Text.Width := 537;
    memo_Text.Left := 6;
    memo_Text.Top := 6;
    memo_Text.ReadOnly := True;
    memo_Text.ScrollBars := ssNone;
    memo_Text.Parent := panel_BehindMemo;
    memo_Text.Text := WindowText;

    label_OKTaste := TLabel.Create(form_Notify);
    label_OKTaste.Caption := 'CTRL + ALT + O + K';
    label_OKTaste.Color := 898061;
    label_OKTaste.Font.Color := clBlue;
    label_OKTaste.Font.Name := 'VerdanaB';
    label_OKTaste.Font.Size := 14;
    label_OKTaste.Font.Style := [fsBold];
    label_OKTaste.AutoSize := True;
    label_OKTaste.Left := 375;
    label_OKTaste.Top := 317;
    label_OKTaste.Parent := form_Notify;

    AAFont(memo_Text.Font);
    AAFont(label_OKTaste.Font);
    form_Notify.ShowModal;
   Finally
    FreeAndNil(form_Notify);
   End;
  Except;
   Exit;
  End;
 End;

End.
Gruß
Martin
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:21 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz