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. Invalidate() Error CDialog

Invalidate() Error CDialog

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++data-structurestutorial
24 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.
  • M mohit 12

    Hey, thx for your reply:D ok let me explain what i have done brifley, I Have 3 classes. First one is gphview which is formview based class which contains mytabctrl and on half window it contains some function of calculater(adding,multiply,subtract) Second one is mytabcontrol which holds 9 different tabs and create dialog for each tab Lastone is tab_one class which is dialog based class which draws the graphs according to tab selected. In first gphView class : void GphView::OnInitialUpdate( void) { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); m_tabMyTabCtrl.InsertItem(0, _T("Graph1")); m_tabMyTabCtrl.InsertItem(1, _T("Graph1")); m_tabMyTabCtrl.InsertItem(2, _T("Graph1")); m_tabMyTabCtrl.InsertItem(3, _T("Graph1")); m_tabMyTabCtrl.InsertItem(4, _T("Graph1")); m_tabMyTabCtrl.InsertItem(5, _T("Graph1")); m_tabMyTabCtrl.InsertItem(6, _T("Graph1")); m_tabMyTabCtrl.InsertItem(7, _T("Graph1(occupied)")); m_tabMyTabCtrl.Init(); } In mytabctrl class: CMyTabCtrl::CMyTabCtrl() { pTab = new CTab_one(this); // instance of tab_one class declared in header file CTab_one *pTab; } CMyTabCtrl::~CMyTabCtrl() { } void CMyTabCtrl::Init() { m_tabPages[0]=new CTab_one; // m_tabpages declared in header like this CDialog *m_tabPages[8]; m_tabPages[1]=new CTab_one; m_tabPages[2]=new CTab_one; m_tabPages[3]=new CTab_one; m_tabPages[4]=new CTab_one; m_tabPages[5]=new CTab_one; m_tabPages[6]=new CTab_one; m_tabPages[7]=new CTab_one; m_nNumberOfPages=8; m_tabCurrent=0; m_tabPages[0]->Create(IDD_TAB_ONE,this); m_tabPages[0]->ShowWindow(SW_SHOW); m_tabPages[1]->Create(IDD_TAB_ONE,this); m_tabPages[1]->ShowWindow(SW_HIDE); m_tabPages[2]->Create(IDD_TAB_ONE, this); m_tabPages[2]->ShowWindow(SW_HIDE); m_tabPages[3]->Create(IDD_TAB_ONE, this); m_tabPages[3]->ShowWindow(SW_HIDE); m_tabPages[4]->Create(IDD_TAB_ONE, this); m_tabPages[4]->ShowWindow(SW_HIDE); m_tabPages[5]->Create(IDD_TAB_ONE, this); m_tabPages[5]->ShowWindow(SW_HIDE); m_tabPages[6]->Create(IDD_TAB_ONE, this); m_tabPages[6]->ShowWindow(SW_HIDE); m_tabPages[7]->Create(IDD_TAB_ONE, this); m_tabPages[7]->ShowWindow(SW_HIDE); SetRectangle(); } void CMyTabCtrl::SetRectangle() { CRect tabRect, itemRect; int nX, nY, nXc, nYc; GetClientRect(&tabRect); GetItemRect(0, &itemRect); nX=itemRect.left; nY=itemRect

    N Offline
    N Offline
    Niklas L
    wrote on last edited by
    #15

    Please use the code block button when pasting code. It will make it readable. The code is roughly what I suggested. But I don't understand what

    pTab = new CTab_one(this);

    is doing i the contructor? What do you need that page for? And also it has to be deleted in the destructor. I suggest you declare it as CTab_one m_tab; in the class declaration instead. Also, there is a message for when the active tab is changed as per my last message. Relying on WM_LBUTTONDOWN is not enough, since one can navigate using keyboard. Was there a question in your last post? :)

    home

    M 1 Reply Last reply
    0
    • N Niklas L

      Please use the code block button when pasting code. It will make it readable. The code is roughly what I suggested. But I don't understand what

      pTab = new CTab_one(this);

      is doing i the contructor? What do you need that page for? And also it has to be deleted in the destructor. I suggest you declare it as CTab_one m_tab; in the class declaration instead. Also, there is a message for when the active tab is changed as per my last message. Relying on WM_LBUTTONDOWN is not enough, since one can navigate using keyboard. Was there a question in your last post? :)

      home

      M Offline
      M Offline
      mohit 12
      wrote on last edited by
      #16

      Hey, Thx a lot for your replies. I have already solved my problem for redrawing graph it was just small stupid pointer mistake i wasn't passing correct value and yeah thx for TCN_SELCHANGE message i was wondering about it but didn't have time to look at it. I will have to google how that works. Could you let me know how that works like what method it will call. and wat's exact message for that. Thx again, cheers from CANADA

      N 1 Reply Last reply
      0
      • M mohit 12

        Hey, Thx a lot for your replies. I have already solved my problem for redrawing graph it was just small stupid pointer mistake i wasn't passing correct value and yeah thx for TCN_SELCHANGE message i was wondering about it but didn't have time to look at it. I will have to google how that works. Could you let me know how that works like what method it will call. and wat's exact message for that. Thx again, cheers from CANADA

        N Offline
        N Offline
        Niklas L
        wrote on last edited by
        #17

        The message description is here[^]. You can create a message handler for it in the resource editor, or using the properties->message window.

        home

        M 2 Replies Last reply
        0
        • N Niklas L

          The message description is here[^]. You can create a message handler for it in the resource editor, or using the properties->message window.

          home

          M Offline
          M Offline
          mohit 12
          wrote on last edited by
          #18

          got it working thx ..

          1 Reply Last reply
          0
          • N Niklas L

            The message description is here[^]. You can create a message handler for it in the resource editor, or using the properties->message window.

            home

            M Offline
            M Offline
            mohit 12
            wrote on last edited by
            #19

            Is there anyway i can resize my tabcontrol. like i wana have some feature like when you double click graph inside tab it will resize to mainwindow and when you double click again it will be back as normal window. I had couple of thoughts like creating frame for tabcontrol and another for rest of the form and then just deal with frame but didn't work. thx

            N 1 Reply Last reply
            0
            • M mohit 12

              Is there anyway i can resize my tabcontrol. like i wana have some feature like when you double click graph inside tab it will resize to mainwindow and when you double click again it will be back as normal window. I had couple of thoughts like creating frame for tabcontrol and another for rest of the form and then just deal with frame but didn't work. thx

              N Offline
              N Offline
              Niklas L
              wrote on last edited by
              #20

              Well, you could just resize it using SetWindowPos(), and then temporarily change the parent window to your CMainFrame I suppose. Another way might be to mimic the behavior of print preview, but without the printing so to speak.

              home

              M 1 Reply Last reply
              0
              • N Niklas L

                Well, you could just resize it using SetWindowPos(), and then temporarily change the parent window to your CMainFrame I suppose. Another way might be to mimic the behavior of print preview, but without the printing so to speak.

                home

                M Offline
                M Offline
                mohit 12
                wrote on last edited by
                #21

                Yet problem's not solved :confused:. Now you know I have two main class. calculator and tab_one(graphs). now calculator is formview and tab_one is dialog box. now everytime i change something in calculator i will need to redraw graphs in dialog box so i will call invalidate but dialog box will need to get new values from calculator, so i created instance of calculator in tab_one but everytime i call invalidate it creates new calculator and all values goes to default value thus not able to get new values. any clue ?

                N 1 Reply Last reply
                0
                • M mohit 12

                  Yet problem's not solved :confused:. Now you know I have two main class. calculator and tab_one(graphs). now calculator is formview and tab_one is dialog box. now everytime i change something in calculator i will need to redraw graphs in dialog box so i will call invalidate but dialog box will need to get new values from calculator, so i created instance of calculator in tab_one but everytime i call invalidate it creates new calculator and all values goes to default value thus not able to get new values. any clue ?

                  N Offline
                  N Offline
                  Niklas L
                  wrote on last edited by
                  #22

                  Can't you just set a pointer to your main calculator in your tab_one dialog? Then you can read up-to-date data from the calculator when repainting your dialog. A better way would be to have a data object, containing all current information in your calculator. This should be owned by the calculator. Then set a pointer to this in your tab_one. Did that make sense?

                  home

                  M 1 Reply Last reply
                  0
                  • N Niklas L

                    Can't you just set a pointer to your main calculator in your tab_one dialog? Then you can read up-to-date data from the calculator when repainting your dialog. A better way would be to have a data object, containing all current information in your calculator. This should be owned by the calculator. Then set a pointer to this in your tab_one. Did that make sense?

                    home

                    M Offline
                    M Offline
                    mohit 12
                    wrote on last edited by
                    #23

                    i don't know if that makes sense or not but somehow i managed to solve that problem. What I did is. mytabcontrol was inside of calculator so whenever i changed something i inform that to mytabcontrol ( i have valid m_hWnd since it's inside calculator ) now all tabs are initialized inside tab control so they wont have problem getting m_hWnd for tabone so if they get called they will inform tab_one to redraw it(invalidate) now problems was if i calls tab_one from tabcontrol , then tab_one will be reinitialzed which will read defaults values of calculaotr so graph will be same. now i have calcparam which holds all values of calculator inside(calculator) and tab_one was reading those value. but now i created another calcparam inside tab_one and made sure tab_one read that calcparam not the one from calculator and if i change something in calculator. it does this memcpy( &m_tabMyTabCtrl.m_tabPages[i]->CalcParam,&CalcParam,sizeof(CALC_PARAMS)); m_tabMyTabCtrl.m_tabPages[i]->Invalidate( ); // m_tabmytabcontrol is instance of mytabcontrol inside gphview and tabpages is instance of tabone defined in mytabcontrol that's how i got it work. anyways thx a lot, cheers from canada.

                    N 1 Reply Last reply
                    0
                    • M mohit 12

                      i don't know if that makes sense or not but somehow i managed to solve that problem. What I did is. mytabcontrol was inside of calculator so whenever i changed something i inform that to mytabcontrol ( i have valid m_hWnd since it's inside calculator ) now all tabs are initialized inside tab control so they wont have problem getting m_hWnd for tabone so if they get called they will inform tab_one to redraw it(invalidate) now problems was if i calls tab_one from tabcontrol , then tab_one will be reinitialzed which will read defaults values of calculaotr so graph will be same. now i have calcparam which holds all values of calculator inside(calculator) and tab_one was reading those value. but now i created another calcparam inside tab_one and made sure tab_one read that calcparam not the one from calculator and if i change something in calculator. it does this memcpy( &m_tabMyTabCtrl.m_tabPages[i]->CalcParam,&CalcParam,sizeof(CALC_PARAMS)); m_tabMyTabCtrl.m_tabPages[i]->Invalidate( ); // m_tabmytabcontrol is instance of mytabcontrol inside gphview and tabpages is instance of tabone defined in mytabcontrol that's how i got it work. anyways thx a lot, cheers from canada.

                      N Offline
                      N Offline
                      Niklas L
                      wrote on last edited by
                      #24

                      mohit`12 wrote:

                      anyways thx a lot,

                      You're welcome

                      home

                      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