Mega Code Archive
Link in Progman ProceduresInternet Sites (2)
Title: Link in Progman Procedures/Internet Sites (2)
Question: How to add Link in MsgBox?
Answer:
if the not create msg boxses link or Link Componenttes not Found?
this now is EASY!
LinkedMsgBox component is add link in MsgBox
Qualities:
Set style to win32/win31 style
Allow set on/off internet link type
Allow change buttons caption
Allow dislabe/enable button(s)
...
Source:
unit LinkedMsgBox;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ShellApi, StdCtrls;
type
TNotifyEvent = procedure(Sender: TObject) of object;
TLinkedMsgBox = class(TControl)
private
FLink: TNotifyEvent;
FPage: String;
FMsg: String;
FType: TMsgDlgType;
FButtons: TMsgDlgButtons;
FTitle: String;
aMsgDlg: TForm;
FClose: Boolean;
FInternetLink: Boolean;
FO: Boolean;
FC: Boolean;
FWF: Boolean;
FOCap: String;
FCap: String;
procedure HandleLink(Sender: TObject);
function MyMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): Integer;
protected
//
public
//
published
property InternetLink: Boolean read FInternetLink write FInternetLink;
property OnLinkClicked: TNotifyEvent read FLink write FLink;
property LPage: string read FPage write FPage;
property Msg: String read FMsg write FMsg;
property GrayOk: Boolean read FO write FO;
property GrayCancel: Boolean read FC write FC;
property OkButtonCaption: String read FOCap write FOCap;
property CancelButtonCaption: String read FCap write FCap;
property MsgBoxType: TMsgDlgType read FType write FType;
property MsgBoxButtons: TMsgDlgButtons read FButtons write FButtons;
property Caption: String read FTitle write FTitle;
property CloseBox: Boolean read FClose write FClose;
property Win31Style: Boolean read FWF write FWF;
function Exec: Integer;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Artun oma komponetit', [TLinkedMsgBox]);
end;
procedure TLinkedMsgBox.HandleLink(Sender: TObject);
begin
TLabel(aMsgDlg.Components[1]).Font.Color:=clOlive;
if Assigned(FLink) then
begin
FLink(Self)
end;
if FInternetLink = True then
begin
ShellApi.ShellExecute(0, nil, PChar(FPage), '', nil, SW_SHOWNORMAL);
end;
if FClose = True then
aMsgDlg.Close
end;
function TLinkedMsgBox.MyMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): Integer;
var i: Integer;
dlgButton: TButton;
begin
{ Create the Dialog }
{ Dialog erzeugen }
aMsgDlg := CreateMessageDialog(Msg, DlgType, Buttons);
TLabel(aMsgDlg.Components[1]).Font.Style:=[fsUnderline];
TLabel(aMsgDlg.Components[1]).OnClick:=HandleLink;
TLabel(aMsgDlg.Components[1]).Cursor:=crHandPoint;
TLabel(aMsgDlg.Components[1]).Font.Color:=clBlue;
if FWF = True then
begin
TLabel(aMsgDlg.Components[1]).Font.Style:=[fsUnderline, fsBold];
for i := 0 to aMsgDlg.ComponentCount - 1 do
begin
{ If the object is of type TButton, then }
{ Wenn es ein Button ist, dann...}
if (aMsgDlg.Components[i] is TButton) then
begin
dlgButton := TButton(aMsgDlg.Components[i]);
dlgButton.Font.Style:=[fsBold];
end;
end;
end;
if (mbOk in MsgBoxButtons) then
begin
TButton(aMsgDlg.Components[2]).Caption:=FOCap;
if FO then
TButton(aMsgDlg.Components[2]).Enabled:=False
end;
if (mbCancel in MsgBoxButtons) then
begin
TButton(aMsgDlg.Components[3]).Caption:=FCap;
if FC then
TButton(aMsgDlg.Components[3]).Enabled:=False;
end;
aMsgDlg.Caption:=Caption;
Result := aMsgDlg.ShowModal;
end;
function TLinkedMsgBox.Exec: Integer;
begin
Result:=MyMessageDialog(Msg, MsgBoxType, MsgBoxButtons);
end;
end.
//Warning, only private use!