|
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. 
|
|
|
|
|
Your class is very useful.
Do you have a unicode version, please?
Bye.
|
|
|
|
|
Hi,
i've already converted the original version to a working unicode version, because this was what i needed, too.
if anyone wants it, i'd be glad to send it to you per email (just send me a PM with your email, and you'll get it)
if the original author is also interested, we could post the unicode version onto the page.
cheers
obliviate
p.s.: thanks to the original author for this really useful piece of work... well done!
|
|
|
|
|
Yes please, send me 
|
|
|
|
|
Please, send to me at:
lvsai@mail.ru
Thanks.
|
|
|
|
|
hi
Could you send me a unicode copy ?
my email is: btbaby@gmail.com
thanks a lot!
wangniu
|
|
|
|
|
hi
Could you send me a unicode copy ?
my email is: btbaby@gmail.com
thanks a lot!
wangniu
|
|
|
|
|
Please, send to me at:
massimo.perfini@virgilio.it
Thanks.
|
|
|
|
|
please send me a copy, many thanks.
hamo2008@gmail.com
|
|
|
|
|
Please, send to me at:
51685050@163.com
Thanks.
|
|
|
|
|
Yes, please can you send me the unicode version ? My email is nicolas.francheteau@europlacer.fr
Thanks for all.
|
|
|
|
|
kilojuliet@paran.com
Thank you.
|
|
|
|
|
Hi
Could you send me a unicode copy ?
email is: dragisa@uns.ac.rs
thanks!
|
|
|
|
|