LB Booster
« List view check box selection »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:07am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: List view check box selection  (Read 456 times)
Phineas Freak
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
xx List view check box selection
« Thread started on: Feb 15th, 2015, 3:17pm »

As i read from MSDN, the status (set or unset) of a list view check box can be changed by sending the LVM_SETITEMSTATE message:

Code:
struct LVITEM,               _
    	mask       as ulong, _
    	iItem      as long,  _
    	iSubItem   as long,  _
    	state      as ulong, _
    	stateMask  as ulong, _
    	pszText$   as ptr,   _
    	cchTextMax as long,  _
    	iImage     as long,  _
    	lParam     as long,  _
    	iIndent    as long

function LVM.SETITEMSTATE(hWnd, nRow, nState)

	LVITEM.mask.struct	= _LVIF_STATE
	LVITEM.state.struct     = nState
	LVITEM.stateMask.struct = _LVIS_STATEIMAGEMASK or _LVIS_SELECTED

     	calldll #user32, "SendMessageA",     _
		hWnd              as ulong,  _
        	_LVM_SETITEMSTATE as long,   _
        	nRow              as long,   _
        	LVITEM  	  as struct, _
        	LVM.SETITEMSTATE  as long

end function
 


Where nRow is the selected row index value and nState the state of the check box.

The problem with the above code is that it highlights the selected index but it doesn't change it's check box status. I have been looking everywhere for a solution but without much success.

I also tried different things like:

* Setting '4096' for the unset state and '8192' for the set (as reported by the LVM_GETITEMSTATE message) instead of '1' and '2' reported by the LVS_EX_CHECKBOXES style.
* Replacing the "mask" and "stateMask" values.
« Last Edit: Feb 15th, 2015, 5:58pm by Phineas Freak » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: List view check box selection
« Reply #1 on: Feb 15th, 2015, 3:41pm »

on Feb 15th, 2015, 3:17pm, PreciseTiming wrote:
I also tried different things like: Setting '4096' for the unset state and '8192' for the set (as reported by the LVM_GETITEMSTATE message) instead of '1' and '2' reported by the LVS_EX_CHECKBOXES style.

4096 and 8192 should be correct (the '1' and '2' referred to are values of the State Image Index, which is held in bits 12-15 of the state). If that isn't working try omitting LVIS_SELECTED from the state mask: perhaps it doesn't like changing both the image index (checkbox state) and the selected state at the same time.

If that still doesn't work you could try the other possible values of the image index (there are 16 in all) but my understanding is that 4096 and 8192 are the right values to use.

If Comctrl version 6.0 is required for this functionality (that isn't clear to me from MSDN) you will need to change the manifest because LBB only calls for Comctrl 4.7.

Richard.
User IP Logged

Phineas Freak
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
xx Re: List view check box selection
« Reply #2 on: Feb 15th, 2015, 5:57pm »

Finally, i made it to work. This is good and bad at the same time (and makes me look stupid)...

The good news are that the '4096' and '8192' values work. Also, the LVIS_SELECTED mask doesn't seem to matter.

The bad news are that it doesn't work with my original code. I wrote a quick and dirty program just to test the check box selection and it works perfectly. So, back to the drawing board... :P

Sorry for wasting your time Richard...i should triple check my code next time.

EDIT: Yep, i had a BIG mistake. For some reason i moved this line:

Code:
null = SendMessageLong(hWndListView, _LVM_SETEXTENDEDLISTVIEWSTYLE, _LVS_EX_CHECKBOXES or _LVS_EX_FULLROWSELECT, _LVS_EX_CHECKBOXES or _LVS_EX_FULLROWSELECT) 


that creates the ability to manipulate the check boxes after the code to insert the columns and rows of the list box...doh! ::)
« Last Edit: Feb 15th, 2015, 7:30pm by Phineas Freak » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls