Copyright © 2002-2009 MultiMedia Soft 
Return to index  
 
Using the SDK in Visual C#.NET 
A sample application is available under the directory Samples\VC#.NET 2003 inside the directory used to install the SDK on you PC (default C:\Program Files\3D Button API\samples\VC#.NET 2003
Here follow the steps required to adapt an application to the use of the API: 
  • Copy in your project directory the module file 3dbapi.cs 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: 
  • using abmApi; 
  • Inside the Form class declaration change the following lines: 
  • private System.Windows.Forms.Button button1; 
    private System.Windows.Forms.CheckBox checkBox1; 
    private System.Windows.Forms.GroupBox groupBox1; 
    private System.Windows.Forms.RadioButton radioButton1; 
    private System.Windows.Forms.RadioButton radioButton2; 
     
    With the following lines: 
    private abmApi.abmPushButton button1; 
    private abmApi.abmCheckBox checkBox1; 
    private System.Windows.Forms.GroupBox groupBox1; 
    private abmApi.abmRadioButton radioButton1; 
    private abmApi.abmRadioButton radioButton2; 
     
  • As you can see we have changed the button classes using three classes (abmPushButton, abmCheckBox and abmRadioButton declared inside the abmApi namespace in 3dbapi.cs) that inherit from the standard buttons classes. 
  • Expand the section named "Windows Form Designer generated code" and change the following lines inside the InitializeComponent function: 
  • this.button1 = new System.Windows.Forms.Button(); 
    this.checkBox1 = new System.Windows.Forms.CheckBox(); 
    this.groupBox1 = new System.Windows.Forms.GroupBox(); 
    this.radioButton1 = new System.Windows.Forms.RadioButton(); 
    this.radioButton2 = new System.Windows.Forms.RadioButton(); 
     
    With the following lines: 
    this.button1 = new abmApi.abmButton(); 
    this.checkBox1 = new abmApi.abmCheckBox(); 
    this.groupBox1 = new System.Windows.Forms.GroupBox(); 
    this.radioButton1 = new abmApi.abmRadioButton(); 
    this.radioButton2 = new abmApi.abmRadioButton(); 
     
  • Override the Load event and add the following line of code to the Form_Load function: 
  • abmApiClass.abmContainerSubclass (this.Handle.ToInt32()); 
    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 function: 
  • int hWnd = this.Handle.ToInt32(); 
    abmApiClass.abmButtonSubclassEx (hWnd, button1.Handle.ToInt32(), abmApiClass.BS_PUSHBUTTON); 
    abmApiClass.abmButtonSubclassEx (hWnd, checkBox1.Handle.ToInt32(), abmApiClass.BS_CHECKBOX); 
    abmApiClass.abmButtonSubclassEx (hWnd, radioButton1.Handle.ToInt32(), abmApiClass.BS_RADIOBUTTON); 
    abmApiClass.abmButtonSubclassEx (hWnd, radioButton2.Handle.ToInt32(), abmApiClass.BS_RADIOBUTTON); 
     
  • 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: 
  • abmApiClass.abmSetShape (button1.Handle.ToInt32(), SHAPE_ELLIPSE); 
  • 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: 
  • abmApiClass.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: 
  • abmApiClass.abmContainerUnsubclass (Me.Handle.ToInt32()) 
    There is no need to unsubclass the previously subclassed buttons. 
     
     
     
     
     
     
     
    Copyright © 2002-2009 MultiMedia Soft 
    Return to index