|
If you are using MFC then add handlers for the OK and/or Cancel buttons (OnOK, OnCancel) and use AfxMessageBox to query the user, if the user wishes to close the dialog, call the super method, if not, then don't.
E.g:
void CMyDialog::OnCancel()
{
if (AfxMessageBox(_T("Are you completely and absolutely super-sure you wish to close this great dialog?", MB_YESNO | MB_ICONQUESTION) == IDYES) __super::OnCancel();
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Code-o-mat wrote: void CMyDialog::OnCancel()
{
if (AfxMessageBox(_T("Are you completely and absolutely super-sure you wish to close this great dialog?", MB_YESNO | MB_ICONQUESTION) == IDYES) __super::OnCancel();
}
This works well. But my Project Name is coming on the caption of the Message Box. How to customize this caption?
|
|
|
|
|
Use MessageBox[^] instead of AfxMessageBox:
void CMyDialog::OnCancel()
{
if (MessageBox(m_hWnd, _T("Are you completely and absolutely super-sure you wish to close this great dialog?"), _T("The Question"), MB_YESNO | MB_ICONQUESTION) == IDYES) __super::OnCancel();
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
pix_programmer wrote: How to customize this caption?
Try reading the MSDN documentation.
The best things in life are not things.
|
|
|
|
|
Hello
in WM_CLOSE (win32) / OnCancel() (MFC) add your message box. and according to the result returned, you can add your code.
Regards,
A. Gopinath.
|
|
|
|
|
Hmm, am I the only one who considers it weird if an attempt to close a dialog results in opening a dialog?
Sorry, just had to add this
|
|
|
|
|
Hehe, no, but I just saw the irony of it
|
|
|
|
|
i am writing small utility that will save webpage in local disk to view offline.. pls help me
|
|
|
|
|
Internet Explorer and other browsers do provide this facility.
Can you show us what have you done so far and did you have a look at the web browser control?
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
yes web browser having that interface to store in local drive. But how can i achieve same using vc++?...i can save html document of the link but some photos and style sheet all won't come ...
|
|
|
|
|
If you are working under windows, check out WinINet[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Hi!
I want to add the Icon through code in MFC. Is it possible? I've to read the Icon file name from an XML file,and add the file as an Icon from VC++ code. I don't want to go and right click the "Ico" folder and add the file. How to add an Icon from code?
|
|
|
|
|
Use the LoadImage API to load the icon from the file and then use CWnd::SetIcon to the loaded icon for the window.
|
|
|
|
|
Add it to what?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
A rather relevant question I might add.
|
|
|
|
|
Thanks.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
Hi,
how to get System CPU_TYPE through C++ code? any method is available?
Please share ur idea and url.
Regards,
M.Mathivanan
|
|
|
|
|
Just grab it from the registry. Also, you could be more fortunate with the results of your searching. This information has been posted many, many, many times before.
HKEY_LOCAL_MACHINE->HARDWARE->DESCRIPTION->System->CentralProcessor
|
|
|
|
|
|
Hardware information can only be retrieved through system libraries, not a standard C++ function. For that reason you should mention the OS you're working on. The answer given above works for Windows systems, but not for e. g. Linux or any Mac OS.
Generally speaking, the answer you seek should be in the documentation for your system libraries, which should be available at the website of the manufacturer of the OS (for Linux you might want to check out the site of the distributor). So if you're seeking an URL, that's where you should go.
|
|
|
|
|
Hi,
I build a SDI project with VS2008. Now I want to change the color of the status bar. I inserted
m_wndStatusBar.GetStatusBarCtrl().SetBkColor(RGB(255, 0, 0));
into function
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
but the color didn't change. Can anybody tell me why?
|
|
|
|
|
Do you have themes enabled?
|
|
|
|
|
No, I just used MFC standard SDI project style.
|
|
|
|
|
OK, if you used Visual Studio (post VS6) to create your project, then inside stdafx.h (at the bottom) you will find manifest directives.
If you find these manifest directives, it means your app is themed. If it is themed, then CStatusBarCtrl::SetBkColor() won't work. You'll have to use a CStatusBar control that draws itself - there are several here on CodeProject: http://www.codeproject.com/KB/statusbar/[^]
|
|
|
|
|
Thank you for answer. I've created a new class CMyStatusBar derived from CStatusBar and then made status bar red.
|
|
|
|