Notifications
Clear all
[Closed] dinamic custom control creation
Aug 02, 2007 1:44 pm
hi there,
does anyone have ever tried to append a max sdk rollup to a IRollupWindow and to fill a dialog template at runtime, rather than getting it from a cpp resource file ? We want to dinamically add custom controls to rollup at runtime. Help will be very much appreciated =)
1 Reply
Aug 02, 2007 1:44 pm
1.) some definitions
// the rollup template
HGLOBAL hTemplate = NULL;
// control-IDs
#define IDC_PUSHME 2000
// dialog proc
INT_PTR CALLBACK dlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
2.) create a dialogtemplate
// create a rollup template
HGLOBAL CreateRolloutTemplate()
{
HGLOBAL _hTemplate = GlobalAlloc(GPTR, sizeof(DLGTEMPLATE)+ LF_FACESIZE * 2);
DLGTEMPLATE* _lpTempl_Rollout = (DLGTEMPLATE*)GlobalLock(_hTemplate);
_lpTempl_Rollout->style = DS_SETFONT | WS_CHILD | WS_VISIBLE;
_lpTempl_Rollout->dwExtendedStyle = 0;
_lpTempl_Rollout->cdit = 0;
_lpTempl_Rollout->x = 0;
_lpTempl_Rollout->y = 0;
_lpTempl_Rollout->cx = 81;
_lpTempl_Rollout->cy = 100;
GlobalUnlock(_hTemplate);
return _hTemplate;
}
3.) appendRollout
hTemplate = CreateRolloutTemplate();
DLGTEMPLATE* _lpTempl_Rollout = (DLGTEMPLATE*)GlobalLock(hTemplate);
IRollupWindow->AddRollupPage(hInstance, _lpTempl_Rollout, dlgProc, _T("mem-template"));
GlobalUnlock(hTemplate);
replace "IRollupWindow" by your IRollupWindow-pointer
4.) create controls
// the rollup proc
INT_PTR CALLBACK dlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
CreateWindow("Button", "Push me", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 5, 5, 100, 21, hWnd, (HMENU)IDC_PUSHME, hInstance, NULL);
break;
default: return FALSE;
}
return TRUE;
}
5.) when you dont need it anymore, call GlobalFree(hTemplate);
somwhere in you code
6.) good luck
any further question ? feel free to ask...
guruware