Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my requirement i have to get the current insert position using below method
C++
GetInsertMark(LPLVINSERTMARK lvim) const


could you please tell me how to use this method

What I have tried:

 LPLVINSERTMARK* lvim =NULL;
    if (m_probelist_ctl.GetInsertMark(lvim)
{

int nitem = = lvim->iItem
}
but i am gettimg compile error here ,
could you pleae tell me how to use GetInsertMark
Posted
Updated 18-Jul-17 4:10am
v2

The compiler messages should be enough to help you.
C++
LPLVINSERTMARK* lvim =NULL; //<-- LPLVINSERTMARK is already a pointer, you do not need more indirection
    if (m_probelist_ctl.GetInsertMark(lvim) //<-- close parenthesis missing here
{
 
int nitem = = lvim->iItem //<-- what is this statement supposed to be?
}
 
Share this answer
 
You have to pass a pointer to an LVINSERTMARK structure (which is an LPLVINSERTMARK; the LP indicates that it is a pointer):
// Structure as local variable
LVINSERTMARK lvim;
// [EDIT]
// Must set the cbSize member
lvim.cbSize = sizeof(LVINSERTMARK);
// [/EDIT]
// Pass the address of the structure
if (m_probelist_ctl.GetInsertMark(&lvim))
{
    // Access structure element
    int nitem = lvim.iItem
}
 
Share this answer
 
v3
Comments
Member 13089825 18-Jul-17 9:16am    
hi thank you its compiling successfully now but GetInsertMark(&lvim)is returning false alwyas.
im doing is im deleting an item in list and after that im calling the GetInsertMark(&lvim) but its returning false alwyas
Jochen Arndt 18-Jul-17 9:24am    
See my updated answer.
The structure must be initialised.
I thought that this is done by the GetInsertMark() but it has to be done.
Member 13089825 18-Jul-17 9:30am    
now also returning false and lvim have the below valuse
cbSize = 16
dwFlags = 2147483648
iItem = -1
dwReserved = 3435973836
do i need to call the setinsertmark before call the getinsertmark?
Jochen Arndt 18-Jul-17 10:10am    
The structure member values are undefined (random) when the call is not successful.

A possible reasons for failures are described at https://msdn.microsoft.com/en-us/library/windows/desktop/bb774945(v=vs.85).aspx (the function is just sending that message to the list control)

"An insertion point can appear only if the list-view control is in icon view, small icon view, or tile view, and is not in group-view mode."

and

"Note To use this message, you must provide a manifest specifying Comclt32.dll version 6.0. For more information on manifests, see Enabling Visual Styles."
Member 13089825 19-Jul-17 3:26am    
"An insertion point can appear only if the list-view control is in icon view, small icon view, or tile view, and is not in group-view mode"
HI even when i use iconview also getinsertmark is returning false.
hi thank you for reply,
when i give below one its trowing error like argument type of LPLVINSERTMARK ** is incompatiable with paramater type of LPLVINSERTMARK
if (m_probelist_ctl.GetInsertMark(lvim)

int nitem = = lvim->iItem //<-- what is this statement supposed to be?

storing the current position of insert marker
 
Share this answer
 
Comments
Richard MacCutchan 18-Jul-17 9:44am    
No it is not, you have two = signs which is a test for equality. You really need to desk check your code more carefully.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900