Modal Dialog OnCancel removes SC_CLOSE

Hello,

I have an app with an modal dialog in which I have removed the default
cancel behaviour by creating an empty OnCancel().

Now I can't close the dialog using the SC_CLOSE (Red-X in upper right
corner)

Why and how can I remove ending the dialoq by pressing Esc but still be
able to close the dialog by clicking on the Red-X[1]



// Anders
-- 
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!

[1] if someone has a official name for this button I would be grateful!
0
andis59 (75)
9/12/2007 1:25:55 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
662 Views

Similar Articles

[PageSpeed] 24

Anders Eriksson schrieb:

> I have an app with an modal dialog in which I have removed the default
> cancel behaviour by creating an empty OnCancel().
> 
> Now I can't close the dialog using the SC_CLOSE (Red-X in upper right
> corner)

See: http://www.flounder.com/dialogapp.htm

The solution is to add an OnClose handler for WM_CLOSE and call 
CDialog::OnOk there:

void CDialogappDlg::OnClose()
{
	CDialog::OnOK();
}

BTW, you should override OnOk as well with an empty function, otherwise 
the dialog might close when pressing the enter key.

Norbert
0
nunterberg (207)
9/12/2007 2:01:29 PM
On Wed, 12 Sep 2007 16:01:29 +0200, Norbert Unterberg wrote:

> Anders Eriksson schrieb:
> 
>> I have an app with an modal dialog in which I have removed the default
>> cancel behaviour by creating an empty OnCancel().
>> 
>> Now I can't close the dialog using the SC_CLOSE (Red-X in upper right
>> corner)
> 
> See: http://www.flounder.com/dialogapp.htm
> 
Due to a memory error I didn't lookup Mr. Newcomers exellent web site. I
usually do this before asking since he usually already have answered my
questions.

Thank you for reminding me!

> BTW, you should override OnOk as well with an empty function, otherwise 
> the dialog might close when pressing the enter key.

I have a OK button in the dialog with an OnOk() where I do stuff(tm)...

Thank you very much!

// Anders
-- 
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
0
andis59 (75)
9/13/2007 6:50:28 AM
Add the following handler:

void CMyDialog::OnClose()
   {
    CDialog::OnOK();
   }

see my essay on dialog-based apps on my MVP Tips site.
					joe

On Wed, 12 Sep 2007 15:25:55 +0200, Anders Eriksson <andis59@gmail.com> wrote:

>Hello,
>
>I have an app with an modal dialog in which I have removed the default
>cancel behaviour by creating an empty OnCancel().
>
>Now I can't close the dialog using the SC_CLOSE (Red-X in upper right
>corner)
>
>Why and how can I remove ending the dialoq by pressing Esc but still be
>able to close the dialog by clicking on the Red-X[1]
>
>
>
>// Anders
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
9/16/2007 3:29:17 AM
Reply:

Similar Artilces:

Changing or removing '($)' text which is appended to currency field labels.
Hi all Does anyone know of a way of achieving either of the following: 1. Change the ($) text which is automatically appended to currency field labels to ($000) ONLY for specific money fields (not all). I know the global setting can be changed under System Settings, but this is not appropriate. 2. Prevent the ($) text from being appended altogether to currency field labels. Unfortunately, setting the currency symbol to an empty string under System Settings still results in () being appended to the money field labels. Thanks Andrew ...

Errors after removing old Exchange server
After removing our old Exchange 2000 server we have issues with Outlook 2003 clients getting error "0x8004010f" when clicking the send receive button. After doing a bit of research I beleive that the old server still housed the following: OAB Version 2 Offline Address Book Schedule+ Free Busy Information I cannot bring the old server back to life now ! Is there a way to rehome these functions to the new Exchange 2003 server manually??? If we did not replicate the system folders off of the decommissioned server we will need to recreate them. You can use a utility that is avail...

unable to remove old 5.5 server...
....from System Manager. Just upgraded/moved yesterday from a 5.5 box to a new Exch 2003 box....following all steps in deployment tools wizard. Now I can't seem to get rid of the old server. It's still listed under the Administrative Groups. Right-clicking it does not give the option to remove it. However, right-clicking the new Exchange 2003 server itself (under 'All Tasks'), does give the option to remove (although I obviously don't want to do that). Any clues? - tex You should be able to remove it using the Exchange 5.5 Administrator. You connect to the E...

Completely Removing User Accounts
Using GP Dynamics 7 on SQL Server 2000. I am having trouble with adding a new user account when that user account used to exist previously, but was deleted from a previous installation. Originally, we had setup user accounts for our sales staff who connect via VPN to our network. We migrated our SQL server/Dynamics and moved it to a new server to accomodate the workload and I had migrated the user accounts using SQL scripting provided by GP Support. (I know this creates a temp table with these old accounts). Reconfiguring security, I deleted accounts and am trying to recreate the...

"Save As" dialog taking a long time to display
Most recently, in trying to save a Word document using the "Save as.." dialog, it took several minutes to display the dialog box. All the while, the SPOD was spinning away in Word. I could use other apps, even other Office apps (Entourage, Excel), but not Word. Is this a known problem (hopefully with a known solution)??? Mark Office 2004 11.2, OS X 10.4.3 P.S. I just noticed it's a problem with the "File, Open" dialog as well, in Word, Excel, and PowerPoint. But once I've used either one of the dialogs, there's no delay using either one of them afterwards du...

Remove Spacing In A Cell
I am trying to eliminate spacing for a upc in a cell. For a example: 0 11111 22222 3 011111222223 I have tried Clean, Trim, & Substitute. Anyone have any answers or Ideas? Thanks, Hi Span, See David McRitchie's TrimAll page at: http://www.mvps.org/dmcritchie/excel/join.htm#trimall --- Regards, Norman "Span" <Span@discussions.microsoft.com> wrote in message news:1343031C-1E8E-4CA8-8B51-B353B734BAE6@microsoft.com... >I am trying to eliminate spacing for a upc in a cell. For a example: > 0 11111 22222 3 > 011111222223 > > I have tried Cl...

removing exchange instances after failure
Hi, how does one go about removing all traces of Exchange 2k3 from the active directory if a failure occurs which prevents the correct removal of the server? Hi Martin, If you have attempted to use the remove form Org switch on the Exchange CD and it is still in AD you can use ADSIEdit to go into the AD and manually remove the Exchange Server attributes. 278918 XADM: How To Manually Remove a Single Exchange-based Server from Active http://support.microsoft.com/?id=278918 Hope this helps, -- Patrick Genova Pgenova@online.microsoft.com Please do not send mail directly to this alias. This...

Hide a modal dialog by a thread
Hi all I am writing an application, using a module. And that module show a modal dialog when i run my app. Now i want to create a thread in my app, that thread will check if that module display a modal dialog, then my thread will hide that dialog. Any way to do this? Pls let me know if you know. Thanks very much. "Duy Trinh" wrote: > Hi all > > I am writing an application, using a module. And that module show a modal > dialog when i run my app. Which module do you speak about? Module is a broad concept.. Perheps you mean a dll?? > Now i want to create a...

Remove unused members when creating 2005 local cubes
I need to create a windows application in which I can programmatically create local cubes from SQL Server 2005 databases using C#. I was able to do this in SQL Server 2000, but I cannot get the same results after upgrading to 2005 because the CREATE GLOBAL CUBE command does not slice the data as it did in 2000. In other words, I get all accounts that exists in the company as opposed to only accounts that belong to the user. This extra data kills browsing performance. Can this be done using XMLA or AMO? If so, any examples would be appreciated. -- DCount -- DCount ...

Disappearing dialogs related to button double clicks?
I've been troubleshooting an elusive bug and I think I've run out of ideas. I'm using MFC with my own subclassed dialogs and button controls. I have a app with many dialogs controlled by a process control layer. When a dialog is ready to disappear it calls the process layer with a "hide me" event. It can also call a second event, like "run the next job setup step," as it goes away. I don't use DoModal(), although I simulate it by disabling dialogs other than the current dialog. The process layer hides the dialog. It also shows dialogs and sends them th...

outlook express removing incoming files
Recently incoming messages have attached files removed with the message, 'OE removed access to the following unsafe files.' Any ideas how I can stop this. tools->options-security tab. This newsgroup is for support of Outlook 97-2003 from the Office family for Windows PCs. For Outlook Express (OE) support try posting in one of these newsgroups: microsoft.public.inetexplorer.ie4.outlookexpress for OE 4.x microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x http://support.microsoft.com/newsgroups/default.aspx?ICP=GSS3&NewsGroup=microsoft.public.windows.inetexpl...

remove my carriage returns
i have a xml w/four carriage returns and for some reason this is preventing me from executing my xpath queries. What is the best way to remove these? thanks mgonzales3 wrote: > i have a xml w/four carriage returns and for some reason this is preventing > me from executing my xpath queries. Why, what exactly are you trying, how exactly does the XML input look? -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ I changed the processor line from: <?xml version="1.0" encoding="UTF-16"?> to <?xml version="1.0" encoding="UTF...

add second dialog to project
I have single document project in MFC. There is main frame with manu in which I may select option 'start dialog window'. is it possible that in one application are two dialogs class ? I want to have two dialogs (modal windows) in my project. Now I have one dialog class and one modal window. How can I add second 'finished' window with dialog class which includes some functions related with this modal window. There are finished controls for this window. When application will starting I will select which dialog I will using. Please help me, how can I add second class with dialog (...

How can I remove time from event banners?
Installed Outlook on new laptop and transferred over info. The banners on my all day events now include a time of 12:00am. I have tried everything to get rid of the time. How can I get the times off the banners? How did you transfer the info over? Usually you need to open each one and fix the time but if you used import, open the pst directly in outlook instead and see if they are ok. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subs...

Removing the Disable/Enable Macros screen?
Is it possible to remove the Disable/Enable Macros screen when document loads ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com Alan, You can't disable the macro warning for a document. If you could, then any self-respecting virus would do exactly that. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Alan T" <Alan.T.x0eqn@excelforum-nospam.com> wrote in message news:Alan.T.x0eqn@excelforum-nospam....

outlook 2007 remove do-do list
Is there a way to remove the to-do list in tasks? everytime i open outlook i have to click on tasks to see my tasks, in 2003 outlook remembers my last selection but not in 2007 ...

Maximizing dialog box and Control list
Hi, I programming using VS 6.0, MFC SDI. I have a dialog box, wich contains a CListCtrl table. My problem is that, when the dialog box is maximized, the control lists and the ok, cancel, and other buttos stay the way their are. I mean, they don't change it size accordingly. How can I maximize or change the dialog box size and everything on it change accordingly? I hope I've made myself clear. Thanks in advance Hi, You should override OnSize method of your dialog box and use SetWindowPos for your child windows. f.e. void CMyDialog::OnSize(UINT nType, int cx, int cy) { CDialog::...

Removing names from Global Address list
we are running exchange 2000 and I need to remove some names from the global address list Thanks in advance for your help The GAL is just an LDAP filter which reflects objects with "email" addresses. In order to remove names from the GAL you need to remove the addresses or the associated AD objects. Nue "jv" <jv@discussions.microsoft.com> wrote in message news:090837CF-902A-444E-82EB-986D8E34D4E7@microsoft.com... > we are running exchange 2000 and I need to remove some names from the > global > address list > > Thanks > in advance for your h...

Remove existing property sets doesn't remove
I have created a new custom property sets in Visio 2003 Professional and it will not allow me the remove the existing property set and replace it with my new set. ...

Suppress UI of Dialog box.
i want to suppress the ui show after installing the cab in the PPC using SHELLEXECUTEINFO. i have tried sei.cbSize = sizeof(sei); sei.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS ; sei.hwnd = NULL; sei.lpVerb = _T("open"); sei.lpFile = tszCabPathName; sei.lpParameters = _T("safe /noui /nouninstall /delete 0"); sei.lpDirectory = _T(""); sei.nShow = SW_HIDE; still it shows successful installation of cab, and i want to avoid that dailog box. Can u please help me? Thanks, Bhavin "Bks" <bhavinshah.com@gmail.com> wrot...

Removing contact items
Hi I need to delete, via code, all contacts whose category field has a certain value (lets say 'xxx') in it. What is the code that I need to use for this? Thanks Regards Hi John, you can loop per For Each through the folders and check the Categories property with the Instr$ function. For better performance I�d do that via CDO instead of the OOM. -- Viele Gr��e Michael Bauer "John" <John@nospam.infovis.co.uk> wrote in message news:eSIsV9iJFHA.2980@TK2MSFTNGP10.phx.gbl... > Hi > > I need to delete, via code, all contacts whose category field has a cer...

Removing Office 2004 Test Drive
Hi, I have searched this group, and found advice to the effect that the Office 2004 for Mac Test Drive folder can be removed from HD/ Applications once the Remove Office utility has run and not found any Office products. Could someone please verify this for me, or tell me how I can get verification of it? I am brand new to Macs, and stupidly clicked on an Excel file I copied over from my old laptop onto my new Mac running Leopard. I was logged in under my regular account, as I've read that it's safer to use the machine as a regular user, rather than as an administrator. Evidently...

'Add/Remove Components' cannot be opened
Hello - Please help me............. when I try to open 'Add/Remove Components' I receive a message about the 'library for fax....' and 'cannot find 'comnt5.inf', what can I do to sort this problem out? I think I have seen this behaviour before a long time ago... What you or somebody else probably did was open some kind of component/extension which was related to control panel... with a certain program. The result is that the extension/file type is now associated with the wrong program. What might need to happen is restore the extension file type...

Remove PST files from Outlook 2003 or 2007 profile
Our Sys Admins are trying to come up with a way to remove a PST file from an Outlook profile. We have a way to batch a login script in Active Directory so that we can delete the PST file from the user's PC, but no way to stop the inevitable error message when Outlook can't find the file(s) at next start-up. Ideally, we would like to have a script or command that removes any PST from the Outlook profile that we could batch at login, followed by our PST delete script. Any way to do this? There was a blog from 2006 (http:// jeremiahcook.blogspot.com/2006/08/how-to-remove-psts-from- ou...

Resolving KDC error... which SPN do I remove???
Hi all. Using the LDAP tool I have found that my domain controller and my admin account have two matching Service Prinicipal Names. HOST/COMPUTER NAME Host/COMPUTER NAME.mydomain.com Everything that I have read tells me to delete the duplicate SPN. How do I know which item to remove the duplicate from? Do I remove it from the Domain Controller or the Admin account? Thanks for any help! Hank Hank, did you have any luck this, can you share how to resolve the KDC error? thanx, Joe "Hank" <anonymous@discussions.microsoft.com> wrote in message news:1f5ca01c457c1$50fe3c...