使用PageUp/PageDown 改变活动选项卡






2.44/5 (6投票s)
1999年11月20日

128194
我开发了一个自定义数据库应用程序,其中包含一些带有大量选项卡/CPropertyPages 的窗口。我的客户希望有一种快速简便的方法来改变选定的选项卡,无需使用鼠标。他说:“在旧的DOS版本中,我们使用Page-Up 和 Page-Down 改变当前窗口....”。啊,那些日子真好!所以客户想要什么,客户就得到什么,这就是结果:Page-Up / Page-Down 将选择下一个 / 上一个选项卡。这很简单,很简单...
基本上,你需要对 CPropertySheet 进行子类化。然后使用类向导,创建 PreTranslateMessage() 函数,并插入以下代码...
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 } }