May 06, 2024, 05:41:23 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Checkboxes with Addstring

Started by Andy, July 26, 2012, 12:42:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

I'm using the recurse_dir example to list .exe files contained in the "Program Files" directory.

That easy enough for me, I can then use the Addstring command to add them to a "Listbox".

But is there a way to add a checkbox next to each string entry and if so how do I detect multiple selections?

Thanks,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

I've got some code somewhere that will do what you want.
I'll see if I can find it later today.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Thanks Larry,

I have 'thrown' together something close, it's based on CrYpT's uTorrent cleaner example - Thanks CrYpT.
It produces a list of .exe files contained in the Program Files directory.

Run it and make some selections of exe files then click 'DoSomething'.
It will then create a text file (in the same path) of your selection.

To exit just clck 'OK'.

But I have some issues with it:

1. It uses @listview which seems to suggest I have to use a Dialog instead of a window?
2. I don't usually use dialogs only windows.
3. The list is the reverse order to which I would like it (want a - z not z -a).
4. If I have to use a dialog, how do I floodfill the screen with a color, it seems there are different commands to which I am used to.

Attached is the program.

Can anyone help please,
Andy.




Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Sorry I took so long to respond.
I got engrossed working on another problem today.

It was faster for me to modify what you posted (to make it window based as opposed to dialog based) then it was to start searching through all my stuff.
The attached is windows based.
It sorts A_Z (controlled by a flag described in the help)

BTW, I know of no control that can be used only in a dialog.

I applied the same dialog to window conversion steps that I described in one of my earlier post to you.

Good Luck
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Thanks Larry,

Any change you can attach your conversion so I can have a look at it.

Thanks,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Quote from: andy1966 on July 26, 2012, 11:40:02 PM
Thanks Larry,

Any change you can attach your conversion so I can have a look at it.

Thanks,
Andy.
DUH ::) ::) ::) ::)
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Thanks Larry,

I do that all the time!

:)

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

That's great, but how do I set an item as selected and highlight it?

This builds up the list:

   'Build up list
   FOR xpr = 1 TO countprogs   
      CONTROLCMD main, ListView, @LVINSERTITEM, 0, progslist[xpr]
   NEXT xpr

If you have used my version previously, any item that was selected will be stored in the registry, I can then find a match using:

   FOR xpr = 1 TO countprogs   
      resultin = ""
      resultin = RegGetValue("HKEY_CURRENT_USER\Software\KMSbrowser\Programs", progslist[xpr])
      resultin = LTRIM$(resultin)

      IF resultin <> ""
         'Match - here I want to highlight the item progslist[xpr]
      ENDIF
   NEXT xpr

When I get a match I want to highlight it, have it ticked and selected so that when the user presses the button 'Apply' the routine that checks what is selected will recognize it as selected and act accordingly.

I'm trying to use the @LVSETSELECTED when I get a match but I can't get it to work.

Thanks,
Andy.



Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

QuoteWhen I get a match I want to highlight it, have it ticked and selected so that when the user presses the button 'Apply' the routine that checks what is selected will recognize it as selected and act accordingly.
I don't know exactly what you are going for but the above seems like a little redundant overkill.

I added a SetCheckMark subroutine that can be used to check and uncheck a line.

For demo purposes I have a save button and a read button.
Run the program.
click some boxes.
click save
uncheck what you just checked
click read
All the previously checked boxes are again checked , selected, and highlighted.

The reason I say it is that if you click and make any selection it clears all other selections unless the control key is depressed
making a selection has no impact of ckbox state unless you write code to make it do it.  That would be triggered off the listview's selectchange notification.

If it was me I would just stick strictly with the check boxes alone.
If you are wanting to use the process of selecting blocks of lines then it would seem you don't really need the ckboxes.

But like I said, I don't know what you are ultimately trying to provide the user.

Hope this helps.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Larry,

That's exactly what I was trying to do, thank you!

The bottom line for asking this was:

The user can scroll through the program files, select the programs they want to disable.

At a later date, they can run the program again, see what they have disabled in the past and then have the ability to either / or disable more programs or "untick" a disabled program which will re-enable it.

With your help I've managed to do this now.

Just when I think I know enough commands to do what I need in IWB I find I have to ask for help with a new command.

Thanks again,
as always sorry for being a pain!

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

Not a pain.  We're here to help.

My response on this question was based, in part, on the response I got when I asked the same basic question 7+ years ago.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library