Click here to Skip to main content
Licence 
First Posted 19 Nov 1999
Views 112,670
Bookmarked 55 times

Changing The Active Tab using PageUp/PageDown

By | 19 Nov 1999 | Article

I produce a custom database application, that has some windows with lots of tabs / CPropertyPages within them. My customer wanted a way to quickly and easily change the selected tab, without using the mouse. He said "In the old DOS version we changed the current window using Page-Up and Page-Down....". Ahh those were the days! So what the customer wants, the customer gets, and here is the result : Page-Up / Page-Down will select the next / previous tab. It's so easy, it's simple...

Basically sub-class your CPropertySheet. Then using the class wizard, create the PreTranslateMessage() function, and insert the text below...

if (pMsg->message == WM_KEYUP && pMsg->wParam == VK_NEXT)
{
    if(GetPageCount() > 1)  // Ignore if only one CPropertyPage
    {
       if(GetActiveIndex() == 0)  //If first page active, select last page
          SetActivePage(GetPageCount() - 1);
       else
          SetActivePage(GetActiveIndex() - 1);  //else select the previous page
    }
}

if (pMsg->message == WM_KEYUP && pMsg->wParam == VK_PRIOR)
{
    if(GetPageCount() > 1)  // Ignore if only one CPropertyPage
    {
       if(GetActiveIndex() == (GetPageCount() - 1))  //If last page active, select the first page
          SetActivePage(0);
       else
          SetActivePage(GetActiveIndex() + 1);  //else select the next page
    }
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Jeremy Davis

Web Developer

United Kingdom United Kingdom

Member

Is was a hardware engineer, that wrote the odd bit of MFC software. I am now training to become a technology teacher for 11 - 19 year olds.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralTab Control PinmemberVijay_Mak0:23 7 Jan '04  
GeneralRe: Tab Control PinmemberJeremy Davis0:30 7 Jan '04  
GeneralModify Text on Tab Pinsussmistroseth2:10 26 Mar '03  
GeneralCTRL+TAB PinsussJeremy Davis4:58 12 Jan '00  
GeneralRe: CTRL+TAB PinmemberJCrane29:37 4 Mar '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 20 Nov 1999
Article Copyright 1999 by Jeremy Davis
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid