Developer: C++
Summary: The Rhino Application Platform (RAP) provides the tools for C++ developers to wrap their application around Rhino by creating a custom Skin.
Rhino allows developers to customize most of Rhino's interface so that the application appears to be their own. We call this a custom Skin. With a custom Skin, you can change the application icon, splash screen, the menu bar, the application title bar, the about box, and the toolbars.
Creating a custom Skin for Rhino involves creating two code modules:
// Skin DLL menu update handler void OnInitPlugInMenuPopups(WPARAM wparam, LPARAM lparam); // Skin DLL menu command handler BOOL OnPlugInMenuCommand(WPARAM wparam ); // Change to CRhinoPlugIn::load_plugin_at_startup plugin_load_time PlugInLoadTime();
CRhinoPlugIn::plugin_load_time CSkinPlugInSamplePlugIn::PlugInLoadTime() { // Override to change load time to "at startup" return CRhinoPlugIn::load_plugin_at_startup; }
#include "stdafx.h" #include "MySkinPlugIn.h" #include "../MySkinDLL/Resource.h" // Put these to overrides in a separate CPP file so they could // include the MySkinDLL/Resource.h file without conflicting // with this projects resource.h void CSkinPlugInSamplePlugIn::OnInitPlugInMenuPopups(WPARAM wParam, LPARAM lParam) { HMENU hMenu = (HMENU)wParam; if( NULL == hMenu ) return; switch( GetMenuItemID(hMenu, LOWORD(lParam)) ) { case IDM_SAMPLE_DISABLE: ::EnableMenuItem( hMenu, IDM_SAMPLE_DISABLE, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED ); break; case IDM_SAMPLE_SUB_DISABLE: ::EnableMenuItem( hMenu, IDM_SAMPLE_SUB_DISABLE, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED ); break; // TODO... } } BOOL CSkinPlugInSamplePlugIn::OnPlugInMenuCommand(WPARAM wParam) { ON_wString w; switch( (UINT)wParam ) { case IDM_SAMPLE_ONE: w = L"Test Item One"; break; case IDM_SAMPLE_TWO: w = L"Two"; break; case IDM_SAMPLE_DISABLE: w = L"Disabled"; break; case IDM_SAMPLE_SUB_A: w = L"Sub Menu A"; break; case IDM_SAMPLE_SUB_B: w = L"Sub Menu B"; break; case IDM_SAMPLE_SUB_DISABLE: w = L"Sub Menu Disabled"; break; default: return true; } ::RhinoMessageBox( w, L"OnMenu", MB_OK ); return true; }
To install your custom Skin, use REGEDIT.EXE to add a scheme key to your registry with a path to your Skin DLL. For example:
| Item | Value |
| Subkey | HKEY_LOCAL_MACHINE\SOFTWARE\McNeel\Rhinoceros\4.0\Scheme: MySkin |
| Entry name | SkinDLLPath |
| Type | REG_SZ |
| Data value | C:\Src\MySkin\MySkinDLL\Release\MySkinDLL.rhs |
You can now test your custom Skin by creating shortcut to your Rhino executable with /scheme=”<scheme name from the previous step>” as command line argument. For example:
"C:\Program Files\Rhinoceros 4.0\System\Rhino4.exe" /scheme=MySkin
If the user chooses not to run your skinned version of Rhino, you might want to prevent your skin plug-in loading. You can do this by checking to see if the name of the scheme, that Rhino is using, matches your skin's scheme name. Do this checking in your plug-in's CRhinoPlugIn::OnLoadPlugIn() member.
For example:
BOOL CSkinPlugInSamplePlugIn::OnLoadPlugIn() { ON_wString scheme = RhinoApp().RegistrySchemeName(); if( scheme.CompareNoCase(L"Scheme: MySkin") != 0 ) return -1; // Fail silently... // TODO... return CRhinoUtilityPlugIn::OnLoadPlugIn(); }