Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MessageBoxIndirect usage

91 views
Skip to first unread message

Sergey

unread,
May 11, 2000, 3:00:00 AM5/11/00
to
Hi!
What I make incorrectly?

Why under Win9x user icon is shown, and under WinNT is not shown?

procedure TForm1.Button1Click(Sender: TObject);
var
mbp: TMSGBOXPARAMS;
begin
mbp.hInstance:= hInstance;
with mbp do
begin
cbSize:= sizeof(mbp);
hwndOwner:= handle;
lpszText:= 'Are you shure you want to close the program?';
lpszCaption:= 'MessageBoxIndirect Test';
dwStyle:= (MB_DEFBUTTON2 or MB_USERICON or MB_YESNO);
lpszIcon:= 'MAINICON'; // << or any in your resource
dwContextHelpId:= 0;
lpfnMsgBoxCallback:= nil;
dwLanguageId:= 0;
end;
sleep(100);
MessageBeep(MB_ICONQUESTION);
if integer(MessageBoxIndirect(mbp))= IDYES then
close;
end;

Michael Cessna

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
Hi,

I posted what appears to be a solution...but on the thread
"MessageBoxIndirect ???". I didn't see your thread...otherwise I would have
placed it there.

Thanks.

Mike

Sergey <k...@NOSPAM.cheerful.com> wrote in message
news:8fdv6s$jh...@bornews.borland.com...

Sergey

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
Hi!

"Michael Cessna" <mce...@saleslogix.com> wrote in message
news:8h51v4$on...@bornews.borland.com...


> Hi,
>
> I posted what appears to be a solution...but on the thread
> "MessageBoxIndirect ???". I didn't see your thread...otherwise I would
have
> placed it there.

Yes! The messages here are lost. My decision I sent here 15.05.2000. But it
here already is not present!

I repeat it again:

--------------------------------

As I have found out, for WindowsNT system it is necessary to use
MessageBoxIndirectW function.
By a call of MessageBoxIndirectA function under WindowsNT the user icon is
_not_ displayed. And the call of MessageBoxIndirectW function under
Windows9x does not give _any_ result!
This knowledge I have issued in MessageBoxUni function. It correctly works
under 95, 98, NT and W2K.

{ --- cut here --- }
function TForm1.MessageBoxUni(sText,sCaption: string; dwStyl: dword; sIcon:
string): integer;
var
mbpA: TMSGBOXPARAMSa;
mbpW: TMSGBOXPARAMSw;
osvi: TOSVERSIONINFO;
begin
osvi.dwOSVersionInfoSize:= sizeof(TOSVERSIONINFO);
GetVersionEx(osvi);
if (osvi.dwPlatformId= VER_PLATFORM_WIN32_NT) then
begin // NT detected
mbpW.hInstance:= hInstance;
with mbpW do
begin
cbSize:= sizeof(mbpW);
hwndOwner:= handle;
lpszText:= PWideChar(WideString(sText));
lpszCaption:= PWideChar(WideString(sCaption));
dwStyle:= (dwStyl or MB_USERICON);
lpszIcon:= PWideChar(WideString(sIcon));


dwContextHelpId:= 0;
lpfnMsgBoxCallback:= nil;
dwLanguageId:= 0;
end;

result:= integer(MessageBoxIndirectW(mbpW));
end
else
begin // other
mbpA.hInstance:= hInstance;
with mbpA do
begin
cbSize:= sizeof(mbpA);
hwndOwner:= handle;
lpszText:= PChar(sText);
lpszCaption:= PChar(sCaption);
dwStyle:= (dwStyl or MB_USERICON);
lpszIcon:= PChar(sIcon);


dwContextHelpId:= 0;
lpfnMsgBoxCallback:= nil;
dwLanguageId:= 0;
end;

result:= integer(MessageBoxIndirectA(mbpA));
end
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if MessageBoxUni('Do you want to leave the program?',
'MessageBoxIndirect test',
(MB_DEFBUTTON2 or MB_YESNO),
'MAINICON')= IDYES then
close;
end;
{ --- and here --- }

--
~~~~~~~~~~~~~~
Best Regards,
Sergey Kirichenko

homepage: http://members.tripod.com/~rcolonel/

Michael Cessna

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
Hi,

Looks like we came up with essentially the same solution! The only
difference is that I re-exported the MessageBoxIndirect functions so that
the return type was Integer.

Thanks.

Mike

Sergey <k...@NOSPAM.cheerful.com> wrote in message

news:8h56n3$v...@bornews.borland.com...

0 new messages