Results 1 to 4 of 4

Thread: MDI Form (Page Up/Page Down) Help Needed

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    2

    Question 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.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: MDI Form (Page Up/Page Down) Help Needed

    Welcome to Forums, Dave!

    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:
    1. Option Explicit
    2.  
    3. Private Const VK_DOWN = &H28
    4. Private Const VK_UP = &H26
    5.  
    6. Private Const WM_KEYDOWN = &H100
    7. Private Const WM_KEYUP = &H101
    8.  
    9. Private Declare Function GetAsyncKeyState Lib "user32" _
    10.     (ByVal vKey As Long) As Integer

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    2

    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.

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width