MFC Activex Control
-
Hi,
i want to create a composite activex control to put together several contols. The control must be fully transparent and consist of several self written and 3rd party controls. I was searching the web for several days now and cannot find any sample / tutorial for this.
Thanks in advance!
-
Hi,
i want to create a composite activex control to put together several contols. The control must be fully transparent and consist of several self written and 3rd party controls. I was searching the web for several days now and cannot find any sample / tutorial for this.
Thanks in advance!
-
Yes, right, that's the question! How can i load / create the additional controls, if not at designtime, maybe at runtime, without getting a linker error? Positioning the additional control will be done at runtime, when the contol changes size, anyway. I have included the LIB-file of my control into the references, but the error stays. Have you got a code snippet of how to create a control at runtime? I am really desperate for this.
-
Yes, right, that's the question! How can i load / create the additional controls, if not at designtime, maybe at runtime, without getting a linker error? Positioning the additional control will be done at runtime, when the contol changes size, anyway. I have included the LIB-file of my control into the references, but the error stays. Have you got a code snippet of how to create a control at runtime? I am really desperate for this.
-
Yes, right, that's the question! How can i load / create the additional controls, if not at designtime, maybe at runtime, without getting a linker error? Positioning the additional control will be done at runtime, when the contol changes size, anyway. I have included the LIB-file of my control into the references, but the error stays. Have you got a code snippet of how to create a control at runtime? I am really desperate for this.
You can do it via the resource system, you can extend it to even deal with custom controls and even activeX ones. Search "Win32 dialog template at runtime" it is fairly commonly done with dialog templates but you can do it with windows or anything else. Essentially the WM_CREATE (OnCreate in MFC) loads the dialog template from a resource and you create the setup on the fly.
In vino veritas
-
You can do it via the resource system, you can extend it to even deal with custom controls and even activeX ones. Search "Win32 dialog template at runtime" it is fairly commonly done with dialog templates but you can do it with windows or anything else. Essentially the WM_CREATE (OnCreate in MFC) loads the dialog template from a resource and you create the setup on the fly.
In vino veritas
Hello Leon, I have included the Controls .h file and created a member variable in the new control's class, but when i try to show the .ShowWindow(SW_SHOW) or MoveWindow function in the OnCreate or OnDraw nothing shows up. I could not add the contol to the ressource editor, because I don't want to / need a dialog in the new control. Have you got any other idea? Thanks a lot. Richard
-
Hello Leon, I have included the Controls .h file and created a member variable in the new control's class, but when i try to show the .ShowWindow(SW_SHOW) or MoveWindow function in the OnCreate or OnDraw nothing shows up. I could not add the contol to the ressource editor, because I don't want to / need a dialog in the new control. Have you got any other idea? Thanks a lot. Richard
You don't have to add the resource you make a memory template, its the exact opposite of a resource ... I am not sure you are really getting it In code you do this creating a memory block which you make the template in
bool CreateRotation (HWND parent){
int nchar, ret;
HGLOBAL hgbl;
LPDLGTEMPLATE lpdt;
LPWORD lpw;
LPWSTR lpwsz;
hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024); // Allocate memory
if (!hgbl) return false; // If allocate fail exit
lpdt = (LPDLGTEMPLATE)GlobalLock(hgbl); // Lock the allocated memory
lpdt->style = WS_POPUP | WS_CAPTION | WS_SYSMENU; // Window style
lpdt->cdit = 0; // Number of controls
lpdt->x = 80; // X position
lpdt->y = 80; // Y position
lpdt->cx = 300; // Window width
lpdt->cy = 100; // Window height
lpw = (LPWORD)(lpdt + 1); // Set pointer address
*lpw++ = 0; // No menu
*lpw++ = 0; // Predefined dialog box class (by default)
lpwsz = (LPWSTR)lpw; // Typecast pointer
nchar = 1 + MultiByteToWideChar(CP_ACP, 0, LanguageString[652],
-1, lpwsz, 50); // Create name of window
lpw += nchar; // Increment by size of name
*lpw++ = 0; // No creation data
GlobalUnlock(hgbl); // Release lock on the memory block
ret = (int)DialogBoxIndirectParam(GetModuleHandle(0),
(LPDLGTEMPLATE)hgbl,
parent,
(DLGPROC)RotationHandler,
0); // Create the dialog from template
GlobalFree(hgbl); // Free the allocated memory
if (ret == ID_Ok) {
PostMessage(parent, WM_COMMAND, WSC_UPDATEEVERYTHING, 0);
return true;
} else return false; // Return result
};They are called runtime dialogs or dynamic dialogs but you can always know you are on the right track when you see the use of GlobalAlloc because you have to lock a block of memory to create the dialog in, which is why you don't need resource files etc. Dynamic Dialog Boxes and C++ | Dr Dobb's[^]
In vino veritas