Hi Guys
I have made a very simple Form in which i have Two buttons which start
two different applications. At the Start up of Form i.e. at Form_Load
I set the my application Window as the Top Most, and when the user clicks
any of the two buttons, my application window is set back to NoTopMost.
But facing some problem with NoTopMost. First See the Code for TopMost
and NoTopMost:
Option Explicit
'''''''''' API CALL
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
''''''''''''''CONSTANTS
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOP = 0
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
'''''''''' TopMost Sub
Public Sub TopMost(ByVal vNewValue As Long, _
Optional ByVal wt As Long = 0, _
Optional ByVal Ht As Long = 0, _
Optional ByVal X As Long = 0, _
Optional ByVal Y As Long = 0)
SetWindowPos vNewValue, HWND_TOPMOST, X, Y, wt, Ht, 0
End Sub
''''''''''''' NoTopMost Sub
Public Sub NotTopMost(ByVal vNewValue As Long)
SetWindowPos vNewValue, HWND_NOTOPMOST, 0, 0, 0, 0, 0
End Sub
'''I am using it in this manner
TopMost Me.hwnd, Screen.Width, Screen.Height
''''''' This is the Code on Button Click & here where i have problem
NotTopMost Me.hwnd
Me.WindowState = 1
Me.Caption = "Pentagon Solutions...."
Call ShellExecute(Me.hwnd, vbNullString, "IExplore.exe", vbNullString, "C:\", 1)
If i dont set the window state to 1 i.e. Minimize the NoTopMost thing doesnt work. And if
i do so, then when the User finish using the application they have to manually click on my application
to bring it back on TOP, what i want is that when the button is clicked my application window
should not remain TopMost anymore and the new window should be displayed on top of it,
And when the Application is closed then my application window should become topmost again,
hope my point is clear
thanks
gazal
I have made a very simple Form in which i have Two buttons which start
two different applications. At the Start up of Form i.e. at Form_Load
I set the my application Window as the Top Most, and when the user clicks
any of the two buttons, my application window is set back to NoTopMost.
But facing some problem with NoTopMost. First See the Code for TopMost
and NoTopMost:
Option Explicit
'''''''''' API CALL
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
''''''''''''''CONSTANTS
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOP = 0
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
'''''''''' TopMost Sub
Public Sub TopMost(ByVal vNewValue As Long, _
Optional ByVal wt As Long = 0, _
Optional ByVal Ht As Long = 0, _
Optional ByVal X As Long = 0, _
Optional ByVal Y As Long = 0)
SetWindowPos vNewValue, HWND_TOPMOST, X, Y, wt, Ht, 0
End Sub
''''''''''''' NoTopMost Sub
Public Sub NotTopMost(ByVal vNewValue As Long)
SetWindowPos vNewValue, HWND_NOTOPMOST, 0, 0, 0, 0, 0
End Sub
'''I am using it in this manner
TopMost Me.hwnd, Screen.Width, Screen.Height
''''''' This is the Code on Button Click & here where i have problem
NotTopMost Me.hwnd
Me.WindowState = 1
Me.Caption = "Pentagon Solutions...."
Call ShellExecute(Me.hwnd, vbNullString, "IExplore.exe", vbNullString, "C:\", 1)
If i dont set the window state to 1 i.e. Minimize the NoTopMost thing doesnt work. And if
i do so, then when the User finish using the application they have to manually click on my application
to bring it back on TOP, what i want is that when the button is clicked my application window
should not remain TopMost anymore and the new window should be displayed on top of it,
And when the Application is closed then my application window should become topmost again,
hope my point is clear
thanks
gazal