|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Form on topHi,
I have an application with two forms. The application is often run in background with form1 (maximized) and with for example Word on top. At a certain time I want form2 to get visible. Question: How can I get form2 on top without also putting form1 on top? I want form1 to reside in the background if it is the current position. Thanks /Tommy Not sure what you are asking but if you are looking to force a window on top
check out the SetWindowPos API. -- Show quoteHide quoteChris Hanscom - Microsoft MVP (VB) Veign's Resource Center http://www.veign.com/vrc_main.asp Veign's Blog http://www.veign.com/blog -- "Tommy" <To***@discussions.microsoft.com> wrote in message news:619B8544-0EF3-4156-8676-D2039C85A0C3@microsoft.com... > Hi, > > I have an application with two forms. The application is often run in > background with form1 (maximized) and with for example Word on top. At a > certain time I want form2 to get visible. > > Question: How can I get form2 on top without also putting form1 on top? I > want form1 to reside in the background if it is the current position. > > Thanks > > /Tommy > Use SetForegroundWindow. Example:
Option Explicit Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Private Sub Form_Load() Timer1.Interval = 5000 ' 5 seconds End Sub Private Sub Timer1_Timer() SetForegroundWindow Me.hwnd End Sub Show quoteHide quote "Tommy" <To***@discussions.microsoft.com> wrote in message news:619B8544-0EF3-4156-8676-D2039C85A0C3@microsoft.com... > Hi, > > I have an application with two forms. The application is often run in > background with form1 (maximized) and with for example Word on top. At a > certain time I want form2 to get visible. > > Question: How can I get form2 on top without also putting form1 on top? I > want form1 to reside in the background if it is the current position. > > Thanks > > /Tommy > "Tommy" <To***@discussions.microsoft.com> wrote in message Due to the voodoo that VB works behind the scenes, this is not possible. news:619B8544-0EF3-4156-8676-D2039C85A0C3@microsoft.com... > I have an application with two forms. The application is often run in > background with form1 (maximized) and with for example Word on top. At a > certain time I want form2 to get visible. > > Question: How can I get form2 on top without also putting form1 on top? I > want form1 to reside in the background if it is the current position. When you activate one window in a VB app, they all come forward. This is because they are all ultimately parented to a hidden window. This came up a long time ago and I speculated that you might be able to play with SetWindowLong() and remove this parentage, but I never tried it myself and I don't think anyone else did either. On Wed, 19 Oct 2005 13:10:06 -0700, "Tommy"
<To***@discussions.microsoft.com> wrote: >I have an application with two forms. The application is often run in As Jeff noted, by default VB forms are z-order linked to a hidden>background with form1 (maximized) and with for example Word on top. At a >certain time I want form2 to get visible. > >Question: How can I get form2 on top without also putting form1 on top? I >want form1 to reside in the background if it is the current position. "owner" window. However it's fairly simple to use the API to remove the linkage and give a form independent z-ordering: 'declares (bas module)... Public Const GWL_HWNDPARENT = (-8) Public Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long 'usage (form module)... SetWindowLong Me.hwnd, GWL_HWNDPARENT, 0 -Tom MVP - Visual Basic (please post replies to the newsgroup) |
|||||||||||||||||||||||