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.
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 ...
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.
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.
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.
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
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); } }
Last edited by anonytmouse; 04-15-2005 at 06:53 PM.
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
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