borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (C++ to Vb)Next Topic (Problems with MSN Api) New Topic New Poll Post Reply
AndreaVB Forum : API : Controlling windows
Poster Message
Juliemac
Level: Trainee

Registered: 01-08-2005
Posts: 3

icon Controlling windows

I have 3 programs that run normally on a system, but only one can be seen at a time.
Is it possible to control which program is maximised (and minimise the others) with the touch of a key? (eg F1,F2 etc)

TIA!

01-08-2005 at 08:07 PM
View Profile Send Email to User Show All Posts | Quote Reply
Juliemac
Level: Trainee

Registered: 01-08-2005
Posts: 3
icon Re: Controlling windows

Ok. Is it possible to write a wrapper in VB6 using "tabs" to start and select the applications? EG: MP3 player, GPS, or Word?
Does this help at all?

05-08-2005 at 07:47 PM
View Profile Send Email to User Show All Posts | Quote Reply
ChaosTheEternal
Level: Whizz Kid


Registered: 13-05-2004
Posts: 17
icon Re: Controlling windows

To try and solve your problem:

To make it detect a keypress (like F1, F2, etc.), you'd need something like:

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal uAction As Long) As Long

Private keyDown as Long

'I don't know the real value of these, if they exist, off the top of my head, and the comp I'm on doesn't have VB on it
Private Const VK_F1 = &H1
Private Const VK_F2 = &H2
Private Const VK_F3 = &H3


Private Sub Timer1_Timer()
    keyDown = GetAsyncKeyState(VK_F1)
    If keyDown <> 0 Then
        'Call the first window
    End If
'etc.
End Sub

Better example could be found here.

Of course, depending on a timer control could be costly on the processor (especially if the interval is 0 or 1).  You might want to throw a DoEvents in the Timer control before the End Sub or any Exit Sub so it doesn't absorb the whole processor and lock up (it's happened to me before, but I think it's only an issue with older processors, like lower than 600 MHz or so).

You could, though, have a tabbed feature.  Just make a form that stays always on top (using SetWindowPos), have it put itself where you want it, and just have three buttons that change what window is in focus (you'll need to have FindWindow or FindWindowEx, to find/know what window you want to effect, and SetWindowPos to change the position, either by depth, on top or on bottom, or change the X and Y coords).

SetWindowPos Examples
http://www.andreavb.com/tip020014.html
http://www.andreavb.com/tip050002.html


____________________________
View what programs I have made for VB6:
http://www.geocities.com/map_hrs/vb/index.html
I also have some source code examples on the page.

05-08-2005 at 08:57 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : API : Controlling windows
Previous Topic (C++ to Vb)Next Topic (Problems with MSN Api) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder