-Ray
Simon wrote:
> Hi All,
> Can you tell me how to clear these error message?
> Regards
> Simon
> =================================================
> --------------------Configuration: ex6_1 - Win32
> Debug--------------------
> Compiling resources...
> Linking...
> ex6_1.obj : error LNK2001: unresolved external symbol "public: void
> __thiscall MyMainWindow::OnUpdateWidthThick(class CCmdUI *)"
> (?OnUpdateWidthThick@MyMainWindow@@QAEXPAVCCmdUI@@@Z)
> Debug/ex6_1.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
>
> ex6_1.exe - 2 error(s), 0 warning(s)
> =====================================
> #include <afxwin.h>
> #include "resource.h"
>
> // Class for the application.
> class MyApp:public CWinApp
> {
> public:
> BOOL InitInstance();
> };
>
> MyApp myApp;
>
> // Class for the main window.
> class MyMainWindow:public CFrameWnd
> {
> public:
> MyMainWindow();
> // attributes
> private:
> UINT PenStyle, PenWidth;
> int TextHeight, TextWidth;
> CString szPenStyle[7];
> // Operations
> public:
> void OnFile(UINT nCmdID);
> void OnEdit(UINT nCmdID);
> void OnExit();
> void OnStyle(UINT nCmdID);
> void OnWidthThin();
> void OnWidthThick();
> afx_msg void OnUpdateWidthThin(CCmdUI*);
> afx_msg void OnUpdateWidthThick(CCmdUI*);
> afx_msg void OnUpdateStyle(CCmdUI*);
> void OnHelp();
> void OnAbout();
> afx_msg void OnPaint();
>
> DECLARE_MESSAGE_MAP()
> };
>
> BEGIN_MESSAGE_MAP(MyMainWindow, CFrameWnd)
> ON_WM_PAINT()
> ON_COMMAND_RANGE(IDM_NEW, IDM_PRINT, OnFile)
> ON_COMMAND(IDM_EXIT, OnExit)
> ON_COMMAND_RANGE(IDM_UNDO, IDM_DELETE, OnEdit)
> ON_COMMAND_RANGE(IDM_SOLID, IDM_INSIDEFRAME, OnStyle)
> ON_COMMAND(IDM_THIN, OnWidthThin)
> ON_COMMAND(IDM_THICK, OnWidthThick)
> ON_UPDATE_COMMAND_UI(IDM_THIN, OnUpdateWidthThin)
> ON_UPDATE_COMMAND_UI(IDM_THICK, OnUpdateWidthThick)
> ON_UPDATE_COMMAND_UI_RANGE(IDM_SOLID, IDM_INSIDEFRAME, OnUpdateStyle)
> ON_COMMAND(IDM_HELP, OnHelp)
> ON_COMMAND(IDM_ABOUT, OnAbout)
> END_MESSAGE_MAP()
>
> // This is the main window's constructor.
> MyMainWindow::MyMainWindow()
> {
> Create(NULL,"Menu Demo", WS_OVERLAPPEDWINDOW, rectDefault, NULL,
> "MyMenu");
> TEXTMETRIC tm;
> CPaintDC dc(this);
> dc.GetTextMetrics(&tm);
> TextHeight = tm.tmHeight;
> TextWidth = tm.tmAveCharWidth * 20;
> PenStyle = IDM_SOLID;
> PenWidth = 1;
> szPenStyle[0]="PS_SOLID";
> szPenStyle[1]="PS_DASH";
> szPenStyle[2]="PS_DOT";
> szPenStyle[3]="PS_DASHDOT";
> szPenStyle[4]="PS_DASHDOTDOT";
> szPenStyle[5]="PS_NULL";
> szPenStyle[6]="PS_INSIDEFRAME";
> }
>
> // This function responds to any menu command in the file menu.
> void MyMainWindow::OnFile(UINT /*nCmdID*/)
> {
> MessageBox("Command Not Implemented !", "File Message",
> MB_OK|MB_ICONSTOP);
> }
>
> void MyMainWindow::OnExit()
> {
> this->DestroyWindow();
> }
>
> void MyMainWindow::OnEdit(UINT /*nCmdID*/)
> {
> MessageBox("Command Not Implemented !", "Edit Message",
> MB_OK|MB_ICONSTOP);
> }
>
> void MyMainWindow::OnStyle(UINT nCmdID)
> {
> PenStyle = nCmdID;
> ScrollWindow(0, -TextHeight);
> }
>
> void MyMainWindow::OnWidthThin()
> {
> PenWidth = 1;
> }
> void MyMainWindow::OnWidthThick()
> {
> PenWidth = 5;
> }
>
> void MyMainWindow::OnUpdateStyle(CCmdUI* pCmdUI)
> {
> pCmdUI->SetCheck(pCmdUI->m_nID==PenStyle);
> }
>
> void MyMainWindow::OnUpdateWidthThin(CCmdUI* pCmdUI)
> {
> pCmdUI->Enable((BOOL)(PenWidth-1));
> }
>
> void MyMainWindow::OnHelp()
> {
> MessageBox("Command Not Implemented !", "Help Message",
> MB_OK|MB_ICONSTOP);
> }
>
> void MyMainWindow::OnAbout()
> {
> MessageBox("Menu Demostration Program", "About",
> MB_OK|MB_ICONINFORMATION);
> }
>
> void MyMainWindow::OnPaint()
> {
> CPaintDC paintDC(this);
> CRect rect;
> GetClientRect(rect);
> CPen *pen = new CPen(PenStyle - IDM_SOLID, PenWidth, (COLORREF)0);
> paintDC.SelectObject(pen);
> paintDC.TextOut(10, rect.bottom-TextHeight,
> szPenStyle[PenStyle-IDM_SOLID]);
> paintDC.MoveTo(TextWidth, rect.bottom-TextHeight/2);
> paintDC.LineTo(rect.right-10, rect.bottom-TextHeight/2);
> delete pen;
> }
>
> BOOL MyApp::InitInstance()
> {
> m_pMainWnd=new MyMainWindow();
> m_pMainWnd->ShowWindow(m_nCmdShow);
> m_pMainWnd->UpdateWindow();
> return TRUE;
> }
void MyMainWindow::OnUpdateWidthThick(CCmdUI* pCmdUI)
{
pCmdUI->Enable((BOOL)(PenWidth-5));
}