[Closed] TYPE_MTLBUTTON and drag/drop?
It’s said on Autodesk help that MTLBUTTON supports drag&drop but unfortunatly that is only true when it is on Material Editor.
I’ve looked for more info on the internet but without luck
Tons of karma for the good person that could help me with any tip
not so, works with drag and drop from the material editor to particleflow…
this is the paramblock def from \maxsdk\samples\ParticleFlow\Actions\PFOperatorMaterialStatic_ParamBlock.cpp
// materialStatic
kMaterialStatic_material, _T("Assigned_Material"),
TYPE_MTL,
P_RESET_DEFAULT|P_SHORT_LABELS|P_NO_REF,
IDS_ASSIGNEDMATERIAL,
// optional tagged param specs
p_ui, TYPE_MTLBUTTON, IDC_MATERIAL,
end,
also in the resource dialog make IDC_MATERIAL class as [b]CustButton
[/b]you then have to initialize the button with ICustom::SetDADMgr(DADMgr *dad)
yeah it’s pretty simple to implement
as above in the dialog resource create the custom control with class set to [b]CustButton [/b]with id
as [b] IDC_MATERIAL[/b]
define your mtl param as so....
kmtn_material, _T("material"), TYPE_MTL, P_SHORT_LABELS, IDS_ASSIGNEDMATERIAL,
p_ui, TYPE_MTLBUTTON, IDC_MATERIAL,
end,
in the param block desc
then in create panel dialog handler proc as so.....
class MapToNormalModDlgProc : public ParamMap2UserDlgProc , DADMgr
{
public:
MapToNormalMod* mod;
HWND panelhWnd;
MapToNormalModDlgProc(MapToNormalMod* m) { mod = m;}
INT_PTR DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
void InitPanel(TimeValue t);
void DeleteThis() { delete this; }
// from DADMgr
SClass_ID GetDragType(HWND hwnd, POINT p) { return MATERIAL_CLASS_ID; }
BOOL OkToDrop(ReferenceTarget *dropThis, HWND hfrom, HWND hto, POINT p, SClass_ID type, BOOL isNew)
{
if (hfrom == hto)
return FALSE;
return (type==MATERIAL_CLASS_ID) ? TRUE : FALSE;
}
int SlotOwner() { return OWNER_SCENE; }
ReferenceTarget *GetInstance(HWND hwnd, POINT p, SClass_ID type)
{
if(!mod)
return NULL;
return mod->pblock->GetMtl(kmtn_material);
}
void Drop(ReferenceTarget *dropThis, HWND hwnd, POINT p, SClass_ID type, DADMgr* srcMgr = NULL, BOOL bSrcClone = FALSE)
{
Mtl *mtl = (Mtl *)dropThis;
if(mod && mtl)
mod->pblock->SetValue(kmtn_material,0,mtl);
}
BOOL AutoTooltip() { return TRUE; }
};
//********************************************************************************************
void MapToNormalModDlgProc::InitPanel(TimeValue t)
{
if(!panelhWnd)
return;
ICustButton* but = GetICustButton(GetDlgItem(panelhWnd, IDC_MATERIAL));
but->SetDADMgr(this);
ReleaseICustButton(but);
}
//********************************************************************************************
INT_PTR MapToNormalModDlgProc::DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
panelhWnd = hWnd;
switch (msg)
{
case WM_INITDIALOG:
{
InitPanel(t);
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
/* case IDC_DIALOG_ITEM:
{
return TRUE;
}*/
}
break;
}
}
return FALSE;
}
// create the dialog handler like so in BeginEditParams....
my_param_desc.SetUserDlgProc(new MapToNormalModDlgProc(this));
i added it to a simple mod i had and it works fine should work for any dialog handler. Works for both drag and drop and as mtl button
Thank you!
I’ve been out for a week, so sorry for being so late, it looks so useful but having inheritance from the plugin wizard (simplymod2 or modifier) since they use IParamBlock2 I didn’t manage to make it work.
Could you post your entire simply example?