Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

mdiform resize picture box

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hide vba in gp 7 104
Child Form in front 4 49
Problem to With line 4 63
VBA: copy range dynamically based on config sheet v2 3 48
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 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