Click here to Skip to main content
12,955,170 members (57,834 online)
Click here to Skip to main content
Add your own
alternative version

Stats

120.6K views
55 bookmarked
Posted 19 Nov 1999

Changing The Active Tab using PageUp/PageDown

, 19 Nov 1999
Rate this:
Please Sign up or sign in to vote.
<!-- Article Starts -->

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

Share

About the Author

jerry0davis
Instructor / Trainer
United Kingdom United Kingdom
Is was a hardware engineer that wrote the odd bit of MFC software. A redundancy and career change later, I now teach 11-19 year olds Mechanical Engineering and Computer Science.
Group type: Organisation (No members)



You may also be interested in...

Pro

Comments and Discussions

 
GeneralTab Control Pin
Vijay_Mak7-Jan-04 0:23
memberVijay_Mak7-Jan-04 0:23 
GeneralRe: Tab Control Pin
Jeremy Davis7-Jan-04 0:30
memberJeremy Davis7-Jan-04 0:30 
GeneralModify Text on Tab Pin
mistroseth26-Mar-03 2:10
sussmistroseth26-Mar-03 2:10 
GeneralMessage Automatically Removed Pin
12-Jan-00 4:58
sussJeremy Davis12-Jan-00 4:58 
Message Automatically Removed
GeneralRe: CTRL+TAB Pin
JCrane24-Mar-04 9:37
memberJCrane24-Mar-04 9:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 20 Nov 1999
Article Copyright 1999 by jerry0davis
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid