If I add a control disabled - how do I enable it later?
Is there a setcontrol class?
As far as I know, EnableWindow (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/enablewindow.asp)
declare import, EnableWindow(unsigned int hWnd, int bEnable),int;
...
EnableWindow(pControl->m_hWnd, 1); // To enable the control
is the only way.
Need to give me more detail on how to do this.
This is the initial declarition line:
d1.AddControl(CTLISTVIEW,"",10,10,500,145,
AWS_DISABLED|ALVS_REPORT|AWS_BORDER|AWS_HSCROLL|AWS_VSCROLL,AWS_EX_CLIENTEDGE,LISTVIEW_1);
What would turn it on?
You can use the GetDlgItem function to get an HWND to pass to EnableWindow, it would look like this
EnableWindow(GetDlgItem(d1.m_hWnd, LISTVIEW_1), 1);
sorry I'm a little busy, you'll have to convert the declare from msdn
Controls are enabled by default.
But not if they're disabled. See above, AWS_DISABLED is explicitly passed.
For GetDlgItem, insert this into your code
import unsigned int GetDlgItem(unsigned int hDlg, int nIDDlgItem);
Ouch. Got me.
I better get some sleep (no cracks please, Paul) - I'll look again tomorrow.
Yes it is disabled at start - I want to be able to turn it off/on on demand.
Just use GetControl to get a pointer to the control. If you in a method of the dialog:
pControl = GetControl(id);
EnableWindow(pControl->m_hWnd, true);
Or if your not in a method of the dialog
pControl = dlg.GetControl(id);
EnableWindow(pControl->m_hWnd, true);
The is no reason to use GetDlgItem
I looked in the includes - is EnableWindow a function?
I can not find it.
I found this in keno.src
DECLARE IMPORT,EnableWindow(hwnd as int,bEnable as int),int;
That solves the compile error - now the program just crashes.
:'(
Got past the crash but still does not make the listview visable.
I had the same problem when I was testing this, it looks like the listview doesn't revert back to the correct color, but is still enabled. If there is a function to set the color of a listview control, try putting that right after the EnableWindow call and see if it works.