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

How do I make a form stay on top and is there a way to change the taskbar Icon color?

P: n/a
Hello Everyone,

QUESTION #1
I am working on a timer. I have the following code which works kind of
OK.

If Form1.WindowState = 1 Then Form1.WindowState = 0

The problem is that if the user has another window open when my timer
program restores itself it ends up behind whatever window is currently open.
Is there any way for my window to be told to be on top?
QUESTION #2
The other question, is there a way to change the image or text on the
taskbar icon as to draw attention to it?
Thanks In Advance For Any Answers.
Jim Mac Millan
San Dimas, CA
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The following code should help:
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40

Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2

Public Declare Sub 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)

Private Sub Form_Activate()
'SETS THE FORM IDENTIFIED AS ME IN THE STATEMENT BELOW TO BE ALWAYS ON TOP
WHEN SET TO "TRUE"
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or
SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE

End Sub

"Jim M M" <Pe*********@SPAMKILLERYahoo.com> wrote in message
news:TQ********************@vel.net...
Hello Everyone,

QUESTION #1
I am working on a timer. I have the following code which works kind of
OK.

If Form1.WindowState = 1 Then Form1.WindowState = 0

The problem is that if the user has another window open when my timer
program restores itself it ends up behind whatever window is currently open. Is there any way for my window to be told to be on top?
QUESTION #2
The other question, is there a way to change the image or text on the
taskbar icon as to draw attention to it?
Thanks In Advance For Any Answers.
Jim Mac Millan
San Dimas, CA

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.