Board index » delphi » Messagebox button caption

Messagebox button caption

Can I change the button caption on a messagebox?
A text of my choice.

// Peter

 

Re:Messagebox button caption


here you go:

procedure TForm1.Button1Click(Sender: TObject);
begin
  MessageBox(0, 'Hey, hello', 'title', MB_OK);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var h, hok: thandle;
begin
 h := findwindow(nil, 'title');
 edit1.text := inttostr(h);
 if (h<>0) then
 begin
   hok := FindWindowEx(h, 0, nil, 'OK');
   edit1.text := edit1.text + '-' + inttostr(hok);
   if (hok<>0) then
     SetWindowText(hok, 'NEW OKAY!!!!!');
 end;
end;

the reason i used a TTimer is that because MessageBox() doesn't is like a
ShowModal call...unless you call a messagebox from within a thread and do
the window handle searching from another thread...

/elias

Quote
"Peter" <sm5...@hem.NOSPAMpassagen.se> wrote in message

news:3b1debbe_1@dnews...
Quote
> Can I change the button caption on a messagebox?
> A text of my choice.

> // Peter

Re:Messagebox button caption


Quote
Elias wrote:
> because MessageBox() doesn't is like a ShowModal call

  Why?

Quote
> ...unless you call a messagebox from within a thread and do
> the window handle searching from another thread...

  ??

Quote
> procedure TForm1.Button1Click(Sender: TObject);
> begin

    PostMessage(Handle, WM_USER+1, 0, 0);

Quote
>   MessageBox(0, 'Hey, hello', 'title', MB_OK);
> end;

  procedure TForm1.WMUser1(var msg : TMessage); //message WM_USER+1;
Quote
> var h, hok: thandle;

..

--
WBR,    LVT

Re:Messagebox button caption


but what if the messagebox delayed and the message got sent before the
messagebox() was shown?

Quote
"Leonid Troyanovsky" <l...@eco-pro.ru> wrote in message

news:3B1E263C.408B96C7@eco-pro.ru...
Quote
> Elias wrote:

> > because MessageBox() doesn't is like a ShowModal call

>   Why?

> > ...unless you call a messagebox from within a thread and do
> > the window handle searching from another thread...

>   ??

> > procedure TForm1.Button1Click(Sender: TObject);
> > begin
>     PostMessage(Handle, WM_USER+1, 0, 0);
> >   MessageBox(0, 'Hey, hello', 'title', MB_OK);
> > end;

>   procedure TForm1.WMUser1(var msg : TMessage); //message WM_USER+1;
> > var h, hok: thandle;
> ..

> --
> WBR, LVT

Re:Messagebox button caption


Quote
Elias wrote:
> but what if the messagebox delayed and the message got sent before the
> messagebox() was shown?

  The message will wait one's turn in a queue.

--
WBR,    LVT

Re:Messagebox button caption


But what if the queue was empty?

Quote
"Leonid Troyanovsky" <l...@eco-pro.ru> wrote in message

news:3B1E3BFA.19D629DE@eco-pro.ru...
Quote
> Elias wrote:

> > but what if the messagebox delayed and the message got sent before the
> > messagebox() was shown?

>   The message will wait one's turn in a queue.

> --
> WBR, LVT

Re:Messagebox button caption


Quote
Elias wrote:
> But what if the queue was empty?

  But, the queue is not empty.
  PostMessage places a message at the end of a message queue.

--
WBR,    LVT

Other Threads