IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: Haim on July 28, 2007, 01:51:50 AM

Title: Checkboxes in listview - help needed
Post by: Haim on July 28, 2007, 01:51:50 AM
I saw in the Microsoft documentation for the listview control, that it supports an extended style LVS_EX_CHECKBOXES
As much as I tried to make my listview display checkboxes I failed.
(I tried to do it by using the SetExtendedStyle method of the listview)
I also noted that Aurora user guide does not specify ALVS_EX_CHECKBOXES, but it does specify other extended style constants.

What am i missiing here?

probably brains...

Haim
Title: Re: Checkboxes in listview - help needed
Post by: srod on July 28, 2007, 03:43:31 AM
Hi,

I don't know Aurora as yet, but the following EMBasic example might help.

'Compile as a WINDOWS target
/* Required for setting listview checkboxes. */
Const LVM_SETEXTENDEDLISTVIEWSTYLE = 4150
Const LVS_EX_CHECKBOXES = 4

def d1:Dialog
def str:STRING
def p as pointer
'standard NMLISTVIEW
'when a column ic clicked on Windows sends a variable
'of this type in @LPARAM.
TYPE NMLISTVIEW
def hwndFrom:UINT
def idFrom:INT
def code:INT
    def iItem:INT
    def iSubItem:INT
    def uNewState:UINT
    def uOldState:UINT
    def uChanged:UINT
    def ptActionx:INT
def ptActiony:INT
    def lParam:INT
ENDTYPE

CREATEDIALOG d1,0,0,295,168,0x80C80080,0,"List view test",&handler
CONTROL d1,@LISTVIEW,"",27,24,240,110,0x50000001,1
CONTROL d1,@STATIC,"TEST",27,140,240,20,0x50000000,2



domodal d1
end

SUB handler
select @MESSAGE
case @IDINITDIALOG
centerwindow d1
'insert columns and some items
'after an item is inserted we use @LVSETTEXT to
'change the subitems text
CONTROLCMD d1,1,@LVINSERTCOLUMN,0,"Column1"
CONTROLCMD d1,1,@LVINSERTCOLUMN,1,"Column2"
CONTROLCMD d1,1,@LVINSERTITEM,0,"Item 1"
CONTROLCMD d1,1,@LVSETTEXT,0,1,"Subitem 1"
CONTROLCMD d1,1,@LVINSERTITEM,1,"Item 2"
CONTROLCMD d1,1,@LVSETTEXT,1,1,"Subitem 2"
/* Set checkboxes/ */
SendMessage(GETCONTROLHANDLE(d1,1), LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES)
case @IDCONTROL
if(@CONTROLID = 1)
'someone clicked on a column header. Read the data from @LPARAM which is
' a pointer to a NMLISTVIEW UDT. Using the C dereferencing style makes
' it much easier
if(@NOTIFYCODE = @LVNCOLUMNCLICK)
CONTROLCMD d1,1,@LVSETCOLUMNTEXT,*<NMLISTVIEW>@LPARAM.iSubItem,"Clicked!"
endif
ENDIF
endselect
return
ENDSUB



The important line in this case is

SendMessage(GETCONTROLHANDLE(d1,1), LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES)

and which should be easy enough to convert to Aurora.
Title: Re: Checkboxes in listview - help needed
Post by: sapero on July 28, 2007, 04:24:28 AM
In Aurora, just include the windows defines:#include "windows.inc"
#include "commctrl.inc"


Apply the styles to list view:CListView *list = GetControl(IDC_LIST);
list->SetExtendedStyle(LVS_EX_CHECKBOXES);


Check an item:LVITEM lvi;
lvi.stateMask = LVIS_STATEIMAGEMASK;
lvi.state     = 0x2000; // pass 0 to uncheck
SendMessage(list->m_hwnd, LVM_SETITEMSTATE, item_index, &lvi);


get the check state:BOOL checked = (0x2000 & SendMessage(list->m_hwnd, LVM_GETITEMSTATE, item_index, LVIS_STATEIMAGEMASK));
Title: Re: Checkboxes in listview - help needed
Post by: Haim on July 28, 2007, 04:47:01 AM
Thank you both for your replies.
I have seen the Ebasic sample but could not make it work in Aurora....
With Sapero's reply my problems are over.


with much appreciation,

Haim
Title: Re: Checkboxes in listview - help needed
Post by: sapero on July 28, 2007, 05:06:12 AM
I'm very sorry, the latest SendMessage should be AND'ed with 0x2000.