Re-mapping Mouse Commands
While testing the Boxee Windows Alpha, I found the need to right click on my touch-screen. After finding that none of my fingers would send a right-click, I thought it would be useful have an app that would send a right-click to the active window whenever a double-click was detected.
I couldn’t find any apps that did this, so I started with some global message hooking code written by George Mamaladze, posted on codeproject.com. A double-click is not something that is sent out as a global message, so you have to track the time and space between clicks on the screen. I’m sure my double-click detection is not as smart as the one used by the OS, but it does the job.
After that, a SendInput command (user32.dll) is sent out with a right-mouse-button-down, then a right-mouse-button-up, and my temporary solution is complete. There is no installer, and no settings. Just a tray icon to allow it to be closed. To run it on startup, add an icon to your Startup folder in the Start Menu.
Here is the source code (VS C# 2008): doubletoright_src
Here is the exe file: doubletoright (.NET 2.0 Required)
Next I plan to make a floating window that will work like an on-screen keyboard, but with only the keys I need to access some of the extra features of Boxee.
Gradient Button Control
Since there seems to be people around who still use VB6, I thought I’d post some more of my stuff. Here is a button control that can add a nice touch to some apps. This control is completely owner drawn, and uses code from Carles P.V. (on planetsourcecode.com) and Karl Peterson. This control can also act as a check button, or as a panel (container) object. I don’t think I need to say too much else about it, apart from the interface description:
Properties:
- BackColor: The backcolor will be seen on the border of the control if BorderWidth > 0 or the control has focus.
- BevelWidth: The number of pixels used for the Bevel (3D effect) of the button.
- BorderWidth: The number of pixels for the solid color border (BackColor).
- Cancel: Indicates whether the button is the Cancel button on the form (reacts to the Esc key).
- Caption: You should know what this is.
- Color1: First color of the gradient pattern. Darker than Color2 for 3D effect.
- Color2: Second color of the gradient pattern. Lighter than Color1 for 3D effect.
- Default: indicates whether the button is the Default button on the form (reacts to the Enter key).
- DownColor1: First color of the gradient pattern when the mouse button is down. Lighter than DownColor2 for 3D effect.
- DownColor2: Second color of the gradient pattern when the mouse button is down. Darker than DownColor1 for 3D effect.
- FontEffect: indicates which effect is applied to the caption text. Options: None, Outline, Shadow, Emboss.
- ForeColor: Color used for Caption.
- ForeColor2: Color used for FontEffect on the Caption.
- HoverColor1: First color of the gradient pattern when the mouse is over the button. Darker than HoverColor2 for 3D effect.
- HoverColor2: Second color of the gradient pattern when the mouse is over the button. Lighter than HoverColor1 for 3D effect.
- Mode: Sets behaviour of control. Options: Command Button, Check Box, Panel
- Picture: Image that is centered on control. Black is transparent (change picButton.ForeColor inside ctl file to change maskcolor).
- RepeatInterval: Sets interval (milliseconds) for MouseDownRepeat event. (Useful for repeated command while button is held down)
- Value: indicates position of button when in Check Box mode.
Image: If you have any style at all, you can do much better than this.
Events:
- MouseDownRepeat: Event fires when button is held down and RepeatInterval > 0. Event repeats on Interval timer until MouseUp occurs.
- MouseOff: Event fires when the mouse cursor leaves the controls boundaries (after final MouseMove event)
- MouseOnTimer: Event fires repeatedly while mouse cursor is over control. Timer interval = 20ms.
MX5000 Laser
I wanted to make a post for all the people who purchased this awful product from Logitech. So if you’re searching the net for a fix, maybe I can help.
This keyboard and mouse have been a constant annoyance since I bought them. If you’ve found this post from a web search, you already know the major problem. The thing just won’t maintain it’s connection to the Bluetooth receiver. Mine has been getting worse over the last couple months, until finally last week both the keyboard and mouse would not connect at all, even after uninstalling everything and starting from scratch.
The problem appears to be centered around the underdeveloped implementation of Bluetooth in this application. And the solution I found was to install a version of SetPoint that doesn’t have anything to do with Bluetooth. You won’t be able to connect other devices, but at least the mouse and keyboard will work. Mine have now been working for a week with no problems, and all the advanced features of the keyboard are active.
Step 1. Uninstall SetPoint for MX5000, and reboot (currently version 3.3 with Bluetooth “support”)
Step 2. Go to Logitech’s site, and download SetPoint for the MX3000 Laser (currently version 4.0)
Step 3. Install downloaded SetPoint
Step 4. Press connect on the mouse/receiver/keyboard/receiver (notice the connect buttons are no longer just for show!)
If you really need a Bluetooth hub, I think you’re out of luck with this one until they fix the drivers.
Underuse of the Hourglass
I have a new rule. I must insert mouse cursor changing code at the beginning and end of any block of non-threaded code that takes control away from the user - no matter how short the code is.
I started thinking about this after a program I wrote at work was found to be too slow in testing. Watching how a user interacts with the app made me think “I need more hourglasses”. I then added the couple lines of code to provide that user feedback, in all of the button presses, and menu commands, and sent it back to the user. The reaction: “program is now much faster”. I didn’t improve the speed of the code at all, but that was the perception.
I think this is a common problem in many apps. Users only need a simple indication to tell that the program is working, otherwise the program seems slow or unresponsive. Apps accessing components that have an unknown response time are the worst offenders. The biggest being Internet and hard drive interaction. There is no way to tell access times on either of those, and a programmer can easily fall victim to a solid Internet connection, or a hard drive that isn’t being defragged while running your program.
So my new rule is to overuse the hourglass (AKA the ‘busy circle’ in Vista)
Eventful Calendar
I’ve been using the Google Calendar lately, and it’s not bad. It reminded me of a calendar I made a few years ago, but Google did it a bit better. So I copied Google’s color scheme and changed a few things to make mine more like the Google one.
This code is in the form of an ActiveX Control written in VB6. Source code is provided below.
Included with the project is a class called clsEvent. The control holds a collection of these classes in chronological order, allowing events for multiple months to be stored. Depending on your application, you can add properties and methods to that class, and use the control to hold all of your information. Check out the test app to see this in action.
![]()
Image: Event Calendar Test Application
Event Calendar Control (28kB)
It’s About Time
Here’s a solution to the lack-luster Timer Control in VB6. Instead of requiring a Form, the code is contained in a class module. It is similar to other Timer class implementations you can find on the web, with one major difference. Each timer requires a call-back function, so to avoid having to keep track of the call-back for every class, a Collection is used, and a single call-back function is re-used. This allows you to use the class as a drop-in replacement for the VB Timer Control. The only thing that is required is to create the collection at the beginning of your app, and to make sure your timers are disabled before releasing them.
Take a look at the code to see what I’m talking about. There are also a couple extra features in this class, like a One-Shot mode, and Elapsed Time counter.
How to Create eBook Files for the ETI-2
The following post is related to the eBook Technologies ETI-2 (also the eBookwise reader), and has nothing to do with anyhting else on this site. I’m posting this under “stuff that’s hard to figure out yourself”. So for anyone using this eBook, these are the simple instructions you need to get your content on your device.
Here are some step-by-step instructions on how to turn your text and html files into a format your eBook can understand. This method requires the eBook Publisher software (freeware, version 2.2.2 at time of post) from eBook Technologies and a SmartMedia card with card reader.
Step 1: Open your text document in Word (or other processor), and save in Rich Text Format (.rtf). This is just a text document that supports a little formatting, and makes a good translation to the eBook format. So make your text document look proper here first.
Step 2: Run eBook Publisher. Select menu ‘File’ then ‘New Project’.
Step 3: In the drop-down box next to ‘Build Target:’, select ‘Grayscale Half-VGA’.
Step 4: Select menu ‘File’ then ‘Save’ to save your project. Give the project a file name in the same folder as your .rtf document. The project file ends with .opf
Step 5: Select menu ‘File’ then ‘Import…’. Browse to your .rtf document and open it. You will then be asked to save it as an .odf file. Give this file a name, and save in your project folder with your other files. This file will automatically add to your project, and be listed under ‘Spline Items’ on the main window.
Step 6: Select menu ‘Project’ then ‘Build Edition…’. In the ‘Edition Settings’ window, the first tab is called ‘Edition Info’. Here you can uncheck ‘Require ISBN’, and enter a title, author and language for your content (the other fields can be ignored). Next go to the ‘Bookstore’ tab to change the ‘Bookshelf Category’ - this will control what group the eBook is listed under on your ETI-2. Hit ‘Ok’, and select your project folder to save the eBook.
Step 7: If there are no errors, you have an .imp and .key file in your project folder. Send both of these files to your SmartMedia card, and shove the card back in your eBook.
That’s it…. a bit too involved, but it works well. And the next time I forget how to do it, I can just look on my webpage. If this actually helps anyone, or you know a faster way, leave a comment.
Copy and Vaste
I’ve tried to get use to the Windows shortcuts for Cut, Copy, Paste, but I can’t do it. I find it much more natural to do editing with one hand; since the arrow keys are on the right side of the keyboard, I use Shift-Delete, Ctrl-Insert, and Shift-Insert. These are throwbacks to the DOS age, but Windows still supports them as default cut-copy-paste keys.
So it bugs me when programs over-ride the function of these keys. The latest to do this is the Xilinx ISE Megalopolis of Software. I use this program for some light VHDL work for one of the Xilinx CPLD chips we use in my office. If that were the only problem with ISE, I wouldn’t mind too much, but the program crashing is also very distracting. Every time I compile my project, ISE will either lockup or simply disappear.
After downloading an updated version all of today, (900MB download) and seeing that they have not fixed these serious infractions, I’m putting the Xilinx ISE software team on my list….. right under the grizzly bears.
Adding the Third Dimension
I’ve been looking through my code to find something worth posting. And I think I’ll start with OpenGL in Classic VB (6.0). This is not often done, but is easy to do, and works very well. All that is needed to start typing OpenGL code is this type library by Patrice Scribe. If you are new to OpenGL, you can download this ‘template’ project that demonstrates how to create OpenGL windows in a Picturebox control. You can use this to create multiple Rendering Contexts in a single desktop application, or use a single control to create a fullscreen OpenGL program.
I have also added a couple other classes that I use regularly in my 3D work. One is a coordinate class that can be used to keep track of an objects position, orientation and motion. The other is a very basic color class that can convert between VB colors and OpenGL colors.
This sample project will create two OpenGL windows, and display a double-helix in the top. Both have axes drawn at the origin. You can use the mouse to rotate about the origin with the left mouse button. Holding down the right button, and moving the mouse up and down will zoom in and out.
I’ll dig up some more code later that use these classes, and others, in some interesting ways. OpenGL is very powerful, but it is also somewhat basic…. it takes time to build a good foundation before you start to create a complex graphical app.
Setting up
After setting up this blog, which WordPress has made so easy, I got to thinking about other good setups. In particular, Inno Setup. This is a simple, script-based installer that is very powerful (and free). You may have seen it in action if you’ve installed any of my programs. For most distributions, it’s as good (or better) then the main-stream installers.
Now, why can’t I find a good text editor?
