|
Here is how I was able to get it to work. I don't know if it is the right way if anyone has any other suggestions I am more than open to them. You can override your OnNotify in your view and do the following...
if(wParam==m_pGrid->GetDlgCtrlID()) //message is coming from the grid
{
NM_GRIDVIEW* pNMHDR;
pNMHDR = (NM_GRIDVIEW*)lParam;
CString szData;
if(pNMHDR->hdr.code == NM_DBLCLK)
{
TRACE("Double clicked on Cell);
*pResult = 0;
return TRUE;
}
}
return CView::OnNotify(wParam, lParam, pResult);
You could switch on the pNMHDR->hdr.code to see and handle the notification accordingly. Look in the Gridctrl.cpp and search for SendMessageToParent and you will see the format of the NM_GRIDVIEW stuct and you will also see the messages that the grid passes to it's parent. You could also catch it in the OnCmdMsg you will have to include the AFXPRIV.H I would put the following code after the suggested code in the article if you are going to do it this way.
if(nID == m_pGrid->GetDlgCtrlID()) //message is coming from the grid
{
if(pExtra)
{
AFX_NOTIFY *notify;
notify = (AFX_NOTIFY*)pExtra;
NM_GRIDVIEW* pNMHDR;
pNMHDR = (NM_GRIDVIEW*)notify->pNMHDR;
if(pNMHDR->hdr.code == NM_DBLCLK)
{
TRACE("Double clicked on Cell);
notify->pResult = 0;
return TRUE;
}
}
}
Hope this helps
|
|
|
|
|
Hi,
In my application, I am using Grid Ctrl for a report.
The no of rows will change dynamically depending upon report type selected.
My problem is , the vertical scroll bar is not visible for a report when i run the application in Windows XP SP2. But the same application when i run on Windows 2000 Professional, the vertical scroll bar is visible .
Can you tell me what may be the problem
Muralidhar
|
|
|
|
|
I wish this would work - why doesn't it work? I solved the previous problem but am now stuck with:
Linking...
GridCtrl.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CTitleTip::~CTitleTip(void)" (??1CTitleTip@@UAE@XZ) referenced in function __unwindfunclet$??0CGridCtrl@@QAE@HHHH@Z$0
GridCtrl.obj : error LNK2019: unresolved external symbol "public: __thiscall CTitleTip::CTitleTip(void)" (??0CTitleTip@@QAE@XZ) referenced in function "public: __thiscall CGridCtrl::CGridCtrl(int,int,int,int)" (??0CGridCtrl@@QAE@HHHH@Z)
GridCtrl.obj : error LNK2019: unresolved external symbol "public: void __thiscall CTitleTip::Hide(void)" (?Hide@CTitleTip@@QAEXXZ) referenced in function "protected: void __thiscall CGridCtrl::OnHScroll(unsigned int,unsigned int,class CScrollBar *)" (?OnHScroll@CGridCtrl@@IAEXIIPAVCScrollBar@@@Z)
GridCtrl.obj : error LNK2019: unresolved external symbol "public: void __thiscall CTitleTip::Show(class CRect,char const *,int,struct tagRECT *,struct tagLOGFONTA const *,unsigned long,unsigned long)" (?Show@CTitleTip@@QAEXVCRect@@PBDHPAUtagRECT@@PBUtagLOGFONTA@@KK@Z) referenced in function "protected: void __thiscall CGridCtrl::OnMouseMove(unsigned int,class CPoint)" (?OnMouseMove@CGridCtrl@@IAEXIVCPoint@@@Z)
Debug/gc.exe : fatal error LNK1120: 4 unresolved externals
Arghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!!!!!!!!!!!!!!!!
|
|
|
|
|
Check out whether you have added the source Grid files to the project from within Visual Studio? I mean in VC++ 6 Project -> Add To Project -> Files. I used to run into such messages when forgetting to add the files to the project itself
|
|
|
|
|
Genius! I'm quite embarrassed though!
|
|
|
|
|
gcView.obj : error LNK2019: unresolved external symbol "public: int __thiscall CGridCtrl::SetColumnCount(int)" (?SetColumnCount@CGridCtrl@@QAEHH@Z) referenced in function "protected: virtual void __thiscall CgcView::OnInitialUpdate(void)" (?OnInitialUpdate@CgcView@@MAEXXZ)
I get this for any function I use from CGridCtrl. What am I doing wrong?
|
|
|
|
|
pleas modify the command "m_arColWidths.InsertAt(nColumn, (int)0);"
to m_arColWidths.InsertAt(nColumn,(UINT)0);
WILSON
A LIKE SOFTWARE AND QUALITY MAN
|
|
|
|
|
This happens when I build:
Compiling...
StdAfx.cpp
WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)
Compiling...
GridCtrlDemoDlg.cpp
GridCtrlDemo.cpp
GridCtrlDemo.cpp(44) : warning C4996: 'CWinApp::Enable3dControls' was declared deprecated
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4369) : see declaration of 'CWinApp::Enable3dControls'
GridURLCell.cpp
GridCellCombo.cpp
TitleTip.cpp
GridCtrl_src\TitleTip.cpp(314) : error C2360: initialization of 'pts' is skipped by 'case' label
GridCtrl_src\TitleTip.cpp(275) : see declaration of 'pts'
GridCtrl_src\TitleTip.cpp(315) : error C2360: initialization of 'pts' is skipped by 'case' label
GridCtrl_src\TitleTip.cpp(275) : see declaration of 'pts'
InPlaceEdit.cpp
GridDropTarget.cpp
GridCtrl.cpp
GridCtrl_src\GridCtrl.cpp(2214) : warning C4244: 'initializing' : conversion from 'ULONGLONG' to 'DWORD', possible loss of data
GridCtrl_src\GridCtrl.cpp(3490) : error C2668: 'CUIntArray::InsertAt' : ambiguous call to overloaded function
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxcoll.h(341): could be 'void CUIntArray::InsertAt(INT_PTR,CUIntArray *)'
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxcoll.h(338): or 'void CUIntArray::InsertAt(INT_PTR,UINT,INT_PTR)'
while trying to match the argument list '(int, int)'
GridCtrl_src\GridCtrl.cpp(3565) : error C2668: 'CUIntArray::InsertAt' : ambiguous call to overloaded function
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxcoll.h(341): could be 'void CUIntArray::InsertAt(INT_PTR,CUIntArray *)'
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxcoll.h(338): or 'void CUIntArray::InsertAt(INT_PTR,UINT,INT_PTR)'
while trying to match the argument list '(int, int)'
GridCellBase.cpp
GridCell.cpp
Generating Code...
c:\documents and settings\richard\my documents\grid\gridctrl_demo221\gridctrl_demo221\newcelltypes\gridcellcombo.cpp(455) : warning C4702: unreachable code
c:\documents and settings\richard\my documents\grid\gridctrl_demo221\gridctrl_demo221\newcelltypes\gridcellcombo.cpp(456) : warning C4702: unreachable code
Build log was saved at "file://c:\Documents and Settings\Richard\My Documents\Grid\gridctrl_demo221\gridctrl_demo221\Debug\BuildLog.htm"
GridCtrlDemo - 4 error(s), 4 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
|
|
|
|
|
I have modified your code that if WS_TABSTOP is not on, then OnLButtonDown will not call SetFocus(). This is very important for our touch screen POS system.
and also can you add column default font? usually display text description on one column and dollar amount on other.
eric feng
www.infospec.com
|
|
|
|
|
Well I'm quite new to MFC programming, so this might be a more general question. How can I Capture one of the GridCtrl specific messages in my View? For example the begin editing Message?
Thnx for any answers..
Sebastian
|
|
|
|
|
Hi,
We have downloaded a Grid Control project from Code project named GridCtrlDemo.
While creating dynamically i need to add a vertical scroll bar to the control.
Can any one help me in this regard.
Nandini
|
|
|
|
|
I Can't Find "mfc42u.lib" File.
LINK : fatal error LNK1104: cannot open file "mfc42u.lib"
Error executing link.exe.
Creating browse info file...
|
|
|
|
|
Sounds like you need to have unicode support and you're probably not going to get it. (IE I don't think MS ever expects to release anything for 9X world) Search the project settings and header files for #define's. I havn't actually downloaded this code, but somewhere in it it's referencing the UNICODE version of MFC.
<<edit>>
I don't know if the code has been updated or not, as I probably should of downloaded it before I posted a solution. The current project settings have support for both UNICODE and ANSI modes (Look at the different project settings). If you're in the 9X world, just select "Win32 Release" or "Win32 Debug" from the all ready defined project settings.
|
|
|
|
|
I'm running on WINXP Pro. Tried compiling under both VC++.net and VC++6 same error in both.
Any ideas where to download the MFC unicode version?
[edit] i think ive found it in SP2 for VC++6
|
|
|
|
|
find mfc42u.lib file or
in your VC , Build -> Set Active Configuration ->
Select Win32 Debug or Win32 Release
Cheers!!
|
|
|
|
|
mfc42u.lib File not found
|
|
|
|
|
because
error LNK1104: cannot open file "mfc42u.lib"
...........
.........
...........
|
|
|
|
|
How can I use events like OnGridDblClick or OnGridClick when using it in a view ?
Thanks in advance for your help
|
|
|
|
|
In the resource editor, add a new Resource Symbol for the Grid, like IDC_GRID
After you create the grid control, use SetDlgCtrlID() to assign it the ID like the following:
<br />
m_pGridCtrl = new CGridCtrl;<br />
if (!m_pGridCtrl) return;<br />
<br />
CRect rect;<br />
GetClientRect(rect);<br />
m_pGridCtrl->Create(rect, this, 100);<br />
m_pGridCtrl->SetDlgCtrlID(IDC_GRID);
In your view class message map you can then add the notify commands and appropriate handlers just as in the Dialog based version, I.E.
<br />
ON_NOTIFY(NM_CLICK, IDC_GRID, OnGridClick)<br />
ON_NOTIFY(NM_DBLCLK, IDC_GRID, OnGridDblClick)<br />
-HTH
|
|
|
|
|
Thanks for posting this. After upgrading the project from VC6 to VS2010 I found all grid control messages for CView no longer received messages but dialogs were fine. Previously they were passed through using WS_CHILD
Previous usage of the following no longer works in later versions
m_ptblgrid->Create(gridrect,this,WS_CHILD);
ON_NOTIFY(NM_CLICK, WS_CHILD, OnGridClick)
modified 17-Aug-12 22:03pm.
|
|
|
|
|
First, Thank you for the excellent grid control. It is very useful to me.
Now, for the question:
What is the correct way to close out the editing operation on a cell that is active at the time that I wish to collect the data values and store them? In other words, if a user edits a cell and leaves the focus in the cell and then clicks my "Save Data" button (or exits the dialog), how do I tell the grid control that the editing on the current cell is finished?
It would seem that the right routine to call would be CGridCtrl::EndEditing(), but is a protected, virtual method.
On a related matter, I found that if I destroy the CGridCtrl object while a cell is open for editing, Windows triggers an exception when CInPlaceEdit::OnKillFocus is called after the call of CGridCtrl::DeleteAllItems() from the destructor.
|
|
|
|
|
I have to display 100000´s of datacells. the virtual mode is perfectly for this. But the editing of the cells is not working:
I´m using OnNotify & GVN_ENDLABELEDIT. The Problem is that everytime calling the GetText-function returns the old and not the new value of the cell.
Interestingly the value get lost by calling the OnNotify function, because in the CInEditPlace::EndEdit()-function the new value is used for calling
<br />
OnNotify(........)<br />
{<br />
......<br />
else if(GVN_ENDLABELEDIT==pDispInfo->hdr.code)<br />
{<br />
CString x;<br />
int y;<br />
TRACE("ENDLABELEDIT");<br />
NM_GRIDVIEW *pItem = (NM_GRIDVIEW *)pDispInfo;<br />
CGridCellBase *pCell =m_pGridCtrl->GetCell(pDispInfo->item.row,pDispInfo>item.col);<br />
y=m_pGridCtrl->IsCellEditable(pDispInfo->item.row,pDispInfo->item.col);<br />
x=pCell->GetText();<br />
}<br />
Thanks in advance for helping me with this Problem
dominik
|
|
|
|
|
Hi, Chris!
thanks for your grid control.
I have one question.
column header is ok, but..
I wanna hide row headers (column0) like listctrl.
Is it possible?
I'll be wating for your answer.
desafinado
|
|
|
|
|
I think this is a typo. It should have been m_pGrid instead, so the over all code becomes
<br />
if (m_pGrid == NULL)
{<br />
m_pGrid = new CGridCtrl;
if (!m_pGrid) return;<br />
<br />
CRect rect;
GetClientRect(rect);<br />
m_pGrid->Create(rect, this, 100);<br />
<br />
m_pGrid->SetRowCount(20);
m_pGrid->SetColumnCount(10);<br />
<br />
}<br />
<br />
<br />
I could not get it to compile, until I made the changes as shown above
|
|
|
|
|
It is (was) absolutely a type. All fixed.
cheers,
Chris Maunder
|
|
|
|