MDI Form (Page Up/Page Down) Help Needed
I am working on making a few enhancements to a legacy VB Application and I've run into something I thought was going to be simple but has proven quite the opposite.
The application has an MDI Form with MANY child forms, some of which contain user controls that are almost forms unto themselves. The problem is that the forms and controls are causing the MDI Form to display scroll bars. The client wants to be able to use the Page Up and Page Down to go to the top and bottom respectively.
As you may or may no know, there is no KeyDown on an MDI Form and I can't even find anything on how to programmatically go to the top and bottom of the MDI Form.
Any ideas or suggestions will help.
Thanks in advance.
Re: MDI Form (Page Up/Page Down) Help Needed
Welcome to Forums, Dave! :wave:
Don't have any samples handy so here is just a logic:
Since MDI forms don't respond to Key events (Down, Up, Press) you'll have to subclass either VK_DOWN/UP or WM_KEYDOWN/UP (whichever works better) messages utilizing GetAsyncKeyState() api function. I'm sure searching forum or googling will give you some samples.
Here are the declarations:
VB Code:
Option Explicit
Private Const VK_DOWN = &H28
Private Const VK_UP = &H26
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer
Re: MDI Form (Page Up/Page Down) Help Needed
Thanks for the reply and warm welcome.
I understand the GetAsyncKeyState function but I'm wondering how to trap for the KeyPress event in the MDI Form.
Sorry if this is a newbie question, but I don't deal with VBA much.
Re: MDI Form (Page Up/Page Down) Help Needed
Quote:
Originally Posted by CodeMonkeyDave
... but I'm wondering how to trap for the KeyPress event in the MDI Form. ...
That's what subclassing would do for you - your program will intersept windows messages and if it is one of those that I've posted it would "know" what to do - perhaps resetting each child form's Top property (say Top = Top +15 if it's a PageUp or -15 for PageDown).