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. Creating ActiveX controls in ActiveX Property pages

Creating ActiveX controls in ActiveX Property pages

Scheduled Pinned Locked Moved C / C++ / MFC
comdockerquestion
3 Posts 2 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.
  • Z Offline
    Z Offline
    Zac Howland
    wrote on last edited by
    #1

    I have an OCX that I wrote containing two controls: a serial port enumerator (gives a list of the available serial ports on a system), and a serial port control (does the communications, event firing etc). The enumerator doesn't have any properties (just 1 method that returns a SAFEARRAY of BSTRs with port names). The serial port control has the usual serial port properties (baud rate, parity, handshaking, data bits, stop bits, and which events the user wants notification of). In the InitDialog function of the Serial port's property page, I wanted to use the Enumerator to fill in a combo box with the port names. However, when I try this, it gives an exception and crashes whatever container it is in. Here is how I am trying to create the enumerator control: BOOL CSerialPortPropPage::OnInitDialog() { COlePropertyPage::OnInitDialog(); CWnd wndEnum; CRect rc; rc.SetRect(0, 0, 0, 0); if (FALSE == wndEnum.CreateControl(_T("SERIALPORT.SerialEnumeratorCtrl.1"), NULL, 0, rc, this, 5000)) AfxMessageBox("Enumerator Creation failed!"); else AfxMessageBox("Enumerator Creation Passed!"); return FALSE; // since this is an OCX property page, return FALSE Is there something I am doing wrong (I've been looking at it way too long . . . everything looks okay to me, but it still isn't working). If this isn't correct, does anyone have a better way of accomplishing this? Thanks Zac Howland "If I create everything new, why would I want to delete anything?"

    E 1 Reply Last reply
    0
    • Z Zac Howland

      I have an OCX that I wrote containing two controls: a serial port enumerator (gives a list of the available serial ports on a system), and a serial port control (does the communications, event firing etc). The enumerator doesn't have any properties (just 1 method that returns a SAFEARRAY of BSTRs with port names). The serial port control has the usual serial port properties (baud rate, parity, handshaking, data bits, stop bits, and which events the user wants notification of). In the InitDialog function of the Serial port's property page, I wanted to use the Enumerator to fill in a combo box with the port names. However, when I try this, it gives an exception and crashes whatever container it is in. Here is how I am trying to create the enumerator control: BOOL CSerialPortPropPage::OnInitDialog() { COlePropertyPage::OnInitDialog(); CWnd wndEnum; CRect rc; rc.SetRect(0, 0, 0, 0); if (FALSE == wndEnum.CreateControl(_T("SERIALPORT.SerialEnumeratorCtrl.1"), NULL, 0, rc, this, 5000)) AfxMessageBox("Enumerator Creation failed!"); else AfxMessageBox("Enumerator Creation Passed!"); return FALSE; // since this is an OCX property page, return FALSE Is there something I am doing wrong (I've been looking at it way too long . . . everything looks okay to me, but it still isn't working). If this isn't correct, does anyone have a better way of accomplishing this? Thanks Zac Howland "If I create everything new, why would I want to delete anything?"

      E Offline
      E Offline
      Ernest Laurentin
      wrote on last edited by
      #2

      Did you call AfxEnableControlContainer()? As my daughter would say, "... Whatever!"

      Z 1 Reply Last reply
      0
      • E Ernest Laurentin

        Did you call AfxEnableControlContainer()? As my daughter would say, "... Whatever!"

        Z Offline
        Z Offline
        Zac Howland
        wrote on last edited by
        #3

        Yes, I called that in the module's InitInstance. Here is the code that throws the assertion in the test container: BOOL CWnd::Attach(HWND hWndNew) { ASSERT(m_hWnd == NULL); // only attach once, detach on destroy ASSERT(FromHandlePermanent(hWndNew) == NULL); // must not already be in permanent map if (hWndNew == NULL) return FALSE; CHandleMap* pMap = afxMapHWND(TRUE); // create map if not exist ASSERT(pMap != NULL); pMap->SetPermanent(m_hWnd = hWndNew, this); #ifndef _AFX_NO_OCC_SUPPORT AttachControlSite(pMap); #endif return TRUE; } I am not sure how it already has a Permanent handle since I just created the object on the stack. Any thoughts? Thanks again Zac "If I create everything new, why would I want to delete anything?"

        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