Using the SDK in Visual Basic.NET
A sample application is available under the directory Samples\VB.NET 2003 inside the directory used to install the SDK on you PC (default C:\Program Files\3D Button API\samples\VB.NET 2003)
Here follow the steps required to adapt an application called MyApp to the use of the API:
Copy in your project directory the module file 3dbapi.vb that you can find in C:\Program Files\3D Button API\include and add it to your project; this file contains all the namespaces and classes needed in order to let your application use the 3dbapi.dll library.
The operations that follow must be executed for every Form inside your application.
Open your Form code, in which we suppose to have one Push Button named Button1, one Check Box named Checkbox1 and two Radio Buttons named RadioButton1 and RadioButton2 and add the following lines of code at the beginning of the file:
Imports System.Runtime.InteropServices.Marshal
Imports MyApp.abmApi
Imports MyApp.abmApi.abmApiClass
Expand the section named "Windows Form Designer generated code": although you will see a warning that this code must not be modified using the code editor, don't worry and make the following modifications to the code that declares and creates the buttons instances. Change the following lines of code:
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.CheckBox1 = New System.Windows.Forms.CheckBox()
Me.RadioButton1 = New System.Windows.Forms.RadioButton()
Me.RadioButton2 = New System.Windows.Forms.RadioButton()
With the following lines:
Friend WithEvents Button1 As abmPushButton
Friend WithEvents CheckBox1 As abmCheckBox
Friend WithEvents RadioButton1 As abmRadioButton
Friend WithEvents RadioButton2 As abmRadioButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New abmPushButton()
Me.CheckBox1 = New abmCheckBox()
Me.RadioButton1 = New abmRadioButton()
Me.RadioButton2 = New abmRadioButton()
As you can see we have changed the button classes using three classes (abmPushButton, abmCheckBox and abmRadioButton declared in 3dbapi.vb) that inherit from the standard buttons classes.
Override the Load event and add the following line of code to the Form_Load subroutine:
Dim hWnd As Int32
hWnd = Me.Handle.ToInt32()
abmContainerSubclass (hWnd)
This will cause your Form HWND to be added to a list of windows subclassed by the API.
Now you must subclass every button inside the form, so do the following:
Add the following code to the Form_Load subroutine:
abmButtonSubclassEx (hWnd, Button1.Handle.ToInt32(), BS_PUSHBUTTON)
abmButtonSubclassEx (hWnd, CheckBox1.Handle.ToInt32(), BS_CHECKBOX)
abmButtonSubclassEx (hWnd, RadioButton1.Handle.ToInt32(), BS_RADIOBUTTON)
abmButtonSubclassEx (hWnd, RadioButton2.Handle.ToInt32(), BS_RADIOBUTTON)
As you can see, in VB.NET, differently from VB 6.0, it's not required the subclassing of the GroupBox control that delimits the Radio Buttons group.
At this point you can modify the buttons look & feel and behavior inside the container in two major ways:
One by one using the functions exported by the API; for example if you would like to set a elliptical shape to the button Button1 you will call the following function:
abmSetShape (Button1.Handle.ToInt32(), SHAPE_ELLIPSE)
If you have the Professional Version, all together at the same time using the abmContainerSetting function; for example if you would like to set a elliptical shape to all the buttons inside the form, you will call the following function:
abmContainerSetting (hWnd, SET_SHAPE, SHAPE_ELLIPSE)
Before destroying the Form, in order to avoid memory leaks, remember to unsubclass the Form itself overriding the Closed event through the Form_Closed subroutine in the following way:
abmContainerUnsubclass (Me.Handle.ToInt32())
There is no need to unsubclass the previously subclassed buttons.