We help IT Professionals succeed at work.
Get Started

what' s going on about this error?

tewe
tewe asked
on
349 Views
Last Modified: 2013-11-20
I HAVE TWO ERROR :
EProgramView.obj : error LNK2001: unresolved external symbol "protected: void __thiscall CEProgramView::OnAbout(void)" (?OnAbout@CEProgramView@@IAEXXZ)
Debug/EProgram.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

EProgram.exe - 2 error(s), 0 warning(s)

MY SOURCE CODE IS :

// EProgramView.cpp : implementation of the CEProgramView class
//

#include "stdafx.h"
#include "EProgram.h"

#include "EProgramSet.h"
#include "EProgramDoc.h"
#include "EProgramView.h"
#include "RSOle1.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEProgramView

IMPLEMENT_DYNCREATE(CEProgramView, CRecordView)

BEGIN_MESSAGE_MAP(CEProgramView, CRecordView)
      //{{AFX_MSG_MAP(CEProgramView)
      ON_COMMAND(ID_EXCELOLE_EXECUTE, OnExceloleExecute)
      ON_UPDATE_COMMAND_UI(ID_EXCELOLE_EXECUTE, OnUpdateExceloleExecute)
      ON_COMMAND(ID_EXCELOLE_LOAD, OnExceloleLoad)
      ON_UPDATE_COMMAND_UI(ID_EXCELOLE_LOAD, OnUpdateExceloleLoad)
      ON_BN_CLICKED(IDC_ABOUT, OnAbout)
      ON_BN_CLICKED(IDC_LOADIMAGE, OnLoadimage)
      ON_WM_PAINT()
      //}}AFX_MSG_MAP
      // Standard printing commands
      ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
      ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
      ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEProgramView construction/destruction

CEProgramView::CEProgramView()
      : CRecordView(CEProgramView::IDD)
{
      //{{AFX_DATA_INIT(CEProgramView)
      m_pSet = NULL;
      //}}AFX_DATA_INIT
      // TODO: add construction code here

}

CEProgramView::~CEProgramView()
{
}

void CEProgramView::DoDataExchange(CDataExchange* pDX)
{
      CRecordView::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CEProgramView)
      DDX_FieldText(pDX, IDC_STOCK_CLOSEPRICE, m_pSet->m_closeprice, m_pSet);
      DDX_FieldText(pDX, IDC_STOCK_DATA, m_pSet->m_data, m_pSet);
      DDX_FieldText(pDX, IDC_STOCK_HIGHPRICE, m_pSet->m_highprice, m_pSet);
      DDX_FieldText(pDX, IDC_STOCK_LOWPRICE, m_pSet->m_lowprice, m_pSet);
      DDX_FieldText(pDX, IDC_STOCK_OPENPRICE, m_pSet->m_openprice, m_pSet);
      DDX_FieldText(pDX, IDC_STOCK_STOCKID, m_pSet->m_stockid, m_pSet);
      //}}AFX_DATA_MAP
}

BOOL CEProgramView::PreCreateWindow(CREATESTRUCT& cs)
{
      // TODO: Modify the Window class or styles here by modifying
      //  the CREATESTRUCT cs

      return CRecordView::PreCreateWindow(cs);
}

void CEProgramView::OnInitialUpdate()
{
      m_pSet = &GetDocument()->m_eProgramSet;
      CRecordView::OnInitialUpdate();
      GetParentFrame()->RecalcLayout();
      ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CEProgramView printing

BOOL CEProgramView::OnPreparePrinting(CPrintInfo* pInfo)
{
      // default preparation
      return DoPreparePrinting(pInfo);
}

void CEProgramView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
      // TODO: add extra initialization before printing
}

void CEProgramView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
      // TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CEProgramView diagnostics

#ifdef _DEBUG
void CEProgramView::AssertValid() const
{
      CRecordView::AssertValid();
}

void CEProgramView::Dump(CDumpContext& dc) const
{
      CRecordView::Dump(dc);
}

CEProgramDoc* CEProgramView::GetDocument() // non-debug version is inline
{
      ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEProgramDoc)));
      return (CEProgramDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CEProgramView database support
CRecordset* CEProgramView::OnGetRecordset()
{
      return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CEProgramView message handlers


void CEProgramView::OnExceloleExecute()
{
   LPDISPATCH pRange, pWorkbooks;
   
   CWnd* pWnd = CWnd::FindWindow("XLMAIN", NULL);
   if (pWnd != NULL) {
     TRACE("Excel window found\n");
     pWnd->ShowWindow(SW_SHOWNORMAL);
     pWnd->UpdateWindow();
     pWnd->BringWindowToTop();
   }

   m_app.SetSheetsInNewWorkbook(1);
   
   VERIFY(pWorkbooks = m_app.GetWorkbooks());
   m_workbooks.AttachDispatch(pWorkbooks);

   LPDISPATCH pWorkbook = NULL;
   if (m_workbooks.GetCount() == 0) {
      // Add returns a Workbook pointer, but we
      //  don't have a Workbook class
      pWorkbook = m_workbooks.Add(); // Save the pointer for
                                     //  later release
   }
   LPDISPATCH pWorksheets = m_app.GetWorksheets();
   ASSERT(pWorksheets != NULL);
   m_worksheets.AttachDispatch(pWorksheets);
   LPDISPATCH pWorksheet = m_worksheets.GetItem(COleVariant((short) 1));

   m_worksheet.AttachDispatch(pWorksheet);
   m_worksheet.Select();

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A1")));
   m_range[0].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A2")));
   m_range[1].AttachDispatch(pRange);
   
   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3")));
   m_range[2].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3"),
         COleVariant("C5")));
   m_range[3].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A6")));
   m_range[4].AttachDispatch(pRange);
   
   m_range[4].SetValue(COleVariant(COleDateTime(1998, 4, 24, 15, 47, 8)));
   // retrieve the stored date and print it as a string
   COleVariant vaTimeDate = m_range[4].GetValue();
   TRACE("returned date type = %d\n", vaTimeDate.vt);
   COleVariant vaTemp;
   vaTemp.ChangeType(VT_BSTR, &vaTimeDate);
   CString str = vaTemp.bstrVal;
   TRACE("date = %s\n", (const char*) str);

   m_range[0].SetValue(COleVariant("test string"));
   
   COleVariant vaResult0 = m_range[0].GetValue();
   if (vaResult0.vt == VT_BSTR) {
     CString str = vaResult0.bstrVal;
     TRACE("vaResult0 = %s\n", (const char*) str);
   }

   m_range[1].SetValue(COleVariant(3.14159));
   
   COleVariant vaResult1 = m_range[1].GetValue();
   if (vaResult1.vt == VT_R8) {
     TRACE("vaResult1 = %f\n", vaResult1.dblVal);
   }
   
   m_range[2].SetFormula(COleVariant("=$A2*2.0"));
   
   COleVariant vaResult2 = m_range[2].GetValue();
   if (vaResult2.vt == VT_R8) {
     TRACE("vaResult2 = %f\n", vaResult2.dblVal);
   }

   COleVariant vaResult2a = m_range[2].GetFormula();
   if (vaResult2a.vt == VT_BSTR) {
     CString str = vaResult2a.bstrVal;
     TRACE("vaResult2a = %s\n", (const char*) str);
   }
   
   m_range[3].FillRight();
   m_range[3].FillDown();
   
// cleanup  
    if (pWorkbook != NULL) {
          pWorkbook->Release();
   }
}

void CEProgramView::OnUpdateExceloleExecute(CCmdUI* pCmdUI)
{
   pCmdUI->Enable(m_app.m_lpDispatch != NULL);
}

void CEProgramView::OnExceloleLoad()
{   // if Excel is already running, attach to it, otherwise start it
   LPDISPATCH pDisp;
   LPUNKNOWN pUnk;
   CLSID clsid;
   TRACE("Entering CExampleView::OnExcelLoad\n");
   BeginWaitCursor();
   ::CLSIDFromProgID(L"Excel.Application.8", &clsid); // from registry
   if(::GetActiveObject(clsid, NULL, &pUnk) == S_OK) {
      VERIFY(pUnk->QueryInterface(IID_IDispatch,
            (void**) &pDisp) == S_OK);
      m_app.AttachDispatch(pDisp);
      pUnk->Release();
      TRACE(" attach complete\n");
  }
   else {
         if(!m_app.CreateDispatch("Excel.Application.8")) {
                  AfxMessageBox("Excel 97 program not found");
         }
       TRACE(" create complete\n");
   }
   EndWaitCursor();
}

void CEProgramView::OnUpdateExceloleLoad(CCmdUI* pCmdUI)
{
   pCmdUI->Enable(m_app.m_lpDispatch == NULL);
}

/////////////////////////////////////////////////////////////
/////////¹Ï§Îµ{¦¡////////////////////////////////////////////
/*
void CEProgramView::OnAbout()
{
      // TODO: Add your control notification handler code here
      CEProgramView About;
    About.DoModal();
}
*/

/*
void CEProgramView::OnSysCommand(UINT nID, LPARAM lParam)
{
      if ((nID & 0xFFF0) == IDM_ABOUTBOX)
      {
            CAboutDlg dlgAbout;
            dlgAbout.DoModal();
      }
      else
      {
            CDialog::OnSysCommand(nID, lParam);
      }
}
*/
void CEProgramView::OnPaint()
{
      CPaintDC dc(this); // device context for painting
      
      // TODO: Add your message handler code here
      
      // Do not call CRecordView::OnPaint() for painting messages
    if(!(OleBmp.m_hObject == NULL))
      {
            CDC dcMem;
            dcMem.CreateCompatibleDC(&dc);//CREATE A MEMORY IMAGE
            CBitmap* pbmpOld;

            BITMAP BmpSize;
            OleBmp.GetBitmap(&BmpSize); // GET IMAGE SIZE

            pbmpOld = dcMem.SelectObject(&OleBmp);
            dc.StretchBlt(5,5,150,200, &dcMem,0,0,BmpSize.bmWidth,BmpSize.bmHeight,SRCCOPY);
            dcMem.SelectObject(pbmpOld);
      }
}

HCURSOR CEProgramView::OnQueryDragIcon()
{
      return (HCURSOR) m_hIcon;
}

BOOL CEProgramView::ReadFromBLOB(CByteArray & DBArray)
{
      CByteArray Array;
      Array.Copy( DBArray);
      // the header of BLOB is OLE stuff like "Paint Brush Application" .... ecc..
      // the len is 78 byte ( I do not know for other headers )
      int HeaderLen =   78 + sizeof(BITMAPFILEHEADER);
      Array.RemoveAt( 0, HeaderLen ); // I cut all Headers

      //some BMP info
      BITMAPINFOHEADER &bmiHeader = *(LPBITMAPINFOHEADER)Array.GetData();
      BITMAPINFO &bmInfo = *(LPBITMAPINFO)Array.GetData();
    int nColors = bmiHeader.biClrUsed ? bmiHeader.biClrUsed : 1 << bmiHeader.biBitCount;

     LPVOID lpDIBBits;
     if( bmInfo.bmiHeader.biBitCount > 8 )
        lpDIBBits = (LPVOID)((LPDWORD)(bmInfo.bmiColors + bmInfo.bmiHeader.biClrUsed) +
                        ((bmInfo.bmiHeader.biCompression == BI_BITFIELDS) ? 3 : 0));
     else
        lpDIBBits = (LPVOID)(bmInfo.bmiColors + nColors);


     CClientDC dc(NULL);
   
       HBITMAP hBmp = CreateDIBitmap( dc.m_hDC,   // handle to device context
                                      &bmiHeader,     // pointer to bitmap size and format data
                                CBM_INIT,       // initialization flag
                                lpDIBBits,      // pointer to initialization data
                                &bmInfo,        // pointer to bitmap color-format data
                                DIB_RGB_COLORS);                // color-data usage
     
      OleBmp.Attach( hBmp );

      Array.RemoveAll(); //Relese Memory

      return TRUE;

}

void CEProgramView::OnLoadimage()
{
      // TODO: Add your control notification handler code here
      
      RSOle db;
      db.Open();
//      db.MoveNext(); // if you want try to load the  next image
      ReadFromBLOB(db.m_Images);
      Invalidate();  
}

MY HEADER FILE IS :

// EProgramView.h : interface of the CEProgramView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_EPROGRAMVIEW_H__49AB1270_4978_11D3_BC84_00A00CC11E38__INCLUDED_)
#define AFX_EPROGRAMVIEW_H__49AB1270_4978_11D3_BC84_00A00CC11E38__INCLUDED_

#include "excel8.h"
// #include "RSOle1.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CEProgramSet;

class CEProgramView : public CRecordView
{
/////////°_©l³]©wexcel//////////

   _Application m_app;
   Range    m_range[5];
   _Worksheet   m_worksheet;
   Workbooks   m_workbooks;
   _Workbook    m_workbook;
   Worksheets   m_worksheets;
   CBitmap OleBmp;

protected: // create from serialization only
      CEProgramView();
      DECLARE_DYNCREATE(CEProgramView)

public:
      //{{AFX_DATA(CEProgramView)
      enum { IDD = IDD_EPROGRAM_FORM };
      CEProgramSet* m_pSet;
      //}}AFX_DATA

// Attributes
public:
      CEProgramDoc* GetDocument();

// Operations
public:

// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CEProgramView)
      public:
      virtual CRecordset* OnGetRecordset();
      virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      virtual void OnInitialUpdate(); // called first time after construct
      virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
      virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
      virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
      //}}AFX_VIRTUAL

// Implementation
public:
      virtual ~CEProgramView();
#ifdef _DEBUG
      virtual void AssertValid() const;
      virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
      HICON m_hIcon;
      //{{AFX_MSG(CEProgramView)
      afx_msg void OnExceloleExecute();
      afx_msg void OnUpdateExceloleExecute(CCmdUI* pCmdUI);
      afx_msg void OnExceloleLoad();
      afx_msg void OnUpdateExceloleLoad(CCmdUI* pCmdUI);
      afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
      afx_msg HCURSOR OnQueryDragIcon();
      afx_msg void OnAbout();
      afx_msg void OnLoadimage();
      afx_msg void OnPaint();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
private:
      BOOL ReadFromBLOB(CByteArray & DBArray);
};

#ifndef _DEBUG  // debug version in EProgramView.cpp
inline CEProgramDoc* CEProgramView::GetDocument()
   { return (CEProgramDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_EPROGRAMVIEW_H__49AB1270_4978_11D3_BC84_00A00CC11E38__INCLUDED_)


HEADER FILE 2 IS:
#if !defined(AFX_RSOLE1_H__C874C0AA_4AD8_11D3_BC88_00A00CC11E38__INCLUDED_)
#define AFX_RSOLE1_H__C874C0AA_4AD8_11D3_BC88_00A00CC11E38__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// RSOle1.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// RSOle DAO recordset

class RSOle : public CDaoRecordset
{
public:
      RSOle(CDaoDatabase* pDatabase = NULL);
      DECLARE_DYNAMIC(RSOle)

// Field/Param Data
      //{{AFX_FIELD(RSOle, CDaoRecordset)
      long      m_ID;
      CString      m_SomeText;
      CByteArray      m_Images;
      //}}AFX_FIELD

// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(RSOle)
      public:
      virtual CString GetDefaultDBName();            // Default database name
      virtual CString GetDefaultSQL();            // Default SQL for Recordset
      virtual void DoFieldExchange(CDaoFieldExchange* pFX);  // RFX support
      //}}AFX_VIRTUAL

// Implementation
#ifdef _DEBUG
      virtual void AssertValid() const;
      virtual void Dump(CDumpContext& dc) const;
#endif
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_RSOLE1_H__C874C0AA_4AD8_11D3_BC88_00A00CC11E38__INCLUDED_)



THANK YOU VERY MUCH!
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE