Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC Activex Control

MFC Activex Control

Scheduled Pinned Locked Moved C / C++ / MFC
c++comalgorithmstutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RichardK151
    wrote on last edited by
    #1

    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!

    L 1 Reply Last reply
    0
    • R RichardK151

      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!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      If Google does not find any then you may have to do the design yourself.

      R 1 Reply Last reply
      0
      • L Lost User

        If Google does not find any then you may have to do the design yourself.

        R Offline
        R Offline
        RichardK151
        wrote on last edited by
        #3

        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.

        L L 2 Replies Last reply
        0
        • R RichardK151

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Member 12785864 wrote:

          Have you got a code snippet of how to create a control at runtime?

          No: as I said, if Google cannot find one then you most likely have to figure it out yourself.

          1 Reply Last reply
          0
          • R RichardK151

            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.

            L Offline
            L Offline
            leon de boer
            wrote on last edited by
            #5

            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

            R 1 Reply Last reply
            0
            • L leon de boer

              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

              R Offline
              R Offline
              RichardK151
              wrote on last edited by
              #6

              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

              L 1 Reply Last reply
              0
              • R RichardK151

                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

                L Offline
                L Offline
                leon de boer
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups