TWAIN ActiveX Control, Plug-in, Scanner SDK, Component, HTTP Control/SDK

Dynamsoft TWAIN Products

Support Community for TWAIN Control/Component/SDK for Scanning Solutions
* Login   * Register
* FAQ    * Search

It is currently Thu Feb 09, 2012 10:06 am




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Using Dynamic TWAIN in VC++ Non-Dialog Based Applications
PostPosted: Tue Mar 08, 2005 1:40 am 
Offline
User avatar

Joined: Tue Mar 08, 2005 12:23 am
Posts: 1067
Adding Dynamic TWAIN to a Visual C++ Project

1. Start Micorosoft Visual C++.
2. On the File menu, click New to bring up the New dialog box.
3. In the New dialog box, select MFC AppWizard (exe) project type and input DynamicTwainNonDlgApp in the Project Name edit box, as seen in the following figure.

Image

4. Click OK button.
5. In the MFC AppWizard - Step 1 dialog box, select Single document application type and click Finish button.
6. In the New Project Information dialog box, click OK button.
7. On the Project menu, point to Add To Project, then click Components and Controls.
8. In the Components and Controls Gallery dialog box , expand the Registered ActiveX Controls folder, select the DynamicTwain Class, click Insert.
9. In the Microsoft Visual C++ dialog box, click OK.
10. In the Confirm Classes dialog box, click OK.
11. In the Components and Controls Gallery dialog box, click Close to close the dialog box.
12. So far, Dynamic TWAIN ActiveX Control has been imported into DynamicTwainNonDlgApp project, and a wrapper class called CDynamicTwain has been generated by Visual C++ IDE, as seen in the following figure:

Image

Adding Code to The Project

1. On the View menu, click Resource Symbols. In the Resource Symbols dialog box, click New button. In the New Symbol dialog box, input ID_DYNAMICTWAIN in the Name edit box, click OK. Click Close.

2. In the DynamicTwainNonDlgAppView.h file, add include "DynamicTwain.h" just before the CDynamicTwainNonDlgAppView class definition.
#include "DynamicTwain.h"
class CDynamicTwainNonDlgAppView : public CView


3. Add a member variable m_DynamicTwain to the private section of the CDynamicTwainNonDlgAppView class definition.
class CDynamicTwainNonDlgAppView : public CView
{
private:
CDynamicTwain m_DynamicTwain;


4. Add DECLARE_EVENTSINK_MAP() after DECLARE_MESSAGE_MAP() in the DynamicTwainNonDlgAppView.h.
DECLARE_MESSAGE_MAP()
DECLARE_EVENTSINK_MAP()


5. Add a WM_CREATE message handler to class CDynamicTwainNonDlgAppView. Edit the function as the following:
int CDynamicTwainNonDlgAppView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;

if (m_DynamicTwain.Create(NULL,NULL,NULL,CRect(1,1,2,2),this,ID_DYNAMICTWAIN,NULL) == FALSE)
return -1;

m_DynamicTwain.AcquireImage();

return 0;
}

m_DynamicTwain.Create() is to create the ActiveX control.
m_DynamicTwain.AcquireImage() is to start the image acquiring process. This is for demonstrating the event handler only. In really application, it may be more reasonable to add a menu item to start the acquiring.

6. Add event sink map after message map in DynamicTwainNonDlgAppView.cpp.
END_MESSAGE_MAP()
BEGIN_EVENTSINK_MAP(CDynamicTwainNonDlgAppView, CView)
ON_EVENT(CDynamicTwainNonDlgAppView,ID_DYNAMICTWAIN,1,OnPostTransferHandler,VTS_NONE)
END_EVENTSINK_MAP()

1 is the Dispatch ID of the OnPostTranfer event. OnPostTransferHandler is a private member function of CDynamicTwainNonDlgAppView class to handle the event. VTS_NONE indicates the event passes no argument.

7. Add a private member function OnPostTransferHandler to handle the event.
void CDynamicTwainNonDlgAppView::OnPostTransferHandler()
{
MessageBox("OnPostTransfer event fired.");
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

It is currently Thu Feb 09, 2012 10:06 am


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Copyright © 2010 Dynamsoft Corporation. All Rights Reserved. | Knowledge Base | Source Control Blog