Invert selection in List Control

Hi all,

I'm trying to invert selection (i.e. select unselected and unselect
selected items) in a multiple-selection List Control in report mode. I
tried the following 

void GetTLETab::OnBnClickedButton4()
{
   for( int i = 0; i < c_loadedList.GetItemCount(); i++)	
   {
       if( c_loadedList.GetItemState( i, LVIS_FOCUSED) == LVIS_FOCUSED)
 	  c_loadedList.SetItemState( i, 0, LVIS_FOCUSED);  // deselect
       else
   	c_loadedList.SetItemState( i, LVIS_FOCUSED, LVIS_FOCUSED); // select
   }
}

but it doesn't seem to work. When I select something and click the
"invert" button, the selected items deselect, but the unselected items
remain unselected. 

However, when I click some other unrelated button, the same thing
happens, so could it be that the List Control is losing focus? 

Thanks for any hints.


Best regards,

Vit Planocka
0
1/25/2004 11:52:25 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
574 Views

Similar Articles

[PageSpeed] 19

Hi!
"To invert selection" you must use LVIS_SELECTED style/mask, not a
LVIS_FOCUSED.
Victor

"Vit Planocka" <vitplanocka@mail.com> wrote in message
news:Xns947B82E1BE7CFvitplanockamailcom@62.24.64.13...
> Hi all,
>
> I'm trying to invert selection (i.e. select unselected and unselect
> selected items) in a multiple-selection List Control in report mode. I
> tried the following
>
> void GetTLETab::OnBnClickedButton4()
> {
>    for( int i = 0; i < c_loadedList.GetItemCount(); i++)
>    {
>        if( c_loadedList.GetItemState( i, LVIS_FOCUSED) == LVIS_FOCUSED)
>     c_loadedList.SetItemState( i, 0, LVIS_FOCUSED);  // deselect
>        else
>    c_loadedList.SetItemState( i, LVIS_FOCUSED, LVIS_FOCUSED); // select
>    }
> }
>
> but it doesn't seem to work. When I select something and click the
> "invert" button, the selected items deselect, but the unselected items
> remain unselected.
>
> However, when I click some other unrelated button, the same thing
> happens, so could it be that the List Control is losing focus?
>
> Thanks for any hints.
>
>
> Best regards,
>
> Vit Planocka


0
Victor
1/25/2004 5:41:41 PM
"Victor" <nothing> wrote in news:OFvDz224DHA.1632@TK2MSFTNGP12.phx.gbl:

> Hi!
> "To invert selection" you must use LVIS_SELECTED style/mask, not a
> LVIS_FOCUSED.
> Victor
> 

Thanks for that. I also found that I should set in the Properties "Always show selection" to True. The 
code now does what I wanted it to do.

One more question. Is there any way to make the List Control permanently focused, so that the 
selected items are marked by a blue highlighting instead of the grey one? It's mostly an esthetic issue, 
I guess.

Thanks and regards,

Vit Planocka



> "Vit Planocka" <vitplanocka@mail.com> wrote in message
> news:Xns947B82E1BE7CFvitplanockamailcom@62.24.64.13...
>> Hi all,
>>
>> I'm trying to invert selection (i.e. select unselected and unselect
>> selected items) in a multiple-selection List Control in report mode. I
>> tried the following
>>
>> void GetTLETab::OnBnClickedButton4()
>> {
>>    for( int i = 0; i < c_loadedList.GetItemCount(); i++)
>>    {
>>        if( c_loadedList.GetItemState( i, LVIS_FOCUSED) == LVIS_FOCUSED)
>>     c_loadedList.SetItemState( i, 0, LVIS_FOCUSED);  // deselect
>>        else
>>    c_loadedList.SetItemState( i, LVIS_FOCUSED, LVIS_FOCUSED); // select
>>    }
>> }
>>
>> but it doesn't seem to work. When I select something and click the
>> "invert" button, the selected items deselect, but the unselected items
>> remain unselected.
>>
>> However, when I click some other unrelated button, the same thing
>> happens, so could it be that the List Control is losing focus?
>>
>> Thanks for any hints.
>>
>>
>> Best regards,
>>
>> Vit Planocka
> 
> 
> 

0
1/25/2004 7:44:01 PM
Reply:

Similar Artilces:

distribution list error #2
Holly Did you ever get an answer to your "unexpected error" problem? Jim ...

How can I get the selected codec?
Hello, I use the cap... functions for video recording from my webcam. How can I get the selected codec which I have selected from the video compression dialog of the webcam driver and which is used from the cap... function while recording? The problem is, that after each restart of my program I have to select my preferred codec again! I want to preselect my wished codec by program. I would be very glad for any ideas. Regards Marc Hello, best way to do this is to use DirectShow interfaces. See AmCap sample from DirectX sdk. enze, www.mpegcode.com - the CaptureEngine >-----Original...

validation list became not working.
hi, i have an excel with lot of validation lists in severals sheets. while working with the excel i all the validation list in specific sheet became not working.the list are still defined in other sheet. but there is no option to select from the list... please help! thanks in advance.... -- Miri Tz. Do you mean that you have lost the drop-down arrow when you select the cell? If so, does typing an invalid value in still throw an error? -- --- HTH Bob (change the xxxx to gmail if mailing direct) "Miri" <miri.tzeelon@amdocs.com> wrote in message news:FABA720A-1F25-42...

range select question
My data colums are fixed, A-J However row changes on daily basis. Range("A1:J11").Select Selection.Copy How do I replace the J11 with J variable to represent the last row, effectively selecting the entire active range. Are you trying to select within a macro or manually? If manually, consider clicking in your cell block and pressing Ctrl+Shift+8 (or Ctrl+A in Excel 2003). If you are doing it in a macro, try activating a cell in your range that will always be in the range and selecting its CurrentRegion. Ex: range("A1").currentregion.copy Or, you could modif...

dynamic dependent list
I have used the method described on Debra Dalgleish's web site to create data validation in column B that is dependent on what is entered in column A. So, column A is validated by a list, the source of which is =list1 The name "list1" is defined by the equation =Sheet2!$A$2:$A$21 These cells contains "item1", "item2" and so on. Column B is validated by a list, the source of which is =INDIRECT(A1) The name "item1" is defined by the equation =Sheet2!$B$2:$B$21 and the name "item2" is defined by the equation =Sheet2!$C$2:$C$21 and so on. All o...

NewsGroup For Common Controls?
Is there a news group for common controls? A place that might have an answer for this: Re: Can't Adjust Size of Balloon-Style ToolTips?? I tried to set the rectangle size for a tooltip control in a handler for TTN_SHOW using the SetWindowPos function (and the TTM_ADJUSTRECT message), as outlined at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/tooltip/messages/ttm_adjustrect.asp This works fine for a normal-style tooltip. My call to SetWindowPos lets me set both the position and the size of the tooltip. But when I set TTS_BALLOON in order...

Select a Signature Icon
In Outlook 2003, I used to have an icon on a menu bar to select and insert one of the signatures that I had set up. I had to reinstall Outlook the other day and can no longer find any way to put the icon back on the menu. It was probably a tip I read somewhere but I have searched in vain for days. What I was able to do was have a combo box drop down on my email compose page that listed all signatures when clicked. If you double clicked on a signature, it inserted it. I know it was not an add-in and I did not write code to do it. Don Glenn I just use Insert, signature and choose from th...

Selecting rows after time intervals
Hello! I have some data which is collected at different times. I need to find the rows who are registered between 1:00:00 and 1:05:00 and copy them to a new worksheet. How do I do that???? Regards dSb ----- dSb wrote: ---- Hello I have some data which is collected at different times. I need to find the rows who are registered between 1:00:00 and 1:05:00 and copy them to a new worksheet. How do I do that??? ********** You could apply a filter (Data/filter/Autofilter) to the column the click on the drop down box and select custom. Here you make it equal to ...

List box, Combo box #2
Thanks for the info, I'll give it a tr -- P-C-Surgeo ----------------------------------------------------------------------- P-C-Surgeon's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1477 View this thread: http://www.excelforum.com/showthread.php?threadid=26396 ...

Advanced visibility control
I am seeking a possibility to switch different parts of a graphic picture visible depending on some "switch". Ideally I would like to have a few "checkboxes" in one of the corners of my slide and - depending on whether the user checks them on/off - certain elements of the drawing are visible or hidden. Is something like that doable with PPT (v2002/XP)? Note: the point is NOT to make things appear one after the other (that I know I could do using animations), the point is to allow the user to see different combinations of things being visible (or not). Lik...

IF for inverting true/false
hello all !! i have this.... =OR(AND(T65-U65>=Q55*N11;L10=TRUE);(U55*Q56<=T55)) but for some formal reason i need it to give false when it's true and vice versa.. with this... if i am not wrong... =IF(OR(AND(T65-U65>=Q55*N11;L10=TRUE);(U55*Q56<=T55));FALSE;TRUE) am i right ?? tx !! paolo Just use the NOT function on your original expression... =NOT(OR(AND(T65-U65>=Q55*N11;L10=TRUE);(U55*Q56<=T55))) -- Rick (MVP - Excel) "pls123" <pls123@discussions.microsoft.com> wrote in message news:0E13B7A5-A512-4A55-A3EA-AA25515A77C8@mi...

Forms Field List
I am using a form that someone else had created but I wanted to add a check box to it. I added a field in the souce table but when I go to the form in design view the new field is not listed. What am I doing wrong? Hendrix, I would imagine that you have a query as the Record Source for your for. So... that field has to be included in that query. In query design mode, just drag that field to the grid. It should then show up on the Field List in Form Design. -- hth Al Campagna Microsoft Access MVP 2007-2009 http://home.comcast.net/~cccsolutions/index.h...

Select the currebt region
Please remind me what is the short cut keys to select the current region. Thanks ------------------------------------------------ Message was posted via http://www.ExcelTip.com -- View and post usenet messages directly from http://www.ExcelTip.com -- Hundreds of free MS Excel tips, tricks and solutions ------------------------------------------------ Shift-Curl-Home and then Shift-Ctrl-End works. -- HTH Bob Phillips "yosi" <yosi.s58ya@timelimit.yourserver.com> wrote in message news:yosi.s58ya@timelimit.yourserver.com... > > Please remind me what is the short cut ...

How to Tell a tab control which tab to have open from the ON_Load
Hi, I have a form with a tab control with lots of tabs. In the on_load of the form, based on where the user came from, I want to be able to tell which tab is "open" when the form is drawn. Any idea? Thanks, Steve Examine the Value of the tab control. It is equal to the PageIndex of the chosen page. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "SteveInBeloit" <SteveInBeloit@discussions.microsoft.com> wrote in message news:DBF790EE-DE33-...

Random items from a list?
Sorry if this has been asked before...just a newbie here with a massive inventory crisis on my hands. I have a list of approx. 5000 different part numbers in my inventory. I need to be able to generate a RANDOM list of 10 to 20 items every week for cycle counts. I know there has to be a formula for this, please help? -- arcngel ------------------------------------------------------------------------ arcngel's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=27073 View this thread: http://www.excelforum.com/showthread.php?threadid=465917 yes: =randbetween() &q...

Multi-select parameter default?
Hi, How do I set the default of a multi-select parameter? In this case I want to default to All. Thanks in advance, Linn Linn There is checkbo multivalu if I remember well under Parameters menu "Linn Kubler" <lkubler@chartwellwisc2.com> wrote in message news:%23ISwBCj5KHA.6052@TK2MSFTNGP02.phx.gbl... > Hi, > > How do I set the default of a multi-select parameter? In this case I want > to default to All. > > Thanks in advance, > Linn > > ...

How not to have those slanted inverted comma when editing text in Word
Hi ! I'm using Word as a text editor. I notice that it uses those slanted " and ' instead of the vertical ones. This cause a problem when my othe program reads the file. Is there are way not to use those slanted " and ' ? Thanks very much in advanced. Word isn't a "text editor", it is a word processing application, if you need interoperability with other programs expecting "plain text" use a "plain text" editor like NotePad (which is on all Windows installations) dingdongdingding wrote: > Hi ! > > ...

Select range of monthly data
I am planning a database that tracks certain data that comes in as a monthly total. So I have a figure for Jan-07, Feb-07, etc. I plan a field for the total and a field for the month/year. In queries I will want to be able to select data that might include a range, such as "between Jan-07 and May-07". My question is, for the field which stores the month and year that the data covers, do I need to make it a date field and enter a complete date, i.e. Jan 30, 2007 in order to select such a range (e.g. select between 1/30/07 and 5/31/07) or does Access have some function that a...

INVERT
How can one invert data in an excel column - i.e. In a column of 20 entries, the 1st becomes last, second entry becomes second last etc - REGARDLESS of the numerical value. Use a help column with numbers from 1 - 20, select both columns and sort by the help column descending Regards, Peo Sjoblom "Austy" <Austy@discussions.microsoft.com> wrote in message news:E1A3FF7F-9B28-4B0D-9AC3-4B6A332EFFCA@microsoft.com... > How can one invert data in an excel column - i.e. In a column of 20 entries, > the 1st becomes last, second entry becomes second last etc - REGARDLESS of &...

I need to merge a list of names from Excel into one Publisher piec
I see how to do a regular mail merge, but I just want to import the Excel list into my front and back program peice I created in Publisher. Thanks Did you try a Copy/Paste? -- Don Vancouver USA "randi" <randi@discussions.microsoft.com> wrote in message news:37B95A63-B638-45E3-81D0-36C1F480E8F5@microsoft.com... >I see how to do a regular mail merge, but I just want to import the Excel > list into my front and back program peice I created in Publisher. > > Thanks Hi, Randi - I often merge into Word first (from Access and Excel) -- do my grammar and spel...

Not in the list event
Hi, I have combo box the takes data from Customerstbl. If a user type into the combo box i would like to propmt him with massage and give hm the option to add it to the table. What is the correct code in the Not in the list event? Thank you , Tom Tom Take a look at http://www.cardaconsultants.com/en/msaccess.php?lang=en&id=0000000011#notinlist for an example, this is something that you can costumize depending on the situation. If you search this forum, or google not in list even you'll get tons more examples. -- Hope this helps, Daniel P "Tom" <part...

excel VBA to select specific rows
I have created a userform in excel VBA use as a data entry form and I have created this VBA code: iRow = ws.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row ws.Cells(iRow, 3) = TextBox1.Value My problem is how to set this code to start the data from row 10 and column 3, because currently it start from raw 2 and column 3. Thanks very much for the help. ws.Cells(10, 3) = TextBox1.Value -- Regards Dave Hawley www.ozgrid.com "dodong" <dodonglopez@yahoo.com> wrote in message news:91c08d4a-5911-4569-95ca-bb9d537a2c27@u20g2000pru.googlegroups.com... &g...

Question about toggle selections?
First off hi... I was wondering if there is a way to have a toggle drop box to list th names of all sheets listed in my workbook. e.g i want all the sheet names listed in the box so that what ever wa entered in the next cell, to be able to research what was selected i the first cell. i want the user to select the option by a drop down button. TI -- Message posted from http://www.ExcelForum.com In the absence of other replies ... the context/meaning of your questio is not clear. Presumably you mean a Combobox/Dropdown but do not indicate whether i a worksheet or user form. Whatever ...

select the last cell in a long list
hello i'm stuck i need some help on selecting the last cell ( 1st blank one available ) in a large list, there will be no gaps in the list at all. so far using VBA i've been able to select and sort my list using CurrentRegion, would like the curser to return to the end of the list so i can enter more data as and when required. i know i will be kicking my self as its bound to be something i'm overlooking. any help would be appreciated Regards DarkNight To select the first empty cell use Range("A1").End(xlDown).Offset(1, 0).Select More reliably if there could be b...

Chart select!
Could anyone tell me how to write a macro that would simply select every chart on the page, and NOT pictures. Thanks! --- Message posted from http://www.ExcelForum.com/ Hi cdegar01, Does this line do what you want? Activesheet.chartobjects.select cdegar01 < wrote: > Could anyone tell me how to write a macro that would simply select every > chart on the page, and NOT pictures. Thanks! > > > --- > Message posted from http://www.ExcelForum.com/ > -- Cheers Andy ------ Andy Pope, Microsoft MVP - Excel http://www.andypope.info ...