Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Button in a toolbar

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
dg3duy
693 Views, 11 Replies

Button in a toolbar

I came up with a tool that saves the amount of frames of the scene by clicking on a button and using the right mouse button loads the amount of saved frames.
I would like to use the tool in a toolbar, seeing the timerange button ready to be clicked and not first click a button and that button opens the tool. 🤔

timerange.gif

(
	global rol_test
	local orig_anim_range
	
	try(destroyDialog rol_test)catch()
	
	rollout rol_test ""
	(
		button btn_pressMe "TimeRange"
		
	fn testA = orig_anim_range=animationRange
	fn testB = 	animationRange=orig_anim_range
		
		
		on btn_pressMe pressed do
		(
			print "Button pressed"
			testA()
		)
		
			on btn_pressMe rightClick do
		(
			print "Button pressed"
			testB()
		)
		
		
		
	)
	createdialog rol_test 
)

 

11 REPLIES 11
Message 2 of 12
istan
in reply to: dg3duy
Message 3 of 12
dg3duy
in reply to: istan

Any example code that I can try?, the help page I think there is no example of what I'm looking for I think.
Message 4 of 12
istan
in reply to: dg3duy

Search for "*.mcr" in the max folders. I'm sure you'll find many examples.

Message 5 of 12
denisT.MaxDoctor
in reply to: dg3duy

macroScript HoldAnimationRange
category:"Animation"
buttontext:"ANIMRANGE"
toolTip:"Hold Animation Range\n +SHIFT\t\t- Fetch"
(
	local animrange = undefined
	on execute do 
	(
		if keyboard.shiftpressed then 
			try (animationRange = animrange) catch() 
		else 
			animrange = animationRange
	)
)

 

Here is a macro script, and this is how I would do it if I wanted to keep all simple.

Instead of defining an additional rollout (popup dialog), I would use the same button on the toolbar to hold the state of the animation range and retrieve the previously held one by pressing the same button with the SHIFT key.

The CTRL and ALT modifier keys are used by the MAX dialog protocol, as well as mouse right-click, and cannot simply be used with a custom user interface. Therefore, only the SHIFT key is available as an option.

 

 

Message 6 of 12
dg3duy
in reply to: denisT.MaxDoctor

Excellent explanation, thank you very much!
Message 7 of 12

We can also use the "button ON" to hold the range and the "button OFF" to bring it back, +SHIFT to override the range. But, in my opinion, this functionality will be less convenient.

Message 8 of 12
dg3duy
in reply to: dg3duy

I totally agree, as it is, it is perfect for my needs.
as it is not a button maybe it is not possible to change the internal text when it was first used?

Message 9 of 12

Hello,

 

After executing this, on the button, we can able to right click, so that some menu will be displayed and functionalities will be executed according to the selection.

 

Upto Max 2015, we superclass the right click procedure to avoid showing the menu, that works fine. When we shifted to Max 2018, (Qt started), the same right click procedure is not working. Means, the menu is showing on right click.

 

Any idea how to disable right click - after Max 2018 version?

 

Regards,

Gopinath.

Message 10 of 12

 


@tagopinath wrote:

Upto Max 2015, we superclass the right click procedure to avoid showing the menu, that works fine.


could you show how you did it in versions "up to max 2015"?

Message 11 of 12

Here is how i am doing 

// this is in begineditparams function

::EnumChildWindows(GetCOREInterface()->GetMAXHWnd(), EnumChildModel, 0);

// using RightWnd - finding the CustButton

for(int i=0;i<NumOfToolBars;i++)
{
EnumChildWindows(RightWnd[i],EnumChildModel1,0);
}

 

///////////////////

// definition for EnumChild functions

//In EnumChildModel - finding all CustToolbar

BOOL CALLBACK EnumChildModel(HWND hWnd, LPARAM lParam)
{
TCHAR stmain1[100], stmain2[100];
static int iCount=0;
GetClassName(hWnd, stmain1, 100);

if(_tcscmp(stmain1, L"CustToolbar")==0)
{
RightWnd[iCount]=hWnd;
iCount++;
}
return true;
}

 

 

 

BOOL CALLBACK EnumChildModel1(HWND hWnd, LPARAM lParam)
{
TCHAR st1[100];
GetClassName(hWnd, st1, 100);

if(_tcscmp(st1, L"CustButton")==0)
{
rightproc = (WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) RightClickProc);
}
return true;
}

 

// superclassing right click procedure

LRESULT APIENTRY RightClickProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
if(uMsg == WM_RBUTTONDOWN)
{
return TRUE;
}
return CallWindowProc(rightproc, hwnd, uMsg,
wParam, lParam);
}

 

Regards,

Gopinath.

Message 12 of 12

Ok. I see now. I was confused by your sentence "we superclass the right click procedure".

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report