Notifications
Clear all

[Closed] Disabling group of CustonControls

I think there are two reasons this method could be failing. One is that the window handle (hDlg) you’re passing in isn’t correct, that is, it’s not the window containing the actual controls. And second, maybe the control IDs (IDC_CHECK_X, etc) are not correct (unlikely).

I’ve tested the code I’ve shown and works perfectly…

2 Replies
(@eledh_telamion)
Joined: 11 months ago

Posts: 0

I’ve made a many variations between all the replies i’ve get, but still doesn’t work.

I think that is the answer but, hDlg is given directly from the CALLBACK to the function, and if IDC_CHECK_X, etc IDs aren’t correct, they’ll never be executed in the CALLBACK proc, am I right?

One thing that I’ve found is that I can’t disable/enable STATIC controlls. But in the RollUp editor, you can easily disable/enable all of them.

If I upload all the VC++ project, would be useful to find why it doesn’t work?

(@halfvector)
Joined: 11 months ago

Posts: 0

Yes, it would be easier!.

Hi,

Also, are you sure your code is executed ? Where is the EnableBlocks() function called ?
It must be in the WindowProc like this :

RESULT CALLBACK WindowProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
   	switch (msg)
   	{
   		case WM_INITDIALOG:
   			return TRUE;
   		case WM_COMMAND:
   
   		if (LOWORD(wParam) == IDC_CHECK_BLOQUEO)
   		{
   			if (HIWORD(wParam) == BN_CLICKED)
   			{
   				EnableBlocks(hDlg, (IsDlgButtonChecked(hDlg, IDC_CHECK_BLOQUEO) == BST_CHECKED) ? TRUE : FALSE); // Use EnableBlocks() by HalfVector
   			}
   		}
   		break;
   	}
   	return FALSE;
}

I’ve not tried this code but it should work.

Uploaded here!

Ok, tested in MAX9. It doesn’t works with the function you have there, obviously. But if you replace your enableBlocks function with the function I showed you earlier:

void enableBlocks(HWND hDlg, BOOL enable)
{
	EnableWindow(GetDlgItem(hDlg, IDC_CHECK_X), enable);
	EnableWindow(GetDlgItem(hDlg, IDC_CHECK_Y), enable);
	EnableWindow(GetDlgItem(hDlg, IDC_CHECK_Z), enable);
	EnableWindow(GetDlgItem(hDlg, IDC_LIST_BLOQUEOS), enable);
	EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_ADD_BLOQUEO), enable);
	EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_DEL_BLOQUEO), enable);
	EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_EMPTY_LIST), enable);
}

It works perfectly for me.

Works! Thanks a lot!

Page 2 / 2