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.
(*
*
* 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.)
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!
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:
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 //...
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.
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!!!
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.