|
-
Dec 2nd, 2012, 07:51 AM
#1
Thread Starter
Frenzied Member
Image Monitor
Image Monitor is a program that captures any image copied to the clipboard and saves it in a directory specified by the user. It's also a demonstration of how to write vb6 programs that display a system tray icon and balloon tooltips.
EDIT:
-Removed the WaitMessage API call because it prevents the program from actively monitoring the clipboard.
-Replaced the number verification procedue with a much simpler check.
Last edited by Peter Swinkels; Dec 14th, 2012 at 10:21 AM.
-
Dec 2nd, 2012, 04:38 PM
#2
Re: Image Monitor
Hi! I would just like to discuss a few points about your code:
- In the NOTIFYICONDATA Type, the members uTimeout and uVersion are both Integers and simultaneously available. However, in the MSDN documentation, they are declared as a Union which means only one member name can be used at a time.
- In order for uVersion = NOTIFYICON_VERSION to have an effect, MSDN says that Shell_NotifyIcon should send the NIM_SETVERSION message.
- Shouldn't the Form's ScaleMode be vbPixels instead of vbCharacters?
- What's the difference between the IsNumber function and VB's IsNumeric function?
- Lastly, how is the outermost Do...Loop block in the Sub StartMonitor exited?
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Dec 3rd, 2012, 08:36 AM
#3
Thread Starter
Frenzied Member
Re: Image Monitor
 Originally Posted by Bonnie West
Hi! I would just like to discuss a few points about your code:
- In the NOTIFYICONDATA Type, the members uTimeout and uVersion are both Integers and simultaneously available. However, in the MSDN documentation, they are declared as a Union which means only one member name can be used at a time.
- In order for uVersion = NOTIFYICON_VERSION to have an effect, MSDN says that Shell_NotifyIcon should send the NIM_SETVERSION message.
- Shouldn't the Form's ScaleMode be vbPixels instead of vbCharacters?
- What's the difference between the IsNumber function and VB's IsNumeric function?
- Lastly, how is the outermost Do...Loop block in the Sub StartMonitor exited?
Thank you for the comments, to answer your questions:
- I fixed the NOTIFYICONDATA structure. It should now be correctly defined.
- I decided to ignore the version setting and only set a timeout value.
- I don't see why this is important in this case. Even though the form contains no interface except for a menu, I usually change several form properties to values I prefer to use.
- The difference is that my IsNumber function doesn't just check whether a value is numeric, but whether it contains nothing else except for the digits 0-9. Perhaps I should rename it and clarify the comments.
- I changed this now to use a global flag indicating whether the monitor should stop. The original method was a bit crude, the program simply was forced to quit using the End statement when the window was unloaded.
I have uploaded several other projects to this form. I would be interested to hear your comments.
Last edited by Peter Swinkels; Dec 4th, 2012 at 03:42 AM.
-
Dec 3rd, 2012, 12:52 PM
#4
-
Dec 4th, 2012, 03:45 AM
#5
Thread Starter
Frenzied Member
Re: Image Monitor
WaitMessage works. SetForegroundWindow doesn't work (returns a zero value). Probably because the window it is used on is invisible.
-
Dec 4th, 2012, 04:17 AM
#6
Re: Image Monitor
SetForegroundWindow ought to work because when the tray icon was right-clicked, the focus transferred to that icon's owner hWnd (set by NOTIFYICONDATA.hWnd). It is a known bug with tray icons and context menus. If SetForegroundWindow isn't called, the context menu is left open even when clicking other windows. SetForegroundWindow fixes that. Google other examples of tray icons and you'll see what I mean.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Dec 4th, 2012, 08:45 AM
#7
Thread Starter
Frenzied Member
Re: Image Monitor
 Originally Posted by Bonnie West
SetForegroundWindow ought to work because when the tray icon was right-clicked, the focus transferred to that icon's owner hWnd (set by NOTIFYICONDATA.hWnd). It is a known bug with tray icons and context menus. If SetForegroundWindow isn't called, the context menu is left open even when clicking other windows. SetForegroundWindow fixes that. Google other examples of tray icons and you'll see what I mean.
SetForegroundWindow works now. Must have overlooked something. I did do a search and found other sites where SetForegroundWindow was recommended. Thanks.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|