Class ViewWindow

3DS Max Plug-In SDK

Class ViewWindow

See Also: Class Interface.

class ViewWindow : public InterfaceServer

Description:

This class is available in release 3.0 and later only.

This the base class for the creation of non-3D windows that appear in a 3ds max viewport. These views are called "Extended Viewports". In order for a window to appear inside a viewport, you need to derive a class from this class. An instance of the derived class must be registered via the RegisterViewWindow() call in the Interface class. A given ViewWindow derivative should only be registered once.

When developers have registered their window types, the list of available extended views will appear in the view selection pop-up (either in the right-click viewport menu or the Viewport Configuration dialog) as a submenu of the "Extended" view label.

There are two items which should be made in the extended viewport dialog proc code:

Interface::MakeExtendedViewportActive() should be called whenever the user clicks in the non-3D window (so as to deactivate the current 3D window, and redirect commands like the Min/Max toggle to the non-3D viewport window).

Interface::PutUpViewMenu() should be called when the user right-clicks in a dead region of the non-3D window. This brings up the view selection menu so that the user can choose to replace the current window with a 3D or other non-3D window without having to go to the Views | Viewport Config dialog directly.

All methods of this class are implemented by the plug-in.

Sample Code:

class TestViewWindow : public ViewWindow {

public:

 TCHAR *GetName() { return _T("TestViewWindow"); }

 HWND CreateViewWindow(HWND hParent, int x, int y, int w, int h);

 void DestroyViewWindow(HWND hWnd);

};

 

HWND TestViewWindow::CreateViewWindow(HWND hParent, int x, int y, int w, int h) {

return CreateWindow("button", "Test Button", WS_VISIBLE | WS_CHILD, x, y, w, h, hParent, NULL, (HINSTANCE)GetWindowLong(hParent, GWL_HINSTANCE), NULL);

}

 

void TestViewWindow::DestroyViewWindow(HWND hWnd) {

 DestroyWindow(hWnd);

}

static TestViewWindow tvw;

Methods:

public:

Prototype:

virtual TCHAR *GetName()=0;

Remarks:

Returns the name of the window type. For example, "Asset Manager".

Prototype:

virtual HWND CreateViewWindow(HWND hParent, int x, int y, int w, int h)=0;

Remarks:

Creates and returns a handle to a new extended view window.

Parameters:

HWND hParent

The handle of the parent window.

int x

The x coordinate of the window's upper left corner.

int y

The y coordinate of the window's upper left corner.

int w

The window width.

int h

The window height.

Prototype:

virtual void DestroyViewWindow(HWND hWnd)=0;

Remarks:

Destroys the previously created window as specified by the handle.

Parameters:

HWND hWnd

The handle of the window to destroy.

Prototype:

virtual BOOL CanCreate();

Remarks:

Returns TRUE if the ViewWindow can be created; otherwise FALSE. This method can be overridden to return FALSE if a ViewWindow can only have a single instance, and that instance is already present. If this method returns FALSE, then the menu item for this ViewWindow will be grayed out.

Default Implementation:

{ return TRUE; }

Prototype:

virtual int NumberCanCreate();

Remarks:

This method is available in release 4.0 and later only.

This method returns the number of instances of a given window that can be created. This allows, for example, the UI to know without physically creating a window that only a limited number of windows of that type can be created. A -1 implies that the count is not known.

Default Implementation:

{ return -1; }