Notifications
Clear all

[Closed] SDK ParamBlockDesc2

Hi, I am using the Luminaire Sample within the SDK. I am trying to get a button within the rollout that comes with it. I have tried different ways of trying to get a DlgProc included so I can have control over the button, but every time it just crashes Max. It uses the ParamBlockDesc2 to show the Rollout. The code I have is below.

class LumDlgProc : public ParamMap2UserDlgProc 
  {
  	public:			
  		INT_PTR DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  		{
  			switch (msg) 
  			{
  				case WM_INITDIALOG:
  				{
  					break;
  				}
  				default:
  					return FALSE;
  			}
  			return TRUE;
  		}
  
  		void DeleteThis() {};
  };
  
  //===========================================================================
  // Param Block  definition
  //===========================================================================
  enum 
  { 
  	kLUM_PARAMS
  };
  
  // Add enums for various parameters
  enum 
  { 
  	pb_Button,
  	kPB_DIMMER,
  	kPB_FILTER_COLOR,
  };
  
  LumDlgProc theProc;
  
  static ParamBlockDesc2 luminaire_param_blk ( 
  
  	kLUM_PARAMS, _T("params"),  0, GetLuminaireDesc(), P_AUTO_CONSTRUCT + P_AUTO_UI, PBLOCK_REF, 
  	
  	// rollout
  	IDD_PANEL, IDS_PARAMS, 0, 0, &theProc,
  
  	// params
  	kPB_DIMMER,				_T("Dimmer"), 			TYPE_FLOAT, 	P_ANIMATABLE, 	IDS_DIMMER_SPIN, 
  		p_default, 	100.0f, 
  		p_range, 		0.0f, 1000.0f, 
  		p_ui, 			TYPE_SPINNER,		EDITTYPE_FLOAT, IDC_DIMMER_EDIT,	IDC_DIMMER_SPIN, 0.1f, 
  		p_end,
  	kPB_FILTER_COLOR,	 _T("FilterColor"),	TYPE_RGBA,		P_ANIMATABLE,	IDS_FILTER_COLOR,	
  		p_default,	Color(1, 1, 1), 
  		p_ui,				TYPE_COLORSWATCH, IDC_FILTER_COLOR, 
  		p_end,
  
  	p_end
  );

Can some one see what I’m doing wrong ??

4 Replies

At first look, I’m not seeing anything wrong with the snippet. Did you debug the crash? It may hint you where the crash is.

Hi, its the &LumDlgProc within the ParamBlockDesc2. That was orignally set to NULL, but as I need control over the Button, I created a DlgProc. If set to NULL, then the code works fine, button will show but no control. If set to &LumDlgProc, it crashes as soon as I try to create a dummy.

Try returning always FALSE for the DlgProc, this will let the DialogManager do what ever it needs, if you return TRUE, the dialog manager stops processing the message received.
Here is a snippet from one of my plugins, this works just fine. In my case I’m doing stuff on paint, not the best approach but works.


class TextureDialogProcClass  : public ParamMap2UserDlgProc {
	public:
		INT_PTR DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) override
		{
			switch( msg )
			{
				case WM_PAINT :
					auto pblock = map->GetParamBlock();
					auto mode		( pblock->GetInt(BlockParams::Mode) );
					auto useProp	( pblock->GetInt(BlockParams::UseUserProperty) );
					SetDlgItemText(hWnd, IDC_VM_VAR1LBL, mode == 0 ? _T("Hue") : _T("Red"));
					SetDlgItemText(hWnd, IDC_VM_VAR2LBL, mode == 0 ? _T("Sat") : _T("Green"));
					SetDlgItemText(hWnd, IDC_VM_VAR3LBL, mode == 0 ? _T("Value") : _T("Blue"));
					ShowWindow(GetDlgItem(hWnd, IDC_VM_PREFIX), useProp);
					ShowWindow(GetDlgItem(hWnd, IDC_VM_PREFIXLBL), useProp);
					EnableWindow(GetDlgItem(hWnd, IDS_VM_USEPROP), FALSE);
					EnableWindow(GetDlgItem(hWnd, IDC_VM_USEID), !useProp);
					EnableWindow(GetDlgItem(hWnd, IDC_VM_USEOBJ), !useProp);
					EnableWindow(GetDlgItem(hWnd, IDC_VM_USEELEMENT), !useProp);
					break;
			}
			return FALSE;
		}

		void DeleteThis() override {}
	};

Never mind, I have got it fixed I was missing one line of code ^^ Thanks for the help anyways.