Solved

mdiform resize picture box

Posted on 2002-03-28
5
469 Views
Last Modified: 2008-03-10
hi I am trying to create a slide menu using a picture box on an mdiform. I have managed to make it slide out by simply setting the width property on the mousemove event.

My problem is that if any child forms are visible, as the picture box gets wider it pushes the child forms accross to the right(picture box is aligned left).Is there any way I can stop this from happening and make the picture box slide over the child forms.(the picture box does this automatically if u align it left or bottom but not if it is aligned left?

Thanks
NIep
0
Comment
Question by:NIep2001
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 6903198
Instead of picturebox, use one mdichild form without border or caption, make it 'On Top', and resize it in MDIForm_Resize()
0
 

Author Comment

by:NIep2001
ID: 6904133
Hey ameba
sounds good but how do I make a child form appear 'on Top'! and make sure that child form always appears on left most  edge of mdiform(sorry if dumb question but first time in such a situation) shot
Niep
0
 
LVL 15

Accepted Solution

by:
ameba earned 100 total points
ID: 6904768
OK, here is the sample (one MDI form and 2 MDIchild forms).

Start new project, Form1 is automatically added.
Form1 - set property: MDIChild=True

Add Form, name it frmMenu:
'---------------------------------------------------------------------------
' frmMenu form (Caption="Menu", MDIChild=True, Moveable=False, BorderStyle=5)
Option Explicit

Private Sub Form_Unload(Cancel As Integer)
    MDIForm1.bMenuVisible = False    ' notify parent form
End Sub
'---------------------------------------------------------------------------

Add MDIForm
'---------------------------------------------------------------------------
' MDIForm1 (AutoShowChildren=False, Scrollbars=False)
' add menu and submenu:
'   mnuView (Caption="&View")
'        mnuVSlideMenu (Caption="&Slide Menu")
Option Explicit
Private Const GWL_HWNDPARENT = (-8)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public bMenuVisible As Boolean ' flag

Private Sub MDIForm_Load()
    mnuVSlideMenu_Click     ' show slide menu
End Sub

Private Sub MDIForm_Resize()
    ' move slide menu to the left
    If bMenuVisible Then frmMenu.Move 2 * Screen.TwipsPerPixelX, 2 * Screen.TwipsPerPixelY, _
        frmMenu.Width, Me.ScaleHeight
End Sub

Private Sub mnuView_Click()
    mnuVSlideMenu.Checked = bMenuVisible
End Sub

' show/hide slide menu
Private Sub mnuVSlideMenu_Click()
    bMenuVisible = Not bMenuVisible
    If bMenuVisible Then
        Load frmMenu
        frmMenu.Move 2 * Screen.TwipsPerPixelX, 2 * Screen.TwipsPerPixelY, 1500, Me.ScaleHeight
        SetChild frmMenu
        frmMenu.Show
    Else
        Unload frmMenu
    End If
End Sub

' this will set mdi child form 'on top of other mdi child forms'
Public Sub SetChild(MdiChildForm As Form)
    Call SetWindowLong(MdiChildForm.hwnd, GWL_HWNDPARENT, Me.hwnd)
End Sub
'---------------------------------------------------------------------------
0
 

Author Comment

by:NIep2001
ID: 6963080
thanks ameba the code worked perfectly
0
 
LVL 15

Expert Comment

by:ameba
ID: 6963093
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now