PDA

View Full Version : SDK: Rollout Panel issues


RustyKnight
01-06-2008, 02:07 AM
Hi all, probably a really stupid question, but...

I've been playing around with a ICUIFrame, IRollupWindow and IRollupPane, but...the IRollupPanel does not appear to be working as I would expect it...

Basically, I'm expecting a rollup simular to the scripted rollup...with a border, title and control...but I don't appear to be getting anything...

The code needs to dynamically generate a un-unknown number of rollout's at runtime, so I can't simply create UI by hand during development, it needs to be done at runtime...just thought I'd mention it.

// Get Max's window handle...this is done this way, because we are in a GUP
HWND hParent = ip->GetMAXHWnd();
// Create the CUI frame window via a dynamic method call...see belown
HWND hWnd = ::CreateCUIFrameWindow(hParent, _T("CUI Test Toolbar"), 0, 0, 250, 100);

// Get a reference to the ICUIFrame interface representing this window...
pCUIFrame = ::GetICUIFrame(hWnd);

// Setup the window
pCUIFrame->SetContentType(CUI_HWND);
pCUIFrame->SetPosType(CUI_HORIZ_DOCK | CUI_VERT_DOCK | CUI_FLOATABLE | CUI_SM_HANDLES);

// Install the message handler...used for dealing with frame specific events
pCUIFrame->InstallMsgHandler(this);

// Move the window to a default location
MoveWindow(hWnd, 100, 100, 100, 100, TRUE);

// Create the rollup window ... see below for the method call
// This is working, as I can see scrollbars and the containers border etc...
pRollupWindow = CreateDynamicRollupWindow(_T("TestRollupWindow"), 0, 0, 100, 100, hWnd, hInstance);

// Append a rollup pane
// This uses a "Dialog"/IDlgEditor resource with nothing but a default
// label on it...
int value = pRollupWindow->AppendRollup(hInstance, MAKEINTRESOURCE(IDD_TEMPLATE), (DLGPROC)DynamicsRollupDialogProc, _T("Test"), (LPARAM)this);

// Get the window handle of the panel...
HWND hRollup = pRollupWindow->GetPanelDlg(value);

// I though that the rollout may need to be resized...?
DebugPrint( _T("Move rollup pane into place...\n") );
MoveWindow(hRollup, 0, 0, 100, 100, true);

//IRollupPanel *pRollup = pRollupWindow->GetPanel(hRollup);

// This does some basic layout functionaility
DoLayout();
}

These are the "dynamic" control creation methods I used in the above snippet
HWND CreateDynamicControl(MCHAR *className, MCHAR *name, DWORD style, int x, int y, int width, int height, HWND hParent, HINSTANCE hInstance) {

return CreateWindow(
className,
name,
style,
x, y, width, height,
hParent,
NULL,
hInstance,
NULL);

}

IRollupWindow *CreateDynamicRollupWindow(MCHAR *name, int x, int y, int width, int height, HWND hParent, HINSTANCE hInstance) {

HWND hCtrl = CreateDynamicControl(
ROLLUPWINDOWCLASS,
name,
WS_CHILD | WS_VISIBLE,
x, y, width, height,
hParent,
hInstance);

return GetIRollup(hCtrl);

}

ICustToolbar *CreateDynamicToolBar(MCHAR *name, int x, int y, int width, int height, HWND hParent, HINSTANCE hInstance) {

HWND hCtrl = CreateDynamicControl(
CUSTTOOLBARWINDOWCLASS,
name,
WS_CHILD | WS_VISIBLE,
x, y, width, height,
hParent,
hInstance);

return GetICustToolbar(hCtrl);

}Any ideas, recommendations and suggestions are, as always, very welcome...

Cheers
Shane

scorpion007
01-06-2008, 02:47 AM
Can you paste the source to IDD_TEMPLATE? (In the .rc file)

I'm guessing either your window is created invisible, or the window creation is failing somewhere. I'd recommend you step through the debugger carefully (with F10) and bring up a Watch window, and add the expression "@err, hr" to one of the entries.

As you step over each call to CreateWindowEx and AppendRollup (which calls CreateWindowEx internally), observe the Watched expression for any changes.

RustyKnight
01-06-2008, 04:46 AM
Can you paste the source to IDD_TEMPLATE? (In the .rc file)

I'm guessing either your window is created invisible, or the window creation is failing somewhere. I'd recommend you step through the debugger carefully (with F10) and bring up a Watch window, and add the expression "@err, hr" to one of the entries.

As you step over each call to CreateWindowEx and AppendRollup (which calls CreateWindowEx internally), observe the Watched expression for any changes.Hi scorpion, good to hear from you...again ;)

I've attached the RC file (VS 2005) so you can have a look over it...I will have a look over the debug when I next get a chance...

Thanks for the ideas

Shane

RustyKnight
01-06-2008, 04:58 AM
Can you paste the source to IDD_TEMPLATE? (In the .rc file)

I'm guessing either your window is created invisible, or the window creation is failing somewhere. I'd recommend you step through the debugger carefully (with F10) and bring up a Watch window, and add the expression "@err, hr" to one of the entries.

As you step over each call to CreateWindowEx and AppendRollup (which calls CreateWindowEx internally), observe the Watched expression for any changes.I had a look at the debug suggestion it remained as s_ok through out the execution the creation methoth (where I setup the window).

It is possible the the window is invisible, although I thought I set the visibility property on the resource and createWindow style to visible...but these things could have been overlooked.

I wondering if it might have to do with the type of panel I'm using....

Shane

scorpion007
01-06-2008, 07:04 AM
Ah, I think I know what the problem is -- you haven't set any content for your CUI frame.

You've told it to show a custom window (HWND), but haven't told it which one.

Call ICUIFrame::SetContentHandle() to do so. Pass in pRollupWindow->GetHwnd() as the argument.

Though personally, from a style POV, I'd refactor your code and get rid of the seemingly useless CreateDynamicControl() function. It looks like a unnecessary wrapper around CreateWindow that adds little functionality, if any. Your CreateDynamicRollupWindow hides the return value of CreateWindow, which you could have used directly in <whatever the main method is called> for ICUIFrame::SetContentHandle().

But anyway, make it work correctly first.

RustyKnight
01-06-2008, 09:34 AM
Ah, I think I know what the problem is -- you haven't set any content for your CUI frame.

You've told it to show a custom window (HWND), but haven't told it which one.

Call ICUIFrame::SetContentHandle() to do so. Pass in pRollupWindow->GetHwnd() as the argument.Knew it was something stupid :P

Though personally, from a style POV, I'd refactor your code and get rid of the seemingly useless CreateDynamicControl() function. It looks like a unnecessary wrapper around CreateWindow that adds little functionality, if any. Your CreateDynamicRollupWindow hides the return value of CreateWindow, which you could have used directly in <whatever the main method is called> for ICUIFrame::SetContentHandle().Yeah, I tend to over abstract, it's a bad habit...

Shane

RustyKnight
01-06-2008, 09:41 AM
Ah, I think I know what the problem is -- you haven't set any content for your CUI frame.

You've told it to show a custom window (HWND), but haven't told it which one.

Call ICUIFrame::SetContentHandle() to do so. Pass in pRollupWindow->GetHwnd() as the argument.Just a quick update, I tried that and it mad no difference...or least from what I can see ;)

I still get the "scrollable" area of the RollupWindow, which, as I understand it, is capable of holding 0 or more RollupPanels...and in fact, when the plugin first loads, it shows the scrollbar...which is making me think that SOMETHING is happening...

However, I'm not seeing the roll up panel when the plugin loads...My expectation is that I'll get the normal "RollUp", with a title area, bounding box and expand/collapse control...now either I'm doing something wrong or my expectations are incorrect...

I will have a look at the custom control example tommorrow and see if I can un-earth anything. If you have any other strokes of brillance, let me know...

Cheers
Shane

scorpion007
01-06-2008, 10:56 AM
Sounds fishy. Did it show the scrollbar before you made the change?

Could you post your dialog procedure for the rollup panel, and DoLayout()'s code, and does your message handler do anything 'funny' (pCUIFrame->InstallMsgHandler(this)) ?

Perhaps post the (modifed) complete method source too.

RustyKnight
01-06-2008, 08:38 PM
Sounds fishy. Did it show the scrollbar before you made the change?Yes, this has been working quite fine since I changed the content type TO hwnd, and before I set the hWnd
Could you post your dialog procedure for the rollup panel, and DoLayout()'s code, and does your message handler do anything 'funny' (pCUIFrame->InstallMsgHandler(this)) ?

Perhaps post the (modifed) complete method source too.Yep, not problem. I've attached the source code (as much as I can and stay under the 2 meg limited)

DoLayout - This method only effcts the pRollupWindow so far, it will handle the remaining windows eventually...
void CustomToolBar::DoLayout() {

// Get the various window rectangles
RECT windowRect;
RECT clientRect;
RECT maxClientRect;
GetWindowRect(pCUIFrame->GetHwnd(), &windowRect);
GetClientRect(pCUIFrame->GetHwnd(), &clientRect);
GetClientRect(GetCOREInterface()->GetMAXHWnd(), &maxClientRect);

// Default spacing within the main CUIFrame
int hGap = 10;
int vGap = 10;

// The default top/left offset
int xOffset = 5;
int yOffset = 5;

// Allow for some additional spacing at the top of the window for the
// CUIFrames handles
if (pCUIFrame->GetCurPosition() != CUI_FLOATING) {

vGap = 15;
yOffset = 10;

}

// Calculate the new client area
int width = (clientRect.right - clientRect.left) - hGap;
int height = (clientRect.bottom - clientRect.top) - vGap;

// Layout the pRollUpWindow...
MoveWindow(pRollupWindow->GetHwnd(), xOffset, yOffset, width, height, TRUE);

}
DynamicRollupDialogProc - Does nothing, as yet...although I might use it to manage the individual rollups contents...INT_PTR CALLBACK DynamicsRollupDialogProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) {

switch ( message )
{
case WM_INITDIALOG:
{
DebugPrint("WM_INITDIALOG\n");
break;
}
/*
DLSetWindowLongPtr(hDlg, lParam);
dlg = (JiggleTrackDlg*)lParam;
dlg->dynDlg = hDlg;
dlg->InitDynamicsParams();
return TRUE;
*/
case WM_DESTROY:
{
DebugPrint("WM_DESTROY\n");
break;
}
}

return FALSE;

}
ProcessMessage - This handles the CUI_POSDATA_MSG, WM_GETMINMAXINFO and, WM_SIZE messages...Yes, I know the breaks after the returns are redundent, force of habitint CustomToolBar::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam) {

switch(message) {
case CUI_POSDATA_MSG:
{

CUIPosData **cpd = (CUIPosData **)lParam;

cpd[0] = this;

return TRUE;

break;
}
case WM_INITDIALOG:
{
DebugPrint("ToolBarMsgHandler.WM_INITDIALOG\n");
break;
}
case WM_DESTROY:
{
DebugPrint("ToolBarMsgHandler.WM_DESTROY\n");
break;
}
case WM_GETMINMAXINFO:
{

DebugPrint( _T("wm_getMinMaxInfo\n") );
MINMAXINFO * pMinmax =( MINMAXINFO *)lParam ;

int width = GetWidth(CUI_MIN_SIZE, CUI_FLOAT);
int height = GetHeight(CUI_MIN_SIZE, CUI_FLOAT);

pMinmax->ptMinTrackSize.x = width;
pMinmax->ptMinTrackSize.y = height;
pMinmax->ptMaxTrackSize.x = width;
pMinmax->ptMaxTrackSize.y = height;

return TRUE;

break;
}
case WM_SIZE:
{

DoLayout();

break;
}
}

return FALSE;
}
The GetHeight/GetWidth methods for the CUIPosData class look like this
int CustomToolBar::GetHeight(int sizeType, int orient) {

int height = 100;

DebugPrint( _T("GetHeight...\n") );

if (GetICUIFrame()->GetCurPosition() != CUI_FLOATING) {
DebugPrint( _T("...CUIFrame is docked...\n") );

RECT windowRect;
RECT clientRect;
RECT maxClientRect;
GetWindowRect(pCUIFrame->GetHwnd(), &windowRect);
GetClientRect(pCUIFrame->GetHwnd(), &clientRect);
GetClientRect(GetCOREInterface()->GetMAXHWnd(), &maxClientRect);

height = (maxClientRect.bottom - maxClientRect.top) - 10;
}

return height;

}

int CustomToolBar::GetWidth(int sizeType, int orient) {

int width = 100;

return width;

}

The over intentation is, obviously, to manage the max/min size of the toolbar while it is floated and docked, as the calculations will change slightly. To this is end, some of the layout needs to be handled by the code into order to keep the RollupWindow sized correctly.

RustyKnight
01-06-2008, 10:55 PM
Slight progress, it doesn't help me much but might point to an underlying issue...

I added a CustEdit field to my dialog panel and now when I call AppendRollup the "@err, hr" returns: 0x00000578 Invalid window handle.And when I remove it, it works fine...

Shane

scorpion007
01-07-2008, 12:53 AM
had a quick look, it's because you're not calling IRollupWindow::Show(). The rollups are hidden by default, IIRC. (Probably so you can add a bunch without it redrawing after each one)

RustyKnight
01-07-2008, 01:09 AM
had a quick look, it's because you're not calling IRollupWindow::Show(). The rollups are hidden by default, IIRC. (Probably so you can add a bunch without it redrawing after each one)Excuse me while I go outside and shot myself...

The stupid thing was that the scrollbar was showing up properly, when the panel was to long for the avaliable space, it would allow scrolling...

Thank you so much for all that Scrop, very much appricated!!

Shane

scorpion007
01-07-2008, 01:22 AM
Glad it worked :)

CGTalk Moderation
01-07-2008, 01:22 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.