[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Hot spots  to trigger a program

Posted on 2000-03-09
5
Medium Priority
?
190 Views
Last Modified: 2010-05-02
How in vb6 do i create hot spots on the screen that can trigger my app?  What I mean is this say My app is running in the system tray and nothing is on the screen  if I move my mouse to one of the corners of the screen I want to activate my app and maximize it.  Ive seen this done with screensaves and a toolbar once.
0
Comment
Question by:ocsscott
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 400 total points
ID: 2603208
Try this:

Option Explicit
Const ZONE = 2 '2 pixel zone
Private Type POINTAPI
    x As Long
    y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" _
    (lpPoint As POINTAPI) As Long
   
Private sx As Long, sy As Long
Dim pt As POINTAPI

Private Sub Command1_Click()
    Hide
    Timer1.Enabled = True
End Sub

Private Sub Form_Load()
    Timer1.Interval = 2000 '2 secs.
    Timer1.Enabled = False
    Command1.Caption = "Hide Me"
    'Get the screen size
    sx = Screen.Width / Screen.TwipsPerPixelX
    sy = Screen.Height / Screen.TwipsPerPixelY
End Sub

Private Sub Timer1_Timer()
    Call GetCursorPos(pt)
   
    'Test for lower right corner
    'If (pt.x > sx - ZONE) And (pt.y > sy - ZONE) Then
   
    'Test for upper left corner
    If (pt.x < ZONE) And (pt.y < ZONE) Then
        Show
        Timer1.Enabled = False
    End If
End Sub
0
 
LVL 12

Expert Comment

by:roverm
ID: 2603571
Erick37 is correct, but to hide your app in the system tray you have to use the Shell_NotifyIcon API:

Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias " Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long

D'Mzzl!
RoverM
0
 

Author Comment

by:ocsscott
ID: 2605038
ok a question or 2 about this method.

1) since it uses a times and checks every 2 seconds or so does this use a lots of cpu?  My app is for a menu system and will be hidden in the system tray most of the time.

2) since my app will be minimized to the system tray do i need to do anything to keep it active or is a program in the system tray always active and recieving events and timer events?  thanks for the code I'll put it in and test it today and let you know.  thanks
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2605226
1) The CPU overhead is minimal, as the code only executes at the Timer event.  There would be a significant performance hit if you used a mouse hook scheme, and this would be hard to implement in VB.

2)  Yes, the code will still run as long as the form with the timer is loaded in memory.  The system tray icon will be used only to hide or show the application.
0
 

Author Comment

by:ocsscott
ID: 2605233
Great thanks for the help and info.

Scott
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question