求ShowMessage()使用方法,该怎么处理
求ShowMessage()使用方法
VC6
rt
求ShowMessage()使用方法,很好奇,因为今天网上有个源码用到了这个函数。我找了baidu,没有什么有价值的资料
------解决方案--------------------
VC不是有AfxMessageBox吗
------解决方案--------------------
ShowMessage没有重载,只有一种形式
ShowMessage("hello heck");
vcl中的ShowMessag内部调用了vcl的ShowMessagePos,ShowMessagePos调用了MessageDlgPos,MessageDlgPos调用了MessageDlgPosHelp,MessageDlgPosHelp调用了CreateMessageDialog,
CreateMessageDialog。
CreateMessageDialog 实现如下:
VC6
rt
求ShowMessage()使用方法,很好奇,因为今天网上有个源码用到了这个函数。我找了baidu,没有什么有价值的资料
------解决方案--------------------
VC不是有AfxMessageBox吗
------解决方案--------------------
ShowMessage没有重载,只有一种形式
ShowMessage("hello heck");
vcl中的ShowMessag内部调用了vcl的ShowMessagePos,ShowMessagePos调用了MessageDlgPos,MessageDlgPos调用了MessageDlgPosHelp,MessageDlgPosHelp调用了CreateMessageDialog,
CreateMessageDialog。
CreateMessageDialog 实现如下:
function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons): TForm;
const
mcHorzMargin = 8;
mcVertMargin = 8;
mcHorzSpacing = 10;
mcVertSpacing = 10;
mcButtonWidth = 50;
mcButtonHeight = 14;
mcButtonSpacing = 4;
var
DialogUnits: TPoint;
HorzMargin, VertMargin, HorzSpacing, VertSpacing, ButtonWidth,
ButtonHeight, ButtonSpacing, ButtonCount, ButtonGroupWidth,
IconTextWidth, IconTextHeight, X, ALeft: Integer;
B, DefaultButton, CancelButton: TMsgDlgBtn;
IconID: PChar;
TextRect: TRect;
begin
Result := TMessageForm.CreateNew(Application);
with Result do
begin
BiDiMode := Application.BiDiMode;
BorderStyle := bsDialog;
Canvas.Font := Font;
KeyPreview := True;
OnKeyDown := TMessageForm(Result).CustomKeyDown;
DialogUnits := GetAveCharSize(Canvas);
HorzMargin := MulDiv(mcHorzMargin, DialogUnits.X, 4);
VertMargin := MulDiv(mcVertMargin, DialogUnits.Y, 8);
HorzSpacing := MulDiv(mcHorzSpacing, DialogUnits.X, 4);
VertSpacing := MulDiv(mcVertSpacing, DialogUnits.Y, 8);
ButtonWidth := MulDiv(mcButtonWidth, DialogUnits.X, 4);
for B := Low(TMsgDlgBtn) to High(TMsgDlgBtn) do
begin
if B in Buttons then
begin
if ButtonWidths[B] = 0 then
begin
TextRect := Rect(0,0,0,0);
Windows.DrawText( canvas.handle,
PChar(LoadResString(ButtonCaptions[B])), -1,
TextRect, DT_CALCRECT or DT_LEFT or DT_SINGLELINE or
DrawTextBiDiModeFlagsReadingOnly);
with TextRect do ButtonWidths[B] := Right - Left + 8;
end;
if ButtonWidths[B] > ButtonWidth then