Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Window Class :: richedit implementation error!

Window Class :: richedit implementation error!

Scheduled Pinned Locked Moved ATL / WTL / STL
c++help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tareqsiraj
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • T tareqsiraj

      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

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      You 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups