Calling an OCX control.

Calling an OCX control.

Postby HunterEC » Thu Mar 12, 2009 7:08 am

Hi guys:

One of my customers needs to use a digital signature pad. The device came with a program that captures the signature and stores it in a folder. The problem is that the user has to manage the mentioned software along ours, and if he/she forgets to hit the save button the signature is lost. The device CD included an OCX control, how can I use it with FiveWin/Harbour ? Thank you.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Calling an OCX control.

Postby Antonio Linares » Thu Mar 12, 2009 7:58 am

Gustavo,

An OCX is an ActiveX control. There are several examples in FWH\samples.

Just look for ACTIVEX in FWH\samples: webexp.prg, media.prg, etc.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calling an OCX control.

Postby HunterEC » Thu Apr 02, 2009 7:29 am

Antonio:

Thank you for your response. Since this is my first OCX experience :oops: I don't know where to begin. I had looked the Media.prg and Webexp.prg samples but don't know what to call when creating the ActiveX object. I do have the properties and methods documentation for the object. This signature pad is from Topaz Systems. Really I don't have any clue. Thank you.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Calling an OCX control.

Postby Antonio Linares » Fri Apr 03, 2009 12:00 pm

Gustavo,

Please check if they provide a Visual Basic or C++ example that you could use as a guide to port it to FWH.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calling an OCX control.

Postby HunterEC » Wed Apr 08, 2009 8:23 am

Antonio: they provide both examples (Visual Basic and C++) but I'm not familiar with none of them. :oops:
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Calling an OCX control.

Postby Antonio Linares » Wed Apr 08, 2009 8:37 am

Gustavo,

If you post them here, then we can review them and help you :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calling an OCX control.

Postby HunterEC » Thu Apr 09, 2009 12:09 am

Code: Select all  Expand view
VERSION 5.00
Object = "{69A40DA0-4D42-11D0-86B0-0000C025864A}#2.23#0"; "SIGPLUS.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
Begin VB.Form Form1
   Caption         =   "Demo OCX"
   ClientHeight    =   3270
   ClientLeft      =   75
   ClientTop       =   300
   ClientWidth     =   6360
   Icon            =   "Ocxcont.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3270
   ScaleWidth      =   6360
   StartUpPosition =   3  'Windows Default
   Begin MSComDlg.CommonDialog CommonDialog1
      Left            =   240
      Top             =   2760
      _ExtentX        =   688
      _ExtentY        =   688
      _Version        =   327681
   End
   Begin VB.CommandButton ok
      Caption         =   "OK"
      Height          =   492
      Left            =   3480
      TabIndex        =   7
      Top             =   2400
      Width           =   1092
   End
   Begin VB.CommandButton about
      Caption         =   "About"
      Height          =   492
      Left            =   4800
      TabIndex        =   6
      Top             =   2400
      Width           =   1212
   End
   Begin VB.CommandButton saveimg
      Caption         =   "Save Img"
      Height          =   492
      Left            =   4800
      TabIndex        =   5
      Top             =   1680
      Width           =   1212
   End
   Begin VB.CommandButton Loadsig
      Caption         =   "Load SIg"
      Height          =   492
      Left            =   4800
      TabIndex        =   4
      Top             =   960
      Width           =   1212
   End
   Begin VB.CommandButton savesig
      Caption         =   "Save SIg"
      Height          =   492
      Left            =   4800
      TabIndex        =   3
      Top             =   240
      Width           =   1212
   End
   Begin VB.CommandButton Stop
      Caption         =   "Stop"
      Height          =   492
      Left            =   3480
      TabIndex        =   2
      Top             =   960
      Width           =   1092
   End
   Begin VB.CommandButton Clear
      Caption         =   "Clear"
      Height          =   492
      Left            =   3480
      TabIndex        =   1
      Top             =   1680
      Width           =   1092
   End
   Begin VB.CommandButton Start
      Caption         =   "Start"
      Height          =   492
      Left            =   3480
      TabIndex        =   0
      Top             =   240
      Width           =   1092
   End
   Begin SIGPLUSLib.SigPlus SigPlus1
      Height          =   2295
      Left            =   240
      TabIndex        =   8
      Top             =   240
      Width           =   3015
      _Version        =   131095
      _ExtentX        =   5318
      _ExtentY        =   4048
      _StockProps     =   0
      TabletLogicalXSize=   2000
      TabletLogicalYSize=   600
      TabletXStart    =   400
      TabletXStop     =   2400
      TabletYStop     =   950
      TabletMode      =   1
      TabletComPort   =   1
      SigBlob         =   "Ocxcont.frx":0442
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()

End Sub

Private Sub about_Click()
    Ocxabout.Show vbModal
    Unload Ocxabout
    Set Ocxabout = Nothing

End Sub

Private Sub Clear_Click()

SigPlus1.ClearTablet

End Sub

Private Sub Loadsig_Click()
'
CancelError is True.
    On Error GoTo ErrHandler
    ' Set filters.
    CommonDialog1.Filter = "Sig Files (*.sig)|*.sig"
    '
Specify default filter.
    CommonDialog1.FilterIndex = 1

    ' Display the Open dialog box.
    CommonDialog1.ShowOpen
    '
Call the open file procedure.
    SigPlus1.ImportSigFile (CommonDialog1.filename)
    Exit Sub

ErrHandler:
' User pressed Cancel button.
    Exit Sub
End Sub


Private Sub ok_Click()
 '
Terminate the program when
 ' The user hits the ok button
 SigPlus1.TabletState = False
 
 
 End
End Sub

Private Sub saveimg_Click()
'
CancelError is True.
    On Error GoTo ErrHandler
    ' Set filters.
    CommonDialog1.Filter = "Bmp Files (*.bmp)|*.bmp"
    '
Specify default filter.
    CommonDialog1.FilterIndex = 1

    ' Display the Open dialog box.
    CommonDialog1.ShowSave
    '
Call the open file procedure.
    SigPlus1.WriteImageFile (CommonDialog1.filename)
    Exit Sub

ErrHandler:
' User pressed Cancel button.
    Exit Sub
End Sub

Private Sub savesig_Click()

'
CancelError is True.
    On Error GoTo ErrHandler
    ' Set filters.
    CommonDialog1.Filter = "Sig Files (*.sig)|*.sig"
    '
Specify default filter.
    CommonDialog1.FilterIndex = 1

    ' Display the Open dialog box.
    CommonDialog1.ShowSave
    '
Call the open file procedure.
    SigPlus1.ExportSigFile (CommonDialog1.filename)
    Exit Sub

ErrHandler:
' User pressed Cancel button.
    Exit Sub
End Sub


Private Sub Start_Click()

SigPlus1.TabletState = 1

End Sub

Private Sub Stop_Click()

SigPlus1.TabletState = 0

End Sub


Code: Select all  Expand view
VERSION 5.00
Begin VB.Form Ocxabout
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "About Demo Ocx"
   ClientHeight    =   2292
   ClientLeft      =   2340
   ClientTop       =   1932
   ClientWidth     =   5736
   ClipControls    =   0   '
False
   Icon            =   "Ocxabout.frx":0000
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   '
False
   Picture         =   "Ocxabout.frx":0442
   ScaleHeight     =   1577.984
   ScaleMode       =   0  'User
   ScaleWidth      =   5380.766
   ShowInTaskbar   =   0   '
False
   Begin VB.PictureBox picIcon
      AutoSize        =   -1  'True
      ClipControls    =   0   '
False
      Height          =   432
      Left            =   0
      Picture         =   "Ocxabout.frx":0884
      ScaleHeight     =   263.118
      ScaleMode       =   0  'User
      ScaleWidth      =   263.118
      TabIndex        =   1
      Top             =   0
      Width           =   432
   End
   Begin VB.CommandButton cmdOK
      Cancel          =   -1  '
True
      Caption         =   "OK"
      Default         =   -1  'True
      Height          =   345
      Left            =   4320
      TabIndex        =   0
      Top             =   1800
      Width           =   1260
   End
   Begin VB.Line Line1
      BorderColor     =   &H00808080&
      BorderStyle     =   6  '
Inside Solid
      Index           =   1
      X1              =   90.055
      X2              =   5315.102
      Y1              =   2313.275
      Y2              =   2313.275
   End
   Begin VB.Label lblDescription
      Caption         =   "Copyright 1996"
      ForeColor       =   &H00000000&
      Height          =   324
      Left            =   1056
      TabIndex        =   2
      Top             =   1200
      Width           =   3888
   End
   Begin VB.Label lblTitle
      Caption         =   "Demo OCX"
      ForeColor       =   &H00000000&
      Height          =   480
      Left            =   1050
      TabIndex        =   3
      Top             =   240
      Width           =   3885
   End
   Begin VB.Line Line1
      BorderColor     =   &H00FFFFFF&
      BorderWidth     =   2
      Index           =   0
      X1              =   98.497
      X2              =   5309.473
      Y1              =   1697.779
      Y2              =   1697.779
   End
   Begin VB.Label lblVersion
      Caption         =   "Version 1.10"
      Height          =   225
      Left            =   1050
      TabIndex        =   4
      Top             =   780
      Width           =   3885
   End
End
Attribute VB_Name = "Ocxabout"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' Reg Key Security Options...
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
                       KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
                       KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
                     
'
Reg Key ROOT Types...
Const HKEY_LOCAL_MACHINE = &H80000002
Const ERROR_SUCCESS = 0
Const REG_SZ = 1                         ' Unicode nul terminated string
Const REG_DWORD = 4                      '
32-bit number

Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
Const gREGVALSYSINFOLOC = "MSINFO"
Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
Const gREGVALSYSINFO = "PATH"

Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long


Private Sub cmdSysInfo_Click()
  Call StartSysInfo
End Sub

Private Sub cmdOK_Click()
  Unload Me
End Sub

Private Sub Form_Load()
    Me.Caption = "About " & App.Title
    lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
    lblTitle.Caption = App.Title
End Sub

Public Sub StartSysInfo()
    On Error GoTo SysInfoErr
 
    Dim rc As Long
    Dim SysInfoPath As String
   
    ' Try To Get System Info Program Path\Name From Registry...
    If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
    '
Try To Get System Info Program Path Only From Registry...
    ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
        ' Validate Existance Of Known 32 Bit File Version
        If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
            SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
           
        '
Error - File Can Not Be Found...
        Else
            GoTo SysInfoErr
        End If
    ' Error - Registry Entry Can Not Be Found...
    Else
        GoTo SysInfoErr
    End If
   
    Call Shell(SysInfoPath, vbNormalFocus)
   
    Exit Sub
SysInfoErr:
    MsgBox "System Information Is Unavailable At This Time", vbOKOnly
End Sub

Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
    Dim i As Long                                           '
Loop Counter
    Dim rc As Long                                          ' Return Code
    Dim hKey As Long                                        '
Handle To An Open Registry Key
    Dim hDepth As Long                                      '
    Dim KeyValType As Long                                  '
Data Type Of A Registry Key
    Dim tmpVal As String                                    ' Tempory Storage For A Registry Key Value
    Dim KeyValSize As Long                                  '
Size Of Registry Key Variable
    '------------------------------------------------------------
    '
Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
    '------------------------------------------------------------
    rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) '
Open Registry Key
   
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Error...
   
    tmpVal = String$(1024, 0)                             '
Allocate Variable Space
    KeyValSize = 1024                                       ' Mark Variable Size
   
    '
------------------------------------------------------------
    ' Retrieve Registry Key Value...
    '
------------------------------------------------------------
    rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
                         KeyValType, tmpVal, KeyValSize)    ' Get/Create Key Value
                       
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          '
Handle Errors
   
    If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 Adds Null Terminated String...
        tmpVal = Left(tmpVal, KeyValSize - 1)               '
Null Found, Extract From String
    Else                                                    ' WinNT Does NOT Null Terminate String...
        tmpVal = Left(tmpVal, KeyValSize)                   '
Null Not Found, Extract String Only
    End If
    '------------------------------------------------------------
    '
Determine Key Value Type For Conversion...
    '------------------------------------------------------------
    Select Case KeyValType                                  '
Search Data Types...
    Case REG_SZ                                             ' String Registry Key Data Type
        KeyVal = tmpVal                                     '
Copy String Value
    Case REG_DWORD                                          ' Double Word Registry Key Data Type
        For i = Len(tmpVal) To 1 Step -1                    '
Convert Each Bit
            KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' Build Value Char. By Char.
        Next
        KeyVal = Format$("&h" + KeyVal)                     '
Convert Double Word To String
    End Select
   
    GetKeyValue = True                                      ' Return Success
    rc = RegCloseKey(hKey)                                  '
Close Registry Key
    Exit Function                                           ' Exit
   
GetKeyError:      '
Cleanup After An Error Has Occured...
    KeyVal = ""                                             ' Set Return Val To Empty String
    GetKeyValue = False                                     '
Return Failure
    rc = RegCloseKey(hKey)                                  ' Close Registry Key
End Function
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Calling an OCX control. (C++)

Postby HunterEC » Thu Apr 09, 2009 12:13 am

Code: Select all  Expand view
// DemoOCXDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DemoOCX.h"
#include "DemoOCXDlg.h"
#include "occimpl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


//#define   SetSigDataTest
//#define   AutoActive

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
    CAboutDlg();

// Dialog Data
    //{{AFX_DATA(CAboutDlg)
    enum { IDD = IDD_ABOUTBOX };
    //}}AFX_DATA

    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAboutDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL

// Implementation
protected:
    //{{AFX_MSG(CAboutDlg)
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
    //{{AFX_DATA_INIT(CAboutDlg)
    //}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CAboutDlg)
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
    //{{AFX_MSG_MAP(CAboutDlg)
        // No message handlers
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDemoOCXDlg dialog

CDemoOCXDlg::CDemoOCXDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CDemoOCXDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CDemoOCXDlg)
    m_KeyReceipt = _T("");
    m_SigReceipt = _T("");
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDemoOCXDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CDemoOCXDlg)
    DDX_Text(pDX, IDC_KeyReceipt, m_KeyReceipt);
    DDX_Text(pDX, IDC_SigReceipt, m_SigReceipt);
    DDX_Control(pDX, IDC_SIGPLUSCTRL1, m_Sig1);
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDemoOCXDlg, CDialog)
    //{{AFX_MSG_MAP(CDemoOCXDlg)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_BN_CLICKED(IDC_Activate, OnActivate)
    ON_BN_CLICKED(IDC_InActivate, OnInActivate)
    ON_BN_CLICKED(IDC_Properties, OnProperties)
    ON_BN_CLICKED(IDC_SaveSig, OnSaveSig)
    ON_BN_CLICKED(IDC_LoadSig, OnLoadSig)
    ON_BN_CLICKED(IDC_SaveImage, OnSaveImage)
    ON_BN_CLICKED(IDC_Clear, OnClear)
    ON_BN_CLICKED(IDC_ABOUT, OnAbout)
    ON_BN_CLICKED(IDC_AutoKey, OnAutoKey)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDemoOCXDlg message handlers

BOOL CDemoOCXDlg::OnInitDialog()
{
BSTR        TestStr = NULL;
char*       TestPtr;
int     i;
CRect       SigRect;
CPoint  SigPoint;
CRect       DlgRect;
CRect       DlgRect2;
int     Offset;
int     SigWidth;
int     SigHeight;
int     MaxHeight;
CString OldTimeStamp;
   
CDialog::OnInitDialog();

    // Add "About..." menu item to system menu.

    // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    CString strAboutMenu;
    strAboutMenu.LoadString(IDS_ABOUTBOX);
    if (!strAboutMenu.IsEmpty())
    {
        pSysMenu->AppendMenu(MF_SEPARATOR);
        pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }

    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);         // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon
   
    // TODO: Add extra initialization here
   
#ifdef  AutoActive
    m_Sig1.SetTabletState( TRUE );
#endif
    m_Sig1.SetDisplayAnnotatePosY( 120 );
    m_Sig1.SetAnnotate( "Topaz\nSystems" );
    m_Sig1.SetDisplayAnnotate( TRUE );

    m_Sig1.SetTimeStamp( "TimeStamp" );
    m_Sig1.SetTimeStamp( "TimeStamp And More" );
    OldTimeStamp = m_Sig1.GetTimeStamp();
    m_Sig1.AutoTimeStamp();
    m_Sig1.SetDisplayTimeStamp( TRUE );
    m_Sig1.SetSaveSigInfo( TRUE );

    TestStr = SysAllocStringByteLen( NULL, 10 );
    TestPtr = (char*)TestStr;
    for( i = 0; i < 10; i++ )
        {
        TestPtr[ i ] = i;
        }


    m_Sig1.SetKey( &TestStr );
    SysFreeString( TestStr );

    m_Sig1.GetKey( &TestStr );
    SysFreeString( TestStr );


    m_KeyReceipt = m_Sig1.GetKeyReceiptAscii();
    m_SigReceipt = m_Sig1.GetSigReceiptAscii();

    GetClientRect( &DlgRect2 );
    GetWindowRect( &DlgRect );
    Offset = DlgRect.Height() - DlgRect2.Height() - 3;

    m_Sig1.GetWindowRect( &SigRect );
    SigPoint = SigRect.TopLeft();
    SigWidth = SigRect.Width();
    MaxHeight = SigRect.Height();

    SigHeight = m_Sig1.GetTabletLogicalYSize() * SigWidth;
    SigHeight /= m_Sig1.GetTabletLogicalXSize();
    if ( SigHeight > MaxHeight )
        {
        SigHeight = MaxHeight;
        }

    m_Sig1.SetWindowPos( &wndTopMost, SigPoint.x, SigPoint.y - Offset, SigWidth, SigHeight, SWP_FRAMECHANGED );


    UpdateData( FALSE );

    return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDemoOCXDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
        CAboutDlg dlgAbout;
        dlgAbout.DoModal();
    }
    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDemoOCXDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // device context for painting

        SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

        // Center icon in client rectangle
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        // Draw the icon
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDemoOCXDlg::OnQueryDragIcon()
{
    return (HCURSOR) m_hIcon;
}

void CDemoOCXDlg::OnActivate()
{
//int   NewState;

//m_Sig1.SetTabletMode( 0x80 );
m_Sig1.SetTabletState( /*TRUE*/ 1 );
//NewState = m_Sig1.GetTabletState();
}

void CDemoOCXDlg::OnInActivate()
{
m_Sig1.SetTabletState( FALSE );
m_SigReceipt = m_Sig1.GetSigReceiptAscii();
UpdateData( FALSE );
}



void
CDemoOCXDlg::OnProperties()

{
int     Count;
//if (m_Sig1.m_pCtrlSite == NULL)
//  return;
//m_Sig1.m_pCtrlSite->DoVerb( OLEIVERB_PROPERTIES );
m_Sig1.Properties();

Count = m_Sig1.NumberOfTabletPoints();

//CFile theFile;
//theFile.Open( "Test.prp", CFile::modeWrite);
//CArchive archive(&theFile, CArchive::store);

//m_Sig1.Serialize( archive );

//archive.Close();
//theFile.Close();
}

//void CSigPlus::Properties()
//
//{
//if (m_pCtrlSite == NULL)
//  return;
//m_pCtrlSite->DoVerb( OLEIVERB_PROPERTIES );
//}


#define UseGetSigString

void
CDemoOCXDlg::OnSaveSig()

{
CFileDialog dlg( FALSE,_T("SIG"),_T("*.SIG"),
                 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
                 _T("Signatures (*.SIG)|*.SIG|"));


if( dlg.DoModal()==IDOK )
    {
#ifdef  SetSigDataTest
    BSTR        TestStr = NULL;
    CRect       rect;
#endif
    CString FileName;
    wchar_t     Buffer[ 256 ];
    char            BufferA[ 256 ];

    sprintf( BufferA, "0123456789ABCDEF" );
    mbstowcs( Buffer, BufferA, strlen( BufferA ));

    FileName = dlg.GetPathName();
    m_Sig1.ExportSigFile( FileName );

//
//      The following section illustrates the use of Get/Set Sig Data
//
#ifdef  SetSigDataTest

    m_Sig1.GetSigData( &TestStr );
    GetClientRect(&rect);
    InvalidateRect(&rect);
    m_Sig1.ClearTablet( );
    m_Sig1.SetSigData( &TestStr );
    SysFreeString( TestStr );

#endif

#ifdef  UseGetSigString
    CString TheSig;

    TheSig = m_Sig1.GetSigString();
    m_Sig1.ClearTablet();
    m_Sig1.SetSigString( TheSig );

#endif
    }
}




void
CDemoOCXDlg::OnLoadSig()

{
CFileDialog dlg( TRUE,_T("SIG"),_T("*.SIG"),
                 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
                 _T("Signatures (*.SIG)|*.SIG|"));
if( dlg.DoModal()==IDOK )
    {
    CString FileName;
    FileName = dlg.GetPathName();

    m_Sig1.ImportSigFile( FileName );
    m_SigReceipt = m_Sig1.GetSigReceiptAscii();
    UpdateData( FALSE );
    }
   
}




void
CDemoOCXDlg::OnSaveImage()

{
CFileDialog dlg( FALSE,_T("*"),_T("*.*"),
                 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
                 _T("Images (*.*)|*.*|"));
if( dlg.DoModal()==IDOK )
    {
    CString FileName;
    FileName = dlg.GetPathName();
    m_Sig1.WriteImageFile( FileName );
    }
}



void
CDemoOCXDlg::OnClear()

{
CRect rect;
//GetClientRect(&rect);
//InvalidateRect(&rect);
m_Sig1.ClearTablet( );

m_SigReceipt = m_Sig1.GetSigReceiptAscii();
UpdateData( FALSE );
}




void
CDemoOCXDlg::OnAbout()

{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}

void CDemoOCXDlg::OnAutoKey()

{
CFileDialog dlg( TRUE,_T("Any"),_T("*.*"),
                 OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
                 _T("All Files (*.*)|*.*|"));
if( dlg.DoModal()==IDOK )
    {
    CString         FileName;
    BSTR                TestStr = NULL;
    unsigned int    i;
    unsigned char   Buffer[ 512 ];

    FileName = dlg.GetPathName();

#ifdef  OldWay
    FILE*               InFile;
    int             Count;
    char*               TestPtr;

    m_Sig1.AutoKeyStart();
    InFile = fopen( FileName, "rb" );
    if ( InFile == NULL )
        {
        return;
        }
    while ( 1 )
        {
        Count = fread( Buffer, 1, 512, InFile );
        if ( Count == 0 )
            {
            break;
            }
        TestStr = SysAllocStringByteLen( NULL, Count );
        TestPtr = (char*)TestStr;
        for( i = 0; i < Count; i++ )
            {
            TestPtr[ i ] = Buffer[ i ];
            }
        m_Sig1.AutoKeyAddData( &TestStr );
        SysFreeString( TestStr );
        }
    m_Sig1.AutoKeyFinish();
    fclose( InFile );
#else
    strcpy( (char*)Buffer, FileName );
    TestStr = SysAllocStringLen( NULL, strlen( (char*)Buffer ) + 1 );
    for( i = 0; i < strlen( (char*)Buffer ) + 1; i++ )
        {
        TestStr[ i ] = (char)Buffer[ i ];
        }
    m_Sig1.AutoKeyAddData( &TestStr );
    SysFreeString( TestStr );
   
#endif
    }
m_KeyReceipt = m_Sig1.GetKeyReceiptAscii();
UpdateData( FALSE );
}

void CDemoOCXDlg::OnButton1()
{
    // TODO: Add your control notification handler code here
   
}
 


Code: Select all  Expand view
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++

// NOTE: Do not modify the contents of this file.  If this class is regenerated by
//  Microsoft Visual C++, your modifications will be overwritten.


#include "stdafx.h"
#include "sigplus.h"
#include "occimpl.h"

/////////////////////////////////////////////////////////////////////////////
// CSigPlus

IMPLEMENT_DYNCREATE(CSigPlus, CWnd)

/////////////////////////////////////////////////////////////////////////////
// CSigPlus properties

BOOL CSigPlus::GetTabletState()
{
    BOOL result;
    GetProperty(0x1, VT_BOOL, (void*)&result);
    return result;
}

void CSigPlus::SetTabletState(BOOL propVal)
{
    SetProperty(0x1, VT_BOOL, propVal);
}

short CSigPlus::GetImageFileFormat()
{
    short result;
    GetProperty(0x2, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetImageFileFormat(short propVal)
{
    SetProperty(0x2, VT_I2, propVal);
}

short CSigPlus::GetImageXSize()
{
    short result;
    GetProperty(0x3, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetImageXSize(short propVal)
{
    SetProperty(0x3, VT_I2, propVal);
}

short CSigPlus::GetImageYSize()
{
    short result;
    GetProperty(0x4, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetImageYSize(short propVal)
{
    SetProperty(0x4, VT_I2, propVal);
}

short CSigPlus::GetImagePenWidth()
{
    short result;
    GetProperty(0x5, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetImagePenWidth(short propVal)
{
    SetProperty(0x5, VT_I2, propVal);
}

short CSigPlus::GetTabletLogicalXSize()
{
    short result;
    GetProperty(0x6, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletLogicalXSize(short propVal)
{
    SetProperty(0x6, VT_I2, propVal);
}

short CSigPlus::GetTabletLogicalYSize()
{
    short result;
    GetProperty(0x7, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletLogicalYSize(short propVal)
{
    SetProperty(0x7, VT_I2, propVal);
}

short CSigPlus::GetTabletXStart()
{
    short result;
    GetProperty(0x8, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletXStart(short propVal)
{
    SetProperty(0x8, VT_I2, propVal);
}

short CSigPlus::GetTabletYStart()
{
    short result;
    GetProperty(0x9, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletYStart(short propVal)
{
    SetProperty(0x9, VT_I2, propVal);
}

short CSigPlus::GetTabletXStop()
{
    short result;
    GetProperty(0xa, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletXStop(short propVal)
{
    SetProperty(0xa, VT_I2, propVal);
}

short CSigPlus::GetTabletYStop()
{
    short result;
    GetProperty(0xb, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletYStop(short propVal)
{
    SetProperty(0xb, VT_I2, propVal);
}

short CSigPlus::GetTabletFilterPoints()
{
    short result;
    GetProperty(0xc, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletFilterPoints(short propVal)
{
    SetProperty(0xc, VT_I2, propVal);
}

short CSigPlus::GetTabletTimingAdvance()
{
    short result;
    GetProperty(0xd, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletTimingAdvance(short propVal)
{
    SetProperty(0xd, VT_I2, propVal);
}

short CSigPlus::GetTabletComPort()
{
    short result;
    GetProperty(0xe, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetTabletComPort(short propVal)
{
    SetProperty(0xe, VT_I2, propVal);
}

short CSigPlus::GetDisplayPenWidth()
{
    short result;
    GetProperty(0xf, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetDisplayPenWidth(short propVal)
{
    SetProperty(0xf, VT_I2, propVal);
}

BOOL CSigPlus::GetTabletLCDMode()
{
    BOOL result;
    GetProperty(0x10, VT_BOOL, (void*)&result);
    return result;
}

void CSigPlus::SetTabletLCDMode(BOOL propVal)
{
    SetProperty(0x10, VT_BOOL, propVal);
}

long CSigPlus::GetTabletBaudRate()
{
    long result;
    GetProperty(0x11, VT_I4, (void*)&result);
    return result;
}

void CSigPlus::SetTabletBaudRate(long propVal)
{
    SetProperty(0x11, VT_I4, propVal);
}

short CSigPlus::GetSigCompressionMode()
{
    short result;
    GetProperty(0x12, VT_I2, (void*)&result);
    return result;
}

void CSigPlus::SetSigCompressionMode(short propVal)
{
    SetProperty(0x12, VT_I2, propVal);
}

BOOL CSigPlus::GetOpaqueMode()
{
    BOOL result;
    GetProperty(0x13, VT_BOOL, (void*)&result);
    return result;
}

void CSigPlus::SetOpaqueMode(BOOL propVal)
{
    SetProperty(0x13, VT_BOOL, propVal);
}

CString CSigPlus::GetTimeStamp()
{
    CString result;
    GetProperty(0x14, VT_BSTR, (void*)&result);
    return result;
}

void CSigPlus::SetTimeStamp(LPCTSTR propVal)
{
    SetProperty(0x14, VT_BSTR, propVal);
}

CString CSigPlus::GetAnnotate()
{
    CString result;
    GetProperty(0x15, VT_BSTR, (void*)&result);
    return result;
}

void CSigPlus::SetAnnotate(LPCTSTR propVal)
{
    SetProperty(0x15, VT_BSTR, propVal);
}

BOOL CSigPlus::GetDisplayTimeStamp()
{
    BOOL result;
    GetProperty(0x16, VT_BOOL, (void*)&result);
    return result;
}

void CSigPlus::SetDisplayTimeStamp(BOOL propVal)
{
    SetProperty(0x16, VT_BOOL, propVal);
}

BOOL CSigPlus::GetImageTimeStamp()
{
    BOOL result;
    GetProperty(0x17, VT_BOOL, (void*)&result);
    return result;
}

void CSigPlus::SetImageTimeStamp(BOOL propVal)
{
    SetProperty(0x17, VT_BOOL, propVal);
}

BOOL CSigPlus::GetDisplayAnnotate()
{
    BOOL result;
    GetProperty(0x18, VT_BOOL, (void*)&result);
    return result;
}

void CSigPlus::SetDisplayAnnotate(BOOL propVal)
{
    SetProperty(0x18, VT_BOOL, propVal);
}

BOOL CSigPlus::GetImageAnnotate()
{
    BOOL result;
    GetProperty(0x19, VT_BOOL, (void*)&result);
    return result;
}

void CSigPlus::SetImageAnnotate(BOOL propVal)
{
    SetProperty(0x19, VT_BOOL, propVal);
}

/////////////////////////////////////////////////////////////////////////////
// CSigPlus operations

void CSigPlus::ClearTablet()
{
    InvokeHelper(0x1a, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}

BOOL CSigPlus::ExportSigFile(LPCTSTR FileName)
{
    BOOL result;
    static BYTE parms[] =
        VTS_BSTR;
    InvokeHelper(0x1b, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
        FileName);
    return result;
}

BOOL CSigPlus::ImportSigFile(LPCTSTR FileName)
{
    BOOL result;
    static BYTE parms[] =
        VTS_BSTR;
    InvokeHelper(0x1c, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
        FileName);
    return result;
}

short CSigPlus::NumberOfTabletPoints()
{
    short result;
    InvokeHelper(0x1d, DISPATCH_METHOD, VT_I2, (void*)&result, NULL);
    return result;
}

BOOL CSigPlus::WriteImageFile(LPCTSTR FileName)
{
    BOOL result;
    static BYTE parms[] =
        VTS_BSTR;
    InvokeHelper(0x1e, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
        FileName);
    return result;
}

short CSigPlus::GetNumberOfStrokes()
{
    short result;
    InvokeHelper(0x1f, DISPATCH_METHOD, VT_I2, (void*)&result, NULL);
    return result;
}

short CSigPlus::GetNumPointsForStroke(short StrokeNumber)
{
    short result;
    static BYTE parms[] =
        VTS_I2;
    InvokeHelper(0x20, DISPATCH_METHOD, VT_I2, (void*)&result, parms,
        StrokeNumber);
    return result;
}

void CSigPlus::HighlightStroke(short StrokeNumber)
{
    static BYTE parms[] =
        VTS_I2;
    InvokeHelper(0x21, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
         StrokeNumber);
}

void CSigPlus::HighlightPoint(short PointNumber)
{
    static BYTE parms[] =
        VTS_I2;
    InvokeHelper(0x22, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
         PointNumber);
}

void CSigPlus::SetDisplayTimeStampData(short X, short Y, short Size)
{
    static BYTE parms[] =
        VTS_I2 VTS_I2 VTS_I2;
    InvokeHelper(0x23, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
         X, Y, Size);
}

void CSigPlus::SetImageTimeStampData(short X, short Y, short Size)
{
    static BYTE parms[] =
        VTS_I2 VTS_I2 VTS_I2;
    InvokeHelper(0x24, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
         X, Y, Size);
}

void CSigPlus::SetDisplayAnnotateData(short X, short Y, short Size)
{
    static BYTE parms[] =
        VTS_I2 VTS_I2 VTS_I2;
    InvokeHelper(0x25, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
         X, Y, Size);
}

void CSigPlus::SetImageAnnotateData(short X, short Y, short Size)
{
    static BYTE parms[] =
        VTS_I2 VTS_I2 VTS_I2;
    InvokeHelper(0x26, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
         X, Y, Size);
}

void CSigPlus::AboutBox()
{
    InvokeHelper(0xfffffdd8, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}


void CSigPlus::Properties()

{
if (m_pCtrlSite == NULL)
    return;
m_pCtrlSite->DoVerb( OLEIVERB_PROPERTIES );
}
 


Code: Select all  Expand view
// DemoOCX.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "DemoOCX.h"
#include "DemoOCXDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDemoOCXApp

BEGIN_MESSAGE_MAP(CDemoOCXApp, CWinApp)
    //{{AFX_MSG_MAP(CDemoOCXApp)
        // NOTE - the ClassWizard will add and remove mapping macros here.
        //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG
    ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDemoOCXApp construction

CDemoOCXApp::CDemoOCXApp()
{
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CDemoOCXApp object

CDemoOCXApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CDemoOCXApp initialization

BOOL CDemoOCXApp::InitInstance()
{
    AfxEnableControlContainer();

    // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.

#ifdef _AFXDLL
    Enable3dControls();         // Call this when using MFC in a shared DLL
#else
    Enable3dControlsStatic();   // Call this when linking to MFC statically
#endif

    CDemoOCXDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with Cancel
    }

    // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
}
 


Code: Select all  Expand view
// DemoOCX.h : main header file for the DEMOOCX application
//

#ifndef __AFXWIN_H__
    #error include 'stdafx.h' before including this file for PCH
#endif

#include "resource.h"       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CDemoOCXApp:
// See DemoOCX.cpp for the implementation of this class
//

class CDemoOCXApp : public CWinApp
{
public:
    CDemoOCXApp();

// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CDemoOCXApp)
    public:
    virtual BOOL InitInstance();
    //}}AFX_VIRTUAL

// Implementation

    //{{AFX_MSG(CDemoOCXApp)
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
 
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Calling an OCX control.

Postby jllinas » Sun Apr 12, 2009 2:20 pm

HunterEC,

Did you do it ?

Regards,
Julio Llinás
Visita mi Blog en http://mangucybernetico.blogspot.com/
xHarbour 1.1.0 + FWH810 + Borland 5.5.1
User avatar
jllinas
 
Posts: 189
Joined: Fri Oct 14, 2005 12:33 am
Location: Santo Domingo, Dominican Republic

Re: Calling an OCX control.

Postby Antonio Linares » Sun Apr 12, 2009 4:07 pm

Gustavo,

First step to proceed is to locate its ProgId.

In example for Microsoft Internet Explorer we use: "Shell.Explorer"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 55 guests