Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Software-Projekte der Mitglieder (https://www.delphipraxis.net/26-software-projekte-der-mitglieder/)
-   -   OOP Dialog-Template based on Windows API dialog resources (https://www.delphipraxis.net/99978-oop-dialog-template-based-windows-api-dialog-resources.html)

Luckie 20. Sep 2007 12:04


OOP Dialog-Template based on Windows API dialog resources
 
Liste der Anhänge anzeigen (Anzahl: 1)
Ich habe mir mal eine nonVCL-Dialog Vorlage erstellt, also quasi so etwas, wie ein Grundgerüst. Ich habe das jetzt mal objekt orientiert programmier nach dem ich so ein Grundgerüst lange Zeit nur prozedural hatte:
Delphi-Quellcode:
type
  TMpuDialog = class(TObject)
  private
    FHandle: THandle;
    FhAccelTbl: THandle;
    FDlgFuncPtr: Pointer;
    FMsg: UINT;
    FwParam: WPARAM;
    FlParam: LPARAM;
    FAppTitle: WideString;
    FhDlgIcon: THandle;
    FLogFont: TLogFont;
    FhBannerFont: THandle;
    function MakeProcInstance(M: TMethod): Pointer;
    function DlgFunc(hDlg: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): BOOL; stdcall;
    // Getters / Setters
    function GethApp: THandle;
    function GetAppTitle: WideString;
    procedure SetAppTitle(Value: WideString);
    function GetIcon: THandle;
    procedure SetIcon(Value: THandle);
    // Internal methodes
    function Run: Integer;
    procedure SetDlgCaption;
    procedure SetBannerCaption;
    procedure SetDlgIcon;
    // Event handlers
    procedure OnInitDialog(hDlg: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM);
    procedure OnWMSize(wParam: WPARAM; lParam: LPARAM);
    function OnCommad: Boolean;
    procedure OnClose(ExitCode: Integer = 0);
  public
    constructor Create;
    destructor Destroy; override;
    property Handle: THandle read GethApp;
    property AppTitle: WideString read GetAppTitle write SetAppTitle;
    property Icon: THandle read GetIcon write SetIcon;
  end;
Und ein Auszug aus der Readme:
Code:
                                                         Applies to version: 1.0
                                                                Date: 2007-09-06


                         OOPDialog Readme file
                         =====================

  1. What is it?
  --------------
    OOPDialog is a Delphi object orientated Dialog-Template based on Windows API
    Dialog resources.


  2. Archive content and directory structure
  ------------------------------------------

  [..]


  3. How to use
  -------------
    3.1 Prearrangements
      Resource file: Main dialog ID = 100.
                     Accelerator table ID = 4001.
                     Needed version information for the about dialog:
             FileVersion, FileDescription, Legal copyright,
             ProductName, Productversion.
                     Main icon ID = 1.

                     To compile the resource script use resbuild.bat.

      make.bat: If you want to use make.bat, make sure it can find the program
                rcstamp.exe for automatically increment the build number.
                rcstamp: [url]http://www.codeproject.com/tools/rcstamp.asp[/url]

                The binary gets automatically packed bei UPX. Make sure make.bat
                can find upx.exe.

    3.2 Constants
      The tooltips array must contain the tooltip strings in the same order in
      which they are assigned to the corresponding controls, because they get
      assigned with a for-loop. See method OnInitDialog for details.

    3.3 Using the template
      Just adjust the personal settings (icon, productname, ...) in the resource
      script, edit the dialog (add / remove controls) and add your own code.


  4. How it works
  ---------------
    For details see:
    [url]http://www.michael-puff.de/Developer/Artikel/2007_08/[/url] ->
      2007_08_02_CallbackMethod.php


                                                      Copyright (c) Michael Puff
                                                      [url]http://www.michael-puff.de[/url]
Eventuell kann ja jemand etwas damit anfangen oder hat Verbesserungsvorschläge. Einen hätte ich schon selber und zwar die Klasse "rausziehen" und eine neue Dialog-Klasse ableiten. Aber das habe ich noch nicht umgesetzt.

Dezipaitor 20. Sep 2007 13:27

Re: OOP Dialog-Template based on Windows API dialog resource
 
Warum machst du nicht richtig OOP und lässt die Klasse überschreiben.
So kann man bestimmte Methoden überschreiben, um z.B. auf Commands zu reagieren.
So müsste man die Klasse jedesmal kopieren und Fehler müssten durch alle Kopien korrigiert werden.

Ich denke da z.B. an Turbo Vision oder Borland Pascal for Windows Stil.
Um ein Fenster zu überschreiben musste man bestimmte Methoden überschreiben.

Luckie 20. Sep 2007 14:22

Re: OOP Dialog-Template based on Windows API dialog resource
 
Ich sagte ja, das wäre dann der nächste Schritt.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:23 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz