May 19, 2024, 04:29:15 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


More help

Started by Rock Ridge Farm (Larry), February 10, 2006, 07:43:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rock Ridge Farm (Larry)

If I add a control disabled - how do I enable it later?
Is there a setcontrol class?

Parker

As far as I know, EnableWindow

declare import, EnableWindow(unsigned int hWnd, int bEnable),int;

...
EnableWindow(pControl->m_hWnd, 1); // To enable the control


is the only way.

Rock Ridge Farm (Larry)

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?

Parker

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

Bruce Peaslee

Controls are enabled by default.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Parker

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);

Bruce Peaslee

Ouch. Got me.

I better get some sleep (no cracks please, Paul) - I'll look again tomorrow.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Rock Ridge Farm (Larry)

Yes it is disabled at start - I want to be able to turn it off/on on demand.

Ionic Wind Support Team

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
Ionic Wind Support Team

Rock Ridge Farm (Larry)

I looked in the includes - is EnableWindow a function?
I can not find it.

Bruce Peaslee

I found this in keno.src

DECLARE IMPORT,EnableWindow(hwnd as int,bEnable as int),int;
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Rock Ridge Farm (Larry)

That solves the compile error - now the program just crashes.
:'(

Rock Ridge Farm (Larry)

Got past the crash but still does not make the listview visable.

Parker

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.