一个关于MessageBox的问题(200分)

  • 主题发起人 主题发起人 daiyl
  • 开始时间 开始时间
D

daiyl

Unregistered / Unconfirmed
GUEST, unregistred user!
请问怎么在MessageBox 上自定义按钮,如有源码那就多谢了
 
he he, 有人是这样做的,不过我知道你不会喜欢的。<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; MessageBox(0, 'Hey, hello', 'title', MB_OK);<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var h, hok: thandle;<br>begin<br>&nbsp;h := findwindow(nil, 'title');<br>&nbsp;edit1.text := inttostr(h);<br>&nbsp;if (h&lt;&gt;0) then<br>&nbsp;begin<br>&nbsp; &nbsp;hok := FindWindowEx(h, 0, nil, 'OK');<br>&nbsp; &nbsp;edit1.text := edit1.text + '-' + inttostr(hok);<br>&nbsp; &nbsp;if (hok&lt;&gt;0) then<br>&nbsp; &nbsp; &nbsp;SetWindowText(hok, 'NEW OKAY!!!!!');<br>&nbsp;end;<br>end;<br>
 
这个稍好些:<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp; MsgDialog: TForm;<br>&nbsp; pt: TPoint;<br>&nbsp; btns: array[0..2] of TButton;<br>&nbsp; c: integer;<br>begin<br>&nbsp; MsgDialog := CreateMessageDialog('Hi', mtInformation, [mbYes,mbYesToAll, mbNo]);<br>&nbsp; c := MsgDialog.ControlCount;<br><br>&nbsp; btns[0] := TButton(MsgDialog.Controls[c-1]);<br>&nbsp; btns[1] := TButton(MsgDialog.Controls[c-2]);<br>&nbsp; btns[2] := TButton(MsgDialog.Controls[c-3]);<br><br>&nbsp; pt := Point(btns[0].Left,btns[0].Top);<br><br>&nbsp; btns[0].SetBounds(btns[1].Left, btns[1].Top, btns[0].Width,btns[0].Height);<br>&nbsp; btns[1].SetBounds(btns[2].Left, btns[2].Top, btns[1].Width,btns[1].Height);<br>&nbsp; btns[2].SetBounds(pt.X, pt.Y, btns[2].Width, btns[2].Height);<br>&nbsp; btns[0].Caption := '我是第一个';<br>&nbsp; btns[1].Caption := '我是第二个';<br>&nbsp; btns[2].Caption := '我是第三个';<br>&nbsp; MsgDialog.ShowModal;<br>end;
 
自己做个form不得了,爱放什么按钮放什么按钮,干吗非要messagebox
 
zw84611多谢啦!
 
后退
顶部