[Closed] [SDK] pblock from HWND
if you have opened dialog and want to find corresponding IParamBlock (ReferenceTarget), the instance of this Object is more likely the Current Edit Object. That’s what I wanted to say.
after that enumerate your HWND by parents up to meet one of ParamBlock dialogs. (pblock->GetMap()->GetHWnd() as Klvnk showed above).
alternatively you could iterate through the all ClassDesc and see if they are being edited if so get the IParamMap2 from that Class and test the HWND against it then goto the IParamBlock2 from there.
I also thought about this opportunity … but I don’t see a safe way to send notification without any ‘real’ parameter changes. Because I see the goal to find corresponding block parameter and its control before ‘editing’ event.
i was thinking along the lines of
DllDir& dlldir = ip->GetDllDir( );
ClassDirectory& cd = dlldir.ClassDir() ;
for(int i = 0; i < cd.Count (); ++i)
{
SubClassList& scl = cd[i];
for(int j = 0; j < scl.Count(); ++j)
{
ClassEntry& ce = scl[j];
if(!ce.IsLoaded()) continue;
// not sure on this but maybe valid approach
if(ce.UseCount() == 0) continue;
ClassDesc* cdesc = ce.CD();
if(cdesc)
{
for(int k = 0; k < cdesc->NumParamMaps (); ++k)
{
IParamMap2 * pmap = cdesc->GetParamMap(k);
if(pmap && pmap->GetHWnd() == OurControlParentHWND)
{
itsPblock = pmap->GetParamBlock();
.....
i’ve just typed that freehand btw so I can’t tell how valid it might be
how to be sure about this one? it has to be a dialog HWND, which can be grand(grand…) parent.
Thanks Klvnk, I like the idea of iterating all the loaded ClassDescs…I’ll try that out and see how it goes.
So Klvnk’s method works well for plugins that call the ClassDesc->BeginEditParams function in their BeginEditParams virtual function override, but unfortunately it doesn’t work for plugins that call CreateCPParamMap instead, in older version of max. I guess the ClassDesc->BeginEditParams function is where parammaps for ClassDescs are registered, whereas CreateCPParamMap seems to register them somewhere else…
are them not the same param blocks as param blocks of the current edit object?
the problem is that can be param block controls which are not in Command Panel. I can make my own dialog to display Params (custom attributes for example).
I’d be ok with just getting the IParamBlock if it were possible…although maybe it’s not worth the effort since ADSK has phased out IParamBlock.
as far as I can see there’s no way of finding what HWND relates to a IParamBlock and visa versa.