Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: MessageBox with "Don't show this again"


This question is answered. Helpful answers available: 0. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Sep 30, 2016 12:16 AM Last Post By: Goran Ekstrom Threads: [ Previous | Next ]
Goran Ekstrom

Posts: 149
Registered: 1/10/04
MessageBox with "Don't show this again"  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2016 2:47 PM
Hi,
occasionally I need a message box with the familiar "Don't show this again" checkbox option. Is there any way to make the regular winapi MesssageBox to have this or do I have to make my own?

Regards
Goran
John May

Posts: 81
Registered: 6/25/10
Re: MessageBox with "Don't show this again"
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2016 5:33 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Standard MessageBox does not offer this. If your app doesn't need to support Windows XP or older and if you can live with Windows Vista and newer only, then you can use TTaskDialog:

http://docwiki.embarcadero.com/CodeExamples/XE8/en/TaskDialogs_(Delphi)
https://msdn.microsoft.com/en-us/library/windows/desktop/bb787471.aspx
https://www.youtube.com/watch?v=HfRllhsHcyg
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: MessageBox with "Don't show this again"
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2016 6:03 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Goran Ekstrom wrote:
occasionally I need a message box with the familiar "Don't show this again"
checkbox option. Is there any way to make the regular winapi MesssageBox
to have this or do I have to make my own?

MessageBox() does not natively support that feature.

As John May stated, on Vista and later you can use the TTaskDialog component, which is a wrapper for the Win32 API TaskDialogIndirect() function:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb760544.aspx

Assign a non-empty string to its VerificationText property to create the checkbox. If the tfVerificationFlagChecked flag is enabled in its Flags property when the dialog is shown, the checkbox will be checked by default. When the dialog is closed, the tfVerificationFlagChecked flag will be enabled or disabled based on the checkbox's state.

On earlier OS versions where TTaskDialog/TaskDialogIndirect() cannot be used, you can use SHMessageBoxCheck() instead:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb773836.aspx

(pay extra attention to the Remarks in that documentation!)

Otherwise, you should just create your own custom VCL window that looks like a MessageBox window.

If you really want to use the standard MessageBox(), you would have to hook and manipulate its dialog window directly. Before calling MessageBox(), you can use SetWindowsHookEx() to install a thread-specific CBT hook for the calling thread, or use SetWinEventHook() to install an event hook for the calling thread. Either approach will allow you to gain access to the dialog's HWND. You can then manipulate that HWND however you want, such as by extending its height and then adding a child checkbox in the new space. When the dialog is being closed, you can retrieve the state of that checkbox.

--
Remy Lebeau (TeamB)
Goran Ekstrom

Posts: 149
Registered: 1/10/04
Re: MessageBox with "Don't show this again"  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 12:16 AM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Thanks for the info, John and Remy.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02