Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Cast in OnGridNotify() method
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Cast in OnGridNotify() method

 Post Reply Post Reply
Author
Message
Gorkystreet View Drop Down
Newbie
Newbie


Joined: 04 July 2007
Location: Ukraine
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gorkystreet Quote  Post ReplyReply Direct Link To This Post Topic: Cast in OnGridNotify() method
    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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Gorkystreet View Drop Down
Newbie
Newbie


Joined: 04 July 2007
Location: Ukraine
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gorkystreet Quote  Post ReplyReply Direct Link To This Post 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?
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Gorkystreet View Drop Down
Newbie
Newbie


Joined: 04 July 2007
Location: Ukraine
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gorkystreet Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2007 at 4:28pm
Thank you Oleg,
this information is right what I need.
Back to Top
Gorkystreet View Drop Down
Newbie
Newbie


Joined: 04 July 2007
Location: Ukraine
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gorkystreet Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Gorkystreet View Drop Down
Newbie
Newbie


Joined: 04 July 2007
Location: Ukraine
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gorkystreet Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.594 seconds.