Typically, buttons (or any other control for that matter) in VB6 are windows, who's window function is designed to handle clicks. Each window has its own handle called an hWnd. However, this has some downsides, particularly when it comes to security. This is because windows can be "hooked" by malware which can then check to see when you click on a button. If the malware is advanced enough it can hook all the events in all the windows, allowing the hacker who's receiving the info from the malware to tell exactly what windows are being clicked, typed in, etc. This allows them to literally map out every moment of your computer usage. For example, it allows them to tell not only what is being typed at any given moment, but also that the fact that what you typed is in a password box (if the text in the titlebar of the window is "password"), so as to clue them in on the importance of what is being typed (in this example, the fact that it is a password).
This is where my sample program comes into play. It prevents malware from determining every single minutia of what you are doing on your computer, by making all of the activity on the window (as far as malware that hooks hWnds is concerned) to all be happening on the same window, preventing a significant amount of information from being leaked from your computer to a hacker. It does this by implementing windowless controls (buttons in this sample program, but I could also extend it to windowless text boxes, check boxes, etc, if given enough time to code all of that). It works by allowing each button to have its own instance of a class called NonWndButton. The only hWnd in the entire program is the one for Form1. This significantly obfuscates the activity that the user performs on the form.
Here's a description of each of the code files in this program.
Windowless Button.frm: This is the form for the program, and has all the code to handle user interactions, as well as an implementation of the NonWndButtonCallback interface.
NonWndButton.cls: This is the class that has code for just drawing the button and handling events.
NonWndButtonCallback.cls: This is actually an interface, that must be implemented in the form (Form1 in my program). This allows for callbacks from the button class so that code for handling what each button does can be directly coded in the form, rather than in the separate class file for the buttons.
modNonWndButton.bas: This is the module file that handles the framework for the buttons, including a method for adding buttons (button class instances) to the Buttons collection which is also contained in this module, as well as one for redrawing the buttons, which is necessary after a screen clearing (as happens when the Cls method). If you wanted to clear text or other graphics on the screen via Cls, but keep the buttons (as these are the main controls now), you absolutely need to be able to redraw them. Also in this module is a method for scanning the buttons when a click occurs on the form, to determine which button actually got clicked, so as to trigger ButtonUp or ButtonDown event of the correct instance of the button class.
GdiModule.bas: This contains declarations and methods needed to perform the basics of drawing text and rectangles. This is necessary for actually rendering the buttons on the screen.
Attached to this post is a zip file containing the complete source code, including the vbp project file and vbw project layout file.
This is where my sample program comes into play. It prevents malware from determining every single minutia of what you are doing on your computer, by making all of the activity on the window (as far as malware that hooks hWnds is concerned) to all be happening on the same window, preventing a significant amount of information from being leaked from your computer to a hacker. It does this by implementing windowless controls (buttons in this sample program, but I could also extend it to windowless text boxes, check boxes, etc, if given enough time to code all of that). It works by allowing each button to have its own instance of a class called NonWndButton. The only hWnd in the entire program is the one for Form1. This significantly obfuscates the activity that the user performs on the form.
Here's a description of each of the code files in this program.
Windowless Button.frm: This is the form for the program, and has all the code to handle user interactions, as well as an implementation of the NonWndButtonCallback interface.
NonWndButton.cls: This is the class that has code for just drawing the button and handling events.
NonWndButtonCallback.cls: This is actually an interface, that must be implemented in the form (Form1 in my program). This allows for callbacks from the button class so that code for handling what each button does can be directly coded in the form, rather than in the separate class file for the buttons.
modNonWndButton.bas: This is the module file that handles the framework for the buttons, including a method for adding buttons (button class instances) to the Buttons collection which is also contained in this module, as well as one for redrawing the buttons, which is necessary after a screen clearing (as happens when the Cls method). If you wanted to clear text or other graphics on the screen via Cls, but keep the buttons (as these are the main controls now), you absolutely need to be able to redraw them. Also in this module is a method for scanning the buttons when a click occurs on the form, to determine which button actually got clicked, so as to trigger ButtonUp or ButtonDown event of the correct instance of the button class.
GdiModule.bas: This contains declarations and methods needed to perform the basics of drawing text and rectangles. This is necessary for actually rendering the buttons on the screen.
Attached to this post is a zip file containing the complete source code, including the vbp project file and vbw project layout file.