Property Page + Back & Next button Focus 
Author Message
 Property Page + Back & Next button Focus

Hello Group..

        I am facing with a focus problem in my Property Page application (
Wizard mode ). Here is the scenario.

    I have a bunch of radio buttons on a page and when I click next using
the keyboard shortcut ( Alt+N ) it moves to the next page.     Now when I
press Back using Alt+B it comes back to my page with Back button having the
focus. Now I can use the arrow keys to do a selection on the radio buttons
and press Enter. Note since the focus is still on the Back button it goes
back to a previous page instead of the Next page as normally after a
selection a user would expect to go to the next page by pressing enter.

    I tried a SetDefID(ID_WIZNEXT) during OnSetActive(..), but it does not
seems to work.

    How do I set the Next button as the default button always ?

    Thanks for any help.

Cheers
Check Abdoul
------------------



Wed, 13 Oct 2004 04:44:38 GMT  
 Property Page + Back & Next button Focus

Quote:
>    I tried a SetDefID(ID_WIZNEXT) during OnSetActive(..), but it does not
>seems to work.

Have you called SetDefID for the property sheet rather than the page?

I've not looked at the MFC implementation of SetDefID, but does it do
all that's necessary as detailed in Knowledge Base article Q67655
"Changing/Setting the Default Push Button in a Dialog Box"?

Here's the crux of the technique:

1. Send the BM_SETSTYLE message to the current default push button to
   change its border to that of a regular push button.

2. Send a DM_SETDEFID message to the dialog box to change the ID of
   the default push button.

3. Send the BM_SETSTYLE message to the new default push button to
   change its border to that of a default push button.

It's possible that it's not working due to any default processing that
happens after the OnSetActive event, so you may need to delay calling
SetDefID.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Wed, 13 Oct 2004 07:20:37 GMT  
 Property Page + Back & Next button Focus
Hi, Check!

If you're still looking for suggestions then mine would be to add a handler for the DM_SETDEFID
message to your CPropertySheet derived class and implement it something like...

    LRESULT CMySheet::OnSetDefId(WPARAM wParam, LPARAM lParam)
    {
        return ((wParam == ID_WIZBACK) && !IsChildButtonFocused(m_hWnd, wParam))
            ? SendMessage(DM_SETDEFID, ID_WIZNEXT) : Default();
    }

...where 'IsChildButtonFocused' is a function the looks something like this...

    static
    __inline
    BOOL
    IsChildButtonFocused(
        IN CONST HWND hWnd,
        IN CONST UINT uChildButtonId
      )
    {
        HWND hWndFocus  = GetFocus();
        return (hWndFocus && IsChildButton(hWnd, hWndFocus) &&
            (uChildButtonId == (UINT)GetDlgCtrlID(hWndFocus)));
    }

...and where 'IsChildButton' is a function that looks something like this...

    static
    __inline
    BOOL
    IsChildButton(
        IN CONST HWND hWnd,
        IN CONST HWND hWndChild
      )
    {
        return ((hWndChild && IsWindow(hWndChild) &&
            IsChild(hWnd, hWndChild) && IsPushButton(hWndChild)));
    }

...and where 'IsPushButton' is a function that looks something like this...

    static
    __inline
    BOOL
    IsPushButton(
        IN CONST HWND hWndButton
      )
    {
        return (BS_PUSHBUTTON == (SendMessage(
            hWndButton, WM_GETDLGCODE, 0, 0) & BS_PUSHBUTTON));
    }

HTH,

--
Jeff Partch

Quote:

> Hello Group..

>         I am facing with a focus problem in my Property Page application (
> Wizard mode ). Here is the scenario.

>     I have a bunch of radio buttons on a page and when I click next using
> the keyboard shortcut ( Alt+N ) it moves to the next page.     Now when I
> press Back using Alt+B it comes back to my page with Back button having the
> focus. Now I can use the arrow keys to do a selection on the radio buttons
> and press Enter. Note since the focus is still on the Back button it goes
> back to a previous page instead of the Next page as normally after a
> selection a user would expect to go to the next page by pressing enter.

>     I tried a SetDefID(ID_WIZNEXT) during OnSetActive(..), but it does not
> seems to work.

>     How do I set the Next button as the default button always ?

>     Thanks for any help.

> Cheers
> Check Abdoul
> ------------------



Wed, 13 Oct 2004 12:22:47 GMT  
 Property Page + Back & Next button Focus
Hi Jeff & David,

        Thanks for your valuable suggestions. I will try them and let you
        know the result.

--
Cheers
Check Abdoul
----------------
[P.S:-    To tell you the truth, I was 100% expecting an answer from Jeff
Partch, the PropertySheet/Page master. Thanks Jeff. ]


Quote:
> Hi, Check!

> If you're still looking for suggestions then mine would be to add a

handler for the DM_SETDEFID
Quote:
> message to your CPropertySheet derived class and implement it something
like...

>     LRESULT CMySheet::OnSetDefId(WPARAM wParam, LPARAM lParam)
>     {
>         return ((wParam == ID_WIZBACK) && !IsChildButtonFocused(m_hWnd,
wParam))
>             ? SendMessage(DM_SETDEFID, ID_WIZNEXT) : Default();
>     }

> ...where 'IsChildButtonFocused' is a function the looks something like
this...

>     static
>     __inline
>     BOOL
>     IsChildButtonFocused(
>         IN CONST HWND hWnd,
>         IN CONST UINT uChildButtonId
>       )
>     {
>         HWND hWndFocus  = GetFocus();
>         return (hWndFocus && IsChildButton(hWnd, hWndFocus) &&
>             (uChildButtonId == (UINT)GetDlgCtrlID(hWndFocus)));
>     }

> ...and where 'IsChildButton' is a function that looks something like
this...

>     static
>     __inline
>     BOOL
>     IsChildButton(
>         IN CONST HWND hWnd,
>         IN CONST HWND hWndChild
>       )
>     {
>         return ((hWndChild && IsWindow(hWndChild) &&
>             IsChild(hWnd, hWndChild) && IsPushButton(hWndChild)));
>     }

> ...and where 'IsPushButton' is a function that looks something like
this...

>     static
>     __inline
>     BOOL
>     IsPushButton(
>         IN CONST HWND hWndButton
>       )
>     {
>         return (BS_PUSHBUTTON == (SendMessage(
>             hWndButton, WM_GETDLGCODE, 0, 0) & BS_PUSHBUTTON));
>     }

> HTH,

> --
> Jeff Partch




- Show quoted text -

Quote:
> > Hello Group..

> >         I am facing with a focus problem in my Property Page application
(
> > Wizard mode ). Here is the scenario.

> >     I have a bunch of radio buttons on a page and when I click next
using
> > the keyboard shortcut ( Alt+N ) it moves to the next page.     Now when
I
> > press Back using Alt+B it comes back to my page with Back button having
the
> > focus. Now I can use the arrow keys to do a selection on the radio
buttons
> > and press Enter. Note since the focus is still on the Back button it
goes
> > back to a previous page instead of the Next page as normally after a
> > selection a user would expect to go to the next page by pressing enter.

> >     I tried a SetDefID(ID_WIZNEXT) during OnSetActive(..), but it does
not
> > seems to work.

> >     How do I set the Next button as the default button always ?

> >     Thanks for any help.

> > Cheers
> > Check Abdoul
> > ------------------



Fri, 15 Oct 2004 22:12:55 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Need Help with Property page next button

2. Owner draw button in replacement of the next/back button in a CPropertySheet in Wizard mode

3. Previous Page and Next Page buttons

4. Multiple Level Dialog with Back, Next buttons

5. Wizard BACK, NEXT buttons

6. Relabeling the Final/Next/Back buttons in Wizard mode on CPropertySheet

7. Wizard Buttons: Back AND Next AND Finish

8. Multiple Level Dialog with Back, Next buttons

9. Wizard BACK, NEXT buttons

10. Multiple Level Dialog with Back, Next buttons

11. CPropertySheet - focus of the Back button

12. Property Sheet (wizard)- Next goes to previous page

 

 
Powered by phpBB® Forum Software