Window Class :: richedit implementation error!
-
Hi ppl, I am new to ATL and trying to add a simple richedit control in a window. But i get "syntax error: missing ';' ..." everytime. Following is my source code. CMainWindow.h
#ifndef CMainWindow_h #define CMainWindow_h #include "stdafx.h" #include "CNoteEdit.h" class CMainWindow : public CWindowImpl < CMainWindow > { public: DECLARE_WND_CLASS_EX(TEXT("NoteMainWindowClass"), CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, COLOR_BTNFACE) private: BEGIN_MSG_MAP(CMainWindow) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_CLOSE, OnClose) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) END_MSG_MAP() LRESULT OnCreate(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClose(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDestroy(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); }; #endif
CNoteEdit.h
#ifndef CNoteEdit_h #define CNoteEdit_h #include "stdafx.h" class CNoteEdit : public CWindowImpl < CNoteEdit > { public: DECLARE_WND_SUPERCLASS(NULL, RICHEDIT_CLASS) BEGIN_MSG_MAP(CNoteEdit) END_MSG_MAP() CNoteEdit(); virtual ~CNoteEdit(); }; #endif
main.cpp
#include "stdafx.h" CComModule _Module; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { _Module.Init(0, hInstance); CMainWindow _MainWindow; _MainWindow.Create(0, CWindow::rcDefault, "Note - ", WS_OVERLAPPEDWINDOW); _MainWindow.ShowWindow(nShowCmd); _MainWindow.UpdateWindow(); MSG msg; while (::GetMessage(&msg,0,0,0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } _Module.Term(); return msg.wParam; }
In the CMainWindow.cpp, its just code for closing the window and in CNoteEdit.cpp, it has an empty constructor and destructor. Now, if i just remove the
CNoteEdit _noteEdit;
line from CMainWindow.h then everything is ok (but no richedit :((). I know i have to create the CNoteEdit object inside my main window, but i have to get pass the error first ... i think. Plz help me find out the error! Thankx in advance. -Tareq -
Hi ppl, I am new to ATL and trying to add a simple richedit control in a window. But i get "syntax error: missing ';' ..." everytime. Following is my source code. CMainWindow.h
#ifndef CMainWindow_h #define CMainWindow_h #include "stdafx.h" #include "CNoteEdit.h" class CMainWindow : public CWindowImpl < CMainWindow > { public: DECLARE_WND_CLASS_EX(TEXT("NoteMainWindowClass"), CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, COLOR_BTNFACE) private: BEGIN_MSG_MAP(CMainWindow) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_CLOSE, OnClose) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) END_MSG_MAP() LRESULT OnCreate(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClose(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDestroy(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); }; #endif
CNoteEdit.h
#ifndef CNoteEdit_h #define CNoteEdit_h #include "stdafx.h" class CNoteEdit : public CWindowImpl < CNoteEdit > { public: DECLARE_WND_SUPERCLASS(NULL, RICHEDIT_CLASS) BEGIN_MSG_MAP(CNoteEdit) END_MSG_MAP() CNoteEdit(); virtual ~CNoteEdit(); }; #endif
main.cpp
#include "stdafx.h" CComModule _Module; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { _Module.Init(0, hInstance); CMainWindow _MainWindow; _MainWindow.Create(0, CWindow::rcDefault, "Note - ", WS_OVERLAPPEDWINDOW); _MainWindow.ShowWindow(nShowCmd); _MainWindow.UpdateWindow(); MSG msg; while (::GetMessage(&msg,0,0,0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } _Module.Term(); return msg.wParam; }
In the CMainWindow.cpp, its just code for closing the window and in CNoteEdit.cpp, it has an empty constructor and destructor. Now, if i just remove the
CNoteEdit _noteEdit;
line from CMainWindow.h then everything is ok (but no richedit :((). I know i have to create the CNoteEdit object inside my main window, but i have to get pass the error first ... i think. Plz help me find out the error! Thankx in advance. -TareqYou don't #include stdafx.h in a header file. That should be the first #include in every CPP file, that's it. --Mike-- "I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage." -- Chris Maunder, relativistic system administrator Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber