| Ch1156 (326) | |||||||
|
Ok so i have a checkbox in my program but it wont check and uncheck. How do i make it do this with as little code as humanly possible? Can someone either add the code thats needed to make it work to my code or show me what needs to be added to the code and what lines they need to go on. Here is my code: main.cpp:
Resource.rc:
Resource.r:
| |||||||
|
|
|||||||
| Ch1156 (326) | |
|
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!! That doesnt help, i dont know where to put it, if theres anything else i need to do or anything. "Can someone either add the code thats needed to make it work to my code or show me what needs to be added to the code and what lines they need to go on." | |
|
|
|
| blackcoder41 (1406) | |
On line 44 of your resource.rc put AUTOCHECKBOX "Checkbox", CheckB, 138, 120, 42, 50 instead.
| |
|
|
|
| Ch1156 (326) | |
| Oh my god, thank you sooo much!! it works now!now my last question is in the Case statements how do i check if its checked or unchecked because what im going to do is use it for a quiz. | |
|
|
|
| Ch1156 (326) | |
| Please help! | |
|
|
|
| modoran (608) | |
|
Use IsDlgButtonChecked() API. http://msdn.microsoft.com/en-us/library/windows/desktop/bb761879(v=vs.85).aspx | |
|
|
|
| Ch1156 (326) | |
| So how do i use this? I looked at the link but i dont really get where it goes or how to get it to understand if its checked. | |
|
|
|
| modoran (608) | |||
Something like this:
| |||
|
|
|||
| Ch1156 (326) | |||
|
Ahh, i get it now, thanks, but i got an error, it says that hDlg was not declared in the scope, i changed hDlg to NULL and it sort of worked, but when i check and uncheck it, in the CMD box it keeps saying Unchecked, when really its checked: C:\Users\Chay Hawk\Desktop\C++\Project Manager\main.cpp||In function 'BOOL DialogProc(HWND__*, UINT, WPARAM, LPARAM)':| C:\Users\Chay Hawk\Desktop\C++\Project Manager\main.cpp|51|error: 'hDlg' was not declared in this scope| ||=== Build finished: 1 errors, 0 warnings ===| Code:
| |||
|
Last edited on
|
|||
| modoran (608) | |
| hDlg is hwndDlg in your case, the first parameter in your DialogD Procedure. | |
|
|
|
| Ch1156 (326) | |
| Ok it works perfect now. How would i grey out a checkbox when another is checked? I dont want the quiz taker checking more than 1 choice. I could use Radio buttons and i have tested them to work 100% but the concept is the same. | |
|
|
|
| modoran (608) | |
| Use EnableWindow. | |
|
|
|
| Ch1156 (326) | |
|
So it would look something like: case CheckBox1: EnableWindow(CheckBox1, FALSE); break; ?????? | |
|
|
|
| Ch1156 (326) | |||
Ok i tried:
and no luck, what else do i need to do? | |||
|
Last edited on
|
|||
| Ch1156 (326) | |
| Please help | |
|
|
|
| andywestken (1478) | |
|
If you want the user to just select one on a set of items, then you should be using a radio button. That's what they're designed for, and why there are radio buttons and check boxes. Using a set of radio buttons signals to the user that they should choose one of the options rather than treating them separately (like check boxes). Ideally you program would stick to the Windows UX idiom! Andy PS That is, you shouldn't be trying to fix the "problem" that checkboxes don't behave like radio buttons. Just use the right kind of controls. | |
|
Last edited on
|
|
| Ch1156 (326) | |
| I know I can use radio buttons but im going to need to grey out things lime buttons and such anyways so I might as well learn it now. | |
|
|
|
| Ch1156 (326) | |
|
Please help i want to get this done!! :( I just need to know which arguments i need for this, i have been trying it for a few days and its driving me craze, im not sure what other arguments i need to put in it. case CheckBox1: EnableWindow(CheckBox1, FALSE); break; | |
|
|
|
| Ch1156 (326) | |
| Bump | |
|
|
|