Notifications
Clear all

[Closed] Plugin Development Advice

Hi all!

I’m currently attempting to develop a plugin for max 8, which will act a generical tool box, allowing users to store macros and scripts that they commonly use during there everyday work.

I have a maxscript version running, but is not very pretty.

I’ve started playing around with a GUP plugin class, as it seems the best choice for what I want to do, but I’m having some issues getting it started…

The basic problem I am having right now is that when the “start” method is called, max is not in a state that it can create a custom ui frame…or at least it is not doing it for me.


 DWORD ZO_ToolBox::Start( ) {
 	HWND hWndMax = MaxWnd();
 
 	// I aslo checked the "GetCOREInterface()->GetMAXHWnd()" at they are the same
 
 	ICUIFrame* iFrame = GetICUIFrame(hWndMax);
 	if (iFrame) {
 		DebugPrint( _T("Start:iFrame = %u
"), iFrame->GetHwnd());
 	} else {
 		DebugPrint( _T("Could not get frame...?
"));
 	}
 
 	//ICUIFrame* iFrame = ::GetICUIFrame(hWndMax);
 	/*
 	iFrame->SetContentType(CUI_TOOLBAR);
 	iFrame->SetPosType(CUI_HORIZ_DOCK | CUI_VERT_DOCK | CUI_FLOATABLE | CUI_SM_HANDLES);
 
 	ReleaseICUIFrame(iFrame);
 	*/
 	return GUPRESULT_KEEP;
 }
 

I guess what I want to know, is there a better plugin interface to use or is there a way to tell when max has finished loading? I had a quick look at the core interface callbacks, but nothing immediatly jumped out at me.

Cheers
Shane

14 Replies

Unless I’m mistaken, you can achieve what you are trying to do without any code at all.

Max allows you to create a custom toolbar (Customize->UI) and add any macroscripts you want to it. You can dock/float the window however you want.

Or did you want something more specific? But it sure sounded like that’s what you’re after from your description.

Note that GUPs are not designed to provide a UI, as stated in the docs, they merely allow you to create a thread that runs alongside max, created during startup to perfrom some sort of custom processing.

If you want to create some sort of graphical Utility plugin, you should use class UtilityObj.

1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

Oh, I wish it were that simple…

We need to be able to add normal maxscripts to it as well (although I believe you can drop scripts onto the toolbar and have them converted). They also need to be sorted into “groups” (hence the question about rollout panels) and the user needs the ability to store both “user” specific tools as well as “studio” specific tools.

That is, the user should be able to add their own tools to the toolbox and intermix it with tools shared over the network by the whole studio…

Note that GUPs are not designed to provide a UI, as stated in the docs,

Yeah, I thought I might be able to sneak one in…

they merely allow you to create a thread that runs alongside max, created during startup to perfrom some sort of custom processing.

That would explain why it won’t create a ui element, it’s not in the right thread.

If you want to create some sort of graphical Utility plugin, you should use class UtilityObj.
Okay, but do utility objects need to be run from the utility pane? Is there a way to get it to run on startup??

Cheers
Shane

Right, maxscripts get converted into macroscripts as that is their purpose. Maxscripts can’t be directly run as ‘actions’ from a toolbar/menu/quadmenu, they must be macros first.

That would explain why it won't create a ui element, it's not in the right thread.

Well, that’s probably not the reason, as you have to create a thread yourself first, which you didn’t. Max won’t create one for you.

I can’t think of any technical reason why you can’t popup your own window during initialization, and have it cleaned up during shutdown (Start(), Stop() methods respectively) though, so it probably should work.

 Okay, but do utility objects need to be run from the utility pane?  Is there a way to get it to run on startup??

Yep, in that case a utility probably won’t be the best idea. You essentially want some sort of uber-custom toolbar. Hmmm…

Looking at your code, I see something suspicious. You are trying to get an interface to a CUIFrame from Max’s HWND. I don’t believe you can do that, as the max window is not of this class. I presume your code is failing there, printing your error message “Could not get frame”. Is that the case?

1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

What, other then the fact I’m doing something wrong…!?

Yep, in that case a utility probably won’t be the best idea. You essentially want some sort of uber-custom toolbar. Hmmm…
You’ve meet my boss then?

Looking at your code, I see something suspicious. You are trying to get an interface to a CUIFrame from Max’s HWND. I don’t believe you can do that, as the max window is not of this class. I presume your code is failing there, printing your error message “Could not get frame”. Is that the case?
Yes, it essentially returning a null pointer at this point…

Shane

ed: So from the sounds of it, I need to create my own HWND…?? How can I do that from inside max??

Yep, that’s what I thought.

Your code was trying to hijack max’s window handle and manipulate it in an impossible way

You can create any HWND using CreateWindow(Ex). However, you probably want to make a dockable window. For this max provides a CUIFrame, as you already know.

To create one, use CreateCUIFrameWindow().

HWND hWnd = CreateCUIFrameWindow(hWndMax, …);

So simple when you think about it…

This seems to work, but the frame is not currently visible…I need to read into the docs a little deeper.

Cheers
Shane

Look up ShowWindow() on the MSDN.

It sounds like you’re relatively new to the Win32 API. Might I recommend a great resource on general Win32 UI programming (as well as some great stuff on systems programming) at http://www.catch22.net .

This guy’s site is really amazing and I wholeheartedly recommend a look at it

MSDN is great, but it’s a reference. It won’t teach you the basic fundamentals and tricks of the trade.

(Of course, it goes without mentioning that you should have some Win32 Books on your desk too)

Success!

Once I actually resized and moved the window onto the screen … should have seen that one…so obvious!

Yes, I’m a noob to the windows api…I’ve been coding under java for the last 7 years…how i miss it…The last time I touched c++ was under dos and unix (wrote my own windowing api under dos, was quite cool)…

Thanks for the heads up. I’ll be heading over to catch22 shortly. I’m trying to come up to speed on several fronts, c++, max api, windows api, fusion api all fun stuff…

Cheers and thanks again!!
Shane

Whoa, that’s quite a lot to chew.

I foresee some major headaches if you’re learning all that at one time.

Good luck, anyhow.

Thanks for the link Alex. I knew this site but forgot it. Very interesting, well written and complete tutorials on win32 API!

No worries, hope you find it useful. I sure have.

Page 1 / 2