Print Page | Close Window

Cast in OnGridNotify() method

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=7573
Printed Date: 02 January 2025 at 10:00am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Cast in OnGridNotify() method
Posted By: Gorkystreet
Subject: Cast in OnGridNotify() method
Date Posted: 10 July 2007 at 7:42pm
Hi all,

I encountered the following problem: I created my custom control derived from CXTPPropertyGridItemEnum-class. I use it in grid (use the toolkit ver. 10.3.1). In OnGridNotify() method I need to spy for some events. In appropriate event I have to perform a cast from 'lParam' parameter just like this: CXTPPropertyGridItem* pItem = (CXTPPropertyGridItem*)lParam;   
But when I look at pItem internals, I can see that some members have wrong values, but it looks like that my object was created successfully in
AddChildItem method. In general all my steps on working with grid amd creation/using custom controls are very similar to steps provided in sample 'PropertyGrid' project. What can source similar problem? And how is better
to fix/overcome such terrible situation? I can provide additional information if needed. Thanx in advance.



Replies:
Posted By: Oleg
Date Posted: 11 July 2007 at 12:02am
Hello,
 
 lParam in OnGridNotify is not always CXTPPropertyGridItem.
you need check wParam first. What wParam you need ?
 


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Gorkystreet
Date Posted: 11 July 2007 at 4:24am
Hmm, it is very interesting. I use some codes, such as XTP_PGN_EDIT_CHANGED,
XTP_PGN_SELECTION_CHANGED,
XTP_PGN_ITEMVALUE_CHANGED,
can you say to what lParam points for each of these codes,
and for those codes which are defined but not listed here? thank you.
It is possible that I will have to add some more custom codes to work
on grid events. How can I do this? and if I will use this code what object reference will be pointed by lParam?
 


Posted By: Oleg
Date Posted: 11 July 2007 at 5:35am
Hi,
 
 
in XTP_PGN_EDIT_CHANGED lParam is
CXTPPropertyGridInplaceEdit* pEdit = DYNAMIC_DOWNCAST(CXTPPropertyGridInplaceEdit, (CWnd*)lParam);
 
for XTP_PGN_SELECTION_CHANGED, XTP_PGN_ITEMVALUE_CHANGED
CXTPPropertyGridItem* pItem = (CXTPPropertyGridItem*)lParam;
for XTP_PGN_INPLACEBUTTONDOWN
CXTPPropertyGridInplaceButton* pButton = (CXTPPropertyGridInplaceButton*)lParam;

please copy this code from our sample - Samples\PropertyGrid\GridSample\PropertyGridDlg.cpp



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Gorkystreet
Date Posted: 12 July 2007 at 4:28pm
Thank you Oleg,
this information is right what I need.


Posted By: Gorkystreet
Date Posted: 12 July 2007 at 6:02pm
Excuse me Oleg,
I made some additional testing on my custom control and one problem is still having place. As I mentioned it is
CXTPPropertyGridItemEnum-derived control with a check-box in it. I need obtain a pointer on it in XTP_PGN_EDIT_CHANGED notif. event. I'm failing the following method:
CCustomItemCheckBox* pItem = DYNAMIC_DOWNCAST(CCustomItemCheckBox, (CWnd*)lParam);
pItem is NULL in such case. What cast should I perform to obtain the proper pointer?


Posted By: Oleg
Date Posted: 13 July 2007 at 5:29am
Hi,
Just wrote that lParam is CXTPPropertyGridInplaceEdit... You need
 
CXTPPropertyGridInplaceEdit* pEdit = DYNAMIC_DOWNCAST(CXTPPropertyGridInplaceEdit, (CWnd*)lParam);
CCustomItemCheckBox* pItem = DYNAMIC_DOWNCAST(CCustomItemCheckBox,  pEdit ->GetItem());


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Gorkystreet
Date Posted: 13 July 2007 at 4:59pm
Great!
Oleg, thank you very much!!! Now everything is fine!
How do you think - maybe it is worth to include such sample cast into the some sample application with grid in it? I guess it would be very useful for such new toolkit users like me ;)
Anyway thanks again!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net