 |
|
 |
Is there an easy way to add subitems?
|
|
|
|
 |
|
 |
in propertygrid.cpp function OnLButtonUp
m_control = new CPropertyGridCombo();
CPropertyGridCombo* pCombo = (CPropertyGridCombo*)m_control;
pCombo->Create(WS_CHILD, rc, this, 0);
doesn't create combobox.
GetLastError gives 0x00000579.
This is under VS2010 SP1.
Does anybody know why?
|
|
|
|
 |
|
 |
Please change the bottom codes
PropertyGridCombo.cpp
BOOL CPropertyGridCombo::Create(DWORD dwStyle, CRect& rc, CWnd* pParent, int nId)
{
.....
BOOL ret = __super::CreateEx(0, AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW), "", dwStyle|WS_POPUP, rc, pParent->GetParent(), nId);
....
}
replace this code
BOOL ret = __super::CreateEx(0, AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW), "",WS_POPUP|WS_BORDER, rc, pParent->GetParent(), nId);
|
|
|
|
 |
|
 |
Example was very good. It helped me a lot in using this class in my code
|
|
|
|
 |
|
|
 |
|
 |
I recently ran some code that uses the PropertyGrid through Purify. When entering text into a text property field I would always get a Free Memory Read error in CPropertyGridInPlaceEdit::EndEdit in PropertyGridInPlaceEdit.cpp circa line 222, which reads if (IsWindow(GetSafeHwnd())). On staring at the code for bit we came up with two possible solutions:
0. Original
CWnd* pOwner = GetOwner();
if (pOwner)
pOwner->SendMessage(WM_PG_ENDLABELEDIT, (WPARAM) LPCTSTR(str), NULL );
if (IsWindow(GetSafeHwnd()))
SendMessage(WM_CLOSE, 0, 0);
bAlreadyEnding = FALSE;
1. Swap the two conditionals
CWnd* pOwner = GetOwner();
if (IsWindow(GetSafeHwnd()))
SendMessage(WM_CLOSE, 0, 0);
if (pOwner)
pOwner->SendMessage(WM_PG_ENDLABELEDIT, (WPARAM) LPCTSTR(str), NULL );
bAlreadyEnding = FALSE;
2. Change the second if to be an else-if
CWnd* pOwner = GetOwner();
if (pOwner)
pOwner->SendMessage(WM_PG_ENDLABELEDIT, (WPARAM) LPCTSTR(str), NULL );
else if (IsWindow(GetSafeHwnd()))
SendMessage(WM_CLOSE, 0, 0);
bAlreadyEnding = FALSE;
I see that both approaches have potential risks if I miss understand the way the code is suppose to flow. The first approach might destroy the edit control before the owner is done with it. The second approach is assuming that the owner will destroy the edit control as opposed to the control destroying itself; thus a potential memory leak. Neither of these issues appear to be happening, but I could be wrong.
Any comments from others that might know what is the best approach?
|
|
|
|
 |
|
 |
Clarification: I should have said, "string" property field instead of "text". I was using string property type, the simple single line in-place edit, not text property type, the multiline dynamic dialog:
I recently ran some code that uses the PropertyGrid through Purify. When entering text into a string text property field I would always get a Free Memory Read error in CPropertyGridInPlaceEdit::EndEdit in PropertyGridInPlaceEdit.cpp circa line 222, which reads if (IsWindow(GetSafeHwnd())).
|
|
|
|
 |
|
 |
When Clicking on an item containing a combobox or calendar control, the parent window (ie. dialog or framewnd) will be deactivated while the control shows. It makes me feel the control a little "heavy". Anybody can improve this?
ice on my way
|
|
|
|
 |
|
 |
Hi all,
Troubled by the two different versions of this genuinely useful control, I've modified the class interfaces and underlying implementation to work properly with the _UNICODE build switch. (I've also removed the need to import the whole of namespace std:: (!) in order to build it.)
(1) All string parameters in the class methods are now specified using the simple build-aware generic string type LPCTSTR.
(2) All internal string members are now stored using CString, which itself is sensitive to the _UNICODE switch.
(3) All conversion and copy functions (like atoi and strncpy) use the generic-text routines, and thus resolve to either ANSI or wide versions of functions in the C runtime based on whether _UNICODE is #defined.
If anyone wants this, I'll happily forward it. It may additionally be of interest/use to remaining VC6 users, due to the removal of some STL code.
Cheers - Duncan.
|
|
|
|
 |
|
 |
I am a VB programmer and can understand C#, but this is written in C, which I don't have on my pc and can't understand it at all. Anyone have a VB or C# example of this?
I just want to know how to do a multiline text in a property grid.
|
|
|
|
 |
|
 |
Hello,
I think this is very nice control and works very nice as a control in Dialog Box.
But now I like to use this control as a child control of normal window(view).
How can I create this control window without using DDX_Control?
I look at the source code and couldn't find a way.
Could you let me know how to use it as a child window?
Thanks,
Sang
|
|
|
|
 |
|
 |
I placed it in a window using CPropertyGrid::CreateEx but you can probably use CPropertyGrid::Create as well...
|
|
|
|
 |
|
 |
Thank you for your comment.
I used the below line to create it and it looks it's working fine now.
Thank you again for your great article.
Sang
RECT rc;
GetClientRect(&rc);
m_ctrlGrid.CreateEx(0, AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW), L"", WS_CHILD|WS_VISIBLE, rc, this, 0x1002);
|
|
|
|
 |
|
 |
Hello,
i try to add some string items, with this tabstop \t characters,
but they are not showed properly!
Any idea how to show special characters in new string items??
thanks for any help!
termal
|
|
|
|
 |
|
 |
Hello,
can i get a pointer to combo item, if yes how, any idea for this?
I like to call the CComboBox function:
SetCurSel(int iIndex);
thanks for any help!
termal
|
|
|
|
 |
|
 |
Hello,
how can i determine witch combo box is clicked if i have more then one??
There is a function:
LRESULT CPropertyGrid::OnComboSelChanged(WPARAM wParam, LPARAM lParam)
but this is for all comboboxes, no matter how many are in the propertygrid,
and i have two in grid, and if i select some text how to know witch combo is clicked??
Thanks for any help!!
termal
|
|
|
|
 |
|
 |
Hello,
from what I recall, wParam should be the HITEM of the combo box...
Regards,
|
|
|
|
 |
|
 |
Hello,
yes you have right, i solved already!
regards
termal
|
|
|
|
 |
|
 |
Hello,
i try to implement this grid in my project, but i have some problems!
I can bring my application to run, but when my dialog is visible and the grid,
i cant collapse the items, what im doing wrong!
Here is code snippet:
HSECTION hs = m_ctrlGrid.AddSection(_T("Basic Items"));
m_ctrlGrid.AddStringItem(hs, _T("String"), _T("A single line string item"));
m_ctrlGrid.AddTextItem(hs, _T("Text"), _T("A multi line text item.\r\nSecond line..."));
m_ctrlGrid.AddStringItem(hs, _T("Disabled item"), _T("A disabled item"), false);
m_ctrlGrid.AddIntegerItem(hs, _T("Integer"), 10);
m_ctrlGrid.AddIntegerItem(hs, _T("Formatted Integer"), 8, _T("%d inches"));
m_ctrlGrid.AddDoubleItem(hs, _T("Double"), 7.33);
m_ctrlGrid.AddDoubleItem(hs, _T("Formatted Double"), 10.25, _T("%gmm"));
m_ctrlGrid.AddBoolItem(hs, _T("Boolean"), true);
All items are showed, and [-] for collapse too, but it dont take effect when i'm click on the symbol!
Do i have to implement a function for collapse??
[EDIT]
What files need to implement to bring this grid to work!?
[/EIDT]
thanks for any help
termal
modified on Friday, November 21, 2008 7:28 AM
|
|
|
|
 |
|
 |
Hi,
does anyone have idea for my problem??
regards
termal
|
|
|
|
 |
|
 |
Hi,
i solved my problem, i forgot to activate Notify in the properties settings
regards
termal
|
|
|
|
 |
|
 |
I have changed the Unicode version to show the combobox list elements only when clicking on the down arrow box. If you need this change here is the code
file PropertyGrid.cpp starting with line 1608. Method CPropertyGrid::OnLButtonUp()
The added code is bolded italic:
else
{
if (m_rect_button.PtInRect(point))
{
// the combo rect
CRect rc = m_rect_button;
rc.left = m_gutter_width;
rc.top += m_line_height;
rc.bottom = rc.top + 100;
// create it
m_control = new CPropertyGridCombo();
CPropertyGridCombo* pCombo = (CPropertyGridCombo*)m_control;
pCombo->Create(WS_CHILD, rc, this, 0);
pCombo->SetColors(m_clrBack, m_clrText, m_clrFocus, m_clrHilite);
pCombo->SetFont(&m_fntNormal);
if (pItem->m_type == IT_BOOLEAN)
{
pCombo->AddString(m_strTrue);
pCombo->AddString(m_strFalse);
if (!pItem->m_undefined)
pCombo->SetCurSel(pItem->m_bValue?0:1);
}
else
{
for (vector::iterator it = pItem->m_options.begin(); it != pItem->m_options.end(); ++it)
pCombo->AddString(*it);
if (!pItem->m_undefined)
pCombo->SetCurSel(pItem->m_nValue);
}
pCombo->ShowWindow(SW_SHOW);
}
}
}
|
|
|
|
 |
|
 |
Good Work!!!
but the "Ccustom Dropdown Edit" also has the problem~
|
|
|
|
 |
|
 |
The item-changed message (WM_PG_ITEMCHANGED) is not sent when a EM_DROPDOWN Custom Item's value changes. To facilitate this, I added a new FlagItemChanged method to CPropertyGrid. In the implementation of the Custom Item, when the value has changed, instead of calling CPropertyGrid's Invalidate, call this new method. The implementation of this method is as follows:void CPropertyGrid::FlagItemChanged()
{
CItem* pItem = FindItem( m_focused_item );
GetOwner()->SendMessage(WM_PG_ITEMCHANGED, pItem->m_id);
Invalidate();
}Maybe a different approach could be used, but this is the approach I am currently using.
modified on Thursday, July 31, 2008 10:55 AM
|
|
|
|
 |
|
 |
hi, I love the control thanks for writing it, but I am curious if I am just missing something here or not. I am dealing with data that forces the bottom droplist off the screen and once it runs off there is no way for the user to access that data. Is there support for Scollbars in the combo box?
thanks
-eric
|
|
|
|
 |