|
-
September 3rd, 2003, 07:51 AM
#1
Edit issue
I want to prohibit writing into an editbox.
I'd use read-only propriety, but it adds disable aspect to my editbox and I want to avoid this.
Thanks,
Snakekaa
Move like a snake, think like a snake, be a snake !!!
-
September 3rd, 2003, 08:10 AM
#2
I guess I should manage a window message by returning it before execute some code from MFC.
But which one ?!?
Snakekaa
Move like a snake, think like a snake, be a snake !!!
-
September 3rd, 2003, 08:17 AM
#3
I think I can make it read only and after change backgroud appearance from gray to white.
Snakekaa
Move like a snake, think like a snake, be a snake !!!
-
September 3rd, 2003, 08:34 AM
#4
I did so and it worked, but when I put some text into edit with SetWindowText, it appears disable (with a gray background).
Does anyone know how to avoid this ?
Thanks,
Snakekaa
Move like a snake, think like a snake, be a snake !!!
-
September 3rd, 2003, 09:53 AM
#5
You could derive a control from CEdit and implement PreTranslateMessage() like this:
Code:
BOOL CLockedEdit::PreTranslateMessage(MSG* pMsg)
{
BOOL retval = TRUE;
if(pMsg->message != WM_KEYDOWN)
{
retval = CEdit::PreTranslateMessage(pMsg);
}
return retval;
}
-
September 3rd, 2003, 10:12 AM
#6
I suppose I cannot do it without deriving a control from CEdit, can I ?
The fact is I have a big number of CEdit-s on my dialog and for all of them I would be forced to define a CMyEdit variable, wouldn't I ?
Thank you very much for your suggestion, gstercken. I cannot imagine why it didn't came to me 
Snakekaa
Move like a snake, think like a snake, be a snake !!!
-
September 3rd, 2003, 10:25 AM
#7
Originally posted by Snakekaa
I suppose I cannot do it without deriving a control from CEdit, can I ?
The fact is I have a big number of CEdit-s on my dialog and for all of them I would be forced to define a CMyEdit variable, wouldn't I ?
Well, you could of course have some code in your dialog which iterates the controls and subclasses all edit controls programmatically. But I think it will be easier to live with a DDX control member for every edit control.
But just another thought: If an edit control is read only, I think it is preferrable to display it the way Windows provides (that is, grayed). IMHO, an edit control which appears as if it were editable but is read only is not what a Windows user expects. That's why there is no easy way to achieve this - it's by design.
Last edited by gstercken; September 3rd, 2003 at 10:28 AM.
-
September 3rd, 2003, 10:36 AM
#8
Originally posted by Snakekaa
I did so and it worked, but when I put some text into edit with SetWindowText, it appears disable (with a gray background).
Does anyone know how to avoid this ?
Thanks,
Snakekaa
How do you change the background? Have you used WM_CTLCOLOR message? I do it with WM_CTLCOLOR and it works for me.
I am Miss Maiden... Miss Iron Maiden :-D
-
September 4th, 2003, 01:27 AM
#9
I also used that, WM_CTLCOLOR. Perhaps I didn't make myself clear : not the backgroud of editbox remained gray, but the backgroud of the text I put in. But this is no longer a problem, since I've adopted gstercken's solution.
Thank you, irona20.
gstercken, thanks for your suggestions. Regarding your advice, I agree, in most of the case it's true what you were saying.
But (there is always a "but"), look in Office Word, in Tools menu, Customize ... In Customize dialog, press Keyboard... button. In Customize Keyboard ... dialog see the behaviour of editbox located under "Press new shortcut key:" static.
Such behaviour I was looking for and, thanks to you, I've found it.
Snakekaa
Move like a snake, think like a snake, be a snake !!!
-
September 4th, 2003, 05:18 AM
#10
Originally posted by Snakekaa
But (there is always a "but"), look in Office Word, in Tools menu, Customize ... In Customize dialog, press Keyboard... button. In Customize Keyboard ... dialog see the behaviour of editbox located under "Press new shortcut key:" static.
Such behaviour I was looking for and, thanks to you, I've found it.
But you know about the CHotKeyCtrl (which can be added using the dialog resource editor), don't you?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|