Solved

mdiform resize picture box

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

747 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