|
How to Subclass a Form
|
Total Hit (3750) |
«Code LangId=1»'==============inside a MODULE
Option Explicit
'************************************************************
'API
'************************************************************
Private Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" ( _
ByVal lpPrev
....Read More |
Rating
|
|
|
Win32 Hooks in VB - The vbAccelerator Hook Library
|
Total Hit (2617) |
When a subclass isn't tough enough for the job, its time to move to an even lower-level and more disruptive technique. Win32 Hooks are a method by which you can tap into the Windows message stream for every single message directed to every window in your application. You can modify or even discard m
....Read More |
Rating
|
|
|
|
Enabling Mouse Gestures with a WH_MOUSE hook
|
Total Hit (2333) |
Use of mouse gestures to control application is becoming increasingly common in the more sophisticated web browsers. This sample demonstrates how you can support a range of mouse gestures in a Visual Basic application using a Windows Hook.
|
Rating
|
|
|
Using CBT Hooks to Centre API Dialogs
|
Total Hit (2146) |
Windows sometimes places Common Dialogs and Message Boxes at the "wrong" position on the screen. Whilst there are some ways of working around this for Common Dialogs, a more general solution which applies to any Windows dialog is to use a CBT (Computer-Based Training) Windows Hook. These Hooks provi
....Read More |
Rating
|
|
|
|
vbAccelerator Accelerator Control
|
Total Hit (812) |
If you've ever tried to pick a keyboard accelerator for the menu items Back and Next in your application, you might have discovered a limitation in VB's ability to set up accelerators. IE offers some sensibly chosen keyboard accelerators for its Back, Next, Home shortcuts, using Alt and the arrow an
....Read More |
Rating
|
|
|
Subclassing Without The Crashes
|
Total Hit (2517) |
Prior to VB5, it was impossible to subclass a control without relying on a proprietary custom control. This greatly restricted what you could do if you wanted to play around with some of the neater customisation features - creating a new control was completely out, finding out in detail what was goi
....Read More |
Rating
|
|
|
Emulating Modal Forms
|
Total Hit (1028) |
Sometimes, the restrictions applied when showing a modal form can be restrictive. For example, if your application can have more than one main view window, a modal dialog prevents any other form from being activated whilst the modal dialog is displayed. Another example occurs when you want to try an
....Read More |
Rating
|
|
|
Tile a Bitmap Into a TextBox Background
|
Total Hit (2915) |
This sample presents a small class that allows you to tile a bitmap into the background of a TextBox. Note that the technique only works on multi-line text boxes, as the drawing of single-line TextBoxes is done in a different way and cannot be easily overridden in code.
....Read More |
Rating
|
|
|
Sophisticated Control Over Window Sizing and Moving
|
Total Hit (2036) |
VB's control over moving and sizing isn't much - basically you have the Resize event, as has been the case since VB1. Windows gives you a lot more control over moving and sizing forms if you need it though. For example, try resizing an undocked tool window in MS Office. You will see that the size sn
....Read More |
Rating
|
|
|
Keep Form Titlebars in Focus when ToolWindows are Shown
|
Total Hit (2150) |
The ToolWindow style, introduced with VB4, allowing you to easily create pop-up tool windows with small captions. However, there is (and has always been) a problem with them: whenever the form or a control on it gets the focus, it appears that the main form of your application looses focus. Whilst m
....Read More |
Rating
|
|
|
Generating MouseLeave Events for a Window
|
Total Hit (2420) |
Almost all of the more recent windows control support a feature known as "Hot-Tracking" - that is, when the control appears to highlight when the mouse moves over it, then returns to normal when the mouse leaves. Common examples include the flat toolbar buttons provided with the Windows Commmon cont
....Read More |
Rating
|
|
|
Creating and Responding to System-Wide Hotkeys
|
Total Hit (2040) |
Win32 allows you to set up combinations of key-presses which can be associated with an application on a system-wide scope, called Hotkeys. When a user presses a registered HotKey it doesn't matter which application is active when they pressed it, the hot-key message will get routed to your applicati
....Read More |
Rating
|
|
|
Drawing Buttons, Option Boxes and Check Boxes In Your Own Style
|
Total Hit (2260) |
If you set the Style property for VB's CommandButton, OptionBox or CheckBox controls to Graphical, VB turns the control into an Owner-Draw control. By default VB allows you to associate three pictures with these controls. However, if you've ever tried this you will know that the button draws like a
....Read More |
Rating
|
|
|
Moving Forms and Creating Resize Gripper Boxes
|
Total Hit (1794) |
This article provides code demonstrating how to modify the behaviour of a VB form so that parts of it behave like title bars and resize borders. You can use this code to:
Create windows without a title bar that you can click on anywhere to move around.
Build fake title bars.
Add a Resize Grippe
....Read More |
Rating
|
|
|
Detecting when another application is activated
|
Total Hit (1041) |
In a form, there is a Deactivate event. Exactly what this method is for is hard to determine, because it hardly ever seems to fire. Ok, that's perhaps a little unfair - it never fires. One thing you certainly can't detect without a bit of additional work is when the user Alt-Tabs to another applicat
....Read More |
Rating
|
|
|
Subclassing and Hooking with Machine Code Thunks
|
Total Hit (2088) |
VB's AddressOf is limited in that it can only provide an address to a function within a module, and not one in a class. This makes doing many things with it harder. However, there is a way of getting a callback to a class function, although you need to know a little assembler to do it. Don't worry i
....Read More |
Rating
|
|