# Disabling a dialogbox text item?

This topic is 4883 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey guys, it's me again. Thanks for all the help you've given me in the past, you guys ROCK! But I gots another easy question for ya... I have a dialog box working, and it has text input blanks (edit controls) and check boxes in it. What I want is to grey out or make invisible some edit controls when certain text boxes are checked. I've already figured out how to do something as soon as my checkbox is checked (under the 'WM_COMMAND:' case in my dialogbox message processing function), and I know how to determine whether the box is checked, but I don't know what command I'd use to actually disable the edit controls! I think I can do it if I knew the commands to actually grey out or make invisible an edit control... For simplicity's sake, my checkbox has the id 'IDC_INVINCIBLE' and the edit control I want affected has the id 'IDC_QUADHEALTH'. I currently know when 'IDC_INVINCIBLE' is actually checked or not checked, but I don't know what command I'd use to actually disable or make invisible the edit control 'IDC_QUADHEALTH'. Would somebody show me what command I'd use (and also show its usage) to disable or enable an edit control? Thanks!

##### Share on other sites
Like this?

HWND hWndEdit = GetDlgItem( hWndDlg, IDC_QUADHEALTH );EnableWindow( hWndEdit, FALSE );

First retrieve the window handle to the edit box using GetDlgItem and then
disable the window with EnableWindow.

##### Share on other sites
Or possibly this : EM_SETREADONLY message.

Jim.

##### Share on other sites
Thanks for the reply and explanation, T1mb0. That's exactly what I needed, and it works perfectly! I'm still trying to get the hang of Windows programming, as I still don't quite understand some of the concepts (an edit blank can have a window handler?). But it's getting easier as I learn more about it, and this forum and all the guys and gals here make it a lot easier to learn!

And thanks for the link to 'EM_SETREADONLY', JimPrice. I'll check it out and see what it does! I played around with that 'SendMessage()' function earlier today, but didn't know that I could turn my 'IDC_QUADHEALTH' id into a windows handler... I was trying to send my control id to that function while using the dialogbox's window handler, and, well, it didn't work... Doh! But I bet it'll work by sending hWndEdit to SendMessage() when hWndEdit = GetDlgItem( hWndDlg, IDC_QUADHEALTH )!

Thanks again for the help, I really appreciate it!

• 23
• 10
• 19
• 15
• 14