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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating a dialog from a COM dll

Creating a dialog from a COM dll

Scheduled Pinned Locked Moved C / C++ / MFC
com
2 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.
  • M Offline
    M Offline
    Matt Gates
    wrote on last edited by
    #1

    I am trying to display a CDialog derived class froma dll using COM. The COM stuff is working. It seems that my dialog is failing to create its own m_hWnd: void __stdcall CMattDlgCmpnt::HtmlMsgBox( HWND wndParent, BSTR strmsg ) { CWnd* pWnd = new CWnd(); pWnd = CWnd::FromHandle(wndParent); CNormalDlg *wndNormalDlg = new CNormalDlg( pWnd ); wndNormalDlg->DoModal(); } Debugging yields the following: {CNormalDlg hWnd=0x00000000} I tried doing this as well: CNormalDlg *wndNormalDlg = new CNormalDlg( pWnd ); wndNormalDlg->Create(IDD_DIALOG1); wndNormalDlg->ShowWindow(SW_SHOW); But then I get an nasty ASSERT here: #ifdef _DEBUG if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE)) { **ASSERT(FALSE); // invalid dialog template name** PostNcDestroy(); // cleanup if Create fails too soon return FALSE; } Any ideas. Thanks. Matt (Padawan Learner)

    P 1 Reply Last reply
    0
    • M Matt Gates

      I am trying to display a CDialog derived class froma dll using COM. The COM stuff is working. It seems that my dialog is failing to create its own m_hWnd: void __stdcall CMattDlgCmpnt::HtmlMsgBox( HWND wndParent, BSTR strmsg ) { CWnd* pWnd = new CWnd(); pWnd = CWnd::FromHandle(wndParent); CNormalDlg *wndNormalDlg = new CNormalDlg( pWnd ); wndNormalDlg->DoModal(); } Debugging yields the following: {CNormalDlg hWnd=0x00000000} I tried doing this as well: CNormalDlg *wndNormalDlg = new CNormalDlg( pWnd ); wndNormalDlg->Create(IDD_DIALOG1); wndNormalDlg->ShowWindow(SW_SHOW); But then I get an nasty ASSERT here: #ifdef _DEBUG if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE)) { **ASSERT(FALSE); // invalid dialog template name** PostNcDestroy(); // cleanup if Create fails too soon return FALSE; } Any ideas. Thanks. Matt (Padawan Learner)

      P Offline
      P Offline
      Prakash Nadar
      wrote on last edited by
      #2

      Hahahaha, i pity you man, coz you just dont know where the problem is:-D. dont worry i have been there too. just add this line at the start of the CMattDlgCmpnt::HtmlMsgBox method. AFX_MANAGE_STATE(AfxGetStaticModuleState()) if this doesnt solve ur problem, ur then on ur own. basically MFC dialogs and COM are not a good mix. u should try to use WTL or win32 way of poping a dialog. The world is becoming small and so are the people.

      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