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. Trying to create a Popup Window

Trying to create a Popup Window

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiodata-structureshelp
3 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.
  • B Offline
    B Offline
    BobInNJ
    wrote on last edited by
    #1

    I would like to add a graph (x vs y plot ) to my application. I would like this graph to be displayed in a new window. Therefore, I wrote the following code: void CMyView::drawGraph() { /* virtual BOOL CreateEx( DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, LPVOID lpParam = NULL ); */ CRect rect1( 100, 200, 300, 400 ); CreateEx( 0, NULL, TEXT("Graph"), WS_OVERLAPPEDWINDOW|WS_CHILD, rect1, this, 0 ); } Unfortunately, the call to CWnd::CreateEx dies with an assertion error. The routine CWnd::CreateEx calls the routine AfxHookWindowCreate. This routine has the following assert statement in it: `ASSERT(pWnd->m_hWnd == NULL); // only do once` In my case, m_hWnd is non-NULL. Therefore, the program aborts. I am sure that I am doing something wrong in the call to CreateEx but I do not know what it is. Also, I find the documentation for this call to be lacking. For one thing, I could not find any examples where it was used to create a sub-window. Thanks Bob

    P I 2 Replies Last reply
    0
    • B BobInNJ

      I would like to add a graph (x vs y plot ) to my application. I would like this graph to be displayed in a new window. Therefore, I wrote the following code: void CMyView::drawGraph() { /* virtual BOOL CreateEx( DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, LPVOID lpParam = NULL ); */ CRect rect1( 100, 200, 300, 400 ); CreateEx( 0, NULL, TEXT("Graph"), WS_OVERLAPPEDWINDOW|WS_CHILD, rect1, this, 0 ); } Unfortunately, the call to CWnd::CreateEx dies with an assertion error. The routine CWnd::CreateEx calls the routine AfxHookWindowCreate. This routine has the following assert statement in it: `ASSERT(pWnd->m_hWnd == NULL); // only do once` In my case, m_hWnd is non-NULL. Therefore, the program aborts. I am sure that I am doing something wrong in the call to CreateEx but I do not know what it is. Also, I find the documentation for this call to be lacking. For one thing, I could not find any examples where it was used to create a sub-window. Thanks Bob

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      BobInNJ wrote:

      CRect rect1( 100, 200, 300, 400 ); CreateEx( 0, NULL, TEXT("Graph"), WS_OVERLAPPEDWINDOW|WS_CHILD, rect1, this, 0 );

      Effectively, here you are trying to create CMyView again, where it already exists. You may want to do something like this

      CRect rect1( 100, 200, 300, 400 );
      m_wndYouwantotCreate.CreateEx( 0, NULL, TEXT("Graph"), WS_OVERLAPPEDWINDOW|WS_CHILD,
      rect1, this, 0 );

      1 Reply Last reply
      0
      • B BobInNJ

        I would like to add a graph (x vs y plot ) to my application. I would like this graph to be displayed in a new window. Therefore, I wrote the following code: void CMyView::drawGraph() { /* virtual BOOL CreateEx( DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, LPVOID lpParam = NULL ); */ CRect rect1( 100, 200, 300, 400 ); CreateEx( 0, NULL, TEXT("Graph"), WS_OVERLAPPEDWINDOW|WS_CHILD, rect1, this, 0 ); } Unfortunately, the call to CWnd::CreateEx dies with an assertion error. The routine CWnd::CreateEx calls the routine AfxHookWindowCreate. This routine has the following assert statement in it: `ASSERT(pWnd->m_hWnd == NULL); // only do once` In my case, m_hWnd is non-NULL. Therefore, the program aborts. I am sure that I am doing something wrong in the call to CreateEx but I do not know what it is. Also, I find the documentation for this call to be lacking. For one thing, I could not find any examples where it was used to create a sub-window. Thanks Bob

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        You can create another window from your view, but it will be a bit complex. I can think of a couple of choices for you... The simplest one is to create a new CDialog based class, that only has one control in it. You can find plenty of graph controls here on codeproject that you can pop in this dialog. Then just call DoModal on it, let it stay up until the user presses OK, and all is nice. The other is a bit more complex. You could make a window like a popup control with your little graph on it, that goes away when the user moves the mouse again. This depends on how you want your software to be. Have a look at: http://www.dilascia.com/PixieDoc.htm#CPopupText[^] for a tooltip alike window - just change the drawing code / size to your desires. Iain.

        Codeproject MVP for C++, I can't believe it's for my lounge posts...

        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