View Full Version : Plugin Development Advice
RustyKnight 10-11-2007, 02:13 AM 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\n"), iFrame->GetHwnd());
} else {
DebugPrint( _T("Could not get frame...?\n"));
}
//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
|
|
scorpion007
10-11-2007, 02:41 AM
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.
RustyKnight
10-11-2007, 03:11 AM
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.
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
scorpion007
10-11-2007, 04:42 AM
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).
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?
RustyKnight
10-11-2007, 04:52 AM
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.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??
scorpion007
10-11-2007, 05:01 AM
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().
RustyKnight
10-11-2007, 05:06 AM
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
scorpion007
10-11-2007, 05:11 AM
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)
RustyKnight
10-11-2007, 05:23 AM
Success!
Once I actually resized and moved the window onto the screen :P ... 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 :P all fun stuff...
Cheers and thanks again!!
Shane
scorpion007
10-11-2007, 05:40 AM
Whoa, that's quite a lot to chew.
I foresee some major headaches if you're learning all that at one time. :P
Good luck, anyhow.
ypuech
10-11-2007, 07:54 AM
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 :)
Thanks for the link Alex. I knew this site but forgot it. Very interesting, well written and complete tutorials on win32 API!
scorpion007
10-11-2007, 08:03 AM
No worries, hope you find it useful. I sure have.
RustyKnight
10-11-2007, 11:54 PM
Whoa, that's quite a lot to chew.
I foresee some major headaches if you're learning all that at one time. :P
Good luck, anyhow.
Oh so use to that...i keep putting maxscript into C, java into maxscript and god knows what I'm puting into C and I want kill the developers of lua...but it's all fun...:scream:
scorpion007
10-12-2007, 01:57 AM
Just wondering, why couldn't this be achieved by making multiple toolbars? E.g. Make one toolbar for "Studio tools", and users can make their own custom ones as they see fit. I believe max allows one to export their set of toolbars, so you easily pass around the .cui file and load it up on each machine, and that would save you the hassle of handling all this stuff manually (making the toolbox UI, remembering what each toolbar has (serializing/deserializing its contents), making it as robust and bugfree as the existing solution). All these things cost time and effort, as you know, so no point reinventing what is already there.
But I can only guess you have some really custom needs that the current toolbar mechanism can't accomplish.
But then again, max is pretty flexible in its UI configuration.
Just my thoughts.
RustyKnight
10-12-2007, 02:04 AM
Don't tell em that! I'm getting paid to do this stuff!! ;)
I think the general idea is to keep the toolbox together in one place/window and allow the addition of standalone scripts, without the need to convert them to macros.
We're having problems with macro's having to be copied locally when the machines start as it is.
But you are right, that would work.
Cheers
Shane
CGTalk Moderation
10-12-2007, 02:04 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.