Grid derived from CWnd (2)

 Download Source Code and Example

 

This is MFC version of grid I originally wrote in OWL. All about grid is in PageWnd.h (cpp) file (which does not mean it is too long). CPageWnd provides public members for getting/setting cell text, color, alignment and font, column width, row height and similar. It is easy to derive CPageWnd and add additional functionality. This code is build with Visual C++ 5.0 (it should work with 4.x version). To integrate in existing project just insert PageWnd.cpp file in your project. How to use CPageWnd find is shown in TestPageView.cpp. If you are interested for OWL version of grid, e-mail me.

Last updated: 25 July 1998



Comments

  • Grid Control in C?

    Posted by Legacy on 09/24/2003 12:00am

    Originally posted by: Mark Richardson

    Is it possible to implement a grid control in plain C rather than C++ or MFC and if so how is it done?

    Reply
  • Suggests and paint errors

    Posted by Legacy on 06/02/2001 12:00am

    Originally posted by: Leandro Gustavo Biss Becker

    Hi

    You class is nice but if you create GDIs object to each cell and hold all of them created, if you have many and many
    cells the systems resources will go down because the GDI resources (pens, fonts, brushes, etc) are limited !
    You can hold to each cell only the infomation about the GDI objects like font typeface, size, color etc, brush color, etc and create them when you will paint the cell and after the cell paint process, free then. I know that this process is a little bit slower but this is the better solution to your case.

    The paint errors are not logical errors. The problem are when you use SelectObject CDC function, you must hold the returned object pointer and call SelectObject again with the held object before release the dc. If you don't do this, even if you destroy the objects before you program exits (I see that you are doing this!) the Windows will not free the object because it was selected in a dc but not deselected !!

    Best Regards

    Leandro Gustavo Biss Becker
    LIT - Laboratory of Information and Telecomunications
    CEFET-PR Brazil

    Reply
  • FlexGrid or Grid Control

    Posted by Legacy on 01/08/2001 12:00am

    Originally posted by: Roberto A. Vidal

    Do you know how use FlexGrid or Grid Control step by step in a dialog box.
    
    

    or any book you suggest where I can find it.

    TXS

    Reply
  • Error & Fix

    Posted by Legacy on 03/12/2000 12:00am

    Originally posted by: Hassanov

    Error:
    
    1. Mark cell A1 as the active cell
    2. Scroll to right (by mouse) to hide current active cell
    3. Click on any cell (let's say B2)
    4. Notice that the old col/row markers are not cleared (i.e., Still shown in BOLD).

    Fix:
    1. In function MarkActiveCell() do:
    ...
    if(fprev)
    {
    MarkHeader(false); //This is new place of this call
    if(m_pScrollData->XPos < m_colEditEx && m_pScrollData >YPos < m_rowEditEx)
    {
    CPen inactivePen(PS_SOLID, 2, GetCellColor(m_rowEditEx, m_colEditEx));
    dc.SelectObject(&inactivePen);
    CRect r(m_EditRect.left + 2, m_EditRect.top + 2, m_EditRect.right, m_EditRect.bottom);
    dc.Rectangle(r);
    //MarkHeader(false); // This is old place of this call
    }
    }
    ...

    2. Retype function MarkHeader() as follows :
    void CPageWnd::MarkHeader(bool mark)
    {
    CRect rowRect(0, m_EditRect.top, m_width[0], m_EditRect.bottom);
    CRect colRect(m_EditRect.left, 0, m_EditRect.right, m_height[0]);

    CClientDC dc(this);

    SetCellFont(m_rowEditEx, 0, *m_pDefFont);
    SetCellFont(0, m_colEditEx, *m_pDefFont);

    SetCellFont(m_rowEdit, 0, *m_pDefFontBold);
    SetCellFont(0, m_colEdit, *m_pDefFontBold);

    if(!mark) {
    if(m_rowEditEx > m_pScrollData->YPos && m_rowEditEx < m_pScrollData->YPos + m_pScrollData->YPage)
    dc.DrawEdge(rowRect, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);

    CellEntry(dc, m_rowEditEx, 0, rowRect);

    if(m_colEditEx > m_pScrollData->XPos && m_colEditEx < m_pScrollData->XPos + m_pScrollData->XPage)
    dc.DrawEdge(colRect, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);

    CellEntry(dc, 0, m_colEditEx, colRect);
    }
    else {
    dc.DrawEdge(rowRect, EDGE_RAISED , BF_RECT | BF_MIDDLE); //BDR_RAISED
    CellEntry(dc, m_rowEdit, 0, rowRect);

    dc.DrawEdge(colRect, EDGE_RAISED, BF_RECT | BF_MIDDLE); //BDR_RAISED
    CellEntry(dc, 0, m_colEdit, colRect);
    }
    }

    Reply
  • Save '\res\TestPage.rc2'...

    Posted by Legacy on 11/16/1999 12:00am

    Originally posted by: Sok Woo, Lim

    //
    // TESTPAGE.RC2 - resources Microsoft Visual C++ does not edit directly
    //

    #ifdef APSTUDIO_INVOKED
    #error this file is not editable by Microsoft Visual C++
    #endif //APSTUDIO_INVOKED


    /////////////////////////////////////////////////////////////////////////////
    // Add manually edited resources here...

    /////////////////////////////////////////////////////////////////////////////

    Reply
  • Error when compile TestPage

    Posted by Legacy on 10/04/1998 12:00am

    Originally posted by: Vatiutov Victor

    When I compile TestPage appears this message:

    TestPage\TestPage.rc(354) : fatal error RC1015: cannot open include file 'res\\TestPage.rc2'.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • When individual departments procure cloud service for their own use, they usually don't consider the hazardous organization-wide implications. Read this paper to learn best practices for setting up an internal, IT-based cloud brokerage function that service the entire organization. Find out how this approach enables you to retain top-down visibility and control of network security and manage the impact of cloud traffic on your WAN.

  • U.S. companies are desperately trying to recruit and hire skilled software engineers and developers, but there is simply not enough quality talent to go around. Tiempo Development is a nearshore software development company. Our headquarters are in AZ, but we are a pioneer and leader in outsourcing to Mexico, based on our three software development centers there. We have a proven process and we are experts at providing our customers with powerful solutions. We transform ideas into reality.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date