15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CancelToClose

mlw -- mlw@i2.co.uk
Monday, July 22, 1996

Environment: VC++ 4.1 / Win95

I have a problem with my derived Property Sheet and Pages classes: =
CancelToClose () has no effect. I am not using a modeless property =
sheet. Nothing seems to happen to either the Cancel or OK buttons when I =
press the Apply button. I have occasionally seen (very fleetingly) the =
OK button change to Close when I hit the OK button to close the Property =
Sheet

Any help with this problem would be much appreciated.

Mark Williams=20
mlw@i2.co.uk






Brian_Dormer@ftdetrck-ccmail.army.mil
Thursday, July 25, 1996

     Post your source - it's probably that you are calling CancelToClose() 
     at the wrong time.
     
     bd


______________________________ Reply Separator _________________________________
Subject: CancelToClose
Author:  mfc-l@netcom.com at Internet-Mail
Date:    7/25/96 3:24 AM


Environment: VC++ 4.1 / Win95
     
I have a problem with my derived Property Sheet and Pages classes: = 
CancelToClose () has no effect. I am not using a modeless property = 
sheet. Nothing seems to happen to either the Cancel or OK buttons when I = 
press the Apply button. I have occasionally seen (very fleetingly) the = 
OK button change to Close when I hit the OK button to close the Property = 
Sheet
     
Any help with this problem would be much appreciated.
     
Mark Williams=20
mlw@i2.co.uk
     
     
     




bop@gandalf.se
Monday, July 29, 1996

Environment: VC++ 4.1 / Win95
     
> I have a problem with my derived Property Sheet and Pages classes: = 
> CancelToClose () has no effect. I am not using a modeless property = 
> sheet. Nothing seems to happen to either the Cancel or OK buttons when I = 
> press the Apply button. I have occasionally seen (very fleetingly) the = 
> OK button change to Close when I hit the OK button to close the Property = 
> Sheet
>  
> Any help with this problem would be much appreciated.
>      
> Mark Williams
> mlw@i2.co.uk
     
     
I have been struggling with this myself for the last couple of days.

More interesting, I had one property sheet where it worked and one
where it did not!  Eventually I realized that the working version called
CancelToClose() from a handler of a "Save" button on the property
PAGE, while calling CancelToClose from OnApply does not work.

Looking into the MFC source, you can see that the CancelToClose
essentially just does a:

GetParent()->SendMessage(PSM_CANCELTOCLOSE);

Which means: Tell the property sheet (the parent of the page) to
change its state. 

A problem here is that the property sheet is probably already 
handling a PSM_APPLY message (that's why it is calling OnApply!)
and cannot handle another message just then! So I changed 
SendMessage into PostMessage, or rather replaced

CancelToClose();

with

GetParent()->PostMessage(PSM_CANCELTOCLOSE);

And it worked! :-))


Bo Persson
bop@gandalf.se


P.S.
Does anyone know why it's called CancelToClose() when
it actually changes the OK button to Close??   :-)





| Вернуться в корень Архива |