Showing a window within another control?!

EFileTahi-A

Contributor
Joined
Aug 8, 2004
Messages
623
Location
Portugal / Barreiro
Is it possible to display a window inside another window so that when I drag the main window all the other attached windows will be moved too? Plus, what about showing a window inside a panel for example?
 
I dont think it is possible to include a form inside another, but you can code something that check the locacation of the mother window on the child and ajust after
 
Well, the "moving window" thing was just for ppl to get an ideia of what I was trying to say. What I really want is something like Paint Shop Pro program. If you ever saw / used this program then you will realise that the program have its own work space where it opens new windows whenever an image is loaded / created... I wonder how they do this...
 
EFileTahi-A said:
Well, the "moving window" thing was just for ppl to get an ideia of what I was trying to say. What I really want is something like Paint Shop Pro program. If you ever saw / used this program then you will realise that the program have its own work space where it opens new windows whenever an image is loaded / created... I wonder how they do this...
MDI windows.

The 'container' (paint shop pro program) is the mdi parent, all the images that are loaded, are loaded into mdi childs.

You might want to read this page (and all the pages it links to) as a starting point.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconmdiapplications.asp
 
MDI = Multiple Document Interface = many documents inside one parent window

SDI = Single Document Interface = each document opened in its own window

Microsoft Office used to use an MDI interface but now uses SDI by default.
 
"Additionally, be aware that the edge of the MDI parent form will pick up the system color (set in the Windows System control panel), rather than the back color you set using the Control.BackColor property."

This is written within the help of .NET MSDN library, my question is, how will I change the forms backcolor then? Also, is there a way do disable the form's scroll bars when a child window reachs the edge of its parent window?
 
When you make a form an MDI container, it actually places an MdiClient control on your form. This means that setting the form's BackColor has no effect because it is hidden behind the MdiClient. There is no member variable for the MdiClient, however, as it is not intended to be used directly. You can change its properties, though, using code like the following:
Visual Basic:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each ctl As Control In Me.Controls
            If TypeOf ctl Is MdiClient Then
                ctl.BackColor = SystemColors.Control
                Exit For
            End If
        Next
    End Sub
As for scrollbars, I'd say that you're stuck with them. How else would you get a window back that was moved out of view?
 
jmcilhinney said:
When you make a form an MDI container, it actually places an MdiClient control on your form. This means that setting the form's BackColor has no effect because it is hidden behind the MdiClient. There is no member variable for the MdiClient, however, as it is not intended to be used directly. You can change its properties, though, using code like the following:
Visual Basic:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each ctl As Control In Me.Controls
            If TypeOf ctl Is MdiClient Then
                ctl.BackColor = SystemColors.Control
                Exit For
            End If
        Next
    End Sub
As for scrollbars, I'd say that you're stuck with them. How else would you get a window back that was moved out of view?


Ok, thks for the color issue explanation.

"How else would you get a window back that was moved out of view?"

I answer that question of your with another question:
How can you move a window out of the view at all? Can you move a window outside Windows Desktop? No, you can't, at least normaly. So?
 
I was under the impression that the user could select Move from the system menu and move the window off screen as well, but I just tried it and it seems that you cannot move it off screen that way. It is true that if you programatically move it to a location off screen, which is unlikely but possible, the user would then have no way to access the window.
 
jmcilhinney said:
I was under the impression that the user could select Move from the system menu and move the window off screen as well, but I just tried it and it seems that you cannot move it off screen that way. It is true that if you programatically move it to a location off screen, which is unlikely but possible, the user would then have no way to access the window.

Actually, you can, but you need to be a keyboard addict to find it ;).
If you open the system menu, select move by pressing enter, then use the direction keys, it allows me to move windows outside the desktop area. It might look like the border is still visible, but if you moved the window off the left side, move it up or down, the border that is still visible doesnt follow the up/down part, if you move the window back to the center the window however did follow the up/down key.

Dont use your mouse during all this, it completely overrides whatever you do with the keyboard ;).

And you can still access it as long as it is in the taskbar. Right click on it in the taskbar, select move, use the arrow keys again and it can be moved back, here the mouse becomes handy: first move the window with the arrow keys, then use the mouse: it pops into the visible area immediatly.
 
Wile said:
Actually, you can, but you need to be a keyboard addict to find it ;).
If you open the system menu, select move by pressing enter, then use the direction keys, it allows me to move windows outside the desktop area. It might look like the border is still visible, but if you moved the window off the left side, move it up or down, the border that is still visible doesnt follow the up/down part, if you move the window back to the center the window however did follow the up/down key.

Dont use your mouse during all this, it completely overrides whatever you do with the keyboard ;).

And you can still access it as long as it is in the taskbar. Right click on it in the taskbar, select move, use the arrow keys again and it can be moved back, here the mouse becomes handy: first move the window with the arrow keys, then use the mouse: it pops into the visible area immediatly.

Well, I do have to confess that this is quite interesting though :)
 
Last edited:
Wile said:
Actually, you can, but you need to be a keyboard addict to find it ;).
If you open the system menu, select move by pressing enter, then use the direction keys, it allows me to move windows outside the desktop area. It might look like the border is still visible, but if you moved the window off the left side, move it up or down, the border that is still visible doesnt follow the up/down part, if you move the window back to the center the window however did follow the up/down key.

Dont use your mouse during all this, it completely overrides whatever you do with the keyboard ;).

And you can still access it as long as it is in the taskbar. Right click on it in the taskbar, select move, use the arrow keys again and it can be moved back, here the mouse becomes handy: first move the window with the arrow keys, then use the mouse: it pops into the visible area immediatly.
That is exactly how I tested. Notice that once you have the window to the edge of the screen, the only way to have it stay there is to press the ENTER key. Once you've done that, you can still access the window from sliver of border that it leaves at the edge. If the window was allowed to move off-screen and had ShowInTaskbar set to False then it would be inaccessible. I'd guess that if they were to implement MDI without scrollbars, it would be done the same way for the same reason.
 
Back
Top