Listview checkboxes

Started by paulDiagnos, May 18, 2009, 05:57:23 AM

Previous topic - Next topic

paulDiagnos

Very frustrating...

I use the following code to set the check boxes in a listview when i need them:
ListView_GetItem (hwnd_scrncapt_CaptureListview,lvi)  
  ListView_GetItem (hwnd_scrncapt_CaptureListview,lvi)  
  EXstyle  =  ListView_GetExtendedListViewStyle (hwnd_scrncapt_CaptureListview)  
EXstyle  = EXstyle Or  %LVS_EX_CHECKBOXES
ListView_SetExtendedListViewStyle (hwnd_scrncapt_CaptureListview,EXstyle)
ListView_SetItem (hwnd_scrncapt_CaptureListview,lvi)


when i dont need them i use this code...

    EXstyle  =  ListView_GetExtendedListViewStyle (hwnd_scrncapt_CaptureListview)    
  EXstyle=  (%LVS_EX_CHECKBOXES Xor -1) And EXstyle    
ListView_SetExtendedListViewStyle (hwnd_scrncapt_CaptureListview,EXstyle )   
     ListView_SetItem (hwnd_scrncapt_CaptureListview,lvi)


works when i first load up, and the check boxes are enabled.
I then disable then, all works fine checks have gone, and images are displayed perfect.

its only when i try and go back to having check boxes where the problem lies. the check boxes appear right in the middle of where my image should be (usually check boxes are top right)

this is driving me nuts. 

I have included a screen shot.

please help

Paul.

paulDiagnos

hmmmm this is not a solution..

but If i resize the images i display, the check box also resizes.
i tried cheating by resizing the image to be 20 by 20 , then setting check boxes. then changing the imagelist to be the normal size again.

kinda works but after 3 seconds the program crashes.

Il keep working , unless one of you guys can use your brains to help me.


paulDiagnos

erm ok Im in the habit now of answering my own questions...


Same solution i used before. where you add an image to the list view with the correct check box size, befroe then going onto add the images you want to display.

ListView_DeleteAllItems   hwnd_form1_Listview   
hImageList = ImageList_Create(18,18, %ILC_COLOR4, 2, 1)     ' use 32, 32 for Large Icons   
ImageList_SetBkColor hImageList, GetSysColor(%COLOR_WINDOW)   
hTemp   = LoadImage(ByVal %Null, "", %IMAGE_BITMAP,160,120, %LR_LOADFROMFILE)     
iImage1 =  ImageList_Add( hImageList, hTemp,0)   
DestroyIcon hTemp     
FF_ListView_SetImageList  hwnd_form1_Listview, hImageList, %LVSIL_NORMAL     
FF_ListView_DeleteAllItems  hwnd_form1_Listview
FF_ListView_InsertColumn  hwnd_form1_Listview, 0, "Column1", 0, 100     
FF_ListView_InsertItem hwnd_form1_Listview, 0, 0, "0 0", 0, 0
FF_ListView_InsertItem hwnd_form1_Listview, 1, 0, "1 0", 0, 0


The secret (to stop it crashing) was to actually insert a few items.

TechSupport

I've been away from home for a few days.... didn't even have an internet connection!!! Wow! I thought that I'd go mad without being connected.  :)

paulDiagnos

#4
hehe, I know what you mean!!

its ok most of the time Its just a matter of being pushed in the right direction. glad I managed to figure a way around it!!!

any idea why the check box likes to take up the same space as an image?