How to make a Read-only view

is there a simple way to make a view read-only (so they can copy text), as well as let me output stuff to the screen? I was gonna use a read-only ceditview-derived class, but then I found out I cannot output to the screen
[222 byte] By [lordkelvan1] at [2007-11-18 22:15:45]
# 1 Re: How to make a Read-only view
If you have an edit box, go to it's properties, select "style" tab and place a check mark next to "Read-only". Where is your edit box? Do you have a dialog based App or an SDI app?
kodeguruguy at 2007-11-11 1:04:31 >
# 2 Re: How to make a Read-only view
One solution is CEditCtrl's SetReadOnly().

Kuphryn
kuphryn at 2007-11-11 1:05:26 >
# 3 Re: How to make a Read-only view
kodeguruguy : Yeah, thnx, I know about the edit box thing, I was actually looking for that sort of functionality in a view for a SDI app.

kuphryn: Hmm, is that the same as setting the window style to ES_READONLY or no? Because, I would need the view to be read-only, but at the same time would need the ability output text to that view (it is in a pane of a splitter window), and to have them copy that text. Before, when I set that particular view to be ES_READONLY, I wasn't able to use the view's OnDraw function to output text to the screen (maybe there is a different way to output text when you have a read-only view?).

Thnx for all of your speedy and helpful replies. Keep'em coming :)
lordkelvan1 at 2007-11-11 1:06:25 >
# 4 Re: How to make a Read-only view
SetReadOnly() grays out the view. Try setting the windows text. I know it does display whatever texts that are there.

Kuphryn
kuphryn at 2007-11-11 1:07:33 >
# 5 Re: How to make a Read-only view
Ceditctrl? There does not seem to be class called that. There is something called cricheditctrl, but that is for edit controls in dialog boxes. I need this for an SDI application.
lordkelvan1 at 2007-11-11 1:08:32 >
# 6 Re: How to make a Read-only view
Edit control, rich edit control are Windows controls. MFC CEdit and CRichEditCtrl are classes that wrap Windows controls.

CEditView and CRichEditView are MFC view classes that use edit and rich edit controls.
JohnCz at 2007-11-11 1:09:31 >
# 7 Re: How to make a Read-only view
Hmm, is that the same as setting the window style to ES_READONLY or no? SetReadOnly is not a member of CEditView. It is a member of CEdit. You would have to make following call from CEditView derived class:

GetEditCtrl().SetReadOnly();

it is the same as sending EM_SETREADONLY message or setting style to ES_READONLY before window is created.

I wasn't able to use the view's OnDraw function to output text to the screen (maybe there is a different way to output text when you have a read-only view?). If you use CEditView derived class use SetWindowText to change display. Edit control does own painting.

None of the classes derived from CCtrlView (and CEditView is the one) calls OnDraw. WM_PAINT handler does not call CView implementation.
JohnCz at 2007-11-11 1:10:29 >
# 8 Re: How to make a Read-only view
So basically you are saying the OnDraw function is useless? Then why does AppWizard put that function in by default (sure its empty, besides creating a pointer to the current document, but why put it in at all if it doesn't do anything?). And I am confused, I thought that SetWindowText only changed the text in the title bar of the window, and didn't change the text displayed in the main window. What I am trying to do is this, I have 3 panes, and one pane displays a real-time graph, while the other pane displays the coordinates of the graph as they are being read in from a file. The problem is I cannot seem to find a view which allows me to make it read only, and also allows me to display text (like in the pane itself). I can seem to only get an either or functionality, where I can make it read-only, but not display text (ceditview), or make it display text, but not read-only (cview -- well, in a sense it is read-only, but I want to allow the user to select the text being displayed in case they want to copy it somewhere else).
lordkelvan1 at 2007-11-11 1:11:32 >
# 9 Re: How to make a Read-only view
So basically you are saying the OnDraw function is useless Yes.
None of the classes derived from CCtrlView (and CEditView is the one) calls OnDraw. Then why does AppWizard put that function in by default (sure its empty, besides creating a pointer to the current document, but why put it in at all if it doesn't do anythingI do not know, thats M$ code, do not ask me. App wizard does it for all view classes.And I am confused, I thought that SetWindowText only changed the text in the title bar of the window, and didn't change the text displayed in the main window Correction: SetWindowText sets window text. If window has a WS_CAPTION style text is displayed in a caption (title) bar. Try using SetWindowText for a CView derived class and after that call GetWindowText; it will return the same string even though you do not see it.
If you use CEditView derived class use SetWindowText to change display
I though our mutual understanding was that we are referring to CEditView:
I was gonna use a read-only ceditview-derived class, but then I found out I cannot output to the screen
What I am trying to do is this, I have 3 panes, and one pane displays a real-time graph, while the other pane displays the coordinates of the graph as they are being read in from a file. The problem is I cannot seem to find a view which allows me to make it read only, and also allows me to display text (like in the pane itself). I can seem to only get an either or functionality, where I can make it read-only, but not display text (ceditview), or make it display text, but not read-only (cview -- well, in a sense it is read-only, but I want to allow the user to select the text being displayed in case they want to copy it somewhere else).Again:
If you use CEditView derived class use SetWindowText to change display. Edit control does own painting.

None of the classes derived from CCtrlView (and CEditView is the one) calls OnDraw. WM_PAINT handler does not call CView implementation.
JohnCz at 2007-11-11 1:12:32 >
# 10 Re: How to make a Read-only view
Yeah, haha, you were right about the setwindowtext, it does display the text in the pane - all of your help was greatly appreciated. So that WS_CAPTION option determines whether or not it gets put on the screen? So the AppWizard automatically makes the main window have the style WS_CAPTION, b/c before, back when I didn't have splitter windows, I did something like

AfxGetMainWnd()->SetWindowText("Untitled");

in my view class, and it altered the title bar. Or is it b/c I called with an instance of the main window?
lordkelvan1 at 2007-11-11 1:13:33 >
# 11 Re: How to make a Read-only view
I told you...

See small sample. I did not create splitter, but you will have pretty good idea how it works.

Instead reading file I have faked it in a timer. It writes to disabled edit view and copies data to a clipboard (edit menu copy all ...)

What b/c means?
JohnCz at 2007-11-11 1:14:40 >
# 12 Re: How to make a Read-only view
b/c = because
lordkelvan1 at 2007-11-11 1:15:33 >
# 13 Re: How to make a Read-only view
Did you try sample?
JohnCz at 2007-11-11 1:16:40 >
# 14 Re: How to make a Read-only view
Actually, I haven't had a chance, this other bug has crept up on me. Everything was running fine, until it started giving me this error. It brings me to the disassembly screen in the debugger, and goes to the line 00000000000000 ?, indicating the problem is there. Unfortunately, I don't know anything about this disassembly, any idea what it might be. I am using mutlithreading (very simple, just one secondary thread) - could it be a problem there?
lordkelvan1 at 2007-11-11 1:17:35 >
# 15 Re: How to make a Read-only view
Problem could be anywhere. It is impossible to tell you where without seeing a code.
Try to bring up call stack window and go down to the point where you can read a code. Besides you should get some kind of error message or assertion.

Are you calling any function recursively?
JohnCz at 2007-11-11 1:18:41 >
# 16 Re: How to make a Read-only view
Don't know how to use the debugger (except in the basic cases, where it shows me code, like some assert failed or couldn't read some file). But anywho, I found the problem: apparently I shouldn't have done something like

using namespace std;

which I had done in order to use sstream to convert from float to string (I like it more than I do _gcvt, but guess I will be stuck with it)
lordkelvan1 at 2007-11-11 1:19:45 >
# 17 Re: How to make a Read-only view
I do not know. using namespace should not create problems.
JohnCz at 2007-11-11 1:20:37 >