Solved

mdiform resize picture box

Posted on 2002-03-28
5
471 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

816 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

10 Experts available now in Live!

Get 1:1 Help Now