Check this checkbox if you don't want to see this again

This is a discussion on Check this checkbox if you don't want to see this again within the C++ Programming forums, part of the General Programming Boards category; How do you make a MessageBox that looks like the one in the Attachment below? I am aware that you ...

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Exclamation Check this checkbox if you don't want to see this again

    How do you make a MessageBox that looks like the
    one in the Attachment below?
    I am aware that you have to save to a file or delete from a file.
    Thanks in advance, August.
    Attached Images Attached Images  

  2. #2
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    Assuming you mean with windows, you can save a boolean value in the registry that indicates that the pop-up should not be shown on subsequent application runs. This is probably how it is done in most cases.
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  3. #3
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    You could also have a .ini file (a file you use to store settings) if you don't feel like messing with the registry at this point.

  4. #4
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    But I don't know how to make a check box in a message box or how to make it sense that the check box has been checked. Any help there?
    Thanks - August

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Traditionally, you would have to do this with a custom dialog and store the view setting in the registry or a file. However, last year Microsoft documented a function that does exactly what you want without the mucking around. Below is a wrapper and sample code for SHMessageBoxCheck. This page says SHMessageBoxCheck is available in shlwapi.dll version 5 and above. This means it should be available on Windows 2000/XP/ME/2003 and above and earlier platforms with IE5 or greater installed.
    Code:
    #include <windows.h>
    
    /*
     * This function is a wrapper for the shell function SHMessageBoxCheck.
     *
     * See the documentation for SHMessageBoxCheck at:
     * http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/shlwapi/others/shmessageboxcheck.asp
     *
     * The ordinals were provided by a usenet post:
     * http://groups-beta.google.com/group/microsoft.public.platformsdk.shell/msg/d638e49f001752b4
     */
    int MessageBoxCheck(HWND hwnd, LPCTSTR pszText, LPCTSTR pszTitle, UINT uType, int iDefault, LPCTSTR pszRegVal)
    {
    	typedef (WINAPI * PSHMBC) (HWND, LPCTSTR, LPCTSTR, UINT, int, LPCTSTR);
    
    	HMODULE hShlwapi          = NULL; 
    	PSHMBC  shMessageBoxCheck = NULL;
    	int     retValue          = -1;
    	WORD    ordinalSHMBC      = (sizeof(TCHAR) == sizeof(WCHAR) ? 191 : 185);
    
    	hShlwapi = LoadLibrary(TEXT("shlwapi.dll"));
    
    	if (hShlwapi)
    	{
    		shMessageBoxCheck = (PSHMBC) GetProcAddress(hShlwapi, (LPCSTR) ordinalSHMBC);
    
    		if (shMessageBoxCheck)
    		{
    			/* For some reason SHMessageBoxCheck seems to require that the thread has a
    			 * message queue to work correctly. So we call PeekMessage to force the
    			 * creation of a message queue. */
    			MSG msg; PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
    
    			retValue = shMessageBoxCheck(hwnd, pszText, pszTitle, uType, iDefault, pszRegVal);
    		}
    
    		FreeLibrary(hShlwapi);
    	}
    
    	return retValue;
    }
    
    /*
     * Sample showing how to use MessageBoxCheck.
     * Note: You must provide a new guid before using this code in a distributed program.
     */
    int main(void)
    {
    	if (-1 == MessageBoxCheck( NULL, TEXT("Your computer is broken."), TEXT("Warning"),
    	                           MB_OK | MB_ICONEXCLAMATION, IDOK,
    	                           TEXT("{D85055F7-4AD0-49d9-9686-35F5A53B2233}") ))
    	{
    		/* If our checked box message box failed, show an ordinary message box. */
    		MessageBox(NULL, TEXT("Your computer is broken."), TEXT("Warning"),
    		           MB_OK | MB_ICONEXCLAMATION);
    	}
    }
    Attached Images Attached Images  
    Last edited by anonytmouse; 04-15-2005 at 06:53 PM.

  6. #6
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    I think i could write this code.. but I am still in the middle of petzold's 1,400 page book.. I think I would just create a dialogue box with pushbutton and checkbox child window controls.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  7. #7
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Okay, let ask a different question that would fare just as well if it was anwered.
    Can you make a dialog with OK and CANCLE buttons, and a checkbox in it. And if the checkbox is checked and OK is pressed, it executes a specific section of code?
    I am a newbie. So I need example code.

    Any help would be most appreciated, August

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. how to check input is decimal or not?
    By kalamram in forum C Programming
    Replies: 3
    Last Post: 08-31-2007, 07:07 PM
  3. setting checks on checkbox , setcheck not working
    By hanhao in forum Windows Programming
    Replies: 2
    Last Post: 06-30-2007, 09:38 PM
  4. Please check this loop
    By Daesom in forum C++ Programming
    Replies: 13
    Last Post: 11-02-2006, 12:52 AM
  5. how to check for end of line in a text file
    By anooj123 in forum C++ Programming
    Replies: 6
    Last Post: 10-24-2002, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21