|
The dialog box for the font control (AddFontItem ) provides a selection for color. However, the color information is not communicated out of the PropertyGrid control in any manner. I can see in PropertyGrid.cpp CPropertyGrid::EditFocusedItem where a CFontDialog is constructed and used. A LOGFONT is copied out of the dialogs m_lf member, but the m_cf member is ignored.
For now I am going to remove the CF_EFFECTS flag from the dialog construction. This will remove the color selector from the dialog box, but also removes the Strikeout and Underline.
|
|
|
|
|
When using the after parameter of any of the CPropertyGrid::AddXXXItem methods, it appears to be completely ignored. The after parameter of the CPropertyGrid::AddSection does appear to work. Following the model of AddSection , I made the following change to AddItem(HSECTION hs, EItemType type, string name, void* pValue, bool editable, bool undefined, HITEM after) :
--- ../PropertyGrid/PropertyGrid.cpp (revision 22)
+++ ../PropertyGrid/PropertyGrid.cpp (working copy)
@@ -373,7 +373,12 @@
item.ValidateChanges();
- it->m_items.push_back(item);
+
+
+
+ vector<citem>::iterator itemIt = find( it->m_items.begin(), it->m_items.end(), after);
+ it->m_items.insert(itemIt, item);
+</citem>
RecalcLayout();
return item.m_id;
}
Thus the resulting function now reads:
HITEM CPropertyGrid::AddItem(HSECTION hs, EItemType type, string name, void* pValue, bool editable, bool undefined, HITEM after)
{
vector<csection>::iterator it = find(m_sections.begin(), m_sections.end(), hs);
if (it == m_sections.end())
return -1;
vector<citem>::iterator it2 = find(it->m_items.begin(), it->m_items.end(), name);
if (it2 != it->m_items.end())
return -1;
CItem item;
item.m_id = m_item_id++;
item.m_type = type;
item.m_name = name;
item.m_editable = editable;
item.m_undefined = undefined;
if (type == IT_CUSTOM) item.m_pCustom = (ICustomItem*)pValue;
else if (type == IT_STRING || type == IT_TEXT || type == IT_FILE || type == IT_FOLDER) item.m_strValue = *(string*)pValue;
else if (type == IT_COMBO || type == IT_INTEGER) item.m_nValue = *(int*)pValue;
else if (type == IT_DOUBLE) item.m_dValue = *(double*)pValue;
else if (type == IT_BOOLEAN) item.m_bValue = *(bool*)pValue;
else if (type == IT_DATE || type == IT_DATETIME) item.m_dtValue = *(COleDateTime*)pValue;
else if (type == IT_COLOR) item.m_clrValue = *(COLORREF*)pValue;
else if (type == IT_FONT) memcpy(&item.m_lfValue, pValue, sizeof(LOGFONT));
else assert(false);
item.ValidateChanges();
vector<citem>::iterator itemIt = find( it->m_items.begin(), it->m_items.end(), after);
it->m_items.insert(itemIt, item);
</citem>
RecalcLayout();
return item.m_id;
}
</citem></csection>
|
|
|
|
|
vector::iterator itemIt = find( it->m_items.begin(), it->m_items.end(), after);
it->m_items.insert(itemIt, item);
how to replace this two lines in the version of vc 6.0?
|
|
|
|
|
Almost a year after I made the post. Took me a moment to remember.
I do not see anything in what I did that would not work under VC6. That code was modeled after code that is in AddSection, therefore I would assume if what I did in AddItem does not work in VC6, it would not work in AddSection either.
However a note, a year ago I was using this code in VC6. However I was not using the the STL that came with VC6. Instead I was using STLport. (Specifically version 4.6.2. What I wasn't using a version 5.X I do not know.) Therefore the issue you are having may be related to this. In general the STLport that came with VC6 was terrible (personal opinion); many bugs, several missing features. STLport is a considerable improvement over the VC6 STL.
|
|
|
|
|
The license of this code is unclear. What is the license of this code?
The article says:
License
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
There is no license file in the source collection. Search for 'license' in all the files of the source collection finds nothing. Searching for 'copyright' in the files of the source collection finds a few things from different authors.
Therefore, I am free to use compiled in any application without encumbrance.
Therefore, I am free to use provided I give extra copyright notices (i.e. Berkeley style license).
Copyrighted, but no release. Thus technically one must assume one must get permission from the author, "nabocorp", to use this code in ANY form.
The rest of the code contains no copyright notice, thus one must assume it is copyrighted, presumably by the author of the article, "Nicolas Bonamy". However, again, with no release one must assume one must get permission from the author to use in ANY form.
modified on Thursday, May 1, 2008 8:43 AM - Minor typo/grammar fixes.
|
|
|
|
|
Hello,
as stated in the article I am using some code from other CP articles so check the license for these. As far as my stuff is concerned I have just chosen the CPOL license.
Regards,
|
|
|
|
|
Excellent. I also see you have now changed the License section in the article.
Thank you.
|
|
|
|
|
Can anyone provide suggestion for C# developers to get this up and running? I think anyone else reading this article can develop a greater appreciation for this control, even if they don't understand the first time.
Wasn't .NET capable of hosting two projects in two languages? Isn't just simply importing references from PropertyGrid into a new project?
What I did was.
1. Set the output type of PropertyGrid project to .dll
2. Compile PropertyGrid
3. Import the reference into my project.
Strangely, i am missing something to make it work.
|
|
|
|
|
Hello,
I have added converted UNICODE examples from the original source to Obliviate's UNICODE version and fixed bug in the integer and the double input field.
The entire project is available here:
http://www.orionsoft.cz/extras/PropertyGridUnicode.zip
Hope it will help someone.
Tomas
|
|
|
|
|
Tomas,
Could you elaborate on what kind of bugs with integer and double you found? I checked your version against the original code and didn't find any changes besides the string stuff. Or is it a bug with Obliviate's unicode version?
Thanks
|
|
|
|
|
Hi!
The Obliviate's unicode version kept the original non-unicode string-to-number conversion functions. It resulted in incorrect conversion, shortening input numbers to the first digit only (as the wide characters consist of two bytes, where the second one is normally zero, it was misinterpreted as a terminating zero of a plain ASCII char string). I replaced these functions by their wide char equivalent.
Tomas
|
|
|
|
|
Thanks for this clarification, Tomas!
|
|
|
|
|
There is a small bug in the Unicode version when using AddTextItem to add a multiline box. This bug causes an ASSERT.
Here is the patch. In the method CDynDialogEx::DoModal
Line 273:
replace
pdest += szBoxLen;
by
pdest += szBoxLen*sizeof(WCHAR);
Line 278:
replace
pdest += szBoxLen;
by
pdest += szBoxLen*sizeof(WCHAR);
Regards
|
|
|
|
|
small-small bug.
Line 279:
replace
pdest += nFontNameLen;
by
pdest += nFontNameLen*sizeof(WCHAR);
not line 278 
|
|
|
|
|
Good Work! but it is for vc 7.0
help there is a UNICODE version for vc 6.0
i have adapted it. If you still need it please email me.(zanget@msn.com)
I'm trying to fix bugs which the board show on this version.
modified on Thursday, May 7, 2009 7:25 AM
|
|
|
|
|
Why your unicode version code does not provide the "AddCheckBox()" ?
|
|
|
|
|
Dear Nicolas,
I went through your Fully Customizable PropertyGrid article. It is quite nice and useful.
However, as I primarily develop in C#, I am unable to understand the C++ code. I would appreciate if you could forward this code in C#.
I am basically interested in the implementation of Full Custom Edit & Ccustom DropDown Edit properties, of your PropertyGrid. I want to open a custom UITypeEditor (already implemented) for Boolean property on a PropertyGrid, while, preserving the original Boolean property behaviour. i. e. to place an extra button to open this custom UITypeEditor.
Any help would be greatly appreciated.
Regards,
Virat Kothari
viratkothari@yahoo.com
virat.kothari@gmail.com
|
|
|
|
|
|
Hi,
Thaks for the link. I have gone through the link. It is really nice one. Bye the way i have customize the propertygrid in my own way using this code and its working fine.
Thanks once again.
Regards,
Virat Kothari
viratkothari@yahoo.com
virat.kothari@gmail.com
|
|
|
|
|
Hi Virat,
Don't want to take up too much of your time, can you quickly explain the steps you took to get your C# project running using this propertygrid.
|
|
|
|
|
I think somebody like to use checkbox, not dropdown false and true. I've add this feature:
In PropertyGrid.h, make modification below:
=========================================================================
1. add EM_IMMEDIATE to enum EEditMode;
2. add IT_CHECK to enum EItemType;
3. add interface:
public:
HITEM AddCheckItem(HSECTION section, string name, bool value, bool editable = true, bool undefined = false, HITEM after = -1);
private:
CRect AdjustCheckBoxRect(CRect* rc);
In PropertyGrid.CPP, make modifications below:
=========================================================================
1. add checkbox bitmap data:
//CheckBox data
static const int CheckBoxHeight = 13;
int Item_CheckOn[169] =
{
0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,
0x1c5180,0xe2e2dd,0xe2e2dd,0xe2e2dd,0xe3e3df,0xe5e5e1,0xe7e7e3,0xeaeae6,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0x1c5180,
0x1c5180,0xe2e2dd,0xe2e2dd,0xe3e3df,0xe5e5e1,0xe7e7e3,0xeaeae6,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f3,0x1c5180,
0x1c5180,0xe2e2dd,0xe3e3df,0xe5e5e1,0xe7e7e3,0xeaeae6,0xecece9,0xefefec,0xf1f1ef,0x21a121,0xf5f5f3,0xf7f7f6,0x1c5180,
0x1c5180,0xe3e3df,0xe5e5e1,0xe7e7e3,0xeaeae6,0xecece9,0xefefec,0xf1f1ef,0x21a121,0x21a121,0xf7f7f6,0xf9f9f8,0x1c5180,
0x1c5180,0xe5e5e1,0xe7e7e3,0x21a121,0xecece9,0xefefec,0xf1f1ef,0x21a121,0x21a121,0x21a121,0xf9f9f8,0xfafaf9,0x1c5180,
0x1c5180,0xe7e7e3,0xeaeae6,0x21a121,0x21a121,0xf1f1ef,0x21a121,0x21a121,0x21a121,0xf9f9f8,0xfafaf9,0xfcfcfb,0x1c5180,
0x1c5180,0xeaeae6,0xecece9,0x21a121,0x21a121,0x21a121,0x21a121,0x21a121,0xf9f9f8,0xfafaf9,0xfcfcfb,0xfdfdfd,0x1c5180,
0x1c5180,0xecece9,0xefefec,0xf1f1ef,0x21a121,0x21a121,0x21a121,0xf9f9f8,0xfafaf9,0xfcfcfb,0xfdfdfd,0xfefefe,0x1c5180,
0x1c5180,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f3,0x21a121,0xf9f9f8,0xfafaf9,0xfcfcfb,0xfdfdfd,0xfefefe,0xffffff,0x1c5180,
0x1c5180,0xf1f1ef,0xf3f3f1,0xf5f5f3,0xf7f7f6,0xf9f9f8,0xfafaf9,0xfcfcfb,0xfdfdfd,0xfefefe,0xffffff,0xffffff,0x1c5180,
0x1c5180,0xf3f3f1,0xf5f5f3,0xf7f7f6,0xf9f9f8,0xfafaf9,0xfcfcfb,0xfdfdfd,0xfefefe,0xffffff,0xffffff,0xffffff,0x1c5180,
0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,
};
int Item_CheckOff[169] =
{
0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,
0x1c5180,0xdcdcd7,0xdcdcd7,0xdcdcd7,0xdeded9,0xe0e0db,0xe2e2de,0xe5e5e2,0xe8e8e5,0xecece9,0xefefec,0xf1f1ef,0x1c5180,
0x1c5180,0xdcdcd7,0xdcdcd7,0xdeded9,0xe0e0db,0xe2e2de,0xe5e5e2,0xe8e8e5,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0x1c5180,
0x1c5180,0xdcdcd7,0xdeded9,0xe0e0db,0xe2e2de,0xe5e5e2,0xe8e8e5,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f4,0x1c5180,
0x1c5180,0xdeded9,0xe0e0db,0xe2e2de,0xe5e5e2,0xe8e8e5,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f4,0xf7f7f6,0x1c5180,
0x1c5180,0xe0e0db,0xe2e2de,0xe5e5e2,0xe8e8e5,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f4,0xf7f7f6,0xf9f9f8,0x1c5180,
0x1c5180,0xe2e2de,0xe5e5e2,0xe8e8e5,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f4,0xf7f7f6,0xf9f9f8,0xfbfbfa,0x1c5180,
0x1c5180,0xe5e5e2,0xe8e8e5,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f4,0xf7f7f6,0xf9f9f8,0xfbfbfa,0xfdfdfc,0x1c5180,
0x1c5180,0xe8e8e5,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f4,0xf7f7f6,0xf9f9f8,0xfbfbfa,0xfdfdfc,0xfefefe,0x1c5180,
0x1c5180,0xecece9,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f4,0xf7f7f6,0xf9f9f8,0xfbfbfa,0xfdfdfc,0xfefefe,0xffffff,0x1c5180,
0x1c5180,0xefefec,0xf1f1ef,0xf3f3f1,0xf5f5f4,0xf7f7f6,0xf9f9f8,0xfbfbfa,0xfdfdfc,0xfefefe,0xffffff,0xffffff,0x1c5180,
0x1c5180,0xf1f1ef,0xf3f3f1,0xf5f5f4,0xf7f7f6,0xf9f9f8,0xfbfbfa,0xfdfdfc,0xfefefe,0xffffff,0xffffff,0xffffff,0x1c5180,
0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,0x1c5180,
};
int Item_CheckOn_Disabled[] =
{
0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,0xcac8bb,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xcac8bb,0xffffff,0xffffff,0xffffff,0xcac8bb,0xcac8bb,0xcac8bb,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xcac8bb,0xcac8bb,0xffffff,0xcac8bb,0xcac8bb,0xcac8bb,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xcac8bb,0xcac8bb,0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,
};
int Item_CheckOff_Disabled[] =
{
0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xffffff,0xcac8bb,
0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,0xcac8bb,
};
2. in function:
HITEM CPropertyGrid::AddItem(HSECTION hs, EItemType type, string name, void* pValue, bool editable, bool undefined, HITEM after)
bool CPropertyGrid::GetItemValue(HITEM item, bool& bValue) const
bool CPropertyGrid::SetItemValue(HITEM item, const bool bValue)
change:
else if (type == IT_BOOLEAN)
to
else if (type == IT_BOOLEAN || type == IT_CHECK )
3. add functions:
HITEM CPropertyGrid::AddCheckItem(HSECTION section, string name, bool value, bool editable, bool undefined, HITEM after)
{
return AddItem(section, IT_CHECK, name, &value, editable, undefined, after);
}
CRect CPropertyGrid::AdjustCheckBoxRect(CRect* rc)
{
CRect rctmp = *rc;
rctmp.left += GetTextMargin();
rctmp.top++;
rctmp.top += ((rctmp.Height() - CheckBoxHeight) / 2);
rctmp.bottom = rctmp.top + CheckBoxHeight;
rctmp.right = rctmp.left + CheckBoxHeight; //m_line_height - 2;
return rctmp;
}
4. in functions add lines with arrow:
void CPropertyGrid::DrawItem(CDC& dc, int w, int x, int y, vector<citem>::iterator& it)
{
case EM_INPLACE:
// whole area is edit
m_rect_button.left = m_gutter_width;
break;
ADD===> case EM_IMMEDIATE: //record check box pos
ADD===> m_rect_button = AdjustCheckBoxRect(&CRect(value_left, y, value_right, y+m_line_height));
ADD===> break;
==============================================
case IT_FONT:
{
CString strTemp;
strTemp.Format("%s; %dpt", it->m_lfValue.lfFaceName, -MulDiv(it->m_lfValue.lfHeight, 72, dc.GetDeviceCaps(LOGPIXELSY)));
strValue = LPCTSTR(strTemp);
modified = (memcmp(&it->m_lfValue, &it->m_lfValue_old, sizeof(LOGFONT))!=0);
break;
}
ADD===> case IT_CHECK:
ADD===> {
ADD===> // draw a sample rectangle
ADD===> CRect rc = AdjustCheckBoxRect(&(it->m_rcValue));
ADD===>
ADD===> BITMAPINFO bmi;
ADD===> bmi.bmiHeader.biBitCount = 32;
ADD===> bmi.bmiHeader.biClrImportant = 0;
ADD===> bmi.bmiHeader.biClrUsed = 0;
ADD===> bmi.bmiHeader.biCompression = BI_RGB;
ADD===> bmi.bmiHeader.biHeight = CheckBoxHeight;
ADD===> bmi.bmiHeader.biPlanes = 1;
ADD===> bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
ADD===> bmi.bmiHeader.biSizeImage = 0; //0 is ok for BI_RGB (uncompressed)
ADD===> bmi.bmiHeader.biWidth = CheckBoxHeight;
ADD===> bmi.bmiHeader.biXPelsPerMeter = 1;
ADD===> bmi.bmiHeader.biYPelsPerMeter = 1;
ADD===>
ADD===> void* pBuffer;
ADD===> if ( it->m_editable )
ADD===> {
ADD===> pBuffer = it->m_bValue? &Item_CheckOn : &Item_CheckOff;
ADD===> }
ADD===> else
ADD===> {
ADD===> pBuffer = it->m_bValue? &Item_CheckOn_Disabled : &Item_CheckOff_Disabled;
ADD===> }
ADD===> StretchDIBits(dc.m_hDC, rc.left, rc.top, rc.Width(), rc.Height(), 0, CheckBoxHeight+1, CheckBoxHeight, -CheckBoxHeight, pBuffer, &bmi, DIB_RGB_COLORS, SRCCOPY);
ADD===>
break;
}
}
}
void CPropertyGrid::OnLButtonUp(UINT nFlags, CPoint point)
{ else if (GetEditMode(*pItem) == EM_CUSTOM)
{
pItem->m_pCustom->OnLButtonUp(pItem->m_rcValue, point);
}
ADD===> else if (GetEditMode(*pItem) == EM_IMMEDIATE)
ADD===> {
ADD===> }
}
CPropertyGrid::EEditMode CPropertyGrid::GetEditMode(CItem& item)
{
ADD===> case IT_CHECK:
ADD===> return EM_IMMEDIATE;
}
5. in function, change lines with arrow:
void CPropertyGrid::OnLButtonDown(UINT nFlags, CPoint point)
{
if (m_rect_button.PtInRect(point))
{
Modify==> ASSERT(m_focused_item != -1);
Modify==> CItem* pItem = FindItem(m_focused_item);
Modify==> if ( pItem && pItem->m_type == IT_CHECK && pItem->m_editable)
Modify==> {
Modify==> pItem->m_bValue = !pItem->m_bValue;
Modify==> GetOwner()->SendMessage(WM_PG_ITEMCHANGED, pItem->m_id);
Modify==> }
Modify==> else
Modify==> {
Modify==> m_button_pushed = true;
Modify==> m_button_depressed = true;
Modify==> SetCapture();
Modify==> }
Invalidate();
return;
}
if (it2->m_rcValue.PtInRect(point))
Modify==> {
Modify==> m_value_clicked = (GetEditMode(*it2) == EM_INPLACE || GetEditMode(*it2) == EM_DROPDOWN);
Modify==> if ( it2->m_type == IT_CHECK && it2->m_editable)
Modify==> {
Modify==> CRect rc = AdjustCheckBoxRect(&(it2->m_rcValue));
Modify==> if ( rc.PtInRect(point))
Modify==> {
Modify==> it2->m_bValue = !it2->m_bValue;
Modify==> GetOwner()->SendMessage(WM_PG_ITEMCHANGED, it2->m_id);
Modify==> }
Modify==> }
Modify==> }
}
|
|
|
|
|
1. when the property of "focus on disable item" set to true, the behavior of items such as bool,combo,datetime was abnormal, it'll response to click or double click.
2. In the picture showed above, you double click on "More Items", you'll find that you can't drag the scroll bar down to show the last items.
-- modified at 22:23 Thursday 11th October, 2007
|
|
|
|
|
Thanks for reporting these bugs, Kindy Chen. I was able to fix them in 10 minutes, thanks to well written code by Nicolas. Here's the fix for those who are interested:
1. In OnLbuttonDblClick, couple lines down, change if (pItem) to if (pItem && pItem->m_editable)
2. In OnLbuttonDown, find this line: it->m_collapsed = !it->m_collapsed; , right below it should be Invalidate(); , change it to RecalcLayout();
Cheers
|
|
|
|
|
Wow, this control is very nice! Thx for sharing it.
|
|
|
|
|
hey Nicolas thx for your article.
i have an opinion, maybe it will be better if there is AddListItem. 
|
|
|
|
|