Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Mon Nov 23, 2009 11:18 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ]  Bookmark and Share
Author Message
 Post subject: form always on top
PostPosted: Fri Mar 06, 2009 10:28 pm 
Offline

Joined: Thu Mar 05, 2009 8:21 pm
Posts: 2
Hi, I'm working on a program to wish my girlfriend a happy birthday, my idea is to show a label like a notification, similar to the one used in messenger, but I want it to be on top of whatever she is working on the computer at the time, even games (she's a hardcore gamer). Is this possible??

what I'm asking for is a form on top of everything, not stealing focus, and if she presses a key, for example "q", the message activates no matter what she is doing. I'm a beginner, and I know how to do the label, the key press, but I don't know how to do the above mentioned, if anyone can help me, I'll be very grateful.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: form always on top
PostPosted: Sat Jul 11, 2009 2:27 am 
Offline
User avatar

Joined: Fri Jun 01, 2007 12:16 pm
Posts: 9
Location: Staffordshire, England
El Don wrote:

what I'm asking for is a form on top of everything, not stealing focus, and if she presses a key, for example "q", the message activates no matter what she is doing. I'm a beginner, and I know how to do the label, the key press, but I don't know how to do the above mentioned, if anyone can help me, I'll be very grateful.


Well to make a Form stay on top of other Forms you need to use a bit of API coding. It maybe easier to put this code into a Module then it can be called from any Form.
Code:
Option Explicit

Public 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

Public Sub FormOnTop(Handle As Long, OnTop As Boolean)

Dim wFlags As Long
Dim PosFlag As Long

Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const SWP_SHOWWINDOW = &H40
Const SWP_NOACTIVATE = &H10
Const HWND_NOTOPMOST = -2
Const HWND_TOPMOST = -1

wFlags = SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOACTIVATE

Select Case OnTop
    Case True
        PosFlag = HWND_TOPMOST
    Case False
        PosFlag = HWND_NOTOPMOST
End Select
SetWindowPos Handle, PosFlag, 0, 0, 0, 0, wFlags

End Sub


Now which ever Form you want to stay on top you just add this line into the Form_Load()
Code:

Private Sub Form_Load()

Call FormOnTop(Me.hwnd, True)

End Sub


True is on top and False is not. :wink:

_________________
Martin2k

I've been programming with VB for 13 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley