CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2012
    Posts
    6

    IDR_MENU_POPUP option [Color] in VS2010 from VC++ 6.0

    Requesting advice for IDR_MENU_POPUP option [Color] in VS2010 implementation from VC++ 6.0

    Hello programmers; my username is Falconcpp and this is my subject:
    Creating a Popup Color Menu in Visual Studio 2010 Ultimate in a Project of C++ Language / Templates Visual C++ MFC / MFC Application.

    Background:
    I saw the 4 tutorial videos about MatrixGrid by thomastom99 on the internet site http://vcplusplustutorials.ktsinfote...ogramming.aspx
    (Reference for internet search: VC++ GUI Tutorials using MFC | VC++ IN)

    These 4 videos are about creating a Matrix Grid of 8 rows and 8 columns, which 64 cells you can eventually paint in different colors and add text within the cells.
    This original MatrixGrid program is made in VC++ 6.0 and using MFC. You can download the source code and give it a try.

    Situation:
    I’m a beginner in both C++ and MFC.
    By analyzing the 4 MatrixGrid videos, I wrote 445 blocks of instructions to follow (step by step) in order to reproduce the MatrixGrid creation.
    So far, I´m already on the step 344 of 445, and my project is running OK. Nevertheless, I’m stuck in the part where the Popup Color Menu should allow me to see the colors palette in order to customize new colors for the 64 cells within the Matrix Grid.

    Request:
    Therefore, my request to all of you -especially for those that are experts about VS2010 Ultimate, C++ and MFC, and that also have knowledge about VC++ 6.0- is to provide me with some advice in order to be able to see the colors palette after clicking with the Mouse Button on the option [Color] of my submenu named (IDR_MENU_POPUP).

    Special considerations:
    The original 4 MatrixGrid videos project were made in VC++ 6.0
    And my own program which I’m developing is being made in VS2010 Ultimate in a Project of C++ Language / Templates: Visual C++ MFC / MFC Application / Visual Style and Colors: Visual Studio 2008.
    So I’ve been having lots of adjustments to implement already due to the difference of versions and yet so far the project is running.

    Visual Display:
    In my own program, after I click [Debug] and [Start without debugging] Compilation is OK and the Main Frame displays the following drawing in the North West corner of the screen:

    (A Matrix grid of 8 rows and 8 columns)

    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]

    Zoom: Then -within the screen- I can resize the whole Matrix Grid to 25%, 50%, 100% or 200% with the [Zoom] button that I created on the top toolbar of the Main Frame.

    Paint: Then I can paint each one of the 64 cells: with 1 click of the Left Mouse Button (LMB) 1 cell becomes painted in Red color; Next, if 1 cell is painted in Red color already then with 1 more click of the LMB this cell becomes painted in Green color; Next, if 1 cell is painted in Green color already then with 1 more click of the LMB this cell becomes painted in Blue color; Next, if 1 cell is painted in Blue color already then with 1 more click of the LMB this cell becomes painted in Black color; Finally, if 1 cell is painted in Black color already then with 1 more click of the LMB this cell becomes painted in White color (so the cell goes back to its original color).

    Popup Menu: Then, if I paint 1 cell in Red color for example, and after this, I click on this Red cell with the Right Mouse Button (RMB) -that is, the secondary mouse button- then my submenu appears (named IDR_MENU_POPUP) and it displays the following 4 options:

    [ Cut ]
    [ Copy ]
    [ Paste ]
    -----------
    [ Color ]

    The Problem: If I place the cursor on the option [Color] then this submenu button becomes highlighted in soft blue color, however, the Problem is that if I click on the option [Color] either with the LMB or the RMB then the Colors Palette DOESN’T APPEAR AT ALL; thus I can’t customize a new color for the cell. And at the present stage this should be possible already.
    And this is why hereby I am requesting your expert advice.

    Source Code:
    I will display the source code related exclusively to my submenu IDR_MENU_POPUP and after this, also I will display the file entitled “MatrixGrid.clw” that appears in the source code of the videos example and that doesn’t appear in my own program, since the Class Wizard is a special class in the version VC++ 6.0 but in my own Version VS2010 it is just a submenu option of the top toolbar [Project] and then [Class Wizard] . . . and I believe that this has something to do with the present Problem.

    The comments before the code are my descriptions of the code reference:

    My project regarding OnPopupColor() in the file MatrixGridView.cpp (Definition)

    void CMatrixGridView::OnPopupColor()
    {
    CColorDialog ColorDialog;
    CMatrixGridDoc *pDoc=GetDocument();
    if(ColorDialog.DoModal()==IDOK)
    {
    pDoc->m_cColor=ColorDialog.GetColor();
    pDoc->m_arrCellArray[m_iRowIndex][m_iColIndex].m_cColor=pDoc->m_cColor;
    pDoc->m_arrCellArray[m_iRowIndex][m_iColIndex].m_iColor=CUSTOM;
    }
    Invalidate();
    }


    My project regarding OnPopupColor() in the file MatrixGridView.h (Declaration)

    // Generated message map functions
    protected:
    //{{AFX_MSG(CMatrixGridView)
    afx_msg void OnZoom25();
    afx_msg void OnZoom50();
    afx_msg void OnZoom100();
    afx_msg void OnZoom200();
    afx_msg void OnEditUndo();
    afx_msg void OnEditPaste();
    afx_msg void OnEditCut();
    afx_msg void OnEditCopy();
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnPopupColor();
    afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };


    My project regarding OnContextMenu(CWnd* pWnd, CPoint point)

    This is how this member function was created in the file MatrixGridView.cpp (Definition) by my program after using the option [Project] and [Class Wizard]

    void CMatrixGridView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
    {
    #ifndef SHARED_HANDLERS
    theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
    #endif
    }

    This is how I modified this function by replacing the green comment /* pWnd */ with the text pWnd and by erasing the 3 lines about #ifndef and theApp.GetContextMenuManager . . . and its respective #endif And then I added the code according to the video’s example source code:

    void CMatrixGridView::OnContextMenu(CWnd* pWnd, CPoint point)
    {
    CMatrixGridDoc *pDoc=GetDocument();
    DeleteWindow();
    //ScreenToClient(&point);
    for(int iRowIndex=0;iRowIndex<pDoc->m_iRow;iRowIndex++)
    {
    for(int iColIndex=0;iColIndex<pDoc->m_iColoums;iColIndex++)
    {
    if(pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect.PtInRect(point))
    {
    CMenu Menu;
    Menu.LoadMenu(IDR_MENU_POPUP);
    CMenu *pMenu =Menu.GetSubMenu(0);
    pMenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON,point.x,point.y,this,pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect);
    }
    }
    }
    }


    This is the file MatrixGridDoc.h after adding code about COLORREF m_cColor;

    class CMatrixGridDoc : public CDocument
    {
    protected: // create from serialization only
    CMatrixGridDoc();
    DECLARE_DYNCREATE(CMatrixGridDoc)

    // Attributes
    public:
    COLORREF m_cColor;
    CCell m_arrCellArray[500][500];
    int m_iYoffset;
    int m_iXoffset;
    int m_iWidth;
    int m_iHeight;
    int m_iColoums;
    int m_iRow;

    Etc...
    };

    This is the file MatrixGrid.clw that appears in the example’s videos source code (but it doesn’t appear in my own program)

    ; CLW file contains information for the MFC ClassWizard

    [General Info]
    Version=1
    LastClass=CMatrixGridView
    LastTemplate=CDialog
    NewFileInclude1=#include "stdafx.h"
    NewFileInclude2=#include "MatrixGrid.h"
    LastPage=0

    ClassCount=5
    Class1=CMatrixGridApp
    Class2=CMatrixGridDoc
    Class3=CMatrixGridView
    Class4=CMainFrame

    ResourceCount=3
    Resource1=IDR_MAINFRAME
    Class5=CAboutDlg
    Resource2=IDR_MENU_POPUP
    Resource3=IDD_ABOUTBOX

    [CLS:CMatrixGridApp]
    Type=0
    HeaderFile=MatrixGrid.h
    ImplementationFile=MatrixGrid.cpp
    Filter=N

    [CLS:CMatrixGridDoc]
    Type=0
    HeaderFile=MatrixGridDoc.h
    ImplementationFile=MatrixGridDoc.cpp
    Filter=N

    [CLS:CMatrixGridView]
    Type=0
    HeaderFile=MatrixGridView.h
    ImplementationFile=MatrixGridView.cpp
    Filter=C
    BaseClass=CScrollView
    VirtualFilter=VWC
    LastObject=CMatrixGridView

    [CLS:CMainFrame]
    Type=0
    HeaderFile=MainFrm.h
    ImplementationFile=MainFrm.cpp
    Filter=T
    LastObject=ID_EDIT_UNDO

    [CLS:CAboutDlg]
    Type=0
    HeaderFile=MatrixGrid.cpp
    ImplementationFile=MatrixGrid.cpp
    Filter=D

    [DLG:IDD_ABOUTBOX]
    Type=1
    Class=CAboutDlg
    ControlCount=4
    Control1=IDC_STATIC,static,1342177283
    Control2=IDC_STATIC,static,1342308480
    Control3=IDC_STATIC,static,1342308352
    Control4=IDOK,button,1342373889

    [MNU:IDR_MAINFRAME]
    Type=1
    Class=CMainFrame
    Command1=ID_FILE_NEW
    Command2=ID_FILE_OPEN
    Command3=ID_FILE_SAVE
    Command4=ID_FILE_SAVE_AS
    Command5=ID_FILE_PRINT
    Command6=ID_FILE_PRINT_PREVIEW
    Command7=ID_FILE_PRINT_SETUP
    Command8=ID_FILE_MRU_FILE1
    Command9=ID_APP_EXIT
    Command10=ID_EDIT_UNDO
    Command11=ID_EDIT_CUT
    Command12=ID_EDIT_COPY
    Command13=ID_EDIT_PASTE
    Command14=ID_VIEW_TOOLBAR
    Command15=ID_VIEW_STATUS_BAR
    Command16=ID_ZOOM_25
    Command17=ID_ZOOM_50
    Command18=ID_ZOOM_100
    Command19=ID_ZOOM_200
    Command20=ID_APP_ABOUT
    CommandCount=20

    [ACL:IDR_MAINFRAME]
    Type=1
    Class=CMainFrame
    Command1=ID_FILE_NEW
    Command2=ID_FILE_OPEN
    Command3=ID_FILE_SAVE
    Command4=ID_FILE_PRINT
    Command5=ID_EDIT_UNDO
    Command6=ID_EDIT_CUT
    Command7=ID_EDIT_COPY
    Command8=ID_EDIT_PASTE
    Command9=ID_EDIT_UNDO
    Command10=ID_EDIT_CUT
    Command11=ID_EDIT_COPY
    Command12=ID_EDIT_PASTE
    Command13=ID_NEXT_PANE
    Command14=ID_PREV_PANE
    CommandCount=14

    [TB:IDR_MAINFRAME]
    Type=1
    Class=?
    Command1=ID_FILE_NEW
    Command2=ID_FILE_OPEN
    Command3=ID_FILE_SAVE
    Command4=ID_EDIT_CUT
    Command5=ID_EDIT_COPY
    Command6=ID_EDIT_PASTE
    Command7=ID_FILE_PRINT
    Command8=ID_ZOOM_50
    Command9=ID_APP_ABOUT
    CommandCount=9

    [MNU:IDR_MENU_POPUP]
    Type=1
    Class=?
    Command1=ID_POPUP_CUT
    Command2=ID_POPUP_COPY
    Command3=ID_POPUP_PASTE
    Command4=ID_POPUP_COLOUR
    CommandCount=4

    ----------------------------------------

    Final comment and request:
    Expert programmers, I will appreciate your kind advice in order to allow the option [Color] of my submenu named IDR_MENU_POPUP to provide the Colors Palette in order to customize a new color for the cells within the Matrix Grid. Thank you very much.
    Falconcpp

  2. #2
    Join Date
    Jun 2012
    Posts
    6

    Re: IDR_MENU_POPUP option [Color] in VS2010 from VC++ 6.0

    Correction.

    This is the right code:

    void CMatrixGridView::OnContextMenu(CWnd* pWnd, CPoint point)
    {
    CMatrixGridDoc *pDoc=GetDocument();
    // DeleteWindow();
    ScreenToClient(&point);
    for(int iRowIndex=0;iRowIndex<pDoc->m_iRow;iRowIndex++)
    {
    for(int iColIndex=0;iColIndex<pDoc->m_iColoums;iColIndex++)
    {
    if(pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect.PtInRect(point))
    {
    CMenu Menu;
    Menu.LoadMenu(IDR_MENU_POPUP);
    CMenu *pMenu =Menu.GetSubMenu(0);
    pMenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON,point.x,point.y,this,pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect);
    }
    }
    }
    }

    Later on, the programmer will invert two lines from:

    // DeleteWindow();
    ScreenToClient(&point);

    to:

    DeleteWindow();
    // ScreenToClient(&point);

    But at the present stage of the program these two lines should remain this way:

    // DeleteWindow();
    ScreenToClient(&point);

    So the program can run OK. And yet, so far, it isn't.

  3. #3
    Join Date
    Apr 1999
    Posts
    26,800

    Re: IDR_MENU_POPUP option [Color] in VS2010 from VC++ 6.0

    Please go back and re-edit your post to use code tags. No one is going to attempt to read the code the way it is (unformatted, flushed to the left).

    Your code looks like this:

    int main()
    {
    int x;
    int y;
    int z;
    z = 1;
    }

    instead of this:
    Code:
    int main()
    {
       int x;
       int y;
       int z;
       z = 1;
    }
    See the difference?

    Secondly:
    Code:
    void CMatrixGridView::OnContextMenu(CWnd* pWnd, CPoint point)
    {
        CMatrixGridDoc *pDoc=GetDocument();
        DeleteWindow();
        for(int iRowIndex=0;iRowIndex<pDoc->m_iRow;iRowIndex++)
        {
            for(int iColIndex=0;iColIndex<pDoc->m_iColoums;iColIndex++)
           {
               if(pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect.PtInRect(point))
               {
                   CMenu Menu;
                   Menu.LoadMenu(IDR_MENU_POPUP);
                   CMenu *pMenu =Menu.GetSubMenu(0);
                   pMenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON,point.x,point.y,this,pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect);
                 
               }
           }
       }
    }
    So once you find the column, you keep looping for no reason. Why not break out of the loop?
    Code:
    void CMatrixGridView::OnContextMenu(CWnd* pWnd, CPoint point)
    {
        bool bFoundColumn = false;
        CMatrixGridDoc *pDoc=GetDocument();
        DeleteWindow();
        for(int iRowIndex=0;iRowIndex<pDoc->m_iRow && !bFoundColumn;iRowIndex++)
        {
            for(int iColIndex=0;iColIndex<pDoc->m_iColoums && !bFoundColumn ;iColIndex++)
           {
               if(pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect.PtInRect(point))
               {
                   CMenu Menu;
                   Menu.LoadMenu(IDR_MENU_POPUP);
                   CMenu *pMenu =Menu.GetSubMenu(0);
                   pMenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON,point.x,point.y,this,pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect);
                   bFoundColumn = true;
               }
           }
       }
    }
    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; June 17th, 2012 at 10:40 PM.

  4. #4
    Join Date
    Jun 2012
    Posts
    6

    Re: IDR_MENU_POPUP option [Color] in VS2010 from VC++ 6.0

    Thread's 2nd edition (using the wrap code tags around selected text and also including one attachment, a PDF file):

    Requesting advice for IDR_MENU_POPUP option [Color] in VS2010 implementation from VC++ 6.0

    Hello programmers; my username is Falconcpp and this is my subject:
    Creating a Popup Color Menu in Visual Studio 2010 Ultimate in a Project of C++ Language / Templates Visual C++ MFC / MFC Application.

    Background:
    I saw the 4 tutorial videos about MatrixGrid by thomastom99 on the internet site http://vcplusplustutorials.ktsinfote...ogramming.aspx
    (Reference for internet search: VC++ GUI Tutorials using MFC | VC++ IN)

    These 4 videos are about creating a Matrix Grid of 8 rows and 8 columns, which 64 cells you can eventually paint in different colors and add text within the cells.
    This original MatrixGrid program is made in VC++ 6.0 and using MFC. You can download the source code and give it a try.

    Situation:
    I’m a beginner in both C++ and MFC.
    By analyzing the 4 MatrixGrid videos, I wrote 445 blocks of instructions to follow (step by step) in order to reproduce the MatrixGrid creation.
    So far, I´m already on the step 344 of 445, and my project is running OK. Nevertheless, I’m stuck in the part where the Popup Color Menu should allow me to see the colors palette in order to customize new colors for the 64 cells within the Matrix Grid.

    Request:
    Therefore, my request to all of you -especially for those that are experts about VS2010 Ultimate, C++ and MFC, and that also have knowledge about VC++ 6.0- is to provide me with some advice in order to be able to see the colors palette after clicking with the Mouse Button on the option [Color] of my submenu named (IDR_MENU_POPUP).

    Special considerations:
    The original 4 MatrixGrid videos project were made in VC++ 6.0
    And my own program which I’m developing is being made in VS2010 Ultimate in a Project of C++ Language / Templates: Visual C++ MFC / MFC Application / Visual Style and Colors: Visual Studio 2008.
    So I’ve been having lots of adjustments to implement already due to the difference of versions and yet so far the project is running.

    Visual Display:
    In my own program, after I click [Debug] and [Start without debugging] Compilation is OK and the Main Frame displays the following drawing in the North West corner of the screen:

    (A Matrix grid of 8 rows and 8 columns)

    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]
    [ ][ ][ ][ ][ ][ ][ ][ ]

    Zoom: Then -within the screen- I can resize the whole Matrix Grid to 25%, 50%, 100% or 200% with the [Zoom] button that I created on the top toolbar of the Main Frame.

    Paint: Then I can paint each one of the 64 cells: with 1 click of the Left Mouse Button (LMB) 1 cell becomes painted in Red color; Next, if 1 cell is painted in Red color already then with 1 more click of the LMB this cell becomes painted in Green color; Next, if 1 cell is painted in Green color already then with 1 more click of the LMB this cell becomes painted in Blue color; Next, if 1 cell is painted in Blue color already then with 1 more click of the LMB this cell becomes painted in Black color; Finally, if 1 cell is painted in Black color already then with 1 more click of the LMB this cell becomes painted in White color (so the cell goes back to its original color).

    Popup Menu: Then, if I paint 1 cell in Red color for example, and after this, I click on this Red cell with the Right Mouse Button (RMB) -that is, the secondary mouse button- then my submenu appears (named IDR_MENU_POPUP) and it displays the following 4 options:

    [ Cut ]
    [ Copy ]
    [ Paste ]
    -----------
    [ Color ]

    The Problem: If I place the cursor on the option [Color] then this submenu button becomes highlighted in soft blue color, however, the Problem is that if I click on the option [Color] either with the LMB or the RMB then the Colors Palette DOESN’T APPEAR AT ALL; thus I can’t customize a new color for the cell. And at the present stage this should be possible already.
    And this is why hereby I am requesting your expert advice.

    Source Code:
    I will display the source code related exclusively to my submenu IDR_MENU_POPUP and after this, also I will display the file entitled “MatrixGrid.clw” that appears in the source code of the videos example and that doesn’t appear in my own program, since the Class Wizard is a special class in the version VC++ 6.0 but in my own Version VS2010 it is just a submenu option of the top toolbar [Project] and then [Class Wizard] . . . and I believe that this has something to do with the present Problem.

    The comments before the code are my descriptions of the code reference:

    My project regarding OnPopupColor() in the file MatrixGridView.cpp (Definition)

    Code:
    void CMatrixGridView::OnPopupColor()
    {
       CColorDialog ColorDialog;
       CMatrixGridDoc *pDoc=GetDocument();
       if(ColorDialog.DoModal()==IDOK)
          {
             pDoc->m_cColor=ColorDialog.GetColor();
             pDoc->m_arrCellArray[m_iRowIndex][m_iColIndex].m_cColor=pDoc->m_cColor;
             pDoc->m_arrCellArray[m_iRowIndex][m_iColIndex].m_iColor=CUSTOM;
          }
       Invalidate();
    }
    My project regarding OnPopupColor() in the file MatrixGridView.h (Declaration)

    Code:
    // Generated message map functions
    protected:
          //{{AFX_MSG(CMatrixGridView)
          afx_msg void OnZoom25();
          afx_msg void OnZoom50();
          afx_msg void OnZoom100();
          afx_msg void OnZoom200();
          afx_msg void OnEditUndo();
          afx_msg void OnEditPaste();
          afx_msg void OnEditCut();
          afx_msg void OnEditCopy();
          afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
          afx_msg void OnPopupColor();
          afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
          //}}AFX_MSG
          DECLARE_MESSAGE_MAP()
    };
    My project regarding OnContextMenu(CWnd* pWnd, CPoint point)

    This is how this member function was created in the file MatrixGridView.cpp (Definition) by my program after using the option [Project] and [Class Wizard]

    Code:
    void CMatrixGridView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
    {
       #ifndef SHARED_HANDLERS
          theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
       #endif
    }
    This is how I modified this function by replacing the green comment /* pWnd */ with the text pWnd and by erasing the 3 lines about #ifndef and theApp.GetContextMenuManager . . . and its respective #endif And then I added the code according to the video’s example source code:

    Code:
    void CMatrixGridView::OnContextMenu(CWnd* pWnd, CPoint point)
    {
       CMatrixGridDoc *pDoc=GetDocument();
       // DeleteWindow();
       ScreenToClient(&point);
       for(int iRowIndex=0;iRowIndex<pDoc->m_iRow;iRowIndex++)
          {
             for(int iColIndex=0;iColIndex<pDoc->m_iColoums;iColIndex++)
                {
                   if(pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect.PtInRect(point))
                      {
                          CMenu Menu;
                          Menu.LoadMenu(IDR_MENU_POPUP);
                          CMenu *pMenu =Menu.GetSubMenu(0);
                          pMenu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON,point.x,point.y,this,pDoc->m_arrCellArray[iRowIndex][iColIndex].m_Rect);
                       }
                 }
           }
    }
    This is the file MatrixGridDoc.h after adding code about COLORREF m_cColor;

    Code:
    class CMatrixGridDoc : public CDocument
    {
       protected: // create from serialization only
       CMatrixGridDoc();
       DECLARE_DYNCREATE(CMatrixGridDoc)
    
       // Attributes
       public:
             COLORREF m_cColor;
             CCell m_arrCellArray[500][500];
             int m_iYoffset;
             int m_iXoffset;
             int m_iWidth;
             int m_iHeight;
             int m_iColoums;
             int m_iRow;
    
    Etc...
    };
    This is the file MatrixGrid.clw that appears in the example’s videos source code (but it doesn’t appear in my own program)

    Code:
    ; CLW file contains information for the MFC ClassWizard
    
    [General Info]
    Version=1
    LastClass=CMatrixGridView
    LastTemplate=CDialog
    NewFileInclude1=#include "stdafx.h"
    NewFileInclude2=#include "MatrixGrid.h"
    LastPage=0
    
    ClassCount=5
    Class1=CMatrixGridApp
    Class2=CMatrixGridDoc
    Class3=CMatrixGridView
    Class4=CMainFrame
    
    ResourceCount=3
    Resource1=IDR_MAINFRAME
    Class5=CAboutDlg
    Resource2=IDR_MENU_POPUP
    Resource3=IDD_ABOUTBOX
    
    [CLS:CMatrixGridApp]
    Type=0
    HeaderFile=MatrixGrid.h
    ImplementationFile=MatrixGrid.cpp
    Filter=N
    
    [CLS:CMatrixGridDoc]
    Type=0
    HeaderFile=MatrixGridDoc.h
    ImplementationFile=MatrixGridDoc.cpp
    Filter=N
    
    [CLS:CMatrixGridView]
    Type=0
    HeaderFile=MatrixGridView.h
    ImplementationFile=MatrixGridView.cpp
    Filter=C
    BaseClass=CScrollView
    VirtualFilter=VWC
    LastObject=CMatrixGridView
    
    [CLS:CMainFrame]
    Type=0
    HeaderFile=MainFrm.h
    ImplementationFile=MainFrm.cpp
    Filter=T
    LastObject=ID_EDIT_UNDO
    
    [CLS:CAboutDlg]
    Type=0
    HeaderFile=MatrixGrid.cpp
    ImplementationFile=MatrixGrid.cpp
    Filter=D
    
    [DLG:IDD_ABOUTBOX]
    Type=1
    Class=CAboutDlg
    ControlCount=4
    Control1=IDC_STATIC,static,1342177283
    Control2=IDC_STATIC,static,1342308480
    Control3=IDC_STATIC,static,1342308352
    Control4=IDOK,button,1342373889
    
    [MNU:IDR_MAINFRAME]
    Type=1
    Class=CMainFrame
    Command1=ID_FILE_NEW
    Command2=ID_FILE_OPEN
    Command3=ID_FILE_SAVE
    Command4=ID_FILE_SAVE_AS
    Command5=ID_FILE_PRINT
    Command6=ID_FILE_PRINT_PREVIEW
    Command7=ID_FILE_PRINT_SETUP
    Command8=ID_FILE_MRU_FILE1
    Command9=ID_APP_EXIT
    Command10=ID_EDIT_UNDO
    Command11=ID_EDIT_CUT
    Command12=ID_EDIT_COPY
    Command13=ID_EDIT_PASTE
    Command14=ID_VIEW_TOOLBAR
    Command15=ID_VIEW_STATUS_BAR
    Command16=ID_ZOOM_25
    Command17=ID_ZOOM_50
    Command18=ID_ZOOM_100
    Command19=ID_ZOOM_200
    Command20=ID_APP_ABOUT
    CommandCount=20
    
    [ACL:IDR_MAINFRAME]
    Type=1
    Class=CMainFrame
    Command1=ID_FILE_NEW
    Command2=ID_FILE_OPEN
    Command3=ID_FILE_SAVE
    Command4=ID_FILE_PRINT
    Command5=ID_EDIT_UNDO
    Command6=ID_EDIT_CUT
    Command7=ID_EDIT_COPY
    Command8=ID_EDIT_PASTE
    Command9=ID_EDIT_UNDO
    Command10=ID_EDIT_CUT
    Command11=ID_EDIT_COPY
    Command12=ID_EDIT_PASTE
    Command13=ID_NEXT_PANE
    Command14=ID_PREV_PANE
    CommandCount=14
    
    [TB:IDR_MAINFRAME]
    Type=1
    Class=?
    Command1=ID_FILE_NEW
    Command2=ID_FILE_OPEN
    Command3=ID_FILE_SAVE
    Command4=ID_EDIT_CUT
    Command5=ID_EDIT_COPY
    Command6=ID_EDIT_PASTE
    Command7=ID_FILE_PRINT
    Command8=ID_ZOOM_50
    Command9=ID_APP_ABOUT
    CommandCount=9
    
    [MNU:IDR_MENU_POPUP]
    Type=1
    Class=?
    Command1=ID_POPUP_CUT
    Command2=ID_POPUP_COPY
    Command3=ID_POPUP_PASTE
    Command4=ID_POPUP_COLOUR
    CommandCount=4
    ----------------------------------------

    Final comment and request:
    Expert programmers, I will appreciate your kind advice in order to allow the option [Color] of my submenu named IDR_MENU_POPUP to provide the Colors Palette in order to customize a new color for the cells within the Matrix Grid. Thank you very much.
    Falconcpp
    Attached Images Attached Images

  5. #5
    Join Date
    Jun 2012
    Posts
    6

    Re: IDR_MENU_POPUP option [Color] in VS2010 from VC++ 6.0

    Paul McKenzie,
    This time I posted the thread properly and I included one attachment for a better view (a PDF file).
    Thank you for your reply. However, please note that I added one correction regarding the two code lines:

    // DeleteWindow();
    ScreenToClient(&point);

    Later on the programmer of the example videos will invert these two lines to:

    DeleteWindow();
    // ScreenToClient(&point);

    However, at the present stage of the program these two code lines must remain like this:

    // DeleteWindow();
    ScreenToClient(&point);

    So the program runs OK; however, the Color option still won´t allow the colors' palette to appear. And I apologize because I had to add this correction, however this happened because later on the programmer will invert the two code lines. If you would take a look at the 4 MatrixGrid videos by thomastom99 on the internet site http://vcplusplustutorials.ktsinfote...ogramming.aspx
    Then my thread would make better sense for your experience. In the meantime I appreciate your concern.
    Falconcpp.

  6. #6
    Join Date
    Jun 2012
    Posts
    6

    Re: IDR_MENU_POPUP option [Color] in VS2010 from VC++ 6.0

    External Dependencies. Please read my attached PDF file "External Dependencies". Falconcpp.
    Attached Images Attached Images

  7. #7
    Join Date
    Jun 2012
    Posts
    6

    Re: IDR_MENU_POPUP option [Color] in VS2010 from VC++ 6.0

    This case is solved, for the present time. Please read my attached PDF file "This case is solved, for the present time." Falconcpp.
    Attached Images Attached Images

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



HTML5 Development Center

Click Here to Expand Forum to Full Width