Home > Software engineering >  Unable to load the data using gridctrl, print preview interface
Unable to load the data using gridctrl, print preview interface

Time:10-08

MFC LIstCtrl controls, within the original use of the base class is LIstCtrl, then based on GridCtrl encapsulates a class, the question now is whether the LIstCtrl controls can be normal load data, but the print preview failed to load the data interface,
This is the print button response function:
 if (0==m_paramVarsListCtrl. GetItemCount ()) 
{
AfxMessageBox (_T (" can not print the variable data!" ));
return;
}
//determine whether to install the printer, not installed cannot print, also does not provide a preview function
if (! TheApp. HasInstallPrinter ())
{
AfxMessageBox (_T (no printer available! "" ));
return;
}

TCHAR * szColumn [10]={_T (" serial number "), _T (" variable name "), _T (" variable description "), _T (" type "), _T (" current value "),
_T (" cap "), _T (" limit "), _T (" data length "), _T (" code "), _T (" offset ")};

CDPView: : sta_pCallback=GridCallback;
CDPView: : sta_lParam=(LPARAM) (& amp; M_paramVarsListCtrl);//associated list

CDPView: : sta_arrColum RemoveAll ();
for(int i=0; I & lt; 10; I++)
{
CDPView: : sta_arrColum. Add (szColumn [I]);
}
CDPView: : sta_ulRowCount=m_paramVarsListCtrl GetItemCount ();

M_pMyFrame=new CDPFrame (this);
M_pMyFrame - & gt; CreateFrame ();

Print preview interface initialization function:
 void CDPView: : InitGrid () 
{
M_pWndGridCtrl - & gt; EnableHeader (TRUE, BCGP_GRID_HEADER_MOVE_ITEMS | BCGP_GRID_HEADER_SORT);

Int nColumNum=sta_arrColum. GetSize ();//the number of columns
If (==10 nColumNum)//this is the main interface variable information
{

M_pWndGridCtrl - & gt; InsertColumn (0, sta_arrColum [0], 40).
M_pWndGridCtrl - & gt; InsertColumn (1, sta_arrColum [1], 100);
M_pWndGridCtrl - & gt; InsertColumn (2, sta_arrColum [2], 60).
M_pWndGridCtrl - & gt; InsertColumn (3, sta_arrColum [3], 60).
M_pWndGridCtrl - & gt; InsertColumn (4, sta_arrColum [4], 60).
M_pWndGridCtrl - & gt; InsertColumn (5, sta_arrColum [5], 70);
M_pWndGridCtrl - & gt; InsertColumn (6, sta_arrColum [6], 70);
M_pWndGridCtrl - & gt; InsertColumn (7, sta_arrColum [7], 60).
M_pWndGridCtrl - & gt; InsertColumn (8, sta_arrColum [8], 50);
M_pWndGridCtrl - & gt; InsertColumn (9, sta_arrColum [9], 50);
}
The else//log information list separate distribution
the width of each column{
M_pWndGridCtrl - & gt; InsertColumn (0, sta_arrColum [0], 40).
M_pWndGridCtrl - & gt; InsertColumn (1, sta_arrColum [1], 100);
M_pWndGridCtrl - & gt; InsertColumn (2, sta_arrColum [2], 320);
M_pWndGridCtrl - & gt; InsertColumn (3, sta_arrColum [3], 60).
M_pWndGridCtrl - & gt; InsertColumn (4, sta_arrColum [4], 125);
}
//m_pWndGridCtrl - & gt; EnableColumnAutoSize (TRUE);

M_pWndGridCtrl - & gt; EnableVirtualMode (sta_pCallback sta_lParam);

M_pWndGridCtrl - & gt; SetVirtualRows (sta_ulRowCount);

M_pWndGridCtrl - & gt; AdjustLayout ();
}

CodePudding user response:

Originally, print preview can be normal load listctrl controls the data inside, now can not loaded, but the header will be successful, according to the virtual lines also set a success, is a list of the data is not successful, now log print or use listctrl base class, the print preview screen is normal, is the parameter to print changed after accumulation, not related
  • Related