|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
TopMost without SetFocusHow do I load a form as the top most form without setting focus to it?
I am using vb.net 2005 Using topmost it take the focus away from the application I am typing into then when it closes it send the focus back. The only way I know to do that is through unmanaged code, api calls.
before opening your form, get the active window Public Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Long open your window frm.show() and set it to the top most form Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Set the previous active window back to active Public Declare Function SetActiveWindow Lib "user32" Alias "SetActiveWindow" (ByVal hwnd As Long) As Long Show quoteHide quote "ATracy" <ATr***@discussions.microsoft.com> wrote in message news:48EB4066-6F70-446C-8E7B-5C1F342BDCF4@microsoft.com... > How do I load a form as the top most form without setting focus to it? > I am using vb.net 2005 > Using topmost it take the focus away from the application I am typing into > then when it closes it send the focus back.
Show quote
Hide quote
"AMDRIT" <amd***@hotmail.com> schrieb These are declartions for VB6, not for VB.Net> The only way I know to do that is through unmanaged code, api > calls. > > > before opening your form, get the active window > > Public Declare Function GetActiveWindow Lib "user32" Alias > "GetActiveWindow" () As Long > > open your window > frm.show() > > and set it to the top most form > Public Declare Function SendMessage Lib "user32" Alias > "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam > As Long, lParam As Any) As Long > > Set the previous active window back to active > Public Declare Function SetActiveWindow Lib "user32" Alias > "SetActiveWindow" (ByVal hwnd As Long) As Long Armin Is there any way I can call the form from vb.net 2005?
vb6 requires handle call, how is done in 2005? Is there any way I can bring the form up then Push it to the top without focus? Thanks, ATracy Show quoteHide quote "Armin Zingler" wrote: > "AMDRIT" <amd***@hotmail.com> schrieb > > The only way I know to do that is through unmanaged code, api > > calls. > > > > > > before opening your form, get the active window > > > > Public Declare Function GetActiveWindow Lib "user32" Alias > > "GetActiveWindow" () As Long > > > > open your window > > frm.show() > > > > and set it to the top most form > > Public Declare Function SendMessage Lib "user32" Alias > > "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam > > As Long, lParam As Any) As Long > > > > Set the previous active window back to active > > Public Declare Function SetActiveWindow Lib "user32" Alias > > "SetActiveWindow" (ByVal hwnd As Long) As Long > > > These are declartions for VB6, not for VB.Net > > > Armin > Yes I know this, stated as much in my opening sentance. In order to make
them useful, you would have to perform a dll import. I didn't provide any code, since I was still working on my solution. but is some additional reading. ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconcreatingprototypesinmanagedcode.htm Imports System.Runtime.InteropServices <StructLayout(LayoutKind.Sequential)> _ Public Structure RECT Dim left As Integer Dim top As Integer Dim right As Integer Dim bottom As Integer End Structure Public Class User32 <DllImport("user32.dll", CharSet:=CharSet.Auto)> _ Public Shared Function MessageBox(ByVal hWnd As Integer, ByVal txt As String, ByVal caption As String, ByVal Typ As Integer) As Integer End Function <DllImport("user32", CharSet:=CharSet.Auto)> _ Public Shared Function GetActiveWindow() As Integer End Function <DllImport("user32", CharSet:=CharSet.Auto)> _ Public Shared Function SendMessage(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As RECT) As Integer End Function <DllImport("user32", CharSet:=CharSet.Auto)> _ Public Shared Function SendMessage(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer End Function <DllImport("user32", CharSet:=CharSet.Auto)> _ Public Shared Function SetActiveWindow(ByVal hwnd As Integer) As Integer End Function End Class Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message news:%23WxKRzSIGHA.2300@TK2MSFTNGP15.phx.gbl... > "AMDRIT" <amd***@hotmail.com> schrieb >> The only way I know to do that is through unmanaged code, api >> calls. >> >> >> before opening your form, get the active window >> >> Public Declare Function GetActiveWindow Lib "user32" Alias >> "GetActiveWindow" () As Long >> >> open your window >> frm.show() >> >> and set it to the top most form >> Public Declare Function SendMessage Lib "user32" Alias >> "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam >> As Long, lParam As Any) As Long >> >> Set the previous active window back to active >> Public Declare Function SetActiveWindow Lib "user32" Alias >> "SetActiveWindow" (ByVal hwnd As Long) As Long > > > These are declartions for VB6, not for VB.Net > > > Armin
Show Modal, then Again
Get associated icon for a file A question about finding class methods in the Help WEBREQUEST AND WEBRESPONSE PROBLEM Assigning a Value to a Structure Pointed to by a Tag ? VB.NET profiler Problem when iterating through custom dictionary based collection with FOR...EACH...NEXT Process output redirection? Using a VB.net dll in VB6 How to know if a file is ready. |
|||||||||||||||||||||||