|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can An MDI child form stay on top ?Hi All
I have an mdi form with serveral mdi child forms. How can I set one mdi child form so that it always stay on top ? Thanks Rony *** Sent via Developersdex http://www.developersdex.com *** "rony g" <nospam> wrote in message For what possible reason would you want to do that? That's completely news:uw2RcR65JHA.1716@TK2MSFTNGP03.phx.gbl... > Hi All > I have an mdi form with serveral mdi child forms. > How can I set one mdi child form so that it always > stay on top ? > against what MDI is for. -- Mike "MikeD" <nob***@nowhere.edu>'s wild thoughts were released on Sun, 7 Jun 2009 17:44:13 -0400 bearing the followingfruit: > Posibly for a side bar type menu thing. Either way, the OP>"rony g" <nospam> wrote in message >news:uw2RcR65JHA.1716@TK2MSFTNGP03.phx.gbl... >> Hi All >> I have an mdi form with serveral mdi child forms. >> How can I set one mdi child form so that it always >> stay on top ? >> > > >For what possible reason would you want to do that? That's completely >against what MDI is for. is going the wrong way about it. -- Jan Hyde Why would you want to do that? As MikeD stated it is against what MDI is
for. But if you really want to do the absurd you will need to basically get a timer to bring that form to focus constantly... -- Show quoteHide quoteRandem Systems Your Installation Specialist The Top Inno Setup Script Generator http://www.randem.com/innoscript.html Disk Read Error Press Ctl+Alt+Del to Restart http://www.randem.com/discus/messages/9402/9406.html?1236319938 "rony g" <nospam> wrote in message news:uw2RcR65JHA.1716@TK2MSFTNGP03.phx.gbl... > Hi All > I have an mdi form with serveral mdi child forms. > How can I set one mdi child form so that it always > stay on top ? > > Thanks > Rony > > > > *** Sent via Developersdex http://www.developersdex.com *** "rony g" <nospam> wrote How about you add a Picutrebox to one edge of the MDI parent> Hi All > I have an mdi form with serveral mdi child forms. > How can I set one mdi child form so that it always > stay on top ? and put your controls on that? LFS "rony g" <nospam> wrote in message You can't. You need to use something other than an MDI child for this.news:uw2RcR65JHA.1716@TK2MSFTNGP03.phx.gbl... > I have an mdi form with serveral mdi child forms. > How can I set one mdi child form so that it always > stay on top ? Going against what all the other replies say, I also have a use for this
from time to time. Our application basically hosts all forms within an MDI container. Most forms are general input entry forms and grids etc, but I occasionally want a window to stay on top of all the others that are open. E.g. When I have a booking form open I want another small window open with the basic clients details visible for various purposes. It's a small Fixed ToolWindow form in the bottom right. I think something like this a great use. It may not be a MDI child in the normal sense, but might be the kind of thing you were referring to. Firstly make sure the MDIChild is set to False In the declarations at the top of the form... Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long In form load set the following... SetParent Me.hwnd, frmMain.hwnd SetForegroundWindow Me.hwnd frmMain should be set to the name of the MDI parent. Even though the form is set to an MDIChild it will still stay within the bounds of the MDI parent with the above code. Hope this helps. Chris Show quoteHide quote "rony g" <nospam> wrote in message news:uw2RcR65JHA.1716@TK2MSFTNGP03.phx.gbl... > Hi All > I have an mdi form with serveral mdi child forms. > How can I set one mdi child form so that it always > stay on top ? > > Thanks > Rony > > > > *** Sent via Developersdex http://www.developersdex.com *** > "Chris" <cw@community.nospam> wrote in message There's no "even though" about it. That's the NORMAL behavior of an MDI news:u0bbYjR6JHA.1424@TK2MSFTNGP02.phx.gbl... > frmMain should be set to the name of the MDI parent. Even though the form > is set to an MDIChild it will still stay within the bounds of the MDI > parent with the above code. child. I actually meant to say "Even though the forms MDIChild is set to False it
will stay in the bounds of the MDI parent". The API call makes the form stay within the MDI window even though MDIChild is set to False. I don't want to argue about whether you should allow "always on top" with MDI Children. I was just trying to help someone out who might have a similar need for it as me. For my application it works perfectly. Having an MDI parent to host all forms works great. One example of where others have used this is in VB6 itself. If you run VB6 in MDI mode... if you undock the Immediate window as you drag it around it always stays on top of the code windows. Perfect use of it! Chris Show quoteHide quote "Jeff Johnson" <i.get@enough.spam> >> frmMain should be set to the name of the MDI parent. Even though the >> form is set to an MDIChild it will still stay within the bounds of the >> MDI parent with the above code. > > There's no "even though" about it. That's the NORMAL behavior of an MDI > child. > >
Show quote
Hide quote
"Chris" <cw@community.nospam> wrote in message But the Immediate window is not an MDI child, and it CAN be dragged outside news:e4aGrpd6JHA.2456@TK2MSFTNGP02.phx.gbl... >I actually meant to say "Even though the forms MDIChild is set to False it >will stay in the bounds of the MDI parent". > > The API call makes the form stay within the MDI window even though > MDIChild is set to False. > > I don't want to argue about whether you should allow "always on top" with > MDI Children. I was just trying to help someone out who might have a > similar need for it as me. For my application it works perfectly. Having > an MDI parent to host all forms works great. > > One example of where others have used this is in VB6 itself. If you run > VB6 in MDI mode... if you undock the Immediate window as you drag it > around it always stays on top of the code windows. Perfect use of it! of the MDI parent. That's the point I was trying to make: if you want this functionality you must not use an MDI child (the definition under VB being "a form with the MDIChild property set to True"). Plus I think limiting the movement of such a form to the parent is just silly. Has anyone ever used a program that did this? What was the justification? Hi Chris, thanks for your post, I need this kind of behavior in my
application too. I tried to put the code exactly as you mentionned and I get errors. Public Class test Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Private Sub test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try SetParent(Me.hwnd, Magentis.hwnd) SetForegroundWindow(hwnd) Catch ex As Exception End Try End Sub End Class This is what I did and the error is : 'hwnd' is not declared. Any ideas what I did wrong? Thanks Marc-Andre *** Sent via Developersdex http://www.developersdex.com *** Hi Marc-Andre,
I assume from your code you are trying this in VB.NET? I've never tried it in there before. My example was for VB6 and I would not know if this is possible in .NET. Thanks, Chris Show quoteHide quote "Marc-Andre Paquette" <marc-andre.paque***@videotron.ca> wrote in message news:%23cLbF2q7JHA.4376@TK2MSFTNGP06.phx.gbl... > > > Hi Chris, thanks for your post, I need this kind of behavior in my > application too. I tried to put the code exactly as you mentionned and I > get errors. > > Public Class test > Private Declare Function SetParent Lib "user32" (ByVal hWndChild As > Long, ByVal hWndNewParent As Long) As Long > Private Declare Function SetForegroundWindow Lib "user32" (ByVal > hwnd As Long) As Long > > Private Sub test_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Load > > Try > SetParent(Me.hwnd, Magentis.hwnd) > SetForegroundWindow(hwnd) > Catch ex As Exception > > End Try > End Sub > End Class > > This is what I did and the error is : 'hwnd' is not declared. > > Any ideas what I did wrong? > > Thanks > Marc-Andre > > *** Sent via Developersdex http://www.developersdex.com *** > "Marc-Andre Paquette" <marc-andre.paque***@videotron.ca> wrote in message [Canned response]news:%23cLbF2q7JHA.4376@TK2MSFTNGP06.phx.gbl... > Private Sub test_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Load This is a VB "classic" newsgroup. Questions about VB.NET (including VB 2005/2008 and VB Express, which have dropped .NET from their names) are off-topic here. Please ask .NET questions in newsgroups with "dotnet" in their names. The *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.* groups on your news server, connect directly to the Microsoft server: msnews.microsoft.com. For questions specific to the VB.NET language, use this group: microsoft.public.dotnet.languages.vb Please note that things like controls and data access, which have their own subgroups in the Classic VB hierarchy, are not language-specific in .NET, so you should look for groups like these: microsoft.public.dotnet.framework.windowsforms.controls microsoft.public.dotnet.framework.adonet (Note that "vb" is not present in the group name.)
Vista SP2 Being "offered"
dhRichClient3 Thread Classes Issues VB6 on Vista Home Premium problem Excel Execution from VB Fails on 2nd Attempt Use an Addin to automatically add date/time stamp to each edited line of VB6 code? Sub .... or Private Sub.... Moving .exe somtimes works In High Density Mode - Looking for previous control counting post How to create the project referencing library, which user may not have on his computer? listing all audio devices |
|||||||||||||||||||||||