By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,900 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,900 IT Pros & Developers. It's quick & easy.

set coordinates to a ListViewItem

P: n/a
Hi everyone !

I would like to set an ListViewItem at a special position, into a ListView.
There is Bounds, but it's a propertie, that can be only get !
I would like to place the item at a special coordinates, not at a
special index.

like:

MFC: BOOL CListCtrl::SetItemPosition(int nItem, POINT pt);

thanks
Nov 16 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi!
Try to use LVM_SETITEMPOSITION.
Hope that helps.
Best regards.
Nov 16 '05 #2

P: n/a
Adrian wrote:
Hi!
Try to use LVM_SETITEMPOSITION.
Hope that helps.
Best regards.


ok , but how to send a message to a ListView ?
Nov 16 '05 #3

P: n/a
You use the SendMessage API call:
http://www.pinvoke.net/default.aspx/user32.SendMessage

"Herbert VON GRÜNENWALD" <he*******************@microsoft.com> wrote in
message news:42**************@microsoft.com...
Adrian wrote:
Hi!
Try to use LVM_SETITEMPOSITION.
Hope that helps.
Best regards.


ok , but how to send a message to a ListView ?

Nov 16 '05 #4

P: n/a
Declare as below the structure

[System.Runtime.InteropServices.StructLayout(System .Runtime.InteropServices.
LayoutKind.Sequential, Pack=2)]
public struct MAKELPARAM
{
public uint wLow;
public uint wHigh;
}

Import the method:

[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static int SendMessage(IntPtr hwnd, uint message, int wparam,
MAKELPARAM lparam);

And finally, in a method, put the code:

MAKELPARAM M = new MAKELPARAM();
M.wHigh = x //New x-position of the item's upper-left corner, in view
coordinates.

M.wLow = y //New y-position of the item's upper-left corner, in view
coordinates. ;

int i = myitem;
SendMessage(listView1.Handle, 0x1000 + 15, i, M);

Hope that helps.
Best regards.
Nov 16 '05 #5

P: n/a
Adrian wrote:
Declare as below the structure

[System.Runtime.InteropServices.StructLayout(System .Runtime.InteropServices.
LayoutKind.Sequential, Pack=2)]
public struct MAKELPARAM
{
public uint wLow;
public uint wHigh;
}

Import the method:

[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static int SendMessage(IntPtr hwnd, uint message, int wparam,
MAKELPARAM lparam);

And finally, in a method, put the code:

MAKELPARAM M = new MAKELPARAM();
M.wHigh = x //New x-position of the item's upper-left corner, in view
coordinates.

M.wLow = y //New y-position of the item's upper-left corner, in view
coordinates. ;

int i = myitem;
SendMessage(listView1.Handle, 0x1000 + 15, i, M);

Hope that helps.
Best regards.


[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static <<int>> SendMessage(IntPtr hwnd, uint message, int
wparam,
MAKELPARAM lparam);
the compiler says that the <<int>> must be 'Class, delegate, enum,
interface or struct'

even with Int32

Nov 16 '05 #6

P: n/a
Declare inside the class, like below:

class Test
{
[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static <<int>> SendMessage(IntPtr hwnd, uint message, int
wparam, MAKELPARAM lparam);
}

Hope that helps.
Best regards.
Nov 16 '05 #7

P: n/a
Adrian wrote:
Declare inside the class, like below:

class Test
{
[System.Runtime.InteropServices.DllImport("User32.d ll")]
public extern static <<int>> SendMessage(IntPtr hwnd, uint message, int
wparam, MAKELPARAM lparam);
}

Hope that helps.
Best regards.


thanks, i've declared the function inside a namespace...
Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.