Results 1 to 8 of 8

Thread: [RESOLVED] Wheelmouse scroll MDI application child forms

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Resolved [RESOLVED] Wheelmouse scroll MDI application child forms

    Bushmobile or anyone who can help?

    Bushmobile posted code in the codebank for setting up the wheelmouse to scroll withn an applcation.

    Attached is a shell of an MDI application.

    The wheelmouse scrolls beautifully in the first opened child form but then the application terminates itself and shuts down vb as soon as a new child form is opened which is preventing me from using it.

    Can anyone give me a suggestion or a fix?
    Attached Files Attached Files
    Last edited by sgrya1; Dec 29th, 2006 at 05:02 PM.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Wheelmouse scroll MDI application child forms

    Hi

    try this in your project...

    VB Code:
    1. Private Sub MNUNew_Click()
    2. 'Dim fForm As Form1
    3. 'Set fForm = New Form1
    4. If Form1.Visible = False Then
    5.     Form1.Show
    6. End If
    7. 'or write a code to create a new form as Form1 already exists!!!
    8. End Sub

    Hope it helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: Wheelmouse scroll MDI application child forms

    You might try searching PSC for Paul Caton's safe, self subclassing code.

    Then place code in the Form_Activate subs of the Midi children to release the last form and hook the new one.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Wheelmouse scroll MDI application child forms

    Longwolf, I can't find the reference you talked about on planet source code. Or not quite sure what I'm was looking for but your post explained what I needed to do.
    I needed to unhook the current form and hook the next one.

    VB Code:
    1. Private Sub MNUNew_Click()
    2. Dim fForm As Form1
    3. Set fForm = New Form1
    4. Call WheelUnHook
    5. fForm.Show
    6. Call WheelHook(fForm)
    7. End Sub

    I've read that the code I'm using is slightly unstable as if you press stop on the project, the wheelmouse doesn't unhook and VB shuts down. As far as I understand it anyway.

    The "safe" subclassing code may be the answer. If you can post a link that would be great but you've been helpful with what you posted already.

    Thankyou both.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Wheelmouse scroll MDI application child forms

    OK, this is a bit irritating.

    I just tried to open three forms. The first and third form scroll but the second one has decided to unhook.
    Any suggestions on how I unhook a form when goes to the background and hook another on it's selection?

  6. #6
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: Wheelmouse scroll MDI application child forms

    I'd place the code in the Activate subs.
    That way your scroll should work even when the user switches between open midi forms.

    Here's a search I did for you at PSC

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Wheelmouse scroll MDI application child forms

    i don't have VB on this comp but I've had a look at your code.

    the module that you've posted doesn't allow several windows to be managed though the same WndProc - hence why things aren't working.

    try using the module in the CodeBank thread, it should work just fine then (as long as you implement it correctly )

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Wheelmouse scroll MDI application child forms

    Got it

    I must have changed your code when I found this extra bit of code which handles the scroll.

    VB Code:
    1. Public Sub MouseWheel(ByVal MouseKeys As Long, ByVal Rotation As Long, ByVal Xpos As Long, ByVal Ypos As Long)
    2.     Dim NewValue As Long
    3.  
    4.     On Error Resume Next
    5.  
    6.     With VScroll1
    7.         If Rotation > 0 Then
    8.             NewValue = .Value - .LargeChange
    9.             If NewValue < .Min Then
    10.                 NewValue = .Min
    11.             End If
    12.         Else
    13.            NewValue = .Value + .LargeChange
    14.            If NewValue > .Max Then
    15.                NewValue = .Max
    16.             End If
    17.         End If
    18.         .Value = NewValue
    19.     End With
    20.  
    21. End Sub

    Thanks. It's one of a few last finishing touches.

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