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. how to show my window derived from CWnd

how to show my window derived from CWnd

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
8 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.
  • G Offline
    G Offline
    gucy
    wrote on last edited by
    #1

    i want to show my window which is derived from CWnd in the button clicked event .the following is my code void CTmp_dlgDlg::OnButton1() { RECT rect; CString str; GetWindowRect(&rect); CMyWnd *mywnd = new CMyWnd; str = AfxRegisterWndClass( 0); int ret=myWnd->Create (str,"text",WS_VISIBLE|WS_CHILD,rect,this,1234); mywnd->ShowWindow (SW_SHOW); } CMyWnd::CWnd but i can't show the window,why? gucy

    H 1 Reply Last reply
    0
    • G gucy

      i want to show my window which is derived from CWnd in the button clicked event .the following is my code void CTmp_dlgDlg::OnButton1() { RECT rect; CString str; GetWindowRect(&rect); CMyWnd *mywnd = new CMyWnd; str = AfxRegisterWndClass( 0); int ret=myWnd->Create (str,"text",WS_VISIBLE|WS_CHILD,rect,this,1234); mywnd->ShowWindow (SW_SHOW); } CMyWnd::CWnd but i can't show the window,why? gucy

      H Offline
      H Offline
      Hans Ruck
      wrote on last edited by
      #2

      Try

      void CTmp_dlgDlg::OnButton1()
      {
      RECT rect;
      CString str;
      GetWindowRect(&rect);
      ScreenToClient(&rect); // new line here !!!
      CMyWnd *mywnd = new CMyWnd;
      str = AfxRegisterWndClass( 0);
      int ret=myWnd->Create (str,"text",WS_VISIBLE|WS_CHILD,rect,this,1234);
      mywnd->ShowWindow (SW_SHOW);
      }

      rechi

      G 1 Reply Last reply
      0
      • H Hans Ruck

        Try

        void CTmp_dlgDlg::OnButton1()
        {
        RECT rect;
        CString str;
        GetWindowRect(&rect);
        ScreenToClient(&rect); // new line here !!!
        CMyWnd *mywnd = new CMyWnd;
        str = AfxRegisterWndClass( 0);
        int ret=myWnd->Create (str,"text",WS_VISIBLE|WS_CHILD,rect,this,1234);
        mywnd->ShowWindow (SW_SHOW);
        }

        rechi

        G Offline
        G Offline
        gucy
        wrote on last edited by
        #3

        it do not work at all:( gucy

        H 1 Reply Last reply
        0
        • G gucy

          it do not work at all:( gucy

          H Offline
          H Offline
          Hans Ruck
          wrote on last edited by
          #4

          How CMyWnd looks like? I made a test wich draws a line on WM_PAINT and worked just fine. rechi

          G 1 Reply Last reply
          0
          • H Hans Ruck

            How CMyWnd looks like? I made a test wich draws a line on WM_PAINT and worked just fine. rechi

            G Offline
            G Offline
            gucy
            wrote on last edited by
            #5

            the app the a dialog based app. i clicked the button on the dialog. nothing changed. i think it would have pop out a window. Can i mail the source to you? gucy

            H 1 Reply Last reply
            0
            • G gucy

              the app the a dialog based app. i clicked the button on the dialog. nothing changed. i think it would have pop out a window. Can i mail the source to you? gucy

              H Offline
              H Offline
              Hans Ruck
              wrote on last edited by
              #6

              gucy wrote: Can i mail the source to you? :) Give it to me! rechi

              G 1 Reply Last reply
              0
              • H Hans Ruck

                gucy wrote: Can i mail the source to you? :) Give it to me! rechi

                G Offline
                G Offline
                gucy
                wrote on last edited by
                #7

                but i can't access your email address! gucy

                H 1 Reply Last reply
                0
                • G gucy

                  but i can't access your email address! gucy

                  H Offline
                  H Offline
                  Hans Ruck
                  wrote on last edited by
                  #8

                  I sent you a mail... rechi

                  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