Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Property Grid. Getting direct access to controls
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Property Grid. Getting direct access to controls

 Post Reply Post Reply
Author
Message
Tomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21 July 2006
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomas Quote  Post ReplyReply Direct Link To This Post Topic: Property Grid. Getting direct access to controls
    Posted: 24 July 2006 at 5:28pm


The property control works really well… May be too well… It works exactly like the MS but here lays the problem. The Microsoft one is not very smart when it comes down to minimize the number of clicks that the user takes to change a value. It usually takes 2 clicks at least. One of them to select the property and the other one to change its value (especially when doing sliders and such). This makes for a poor user control.

Does anyone know how to tell the property grid to set all its property controls as active, ready for the user to change them without the need to select them first?

 
Tomas

 

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: 25 July 2006 at 8:40am
Hi,
It is not possible :(
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Tomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21 July 2006
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomas Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2006 at 11:13am
Originally posted by oleg oleg wrote:

Hi,
It is not possible :(

However I notice that in one of your examples exhibits this desirable behavior.

The example name is "Property Grid Sample". Ones running you can check in the grid under the "Dynamic options". There the bool item is able to be toggle without the need of selecting the it first. Which contrast with the other type of bool found under: "Standard Items" which you need to click 3 times to make a change.

Any glimpses of hope there?

Tomas

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: 25 July 2006 at 12:51pm
:) Added to wish list for 10.4.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Tomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21 July 2006
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomas Quote  Post ReplyReply Direct Link To This Post Posted: 26 July 2006 at 9:36am
Originally posted by oleg oleg wrote:

:) Added to wish list for 10.4.


Ho man 10.4 and in a wish list? That doesn't sound very promissing... Ouch

Tomas

Back to Top
Tomasz View Drop Down
Senior Member
Senior Member


Joined: 05 August 2006
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomasz Quote  Post ReplyReply Direct Link To This Post Posted: 05 August 2006 at 7:08am
I place my vote for this too!
 
2+ clicks or more for changing property value is way too much for user-friendly application. My customers are complaining about having to click twice.
 
So please, pretty please with sugar on top, give us an option for one-click property change.
Back to Top
JohnCrenshaw View Drop Down
Groupie
Groupie
Avatar

Joined: 08 September 2006
Status: Offline
Points: 65
Post Options Post Options   Thanks (0) Thanks(0)   Quote JohnCrenshaw Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2006 at 11:17am
Originally posted by oleg oleg wrote:

Hi,
It is not possible :(
 
Are you sure? C'mon, you don't strike me as a defeatist. Not only is there a way to do this, it is painfully simple.
 
There is a function CXTPPropertyGridItem::SetFocusToInplaceControl() that is designed for setting this editable state.
 
Inside CXTPPropertyGrid::OnNavigate() we find this snippet, suggesting that the item must be selected prior to focusing the control but I havn't checked this for sure.

    pItem->OnSelect();
    pItem->SetFocusToInplaceControl();
    return;
 
Finally, the CXTPPropertyGrid class has the following function declaration:

   virtual void OnSelectionChanged(CXTPPropertyGridItem* pItem);
 
To get what you want, declare a new class based on the grid, then override the selection changed function. Call SetFocusToInplaceControl() for the control recieving the focus in the override. I make this call AFTER calling the base OnSelectionChanged() since it is for the user's convenience only. See the following snippet:

class COneClickPropertyGrid : public CXTPPropertyGrid
{
// Best Practice: Uncomment this and call IMPLEMENT_DYNAMIC() in the CPP file
//   DECLARE_DYNAMIC(COneClickPropertyGrid)
public:
   COneClickPropertyGrid() : CXTPPropertyGrid() {}
   // Best Practice: this shouldn't be inline
   virtual void OnSelectionChanged(CXTPPropertyGridItem* pItem)
   {
      CXTPPropertyGrid::OnSelectionChanged(pItem);
      // pItem is NULL sometimes
      if (pItem)
      {
         // set the item focus with a single click
         pItem->SetFocusToInplaceControl();
      }
   }
};
 
This is probably incomplete, for example, you may want to do something similar when the control is activated. Also, the edit control is fully highlighted at this point. This may or may not be the behavior you want but can be fixed.
 
This is the code responsible for highlighting everything:

void CXTPPropertyGridItem::SetFocusToInplaceControl()
{
 CXTPPropertyGridInplaceEdit& wndEdit = GetInplaceEdit();
 if (wndEdit.GetSafeHwnd() && wndEdit.GetItem() == this)
 {
  wndEdit.SetFocus();
  wndEdit.SetSel(0, -1); // This highlights all the text
 }
}
 
Since the above is a virtual function, you can change the behavior on a case by case basis.
 
Hope this helps!
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: 28 December 2006 at 1:25am
btw.. In 10.4 added property to show all inplace buttons.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Tomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21 July 2006
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomas Quote  Post ReplyReply Direct Link To This Post Posted: 15 February 2007 at 6:31pm

That is a cool first step. What I really need to display are ALL the buttons not just the in-place buttons. That means that things like the sliders (User controls) and such should display as well. This is very important for us. As the user can be tweaking their properties and they don’t want to be selecting them first. Do you think it will be a hard feature to add for you guys?

Tomas

Back to Top
Tomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21 July 2006
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomas Quote  Post ReplyReply Direct Link To This Post Posted: 23 February 2007 at 12:09pm
In 10.4.2 ones you are drawing your own grid using  XTP_PGS_OWNERDRAW the inplace buttons don't show any more.
 
 
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: 25 February 2007 at 12:28am
Hello, Yes, buttons now drawn in Drawitem method. Add this call:
 
if (bSelected || m_pGrid->GetShowInplaceButtonsAlways()) pPaintManager->DrawInplaceButtons(&dc, pItem, rcValue);
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Tomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21 July 2006
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomas Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2007 at 2:56pm
DrawInplaceButtons is a protected member of CXTPPropertyGridPaintManager so I dont have access to it. Do you have an example of this?
Back to Top
JohnCrenshaw View Drop Down
Groupie
Groupie
Avatar

Joined: 08 September 2006
Status: Offline
Points: 65
Post Options Post Options   Thanks (0) Thanks(0)   Quote JohnCrenshaw Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2007 at 3:23pm
Originally posted by Tomas Tomas wrote:

DrawInplaceButtons is a protected member of CXTPPropertyGridPaintManager so I don't have access to it. Do you have an example of this?
When I have a problem like this, where a member is protected that ought not be, I cheat. Derived classes can access protected members so I create a derived class with a static "access" function that takes a pointer to the other class and the parameters. For example:
 
class CSomeHelper : publid CClassWithStupidProtectedMember
{
public:
   static int DoProtectedFunction(CClassWithStupidProtectedMember* p, UINT param)
   {
      return ((CSomeHelper*)p)->ProtectedFunction(param);
   }
};
 
Then, in places where I really am sure that I should call the protected function, and have the right to, I can  do so via CSomeHelper::DoProtectedFunction(p, param);
 
This is technically bad, but it is a lot more clean than changing the protected status of things or adding a friend. If you change the CodeJock code, then when the next update comes out, your program breaks. If you use my nasty hack, your code (probably) works.
 
The way I see it, this hack is far from clean code, but it is much cleaner and maintainable than any alternative.
Back to Top
Tomas View Drop Down
Newbie
Newbie
Avatar

Joined: 21 July 2006
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tomas Quote  Post ReplyReply Direct Link To This Post Posted: 05 March 2007 at 11:37am
Thanks you so much guys. The new property system rocks!!!
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.141 seconds.