(SDK) How can I get UI control associated with a param of a ParamBlock2?

(SDK) How can I get UI control associated with a param of a ParamBlock2?

denisT.MaxDoctor
Advisor Advisor
1,351 Views
5 Replies
Message 1 of 6

(SDK) How can I get UI control associated with a param of a ParamBlock2?

denisT.MaxDoctor
Advisor
Advisor

The task should be easily solved by using ParamDef, where we can ask ctrl_count and ctrl_IDs properties. But for all parameters ctrl_count is 0.

Am I missing anything?

 

 

0 Likes
1,352 Views
5 Replies
Replies (5)
Message 2 of 6

istan
Advisor
Advisor
and what about all the other fields? are the returning useful information? is for instance "ctrl_IDs" a NULL pointer?
0 Likes
Message 3 of 6

klvnk
Collaborator
Collaborator

 

 

just run the following in both the constructor (after the  MakeAutoParamBlocks() call) and in the BeginEditParams() functions



ParamDef& def = params_pb->GetParamDef(ksem_radius); mprintf("%d\n", def.ctrl_count); for(int i = 0; i < def.ctrl_count; ++i) mprintf("%d\n", def.ctrl_IDs[i]);

gives the following (correct) result

 

2
1043
1044

 

 

0 Likes
Message 4 of 6

denisT.MaxDoctor
Advisor
Advisor

ok... 

 

i want to have this snippet works:

 

/************ MXS **********/

ca = attributes ca
(
	parameters params rollout:params
	(
		count type:#integer ui:ui_count
		numbers type:#inttab tabsize:3 ui:(ui_number1, ui_number2, ui_number3)
	)
	rollout params ""
	(
		spinner ui_count "Count: " type:#integer 
		spinner ui_number1 "1: " type:#integer  
		spinner ui_number2 "2: " type:#integer  
		spinner ui_number3 "3: " type:#integer  
	)
)

/*
_a = createinstance ca
getPBlockParamControl _a
*/

/************ SDK **********/

def_visible_primitive(getPBlockParamControl, "getPBlockParamControl");
Value* getPBlockParamControl_cf(Value** arg_list, int count)
{
	check_arg_count(getPBlockParamControl, 1, count);
	ReferenceTarget *ref = arg_list[0]->to_reftarg();
	if (!ref) return &undefined;
	for (int k=0; k < ref->NumParamBlocks(); k++)
	{
		IParamBlock2* pb2 = ref->GetParamBlock(k);
		ParamBlockDesc2* pdc = pb2->GetDesc();
		for (int i = 0; i < pb2->NumParams(); i++) 
		{
			ParamDef pdef = pdc->paramdefs[i];
			mprintf(_M("%s >> %i\n"), pdef.int_name, pdef.ctrl_count);
		}
	}
	return &ok;
}

 

thank you

0 Likes
Message 5 of 6

klvnk
Collaborator
Collaborator

I doubt in that case they will ever have a resourse ID as such, the control would be created on the fly using something like

 

 

 hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", 
            WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 
            0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);

this i guess, it would have a valid HWND when it's been edited which you can test via

 

 

 

IParamMap2* IParamBlock2::GetMapMapID map_id = 0 ) 

 

and from there the get the HWND, IRollupWIndow  etc

 

then you would need to use EnumChildWindows to iterate through the controls in the rollout

0 Likes
Message 6 of 6

klvnk
Collaborator
Collaborator

did a quick test with this

 

BOOL CALLBACK EnumChildWindowProc(HWND hWnd, LPARAM lParam) 
{
	static TCHAR className[256];
	static TCHAR windowText[256];
	int bufSize = sizeof(TCHAR)*256;

	int res1 = GetClassName(hWnd, className, bufSize);
	int res2 = GetWindowText(hWnd, windowText, bufSize);

	mprintf("class = %s\n", className);
	mprintf("text = %s\n", windowText);
    return TRUE; 
}

called by this in a BeginEditParams() call

 

 

IParamMap2* map = params_pb->GetMap();
if(map)
{
	IRollupWindow*  rollup = map->GetIRollup();
	if(rollup)
	{
		for(int p = 0; p < rollup->GetNumPanels(); ++p)
		{
			HWND panelHWnd = rollup->GetPanelDlg(p);
			if(panelHWnd)
			{
				IRollupPanel* panel = rollup->GetPanel(panelHWnd);
				if(!panel) continue;
				EnumChildWindows(panel->GetPanelWnd(), EnumChildWindowProc, LPARAM(panel->GetHInst()));
			}
		}
	}
}

in your case your going to have to know when your ca is being edited.

 

 

 

0 Likes