0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

c++ builder XE4, 10.2 Tokyo > dialog > 初期ボタンを設定する方法 > MessageBox()を使う

Last updated at Posted at 2016-03-08
動作確認
C++ Builder XE4
Rad Studio 10.2 Tokyo Update 2 (追記: 2017/12/27)

OK, CANCELなどの確認ダイアログを表示するとき、誤操作防止の観点からCANCELボタンにフォーカスが移っていて欲しい場合がある。

C++ Builderで知っている方法としては以下の方法がある。

Unit1.cpp
void __fastcall TForm2::Button1Click(TObject *Sender)
{
	String cnfmsg = L"Are you sure?";

	if (IDOK == MessageBox(Handle, cnfmsg.c_str(), L"Confirmation",
		  MB_ICONQUESTION | MB_OKCANCEL | MB_DEFBUTTON2) ) {
		ShowMessage(L"DONE");
	}
}

MB_DEFBUTTON2 がCancelボタンに対応する。

他のメッセージ表示機能では調べた限りでデフォルトフォーカスの設定変更方法は見つかっていない。
OK,Cancelボタンの場合、OKがデフォルトになっていて、誤操作を誘発する。

検索キーワード

  • MessageDlg()
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?