?
Solved

How toenble & disable edit boxes

Posted on 1998-12-07
2
Medium Priority
?
219 Views
Last Modified: 2013-12-03
Hi everyone. Just when you thought it was safe to look at a question. I'm back!

Still doing edit & static controls in dialog boxes.
I would like to display and remove boxes depending on selection in checkbox.
eg. click checkbox and change an edit box from enabled to disabled to enabled etc.

case      IDC_CHECKBOX:
{                        if(1==SendMessage(GetDlgItem(hdlg,IDC_CHECKBOX),BM_GETCHECK,0,0))
{SetWindowLong(
GetDlgItem(hdlg,IDC_TEXTBOX),      // handle of window
GWL_STYLE,      // offset of value to set
ES_RIGHT | WS_BORDER | WS_TABSTOP        // new value
);
                                                MessageBox(hdlg,"Clicked","",MB_OK | MB_ICONINFORMATION);
}
else
{SetWindowLong(
GetDlgItem(hdlg,IDC_TEXTBOX),      // handle of window
GWL_STYLE,      // offset of value to set
ES_RIGHT | WS_BORDER | WS_TABSTOP | WS_DISABLED       // new value
);
MessageBox(hdlg,"UNClicked","",MB_OK | MB_ICONINFORMATION);
}
break;
}

I know that the message is being seen as the correct MessageBox is shown when I click the checkbox. All that happens though is it disables the edit box permanentley.
Like I say, I would really like it to disapear the become visible when I want it to be.
I am sure this must be trivial but I've been trying to do this for three nights now (It is a home project and it's driving me mad)
Regards to U all.
dsch
P.S.
Please no MFC or OWL
The app is win32 written in c++
0
Comment
Question by:dsch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
snoegler earned 240 total points
ID: 1416825
Take a look at EnableWindow(). I've never had problems with the code below:

BOOL bEnable;
EnableWindow(GetDlgItem(hDlg, IDC_EDIT), bEnable);
0
 
LVL 1

Author Comment

by:dsch
ID: 1416826
That's great, I originally just wanted to grey out the box and disable it which that does. Thanks.
In fact, I've just found ShowWindow(I didn't realise you could use it for anything) and it works in a similar way to EnableWindow, SW_HIDE & SW_SHOW sort that out.
Regards and thanks
Dsch
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question