[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Make window not on a top

How I can from VB send window from another program(which is
always on a top but not modal) to back???
0
igorshul
Asked:
igorshul
1 Solution
 
chabaudCommented:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TOPMOST = &H8&

'You must pass the window handle
Public Sub SetNoTopmost(ByVal hWnd As Long)
   
    Dim wexstyle As Long
   
    wexstyle = GetWindowLong(hWnd, GWL_EXSTYLE)
    wexstyle = (wexstyle And (Not WS_EX_TOPMOST))
    SetWindowLong hWnd, GWL_EXSTYLE, wexstyle

End Sub

0
 
igorshulAuthor Commented:
This one doesn't work.
How you find window handle if this window from another program?
But even when I get window handle those functions not working...
0
 
BabyFaceCommented:
How did you find the window handles?
FindWindow?
If not, try FindWindow function.

0
 
luisrCommented:
Call FindWindow("window classname", "caption"). If you know the class name you can pass it as the class name, and pass NULL as the caption argument. Otherwise, pass NULL as classname and pass the window caption as the second arg.

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal szClass As String, ByVal szCaption As String) As Long

FindWindow will return the window handle, which you can pass to the SetNoTopmost() subroutine written by chebada.

0
 
BabyFaceCommented:
Ok,
Thanks for stealing my answer Luisr.
You're such an asshole.
What a cheap way to get your kicks.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now