// 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
}
// 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 );
}