Creating simple text editor using CView as base
-
Hello all I'm new to doc/view architechture. I want to create a simple text editor which have to enable me to enter text, open files, edit,cut and copy. I'm using MFC AppWizard and accepting the defaults. It's creating a basic skeleton and when I ran it it show's up a simple editor, but when I open a file it's not showing the contents. Similarly its not allowing me to enter anything. When creating the application if I change the base class of myview to CEditView then I'm able to do all the above operations. But I want to implement all the functionality just by deriving from CView. Can anyone help me in this regard? Any example code or article which explains how to do will be of great help. Thank you very much for your help. Hari.
-
Hello all I'm new to doc/view architechture. I want to create a simple text editor which have to enable me to enter text, open files, edit,cut and copy. I'm using MFC AppWizard and accepting the defaults. It's creating a basic skeleton and when I ran it it show's up a simple editor, but when I open a file it's not showing the contents. Similarly its not allowing me to enter anything. When creating the application if I change the base class of myview to CEditView then I'm able to do all the above operations. But I want to implement all the functionality just by deriving from CView. Can anyone help me in this regard? Any example code or article which explains how to do will be of great help. Thank you very much for your help. Hari.
To create just a text editor using CView will require alot of (unnecessary) work! If that's actually all you you want to do then use CEditView (as you suggested) or CRichEditView when creating the application in the wizard. If your problem is actually that you wish to display graphics as well, then the CRichEditView will take care of that too. Otherwise, take a look at some of the examples here on Code Project: there are many that show you how to over ride "OnPaint", which is what you're going to have to do if you wish to manually code to at least display text in a CView. Another method (not necessarily the best: you need to be more specific as to your problem) is to write text / draw to a bit map and then simply display that in the CView. Search for "double buffering", "bitmap" or "graphics" in Code Project. "Code Guru" is another good site to try. :)
-
To create just a text editor using CView will require alot of (unnecessary) work! If that's actually all you you want to do then use CEditView (as you suggested) or CRichEditView when creating the application in the wizard. If your problem is actually that you wish to display graphics as well, then the CRichEditView will take care of that too. Otherwise, take a look at some of the examples here on Code Project: there are many that show you how to over ride "OnPaint", which is what you're going to have to do if you wish to manually code to at least display text in a CView. Another method (not necessarily the best: you need to be more specific as to your problem) is to write text / draw to a bit map and then simply display that in the CView. Search for "double buffering", "bitmap" or "graphics" in Code Project. "Code Guru" is another good site to try. :)
Hello Clevedon_Peanut Thanks you very much for the reply. I'll try for samples in codeproject and codeguru. Thanks Hari.