Solved

Beginner MFC - How to use functions from a .dll file in program?

Posted on 2004-03-29
3
251 Views
Last Modified: 2013-11-20
Started to try and learn C++ and MFC. I'm a total beginer. I have the following code that creates a simple 200x200 window and shows it. I retyped it so it may have a syntax error somewhere. This code is all in one file MFC.cpp



#include <afxwin.h>

class COurApp: public CWinApp
{
public:
      virtual BOOL InitInstance();
};


class COurWnd: public CFrameWnd
{
public:
      COurWnd()
      {
            CRect rect(0, 0, 200, 200);
            ASSERT(rect.Width() == 200);
            ASSERT(rect.Height() == 200);
            Create(0,"MFC",WS_OVERLAPPEDWINDOW,rect);
      }

};


BOOL COurApp::InitInstance(void)
{
      m_pMainWnd = new COurWnd;
      m_pMainWnd->ShowWindow(m_nCmdShow);
      return TRUE;
};


COurApp AnApplication;


Question:
How do I call functions in a .dll file to use in this progam? I assume I must use a #include<header.h> file. Where would I put the function call in the above MFC program if I want to call it right after the progarm starts.

The function I'm interested in is TWAIN_AcquireNative(0,0) from the EZTW32.dll. I have the EZTWAIN.h file but don't know if I need some other files as well. Wan't to take the acquired image and draw it in this window.

Thanks for any help



0
Comment
Question by:cshorey
  • 2
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10703304
Include EZTWAIN.h to the file from which you want to call Dll functions. Add EZTWAIN.lib file to project linker list (Project - Settings - Link - Additional libraries). After this you can call functions from this Dll.
0
 

Author Comment

by:cshorey
ID: 10703351
O.K., can I do something like this in the InitInstance(void).....
BOOL COurApp::InitInstance(void)
{
HANDLE myhandle;
myhandle = TWAIN_AcquireNative(0,0);
TWAIN_FreeNative(myhandle);


     m_pMainWnd = new COurWnd;
     m_pMainWnd->ShowWindow(m_nCmdShow);
     return TRUE;
};




EZTWAIN claims it returns a handle to a windows dib. TWAIN_FreeNative lets it go when all through.

0
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 10703606
Sure you can do this.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question