|
Jethro63 wrote: It seems like a pretty common need...
This marks the first time I've heard of it.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Really? Then I've gone from surprised to utterly gob-smacked. Nobody ever wants the list control to just jump to record N?
If I have a list of records that include, say, dates and times, and the user can search the list for the first record occuring on date XYZ or the nearest record after that. The program engine locates this record, its item #456. Wouldn't it be nice if the next thing that happens is that the list view range is repositioned with this record at the top? We have an inventory tracking system here that does that very thing. It doesn't produce a sub-set of the list (there's other search features that do that) it just adjusts the scroll position so that the record of interest is displayed at the top of the list.
List Boxes and Combo Boxes are loaded with items and have a member to fetch the current position (GetCurSel) and adjust the current item displayed (SetCurSel). It seems odd that this was not extended to CListCtrl.
Nevertheless, I am trying to extend CListCtrl into something with a few extra useful features. If I ever figure out how to do it, this will be one of the items that I add, even if I end up being the only person in explored space that appreciates it.
Thanks for your input.
Mark
|
|
|
|
|
Jethro63 wrote: Nobody ever wants the list control to just jump to record N?
Sure, but not so far as requiring it be at the top of the list. As long as it's visible, and possibly selected, that's good enough.
Jethro63 wrote: We have an inventory tracking system here that does that very thing.
There's nothing wrong with custom controls. CP is full of 'em.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I get a lot of help from CP when I'm trying to figure out how to do things. But I don't like just taking somebody's solution and using it. I don't learn anything that way. I typically study a lot of different submissions and try to decide which way I would like to do it. Its slower but I feel better about it and I also stand a better chance of fixing things when they break.
Cheers,
Mark
|
|
|
|
|
This requirement is not uncommon. Unfortunately, CListCtrl has no support for the feature. I have encountered and implemented a couple of such cases. It's not as difficult as you thought
Best,
Jun
|
|
|
|
|
Thanks Jun, I will keep plugging at it...
Mark
|
|
|
|
|
One sort of hack at it is to get the current number of items the list control displays (call it N), use Ensure Visible on the item you want to see and then on the item that is N-1 visible items away.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Here is one way to move a specific list item to the top
void CTestDlg::MoveItemToTop( int itemIndex )
{
CRect topItemRect;
CRect itemRect;
//Figure out which item is currently at the top of the list
int topIndex = m_ListCtrl.GetTopIndex();
//Get the bounding rectangle around the current top item
m_ListCtrl.GetItemRect(topIndex+1,&topItemRect,LVIR_BOUNDS);
//Get the bounding rectangle around the desired top item
m_ListCtrl.GetItemRect(itemIndex,&itemRect,LVIR_BOUNDS);
//Compute the y distance between the 2 items
CSize size(0,itemRect.bottom-topItemRect.bottom);
//Scroll the list
m_ListCtrl.Scroll(size);
}
|
|
|
|
|
I need a report or a link where I can find the steeps to change window style to XP style.
|
|
|
|
|
Hi.
There's a fair amount of coding to support the XP look, but there are a number of good articles here on that. Type do a Search on Articles for XP styles and you'll find a lot of great stuff that should help you out.
|
|
|
|
|
Hello All,
I am launching a Modal dialog box on selecting of a menu item in my SDI application. I want that dialog to be resizable.
Dialog box is created using Resource Editor and class is derived from CDialog and I launch using DoModal ().
By Default Dialog box comes only with close button. I enabled Minimize and Maximize button property it allows me maximize and minimize only (Quite Natural ) and not able to resize the dialog window. I need only resizing and not minimize and maximize the dialog window.
How can i achive it? plz guide me!!!!
Thanks for your time.
Ravi
|
|
|
|
|
I think a dialog can be resized if its Border property (in Properties panel of Dialog Editor) is set to "Resizing".
I hope this helps.
|
|
|
|
|
yeah, but only the frame will be resized, the original poster will have to manually resize/move all the controls in the dialog.
he can use one of the "resize manager" that can be found on CP to help him do that.
|
|
|
|
|
I'm somewhat new to the CMap Collection class, and I'm having trouble with my program that's using them.
Using:
- MSVS2005
- CMapStringToString
- CMap<LPCTSTR,LPCTSTR,int,int>
I've done an inithash with 1000 as the input.
Items seem to be added fine until I get around 100 items... then:
Unhandled exception at 0x00435971 in test.exe: 0xC0000005: Access violation reading location 0x726e6e75.
This occurs in the CMapStringToString::GetAssocAt function at the point indicated by the arrow:
for (pAssoc = m_pHashTable[nHashBucket]; pAssoc != NULL; pAssoc = pAssoc->pNext)
{
--> if (pAssoc->nHashValue == nHashValue && pAssoc->key == key)
return pAssoc;
}
Based on what MSVS2005 is telling me in Debug, pAssoc is not null, but the nHashValue and key properties "cannot be evaluated".
Not sure where to go from here...
Thanks for any help.
|
|
|
|
|
You probably cause data corruption somewhere else in your code.
How do you allocate the LPCTSTR that you insert?
|
|
|
|
|
Would that cause this error? If so, that gives me a good place to start debugging.
currently I am using the TConvert class _towchar to generate the LPCTSTR's. Within my loop, I checked every iteration to ensure the string was good before trying to insert it...
I can try inserting hardcoded strings to eliminate this as a possible cause though...
Thanks
|
|
|
|
|
If the memory for those strings is on the stack, when the scope that is adding them to the map is complete (e.g. the function finishes) all that memory is now invalid. You may still have "valid" data for a while, but all that stack memory is no unallocated/unprotected and will be overwritten eventually. That will cause problems later, if it isn't already.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
So, are you saying that the map does not make copies of the string data, but simply points to the strings I'm sending in?
If so, that's useless to me, any way around this?
|
|
|
|
|
LPCTSTR is not a string, it is either a const char* or a const wchar_t* depending on whether UNICODE is defined or not. So, yes, the CMap class copies the pointer, but not the string (because it doesn't know you are passing it a string).
To get around that, declare your map type as CMap<CString, CString&, int, int>
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Bingo!
Thanks, pardon my earlier cynicism... now to post a new problem with the debug heap...
|
|
|
|
|
Hello,
can someone help me with this problem in ETSLayoutManager??
thax
break;
|
|
|
|
|
Err... That's a very clear description of your problem
|
|
|
|
|
Hello Moonen,
sorry :->, ETSLayoutDialog Manager is here in the comunity, a litle framework to manage the dialog items,
mean, when dialog resize, normaly all dlg items stay on the same place, with this framework you can
replace and resize all items!
Here is the url:
http://www.codeproject.com/dialog/layoutmgr.asp
and my try:
<br />
CMyDialog* pdlg = ((CMyDialog*)m_cTabAll.GetTab(0));<br />
<br />
CPane DIALOG = paneCtrl( pdlg, HORIZONTAL, RELATIVE_VERT, 0,0,-125,0)<br />
<< item(pdlg, GREEDY);<br />
<br />
CPane TABCTRL = paneTab(&m_cTabAll,HORIZONTAL, GREEDY)<br />
<< DIALOG<br />
<< itemGrowing(VERTICAL);<br />
<br />
CreateRoot(VERTICAL)<br />
<< TOOLBAR
<< TABCTRL<br />
<< PROGRESS<br />
<< itemGrowing(HORIZONTAL)<br />
<< itemGrowing(HORIZONTAL)<br />
<< item(IDC_STATUSBAR, ABSOLUTE_VERT);<br />
<br />
<br />
UpdateLayout();<br />
hope this is a litle more information!
with best regards
berak;
|
|
|
|
|
If it comes from an article, then it's better to post in the message board at the bottom of the article if the article doesn't provide enough information.
|
|
|
|
|
Hi,
yes, that what i think before, but, in this artikle does nobody maintain this posts, they are no answers on questions !?
Therefore i think maybe is someone in the comunity who use this framework to and so can help me???
regards
break;
|
|
|
|