|
As the maps & vectors are dynamically created, the wrapper object may be on the stack, but its data will be on the heap, as it will be dynamically allocated. And that will apply to classes allocated by dynamically allocated classes allocated by... (etc).
Iain.
|
|
|
|
|
Thank you very much for your response!
Manu
|
|
|
|
|
The map class gets data from you and gives it back to you whereever it stores said data in encapsulated within the map-class.
Whether you construct the map-object on stack or in heap is irrlevant, as the same code for datastorage will be called in both cases.
The implementation can be controlled by you by giving it an appropriate allocator for your data.
The default allocator uses the heap, afaik.
You can read the code yourself, it comes with VC. On my VC2005 it in
C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\map
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hi,
What is the difference between DS_CONTROL and WS_EX_CONTROLPARENT? I know DS_CONTROL will remove the WS_CAPTION and WS_SYSMENU styles from the dialog. But I dont know if any other differences are there.
Thanks in advance.
- NS -
|
|
|
|
|
Off memory, DS_CONTROL style governs what happens when you reach the end of the tab order of controls in a dialog. If it's not set, the tab order will wrap around. If it *is* set, the tab will pass to a window governed by the dialogs parent window.
The documentation for WS_EX_CONTROLPARENT pretty much tells a normal window to do the tab order thing for it's children. I bet if you look at a normal dialog using spy++ you will see this bit is set.
Iain.
|
|
|
|
|
But I am very much confused with this DS_CONTROL
I have a dialog havning two buttons. And another dialog with two edit boxes. And in the OnInitDialog I have as follows.
m_dlgctrl.Create( m_dlgctrl.IDD, this );
ModifyStyleEx( 0, WS_EX_CONTROLPARENT );
m_dlgctrl.ModifyStyleEx( 0, WS_EX_CONTROLPARENT );
m_dlgctrl.ModifyStyle( DS_CONTROL, 0 );
Now the child dialog has no DS_CONTROL. But the tab order quite fine. This proves that DS_CONTROL has no influence in tab setting?
- NS -
|
|
|
|
|
I can do no better than to point to the explanation on Raymond Chen's blog (one of the first few google results for DS_CONTROL, by the way...
http://blogs.msdn.com/oldnewthing/archive/2004/07/30/201988.aspx[^]
"When you set the DS_CONTROL style on a dialog template (or set the WS_EX_CONTROLPARENT extended style on a regular window), a bunch of new rules kick in."
I hope his article can help!
Iain.
|
|
|
|
|
Ya. I have already read that. I understood nothing more... That is why I posted this doubt.
- NS -
|
|
|
|
|
I am creating an ownerdraw listbox. In DrawItem function I want to draw text. There's a code snippet in MSDN that is a little bit strange:
It uses this code to retrieve the text of current item.
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
I think it's wrong because a user might add custom data to items of the control and it's logical that itemData member refers to that data, anyway it doesn't work for me. I used this code which works just fine:
GetText(lpDrawItemStruct->itemID, str);
Is this ok?. If not, then is there any better way of finding text of current item in DrawItem ?
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Reading the MSDN documention about the DRAWITEMSTRUCT will give you the information about itemData. Hope you will...
Anyway the second method you used is not wrong.
- NS -
|
|
|
|
|
NS17 wrote: Reading the MSDN documention about the DRAWITEMSTRUCT will give you the information about itemData.
I did, and that's the reason of this question. It says something that seems to be wrong to me:
from MSDN:
itemData
For a combo box or list box, this member contains the value that was passed to the list box by one of the following:
CComboBox::AddString
CComboBox::InsertString
CListBox::AddString
CListBox::InsertString
this description with the snippet try to prove the string added can be found in itemData variable. I'm wondering at the moment, whether it differs if a list box has HAS_STRING style or not. Mine has and the itemData has not the string.
I'm completely confused
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hamed Mosavi wrote: it differs if a list box has HAS_STRING
Yes.
- NS -
|
|
|
|
|
A different question why you dont use of ListCtrl instead ListBox?
|
|
|
|
|
I like listbox because of its simplicity. But could you please point out the advantage of listctrl that made you to ask so?
- NS -
|
|
|
|
|
Instead my choice is Listctrl and ListBox is simple to use but its limited.
|
|
|
|
|
Hamid. wrote: but its limited.
That's true...
- NS -
|
|
|
|
|
Hamid. wrote: why you dont use of ListCtrl
Because all I need is a list of names.
CListCtrl has been designed to do more, like icons, different views(like report), good in-place edit, etc. and more flexibility cause more complexity, so one should spend a lot more time and write more codes to do the same work that could be easily done by a ListBox.
Now that I don't need those features, why should I go the hard way?
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hamed Mosavi wrote: Now that I don't need those features, why should I go the hard way?
I agree. It was an odd suggestion.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Your method seems fine to me - but have a look at LBS_HASTRINGS to be sure.
My suspicion is that the example snippet is just storing a pointer to some text in itemData in order to have something simple to draw. There's nothing to stop you have your code numbers in it, or neglecting it completely.
Iain.
|
|
|
|
|
I try to subclass and use this code for change background color in list control
<br />
BOOL CSubListCtrl::OnEraseBkgnd(CDC* pDC) <br />
{<br />
CRect rect;<br />
GetClientRect(&rect);<br />
pDC->FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(100,200,0));<br />
return TRUE;<br />
}
it work only when first time show.
but when I add item to it, that item will change to default color.
Please help me for solve this problem.
|
|
|
|
|
I think you should override DrawItem which will be called when each item of the control is to be drawn. Then use the input parameter for that function(lpDrawItemStruct ) like this:
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
dc.FillSolidRect(&lpDrawItemStruct->rcItem, RGB(100,200,0));
dc.Detach();
You should also manually draw text of each item, check to see if it is selected to highlight it and draw a border for active item.
By the way if your list control is inside a dialog, take a look at OnCtlColor of the dialog. It makes life times easier if you just need to change background or text color of a dialog control.
-- modified at 6:59 Wednesday 3rd October, 2007
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
I wonder why you do such a thing when SetBkColor and SetTextBkColor are available for CListCtrl.
- NS -
|
|
|
|
|
|
But he needs a single bk color. So my suggestion is good, right?
- NS -
|
|
|
|
|
I didnt see your answer but I see your answer yeah its good and perfect.;) but he must tells more detaily of his control.
|
|
|
|