Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PictureBox in MDI is hiding MDIChild 4

Status
Not open for further replies.

SH4F33

Programmer
Apr 1, 2005
58
MU
Hello everybody.
Im having a little problem with my MDIChild.
I Have an MDI form, and Ive put a picturebox(picFull) in it. The height of the picturebox is the same as the MDI form, even when resizing the MDI form.
Ive put another picturebox(picMove) in picFull. picMove has a frame, a listbox and a commandbutton(ShowLog).
When loading the MDI, the picMove will be at the bottom, u wont see it, only the commandbutton will b seen which is just above the statusbar.
When clicking on the command button, a timer will be activated and picMove will start moving up at around 1/3 the width of the MDI. Its like the .Net IDE (I don't know how to make a toggle button by the way..).
The user can read some messages(log) in the listbox. And after 20seconds,picMove will slide down,leaving only the command button to be visible, or the user can just click on the same button to hide the log.
And also the picMove will move up on a particular event and will slide down after 20seconds.
The result is pretty cool.
But the problem arises when adding an MDI child. When calling the child, I can't see it. I guess its behind picFull. Even using zorder wont make the child to show.
Is there something that I can do to make the child to show up?
Ive been thinking about removing all the picturebox and displaying the messages on the statusbar of the MDI, but if I can fix this one, it will be great because I really like the visual effect of the current one, its just a non-functional requirement but I really like it.
Thanks for your response.
 
I suggest first remove picFull (or make vizible=false or make it smaller) just to make sure that it is indeed source of problem.
 
Have you thought about making your picture box another MDIchild?

You could then tile the two MDIchild forms horizontally and play with their height and border style properties to get the effect that you want.

Other issues may arise when a third form is added. To be honest I have not done this but it should be possible. Food for thought anyway.

zemp
 
One thing needed to mention is that what you are looking for is NOT possible.

MDI forms have limited capabilities as containers. Only two type of controls can be placed on an MDI form.

1. Those which are not visible at runtime, like Timer, CommonDialog and ImageList. These control have a fixed size and you cannot change their width or height.

2. Those which have the 'Align' property, set to some value other than 'None'. These include Picturebox, Statusbar, Toolbar and Coolbar.

When a control of second type is placed on an MDI form, it is always docking to one of the edges of the MDI form, depending upon the value of Align property. When a child form is shown, it is ALWAYS placed behind this control if its position overlaps. You cannot bring the MDI child above the picturebox as it lies outside the available client area of the MDI form for displaying childs.

So, you should try some other method or look at zemp's advice for using anther MDI child form.
 
Of course you can do it ...

And, rather than a major revamp of your code, we'll only really need one minor change

You just need to make judicious use the SetParent API call. Once you see the technique you may realise that you can do probably do away with picFull and just use picMove, but we'll leave that for now)

Here is the sum total of the changes I believe you'll need to make to your current code; it goes in the MDIForm:
Code:
[blue]Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Sub MDIForm_Load()
    SetParent picFull.hWnd, FindWindowEx(Me.hWnd, 0&, vbNullString, vbNullString)
End Sub[/blue]

 
Hello everybody. Sorry for the late response, I was a bit busy. But I spent quite some time thinking about this. I finally came with the idea of removing all picturebox and do the sliding log with an mdiChild with borderstyle 0. I think it wont "interfere" with the other child. Ive tried showing another child and no problem at all.

@zemp: Im using a child instead of the picturebox. Uve said that problem may arise when a third child is added. What problem may I encounter when using this method?

@Hypetia: Thanks for the explanation. I know that these controls can be placed on an MDI form but I never knew why and why the child always kept behind the picturebox. Thanks.

@strongm: Thanks for the API function.

You are all some kind of superstars.
 
I didn't say 'problem' I said 'other issues'. Which could be a 'problem' or not.

Tiling could be an issue, If you want to only tile the the sliding MDI and one other then you may not be able to have more than two child forms open at once. Or you can chose to not tile and just manipulate the child form sizes. The issues I was thinking about was more code required to manage the various forms. Might not be a 'problem' but still needs to be addressed.

Sorry for the confusion.


zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top