|
waldermort wrote: I had already tried the 1 line method, but the code calls for the address of operator and throws an exception when using it within the memcpy() function.
From your description, using it in functions like memcpy would do far worse than throw an exception. Unless that memory is allocated somewhere, you will be trying to copy/write to a very high location in memory that isn't yours to write to.
waldermort wrote: I'm not sure I understand what you mean about using an inline helper. I'm guessing it's similar to a macro right?
Not exactly, but the idea is the same. I believe I gave an example in my previous response.
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
|
|
|
|
|
The 1-line one do not have the same meaning as the 2-line one.
In
const UINT D_N_ = 0xFFFFFF00;
const LPVOID DOUBLE_NULL = (LPVOID)&D_N_;
DOUBLE_NULL is an address that points to 0xFFFFFF00 , but in
const LPVOID DOUBLE_NULL = (LPVOID)0xFFFFFF00;
DOUBLE_NULL is an address while the address itself is 0xFFFFFF00 , and nobody knows what it is pointing to.
|
|
|
|
|
fefe.wyx wrote: The 1-line one do not have the same meaning as the 2-line one.
I realize that. I was under the impression that is what he was looking for (that is, a pointer to 0xFFFFFF00). If he really wanted some variable declared to with that value to point to, then the two line version is the only want to accomplish it.
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
|
|
|
|
|
Greetings:
I have a simple question: In a CListCtrl (configured in report mode), how do I simply select the item number that I want to appear at the top of the list. In other words, my list has, say, 1000 items and I would like to programatically scroll the list so that item number 500 is positioned at the top of the view. I do not necessarily need it to be selected or have the focus, I just want to position it.
Thanks in advance,
Mark
|
|
|
|
|
Note the difference between the item indices CListCtrl saved and logical indices you used in putting which item on the top. CListCtrl always sets the top item's index to 1, which you cannot change. If you moved item #500 to the top, then its index will be changed to 1. CListCtrl maintains this indexing for user selection purpose.
Thus, to programmatically move the items any way you want, you have to maintain your own logical indexing, as you do with sorting criteria.
Best,
Jun
|
|
|
|
|
Can you make use of CListCtrl::EnsureVisible() ?
"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
|
|
|
|
|
Hi:
I found that EnsureVisible will only make sure that you can SEE the item. It does not necessarily put it at the top of the view. If the box is currently showing item 0 at the top, and I ask to EnsureVisible for item 500, then it will only scroll enough to show item 500 at the BOTTOM of the view range.
Its all very surprising. It seems like a pretty common need - to want to scroll the view range so that item N appears at the top of the view range - yet it is not easy to do...
Cheers,
Mark
|
|
|
|
|
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?
|
|
|
|