By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

make windows always active

P: 7
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

Sep 22 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,445

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

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
  2. ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
  3. ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  5. Private Const HWND_TOPMOST = -1
  6. Private Const HWND_NOTOPMOST = -2
  7. Private Const SWP_NOACTIVATE = &H10
  8. Private Const SWP_SHOWWINDOW = &H40
Call this in FormLoad :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Dim iFlag As Long
  3.     iFlag = IIf(True, HWND_TOPMOST, HWND_NOTOPMOST)
  4.     SetWindowPos Me.hwnd, iFlag, Me.Left / Screen.TwipsPerPixelX, Me.Top / Screen.TwipsPerPixelY, _
  5.                 Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY, SWP_NOACTIVATE Or SWP_SHOWWINDOW
  7. End Sub
Sep 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.