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

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • Relying on outside companies to manage your network and server environments for your business and applications to meet the needs and demands of your users can be stressful. This is especially true as many Managed Hosting organizations fail to meet their service level agreements. Read this Forrester total economic impact report and learn what makes INetU different and how they exceed their customers' managed hosting expectations.

Most Popular Programming Stories

More for Developers

RSS Feeds