make windows always active

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • junis
    New Member
    • Nov 2006
    • 7

    #1

    make windows always active

    dear all..

    i have some application running (ex. Winword, Notepad, and My Application).

    the objective is ...
    i want My Application always active ... i mean that the windows is always see in screen and any other can't be active ...

    thx 4 ur advice

    -junis-
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    This is doen by using "SetWindowP os" API
    Declare this at the top of CodeWindow (after Option Explicit) :

    [code=vb]
    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

    Private Const HWND_TOPMOST = -1
    Private Const HWND_NOTOPMOST = -2
    Private Const SWP_NOACTIVATE = &H10
    Private Const SWP_SHOWWINDOW = &H40
    [/code]

    Call this in FormLoad :

    [code=vb]
    Private Sub Form_Load()
    Dim iFlag As Long
    iFlag = IIf(True, HWND_TOPMOST, HWND_NOTOPMOST)
    SetWindowPos Me.hwnd, iFlag, Me.Left / Screen.TwipsPer PixelX, Me.Top / Screen.TwipsPer PixelY, _
    Me.Width / Screen.TwipsPer PixelX, Me.Height / Screen.TwipsPer PixelY, SWP_NOACTIVATE Or SWP_SHOWWINDOW

    End Sub
    [/code]

    REgards
    Veena

    Comment

    Working...