1,183
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Button1Click(Sender: TObject);
function MessageEx(lText, lCaption: PChar; lStyle: DWORD; IconId: Integer): Integer;
var
Msg: TMsgBoxParams;
begin
Msg.cbSize := Sizeof(Msg);
Msg.hwndOwner := Application.Handle;
Msg.hInstance := HInstance;
Msg.lpszText := lText;
Msg.lpszCaption := lCaption;
Msg.dwStyle := lStyle;
Msg.lpszIcon := MakeIntResource(IconId);
{如果改成Msg.lpszIcon := 'MAINICON';不能显示图标MAINICON}
Msg.dwContextHelpId := 0;
Msg.lpfnMsgBoxCallback := nil;
Msg.dwLanguageId := LANG_NEUTRAL;
Result := Integer(MessageBoxIndirect(Msg));
end;
begin
MessageEx('MessageEx', 'MessageEx', MB_OK or MB_USERICON, 101);//可以显示图标101
end;
procedure TForm1.Button1Click(Sender: TObject);
function MessageEx(lText, lCaption: PWideChar; lStyle: DWORD; IconID: PWideChar): Integer;
var
Msg: TMsgBoxParamsW;
begin
Msg.cbSize := Sizeof(Msg);
Msg.hwndOwner := Application.Handle;
Msg.hInstance := HInstance;
Msg.lpszText := lText;
Msg.lpszCaption := lCaption;
Msg.dwStyle := lStyle;
Msg.lpszIcon := IconID;
Msg.dwContextHelpId := 0;
Msg.lpfnMsgBoxCallback := nil;
Msg.dwLanguageId := LANG_NEUTRAL;
Result := Integer(MessageBoxIndirectW(Msg));
end;
begin
MessageEx('Hello MessageEx!','MessageEx', MB_OK or MB_USERICON, 'MAINICON');{PWideChar(101)}
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Msg: TMsgBoxParamsW;
begin
Msg.cbSize := Sizeof(Msg);
Msg.hwndOwner := Application.Handle;
Msg.hInstance := HInstance;
Msg.lpszText := 'MY MAINICON !';
Msg.lpszCaption := 'MAINICON';
Msg.dwStyle := MB_OK or MB_USERICON;
Msg.lpszIcon := 'MAINICON';
Msg.dwContextHelpId := 0;
Msg.lpfnMsgBoxCallback := nil;
Msg.dwLanguageId := LANG_NEUTRAL;
MessageBoxIndirectW(Msg);{成功显示MAINICON}
end;