Home > Archive > VC Language > November 2005 > Property sheet behaviour OnApply
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Property sheet behaviour OnApply
|
|
| David Webber 2005-11-23, 3:59 am |
| In a tabbed dialogue, I make changes on various PropertySheets and
press Apply.
The standard recommendation at this stage seems to be to send the
PropertySheet a PSM_CANCELTOCLOSE message, which (despite its name)
disables the cancel button and turns the OK button into Close.
This seems crazy. For if I now make any more changes in the
PropertySheets, there is no going back. The "Close" button
accepts them and the "Cancel" button is no longer available.
A far more sensible behaviour (which is sort of suggested by the
name of the message) would be to change the "Cancel" button into
"Close" and leave the "OK" alone.
Question: *is* this more sensible or am I missing something.
Of course I can implement this behaviour with SetWindowText() on the
Cancel button, but as there is no message to do it automatically, I
am in danger of getting the English text "Close" on the button no
matter what the language of the user. I can avoid this (I reckon)
by the slightly devious method in the PropertySheet:
CString sOk;
CString sClose;
CWnd *pWndOk = GetDlgItem( IDOK );
CWnd *pWndCancel = GetDlgItem( IDCANCEL );
if( pWndOk && pWndCancel )
{
pWndOk->GetWindowText( sOk ); // Get "OK" text
SendMessage(PSM_CANCELTOCLOSE); // "Ok" -> "Close"
pWndOk->GetWindowText( sClose ); // Get "Close" text.
pWndCancel->SetWindowText( sClose ); // "Cancel" -> "Close"
pWndOk->SetWindowText( sOk ); // Reset "Ok" -> "Ok"
pWndCancel->EnableWindow(TRUE); // Don't disable cancel.
}
but doing so makes me feel a little unclean, as I am sneakily
bypassing what Mr Gates tells me to do. Someone please tell me
it's ok!
Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
| |
| John Carson 2005-11-23, 7:59 am |
| "David Webber" <dave@musical.demon.co.uk> wrote in message
news:%23asdqqA8FHA.3592@TK2MSFTNGP12.phx.gbl
> In a tabbed dialogue, I make changes on various PropertySheets and
> press Apply.
>
> The standard recommendation at this stage seems to be to send the
> PropertySheet a PSM_CANCELTOCLOSE message, which (despite its name)
> disables the cancel button and turns the OK button into Close.
>
> This seems crazy. For if I now make any more changes in the
> PropertySheets, there is no going back. The "Close" button
> accepts them and the "Cancel" button is no longer available.
>
> A far more sensible behaviour (which is sort of suggested by the
> name of the message) would be to change the "Cancel" button into
> "Close" and leave the "OK" alone.
And what is the difference between OK and Close in this case? I guess none,
but Cancel is more accurately labelled.
> Question: *is* this more sensible or am I missing something.
Looking back over some old code that uses a property sheet, I note that the
PSM_CANCELTOCLOSE message is there but commented out, with a note that I
don't want that behaviour. In that code I just leave the Cancel and OK
buttons as they are. If you look at the Properties Dialog for a Visual
Studio 8 Project (which is not actually a property sheet, but the principle
is the same), then hitting Apply has no effect on OK or Cancel. Of course,
the effect of this is that, after Apply is clicked, OK and Cancel have the
same effect.
If I was to use the PSM_CANCELTOCLOSE message, then I think I would let it
have its current effect, but then as soon as the user made a change, I would
restore the OK and Cancel buttons to their original enabled state at the
same time as I enabled the Apply button.
--
John Carson
| |
| David Wilkinson 2005-11-23, 7:59 am |
| David Webber wrote:
> In a tabbed dialogue, I make changes on various PropertySheets and
> press Apply.
>
> The standard recommendation at this stage seems to be to send the
> PropertySheet a PSM_CANCELTOCLOSE message, which (despite its name)
> disables the cancel button and turns the OK button into Close.
>
> This seems crazy. For if I now make any more changes in the
> PropertySheets, there is no going back. The "Close" button
> accepts them and the "Cancel" button is no longer available.
>
> A far more sensible behaviour (which is sort of suggested by the
> name of the message) would be to change the "Cancel" button into
> "Close" and leave the "OK" alone.
>
> Question: *is* this more sensible or am I missing something.
>
> Of course I can implement this behaviour with SetWindowText() on the
> Cancel button, but as there is no message to do it automatically, I
> am in danger of getting the English text "Close" on the button no
> matter what the language of the user. I can avoid this (I reckon)
> by the slightly devious method in the PropertySheet:
>
> CString sOk;
> CString sClose;
>
> CWnd *pWndOk = GetDlgItem( IDOK );
> CWnd *pWndCancel = GetDlgItem( IDCANCEL );
>
> if( pWndOk && pWndCancel )
> {
> pWndOk->GetWindowText( sOk ); // Get "OK" text
> SendMessage(PSM_CANCELTOCLOSE); // "Ok" -> "Close"
> pWndOk->GetWindowText( sClose ); // Get "Close" text.
> pWndCancel->SetWindowText( sClose ); // "Cancel" -> "Close"
> pWndOk->SetWindowText( sOk ); // Reset "Ok" -> "Ok"
> pWndCancel->EnableWindow(TRUE); // Don't disable cancel.
> }
>
> but doing so makes me feel a little unclean, as I am sneakily
> bypassing what Mr Gates tells me to do. Someone please tell me
> it's ok!
>
> Dave
Dave:
Personally, the first thing I always do with a Property Sheet is remove
the Apply button. I always find its action confusing in other peoples'
applications, and I dont want my users to be in mine. If we
developers cannot agree how to code when the Apply button is pressed,
how is the user supposed to figure out how to use it?
David Wilkinson
| |
| David Webber 2005-11-23, 7:04 pm |
|
"John Carson" <jcarson_n_o_sp_am_@netspace.net.au> wrote in message
news:%23wmtUlB8FHA.1416@TK2MSFTNGP09.phx.gbl...
> If I was to use the PSM_CANCELTOCLOSE message, then I think I
> would let it have its current effect, but then as soon as the user
> made a change, I would restore the OK and Cancel buttons to their
> original enabled state at the same time as I enabled the Apply
> button.
That seems a reasonable behaviour - as long as "cancel" is
interpreted as cancel everything since the last "apply".
Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
| |
| David Webber 2005-11-23, 7:04 pm |
|
"David Wilkinson" <no-reply@effisols.com> wrote in message
news:e$Jb0zB8FHA.3224@TK2MSFTNGP09.phx.gbl...
> Personally, the first thing I always do with a Property Sheet is
> remove the Apply button. I always find its action confusing in
> other peoples' applications, and I dont want my users to be
> in mine. If we developers cannot agree how to code when
> the Apply button is pressed, how is the user supposed to figure
> out how to use it?
Donkey's years ago I read that the recommendation was not to remove
it but leave it greyed out if it was not in use. I wondered about
it, but have been doing that ever since. My current reflections are
because users have pestered me to enable the apply button for long
enough now that I am finally doing it - on one or two judiciously
chosen property sheets. :-)
Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
|
|
|
|
|