What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Help]Listview insert column

[Help]Listview insert column
Author: Message:
DaAniv
Junior Member
**


Posts: 19
30 / Male / Flag
Joined: Jan 2009
O.P. [Help]Listview insert column
can you Insert a new column using http://msdn.microsoft.com/en-us/library/bb761101(VS.85).aspx and if yes how?
and remove using http://msdn.microsoft.com/en-us/library/bb774894(VS.85).aspx?

This post was edited on 02-08-2009 at 02:17 PM by DaAniv.
02-08-2009 02:11 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Help]Listview insert column
You need to use the SendMessage API as stated on MSDN.

SendMessage has 4 parameters.
  • The handle to the item
  • The Message (LVM_INSERTCOLUMN)
  • The wParam (in this case column number)
  • The lParam (in this case LPLVCOLUMN)

This post was edited on 02-08-2009 at 02:27 PM by matty.
02-08-2009 02:26 PM
Profile E-Mail PM Find Quote Report
DaAniv
Junior Member
**


Posts: 19
30 / Male / Flag
Joined: Jan 2009
O.P. RE: [Help]Listview insert column
how do you write it?
02-08-2009 02:44 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Help]Listview insert column
Try it and post what you come up with and we will go from there. I wont just give you the code you wont learn that way.
02-08-2009 02:46 PM
Profile E-Mail PM Find Quote Report
DaAniv
Junior Member
**


Posts: 19
30 / Male / Flag
Joined: Jan 2009
O.P. RE: [Help]Listview insert column
I don't really get how to set the LPLVCOLUMN structure

code:
Interop.Call("user32", "SendMessageW",GetControlHandle("LsvSentences"),"LVM_INSERTCOLUMN",2,LPLVCOLUMN);
and this is fine for the sendmessage?

This post was edited on 02-08-2009 at 02:57 PM by DaAniv.
02-08-2009 02:52 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Help]Listview insert column
quote:
Originally posted by DaAniv
code:
Interop.Call("user32", "SendMessageW",GetControlHandle("LsvSentences"),"LVM_INSERTCOLUMN",2,LPLVCOLUMN);
and this is fine for the sendmessage?
No this will not work at all.

The message you are sending through SendMessage is not a string it is an integer. LVM_INSERTCOLUMN is 0x101B. Column index I also believe is zero-based meaning the first column is 0 the second is 1 etc.

LPLVCOLUMN you need to allocate memory for and fill the structure yourself.

Javascript code:
var LPLVCOLUMN = Interop.Allocate(32);

If you have no idea about what I just wrote then read the documentation and study a bit more :)
02-08-2009 03:04 PM
Profile E-Mail PM Find Quote Report
DaAniv
Junior Member
**


Posts: 19
30 / Male / Flag
Joined: Jan 2009
O.P. RE: [Help]Listview insert column
Javascript code:
function InserColumn(hWnd,iCol,Header)
{
    //Message constants
    var LVM_INSERTCOLUMN = 0x101B;
    var LVCF_TEXT = 0x4;
    var LVCF_WIDTH = 0x2;
       
    var cx= Interop.Allocate(4)//How do I know how much bytes I need?
    cx.WriteWord(0, 50)
 
    var  pszText=Interop.Allocate((Header.length+2)*2)
    pszText.WriteString(0, Header,true)
    //Create an LVCOLUMN structure
    var LVCOLUMN = Interop.Allocate(32);
    LVCOLUMN.WriteDWord(0,  LVCF_WIDTH); //How do I know the offset?
    LVCOLUMN.WriteDWord(6, cx.DataPtr);  //How do I know the offset?
    LVCOLUMN.WriteDWord(16, LVCF_TEXT); //How do I know the offset?
    LVCOLUMN.WriteDWord(22, pszText.DataPtr); //How do I know the offset?
   
 
    var Result = Interop.Call("user32", "SendMessageW", hWnd, LVM_INSERTCOLUMN, iCol, LVCOLUMN);
   
    //Clear the DataBlocs
    cx.Size = 0;
    pszText.size=0;
    LVCOLUMN.Size = 0
   
    //Return the result
    return Result;
}

as said in the comments how do I know the cx bytes and offset when I create the structure?
02-08-2009 06:11 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [Help]Listview insert column
It is found on this page which I already linked to.

quote:
Originally posted by http://msdn.microsoft.com/en-us/library/bb774743(VS.85).aspx
typedef struct _LVCOLUMN {
    UINT mask;
    int fmt;
    int cx;
    LPTSTR pszText;
    int cchTextMax;
    int iSubItem;
#if (_WIN32_IE >= 0x0300)
    int iImage;
    int iOrder;
#endif
#if (_WIN32_WINNT >= 0x0600)
    int cxMin;
    int cxDefault;
    int cxIdeal;
#endif
} LVCOLUMN, *LPLVCOLUMN;

You need to match up the offset with the specific field you are filling.

This post was edited on 02-08-2009 at 09:10 PM by matty.
02-08-2009 09:09 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On