Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Bug in CExtMsgBox checkboxes Collapse All
Subject Author Date
Ashley Gullen Jan 10, 2009 - 4:18 AM

Hi,


We are looking to use the new 2.84 CExtMsgBox class to replace our old messagebox class (which also had ’do not display/ask again’ support).  However, if __EXT_MB_DO_NOT_DISPLAY_AGAIN or __EXT_MB_DO_NOT_ASK_AGAIN is specified, the checkbox is always checked by default, regardless of the __EXT_MB_DEFAULT_CHECKED setting.  Can this be fixed?


Additionally, we need support for manual checking/unchecking of the checkbox which does not seem to be available.  Considering we call the same messagebox from several places in the code, unticking the checkbox should affect several messagebox prompts.  Is there a way to do this or a way for us to specify whether the checkbox is already checked before calling a messagebox?


 

Technical Support Mar 10, 2009 - 1:17 PM

The CExtMsgBox::ResetMsgBox() needs to know the unique name of the message box which is specified in the strUniqueID parameter of the CExtMsgBox class constructor. The ProfUISMsgBox() function and the CExtMsgBox::DoMsgBox() static method also have the same strUniqueID parameter. The unique message box name is the internally used text string which is never displayed on the screen. You need to provide all your message boxes with check box options with the unique names if you want to be able to reset their checked states. If you need to check whether the particular message box has the checked state, then you should invoke the following code:

HWND hWndParent = NULL; // not used in this task
LPCTSTR strUniqueID = . . .
CExtMsgBox _MB( hWndParent, strUniqueID );
CExtSafeString strRegVarName = MB.OnMsgBoxGetRegVarName();
int nResult = ::AfxGetApp()->GetProfileInt( CExtMsgBox::g_strRegSectionName, LPCTSTR(strRegVarName), (-1) );

If the nResult variable is -1, then the message box is not checked and it will be displayed at least once again or until user will set on check box inside it. In other cases, the nResult variable is equal to identifier of some button in the message box. This button was pressed by user after it has set on the check box inside the message box. The common button identifiers are IDOK, IDCANCEL, IDYES and IDNO. Here is the complete list of button identifiers:
// first group of message box button identifiers uses same values as in Win32
#define ID_EXT_MBB_OK                                                                                                                     1
#define ID_EXT_MBB_CANCEL                                                                                                 2
#define ID_EXT_MBB_ABORT                                                                                                   3
#define ID_EXT_MBB_RETRY                                                                                                   4
#define ID_EXT_MBB_IGNORE                                                                                                  5
#define ID_EXT_MBB_YES                                                                                                                   6
#define ID_EXT_MBB_NO                                                                                                                     7
#define ID_EXT_MBB_CLOSE                                                                                                   8
#define ID_EXT_MBB_HELP                                                                                                                  9
#define ID_EXT_MBB_TRY_AGAIN                                                                                            10
#define ID_EXT_MBB_CONTINUE                                                                                                          11

// second group of message box button identifiers defines extended features
#define ID_EXT_MBB_YES_TO_ALL                                                                                          14
#define ID_EXT_MBB_NO_TO_ALL                                                                                            15
#define ID_EXT_MBB_SKIP                                                                                                                   16
#define ID_EXT_MBB_SKIP_ALL                                                                                                           17
#define ID_EXT_MBB_IGNORE_ALL                                                                                          18
#define ID_EXT_MBB_CHECK_BOX                                                                                          19
#define ID_EXT_MBB_EX_COPY_BUTTON                                                                                20


Technical Support Jan 12, 2009 - 12:23 PM

Thank you for reporting this issue. The __EXT_MB_DEFAULT_CHECKED constant has incorrect name. It’s simply combination of the <code__EXT_MB_DO_NOT_DISPLAY_AGAIN</code> and <code__EXT_MB_DO_NOT_ASK_AGAIN</code> constants. The __EXT_MB_DEFAULT_CHECKED constant is used by message box internally and allows to detect whether the check box present. We have removed this constant. By default, the check box inside the message box in Prof-UIS 2.84 is always checked initially and there is no style for making it initially unchecked. We have added the new __EXT_MB_EX_CHECK_BOX_IS_NOT_CHECKED_INTIALLY extended message box style for fixing this issue:

   ::ProfUISMsgBox(
                        NULL,
                        _T("Some question as strMessageText parameter?"),
                        _T("Some caption..."),
                        __EXT_MB_DO_NOT_ASK_AGAIN,
                        0,
                        _T("UniqueIdOfThisMessageBox"),
                        __EXT_MB_EX_CHECK_BOX_IS_NOT_CHECKED_INTIALLY
                        );

We cannot add this style into basic set of style styles because all the 32 bits of basic styles are already occupied. Here is the source code update:

http://www.prof-uis.com/download/forums/tmp/MsgBoxUpdate285.zip

Technical Support Mar 10, 2009 - 8:13 AM

This is not a problem of Prof-UIS message box. This is incorrect usage of it in your application. You displayed the "Do you want to close this application?" message box with OK/Cancel buttons and "Do not ask again" check box. You checked the "Do not ask again" check box and pressed the Cancel button. This means you designed this message box for providing your users with ability to disable closing your application forever. This is simply incorrect UI design. You should not use the "Do not ask again" check box in such message boxes. You should implement some settings dialog in your application and implement some group of options in it called Confirmations. These group of options contains set of check boxes. One of them should be called "Confirm exit". If the "Confirm exit" option is checked, then you should display the "Do you want to close this application?" message box with OK/Cancel buttons and without check box. If the "Confirm exit" option is not checked, then you should simply shutdown your application without displaying any message boxes.

Emmanuel V. Mar 10, 2009 - 5:18 AM

Hi,


there is another bug/problem (in the MsgBoxUpdate285.zip). This dialog is displayed when leaving my application, and a confirmation is requested:


dlgConfirmClose.DoMsgBox(m_hWnd, IDS_SURETOQUIT, 0, __EXT_MB_OKCANCEL | __EXT_MB_DO_NOT_ASK_AGAIN, 0, 0, __EXT_MB_EX_CHECK_BOX_IS_NOT_CHECKED_INTIALLY)

If I check "Don’t ask this question again", then clicking <Cancel>, I will not be able to close the application anymore. The <Cancel> button is now automatically pressed when my dialog is displayed.


So is it a bug, or do I need to call ResetMsgBox() in this special case?


Thanks.

Emmanuel V. Mar 10, 2009 - 7:22 AM

Some news: ResetMsgBox() does not reset the "Don’t ask this question again" flag. I’m calling this method if user press <Cancel>, but I can see in registry that a key "msgbox-not-unique-helpid-0-chksum-86226" is not reset.

Ashley Gullen Jan 10, 2009 - 4:19 AM

Sorry, to clarify, I was also asking if there’s a way to test if some messagebox has already been disabled by ticking its checkbox.