Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » CGrid Collapse All
Subject Author Date
tarou iiyama Jul 14, 2005 - 3:13 AM

Hello


Question: 1


  I want to choose a thing of a specification range. (Row - Line)
Should I use CGridBase.SelectionSet?



Question: 2


  I use CGridBase.
May not you print it?  (there is frame Line)  (like Excel)



Print Image


| -------------------|
|  Apple |  Orange|
| -------------------|
|   100   |  200     |
| -------------------|


Question: 3


  An argument of SeleectionGet.
I do not understand how to use nAreaNumber.
  How will you use it?

Technical Support Jul 14, 2005 - 7:26 AM

The Prof-UIS grid is designed to be universal and this does not allow the grid to know exactly which data are displayed in it. That is why we did not implement the print feature in it. The printing task in this case is specific to a particular project. But it is not difficult to add MFC’ printing feature similar to that in CView to any C++ class:

void CYourClass::Print()
{
CDC dc;
CPrintDialog dlg(FALSE);
    if( dlg.DoModal() == IDCANCEL )
        return;
    dc.Attach( dlg.GetPrinterDC() );
    dc.m_bPrinting = TRUE;
DOCINFO docInfo;
    ::memset( &docInfo, 0, sizeof(DOCINFO) );
    docInfo.cbSize = sizeof(DOCINFO);
    docInfo.lpszDocName = _T("Your title string");
BOOL bOK = dc.StartDoc( &docInfo );
CPrintInfo printInfo;
    printInfo.m_rectDraw.SetRect(
        0,
        0, 
        dc.GetDeviceCaps(HORZRES), 
        dc.GetDeviceCaps(VERTRES)
        );
    OnBeginPrinting( &dc, &printInfo );
UINT nPageIndex = printInfo.GetMinPage(); 
    for( nPageIndex <= printInfo.GetMaxPage() && bOK; nPageIndex++ )
    {
        dc.StartPage();
        printInfo.m_nCurPage = nPageIndex;
        OnPrint( &dc, &printInfo );
        bOK = ( dc.EndPage() > 0 );
    }
    OnEndPrinting( &dc, &printInfo );
    if( bOK )
        dc.EndDoc();
    else
        dc.AbortDoc();
    dc.DeleteDC();
}
 
void CYourClass::OnBeginPrinting( CDC * pDC, CPrintInfo * printInfo )
{
    // TO DO: prepare printing here, cache GDI objects if any
}
 
void CYourClass::OnPrint( CDC * pDC, CPrintInfo * printInfo )
{
    // TO DO: print one page
}
 
void CYourClass::OnEndPrinting( CDC * pDC, CPrintInfo * printInfo )
{
    // TO DO: printing finished, cleanup resources if any
}
The table printing task is very specific in each particular case. Whether table headers are going to be printed on each page? Whether combo box buttons will be printed? We guess there are lots of questions with regard to this task which will have different answers for each particular project.

The cell range selection in the grid control is based on the array with CRect objects. Each CRect describes an area of selected cells. This explains the meaning of the nAreaNumber parameter. To select cells in some range you should add a rectangle that describes the selected range. The SelectionSet() methods allow you to perform this task.