AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte MpuAboutWnd
Thema durchsuchen
Ansicht
Themen-Optionen

MpuAboutWnd

Ein Thema von Luckie · begonnen am 6. Jan 2007 · letzter Beitrag vom 13. Jul 2007
Antwort Antwort
Seite 4 von 4   « Erste     234   
Benutzerbild von Luckie
Luckie
Registriert seit: 29. Mai 2002
Ihr habt eventuell mitbekommen, dass ich heute kräftig an einem About-Dialog gearbeitet habe. Und mit der Hilfe von NicoDE und xarmox ist es mir dann auch gelungen das ganze zu meiner vollsten Zufriedenheit fertig zu stellen.

Ich wollte schon immer einen About-Dialog haben, der hübsch anzusehen und im Quellcode leicht zu handhaben ist. Früher habe ich MessageBoxen benutzt. Aber selbst meine benuterspezifischen MessageBoxen waren mir dann irgendwann mal etwas zu langweilig. Also habe ich mich heute mal hingesetzt und habe mir die Arbeit gemacht und einen About-Dialog geschrieben, der meinen Wünschen entspricht. Es war zwar ein gutes Stück Arbeit und ich musste einige Hindernisse überwinden, aber letztendlich hat sich für mich dann doch die Arbeit gelohnt. Ich will euch natürlich das Ergebnis meines Schaffens nicht vorenthalten und stellen ihn hiermit der Allgmeinheit zur Verfügung. Sourcecode und Screenshot im Anhang.

Delphi-Quellcode:
(*
*
*  How to use:
*  1.) Fill out the Fileversion properties:
*      - FileDescription
*      - FileVersion
*      - LegalCopyRight
*      - Productname
*      because these properties will be displayed in the dialog.
*
* 2.) Adjust the value of the constant URI.
* 3.) Replace the IconByteArray with the IconByteArray of your icon.
* 4.) Call the class procedure ShowAboutWnd:
*    TAboutWnd.ShowAboutWnd(Handle);
* 5.) Enjoy the dialog. ;)
*
*
* Special thanks go to NicoDE and xarmox for their help.
*
*)


 {*
  * If you wonder why...
  * Why don't use the VCL and formulars or at least a Dialog resource?
  * I wanted a nice About-Dialog that is easy to handle. I used to use
  * MessageBoxes and even customized MessageBoxes. But they are boring.
  * So I decided to roll up my sleeves and write a piece of code that
  * satisfies my needs: Nice to look at and easy to handle:
  * Just add the unit and call the dialog. If you use the VCL you always
  * have the dfm file that holds the formular. If you use dialog resource
  * you have the resource file and you have to include the resource
  * file into your source code. Now even the icon is in the sourcecode
  * you don't have a resource file for the icon.
  *
  *}
Was noh fehlt ist ein kleines Tool, was das Byte-Array für das Icon erzeugt und eventuell das ändern des Mauscursors in eine Hnad, wenn man über den Link fährt mit der Maus.

Über Kommentare und Kritik (auch am Code würde ich mich freuen).

Nachtrag: Hier noch das versprochene Tool, um ein Icon in ein Delphi Byte Array zu konvertieren. Der Quelltext landet in einer Textdatei. (Mit einem einzigen Icon in einer Icon-Datei hat es funktioniert.)
Miniaturansicht angehängter Grafiken
mpuaboutwnd_665.jpg  
Angehängte Dateien
Dateityp: pas mpuaboutwnd_186.pas (36,6 KB, 97x aufgerufen)
Dateityp: zip bintohexarray_186.zip (63,7 KB, 54x aufgerufen)
Ein Teil meines Codes würde euch verunsichern.
 
Benutzerbild von calculon
calculon

 
Delphi 7 Personal
 
#31
  Alt 8. Jan 2007, 00:05
Ich hab' eine Einstellung gefunden, die für 3 zeilenlange File-Descriptions wie ich finde schöne Ergebnisse liefert (siehe Anhang).

Delphi-Quellcode:
const
  WINDOWWIDTH = 300;
  WINDOWHEIGHT = 224;
  
  // product name
  CreateWindowEx(0, 'STATIC', '', WS_CHILD or WS_VISIBLE or SS_CENTER, 17, 10, 285, 24, hWnd, ID_STC_PRODUCTNAME,
  HInstance, nil);
  // description, version and copyright
  CreateWindowEx(0, 'STATIC', '', WS_CHILD or WS_VISIBLE or SS_CENTER, 10, 44, 280, 130, hWnd, ID_STC_DESCRIPTION,
  HInstance, nil);
  // "Link" static
  CreateWindowEx(0, 'STATIC', PCHar(URI), WS_CHILD or WS_VISIBLE or SS_NOTIFY or SS_CENTER, 5, 135, 285, 15, hWnd,
  ID_STC_WEB, HInstance, nil);
  // devider
  CreateWindowEx(0, 'STATIC', '', WS_CHILD or WS_VISIBLE or SS_SUNKEN, 0, 128, 300, 8, hWnd, 0, HInstance, nil);
  // OK button
  CreateWindowEx(0, 'BUTTON', 'OK', WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON, 210, 155, 75, 24, hWnd,
  ID_BTN_OK, HInstance, nil);
Miniaturansicht angehängter Grafiken
about_173.jpg  
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

 
Delphi 2006 Professional
 
#32
  Alt 8. Jan 2007, 09:34
Zitat von Olli:
Zitat von Luckie:
Aber ich bekomme kein WM_CREATE.
Das wäre ja nicht unbedingt nötig. Dein vorhandener Code hätte ja bequem umgeschrieben werden können:
Vorschlag angenommen.

@calculon: Du hast einfach nur die Fenster größer gemacht? Dabei sind dir aber ein paar Fenster durcheinander geraten.
Michael
  Mit Zitat antworten Zitat
Benutzerbild von calculon
calculon

 
Delphi 7 Personal
 
#33
  Alt 8. Jan 2007, 13:23
Zitat von luckie:
Dabei sind dir aber ein paar Fenster durcheinander geraten.
Ja hast schon recht. Perfekt ist das ganze nicht ...wie gesagt trial and error Verfahren. Aber für meine Bedürfnisse passt des schon und einem flüchtigen Blick des Benutzers fällt das auch nicht weiter auf.
Also danke für die Unit. Die werde ich mit Sicherheit mal brauchen!

Gruß

Calculon
--
  Mit Zitat antworten Zitat
Benutzerbild von turboPASCAL
turboPASCAL

 
Delphi 6 Personal
 
#34
  Alt 29. Apr 2007, 12:46
So, endlich den Fehler gefunden der bei deinem MpuAboutWnd den Rangecheck Error verursacht:
Code:
function LinkStcWndProc(hLinkStc, uMsg, wParam, lParam: [color=#ff0000]DWORD[/color]): [color=#ff0000]DWORD[/color]; stdcall;
So sollte es sein damit auch die LinkStcWndProc mit der CallWindowProc übereinstimmt:
function LinkStcWndProc(hLinkStc, uMsg: DWORD; wParam, lParam: integer): LRESULT; stdcall; und dann noch:
Code:
WM_CTLCOLORSTATIC:
      begin
        // set textcolor of "Link" tatic
        if lParam = Integer(GetDlgItem(hWnd, ID_STC_WEB)) then
        begin
          [color=#ff0000]SetTextColor(wParam, RGB(0, 0, 255));
          SetBkColor(wParam, GetSysColor(COLOR_BTNFACE));[/color]
          Brush := GetSysColorBrush(COLOR_BTNFACE);
          // save brush as a window property
          SetProp(hWnd, PROP_BRUSH, Brush);
          // return brush
          Result := Brush;
        end //...
Integer ist kein Word.

Sollte so aussehen:
Delphi-Quellcode:
WM_CTLCOLORSTATIC:
      begin
        // set textcolor of "Link" tatic
        if lParam = Integer(GetDlgItem(hWnd, ID_STC_WEB)) then
        begin
          SetTextColor(DWORD(wParam), RGB(0, 0, 255));
          SetBkColor(DWORD(wParam), GetSysColor(COLOR_BTNFACE));
          Brush := GetSysColorBrush(COLOR_BTNFACE);
          // save brush as a window property
          SetProp(hWnd, PROP_BRUSH, Brush);
          // return brush
          Result := Brush;
        end //...
Dazu habe ich dann für den Link noch ein passenden Cursor eingebaut ohne viel Tamtam im Quelltext.
Delphi-Quellcode:
// "Link" static
        hstcWeb := CreateWindowEx(0, 'STATIC', PCHar(URL), WS_CHILD or WS_VISIBLE or SS_NOTIFY or SS_CENTER, 5, 97, WINDOWWIDTH -
          15, 18, hWnd, ID_STC_WEB, HInstance, nil);
        SetClassLong(hstcWeb, GCL_HCURSOR, LoadCursor(0, IDC_HAND));

Dann habe ich mir erlaubt das Iconarray zu entfernen im es durch ein Res.-Icon zu ersetzen.

Ein Aufruf sieht dann zB. so aus.:
Delphi-Quellcode:
procedure IrgendWieIrgendWoIrgendWann;
begin
  MpuAboutWnd.URL := 'http://www.michael-puff.de';
  MpuAboutWnd.ICON_ID := 1;

  TAboutWnd.ShowAboutWnd(hDlg);
end;
Überlauf und Bereichsprüfung sind bei meinem Delphi immer an!

Done.
Angehängte Dateien
Dateityp: zip mpuaboutwnd_edit_266.zip (5,5 KB, 11x aufgerufen)
Matti
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

 
Delphi 2006 Professional
 
#35
  Alt 29. Apr 2007, 22:40
Hallo,
danke für deine Mühe, ich werde meinen Code entsprechend korrigieren.

Zitat von turboPASCAL:
Dann habe ich mir erlaubt das Iconarray zu entfernen im es durch ein Res.-Icon zu ersetzen.
Das war ja gerade der Gag, dass man nur die Unit braucht und nichts anderes und trotzdem ein Icon hat.
Michael
  Mit Zitat antworten Zitat
Benutzerbild von lbccaleb
lbccaleb

 
Delphi 7 Enterprise
 
#36
  Alt 13. Jul 2007, 13:53
kann ich es auch irgendwie verwirklichen, den link der hompage in das edit zu verfrachten???
Martin
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

 
Delphi 2006 Professional
 
#37
  Alt 13. Jul 2007, 13:54
In welches Edit? Ersetz den Klassennamen "STATIC" durch "EDIT" und du hast ein Edit-Kontrol.
Michael
  Mit Zitat antworten Zitat
Benutzerbild von lbccaleb
lbccaleb

 
Delphi 7 Enterprise
 
#38
  Alt 13. Jul 2007, 14:07
ach sorry hatte ganz vergessen das hab ich ja eingefügt das war ja gar kein standart na ich hab noch nen edit eingefügt als richedit 2.0 und in dem steht halt noch sonn kleiner text, in diesem wollte ich dann dierekt den link darstellen!!!
Martin
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

 
Delphi 2006 Professional
 
#39
  Alt 13. Jul 2007, 14:35
Na das sind aber schon größere Modifikationen, die mit meinem Code eigentlich nichts mehr gemeinsam haben. Wie man mit Links in RichEdits umgeht, kannst du, glaube ich, in meinen Win32-API Tutorials für Delphi nachlesen.
Michael
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 4 von 4   « Erste     234   


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 15:40 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