Search

How to Use MFC Grid control 2.27

Programming/MFCGridCtrl 2016. 8. 12. 16:13 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

How to Use MFC Grid control 2.27


http://www.codeproject.com/Articles/8/MFC-Grid-control-2-27

1. Download


MFC Grid control 2.27

6 May 2010 CPOL
A fully featured MFC grid control for displaying tabular data. The grid is a custom control derived from CWnd





2. Essential Include Files



Files

To use the Grid control in your project you will need to add a number of files to your project:

gridctrl.cpp, gridctrl.hMain grid control source and header files.
gridcellbase.cpp, gridcellbase.hMain grid cell base class.
gridcell.cpp, gridcell.hMain grid cell default class implementation.
CellRange.hDefinition of CCellID and CCellRange helper classes.
MemDC.hKeith Rule's memory DC helper class.
InPlaceEdit.cpp, InPlaceEdit.hIn-place edit windows source and header files.
GridDropTarget.cpp, GridDropTarget.hGrid control OLE drag and drop target. Only necessary if you don't define GRIDCONTROL_NO_DRAGDROP in gridctrl.h
Titletip.cpp, Titletip.h

Titletips for cells, from Zafir Anjum. Only necessary if you don't define GRIDCONTROL_NO_TITLETIPS in gridctrl.h



3. Essential Include Files Add to Project 







4. Custom Control Add to Dialog




ID : IDC_GRID


Class : MFCGridCtrl (No CGridCtrl)


if you use CGridCtrl, you can see this error








5. Make Member Variable m_Grid



Dlg.h


- Include


#include "GridCtrl.h"


Make Member Variable m_Grid


CGridCtrl m_Grid;




Dlg.cpp


- Include


#include "GridCtrl.h"





6. IDC_GRID Connect with Member Variable




DDX_GridControl(pDX, IDC_GRID, m_Grid);


DDX_GridControl Function defined in GridCtrl.h









336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

How to prevent MFC dialog closing on Enter and Escape keys?


There is an alternative to the previous answer, which is useful if you wish to still have an OK / Close button. If you override the PreTranslateMessage function, you can catch the use of VK_ESCAPE / VK_RETURN like so:



BOOL CMainDialog::PreTranslateMessage(MSG* pMsg)

{


if (pMsg->message == WM_KEYDOWN)

{

if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)

{

return TRUE;                // Do not process further

}

}


return CDialogEx::PreTranslateMessage(pMsg);

}




이렇게 수정하여야 한다.




PreTranslateMessage 함수를 생성하는 방법은


1. Enter, ESC 키를 차단할 DialogClass 를 우클릭


2. [클래스 마법사] 를 켠다.


3. [가상 함수]


4. 가상 함수 탭에서 PreTranslateMessage 를 선택


5. [함수 추가]


6. 추가된 함수에


if (pMsg->message == WM_KEYDOWN)

{

if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)

{

return TRUE;                // Do not process further

}

}


추가 작성