 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Tue Oct 20, 2009 7:14 pm Post subject: [SOLVED] Deselect ListBox that is not multi-select |
|
|
The following from GuiControl does not work:
| Code: | | PostMessage, 0x185, 0, -1, ListBox1 ; Deselect all items. |
The ListBox is not multi-select.
Solution:
Thanks to all involved.
| jaco0646 wrote: | You may use the window handle (HWND) of each listbox. | Code: | Gui, Add, ListBox, AltSubmit HWNDbox_1 , No|Yes
Gui, Add, ListBox, r4 AltSubmit HWNDcrq_impact , 1-Major|2-Significant|3-Minor|4-Standard
Gui, Add, Button, , Test
Gui, Show, , Test listbox unselect
return
GuiClose:
ExitApp
ButtonTest:
PostMessage, 0x186, -1, 0,,ahk_id %box_1%
PostMessage, 0x186, -1, 0,,ahk_id %crq_impact%
Gui,Submit,NoHide
Return |
|
Last edited by ghee22 on Sat Nov 07, 2009 2:10 pm; edited 3 times in total |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Tue Oct 20, 2009 7:29 pm Post subject: |
|
|
Here is a simpler method.
| Code: |
Gui, Show
SendInput {PgUp} ; deselects a control when the text is highlighted after creating and showing it |
_________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Tue Oct 20, 2009 7:39 pm Post subject: |
|
|
| txquestor wrote: | Here is a simpler method.
| Code: |
Gui, Show
SendInput {PgUp} ; deselects a control when the text is highlighted after creating and showing it |
|
This does not deselect all items. This selects the first item. How can I select no items? |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Tue Oct 20, 2009 7:52 pm Post subject: Re: Deselect ListBox that is not multi-select |
|
|
The message for single-selection list boxes is different. | Code: | | PostMessage, 0x186, -1, 0, ListBox1 ; Deselect item. |
|
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Fri Oct 30, 2009 9:40 pm Post subject: Re: Deselect ListBox that is not multi-select |
|
|
| jaco0646 wrote: | The message for single-selection list boxes is different. | Code: | | PostMessage, 0x186, -1, 0, ListBox1 ; Deselect item. |
|
This did not work for me. Here's my example code:
| Code: | Gui, Add, ListBox, vlistbox1 , No|Yes
Gui, Add, Button, , Test
Gui, Show, , Test listbox unselect
ButtonTest:
PostMessage, 0x186, -1, 0,,listbox1
Gui,Submit,NoHide
Return |
|
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Fri Oct 30, 2009 10:51 pm Post subject: |
|
|
| You added a comma. |
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Sat Oct 31, 2009 5:37 pm Post subject: |
|
|
| jaco0646 wrote: | | You added a comma. |
You are correct! Without the repeat comma at the end, the code works:
| Code: | Gui, Add, ListBox, AltSubmit vlistbox1 , No|Yes
Gui, Add, Button, , Test
Gui, Show, , Test listbox unselect
ButtonTest:
PostMessage, 0x186, -1, 0,listbox1
Gui,Submit,NoHide
Return
|
|
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Tue Nov 03, 2009 3:10 pm Post subject: |
|
|
How can one use the PostMessage command to work with the listbox's associated variable name?
I could only get the PostMessage command to work with listbox# where '#' is the number of which the listbox was added (listbox1 for the first listbox added, listbox2 for the second, and so on).
To exemplify, here are three different scenarios:
Scenario 1:
Both listboxes will clear.
| Code: | Gui, Add, ListBox, AltSubmit vbox_1 , No|Yes
Gui, Add, ListBox, r4 AltSubmit vcrq_impact , 1-Major|2-Significant|3-Minor|4-Standard
Gui, Add, Button, , Test
Gui, Show, , Test listbox unselect
ButtonTest:
PostMessage, 0x186, -1, 0, listbox1
PostMessage, 0x186, -1, 0, listbox2
Gui,Submit,NoHide
Return |
Scenario 2:
Only the second listbox will clear.
| Code: | Gui, Add, ListBox, AltSubmit vbox_1 , No|Yes
Gui, Add, ListBox, r4 AltSubmit vcrq_impact , 1-Major|2-Significant|3-Minor|4-Standard
Gui, Add, Button, , Test
Gui, Show, , Test listbox unselect
ButtonTest:
PostMessage, 0x186, -1, 0, box_1
PostMessage, 0x186, -1, 0, listbox2
Gui,Submit,NoHide
Return |
Scenario 3:
No listboxes will clear
| Code: | Gui, Add, ListBox, AltSubmit vbox_1 , No|Yes
Gui, Add, ListBox, r4 AltSubmit vcrq_impact , 1-Major|2-Significant|3-Minor|4-Standard
Gui, Add, Button, , Test
Gui, Show, , Test listbox unselect
ButtonTest:
PostMessage, 0x186, -1, 0, box_1
PostMessage, 0x186, -1, 0, crq_impact
Gui,Submit,NoHide
Return |
|
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Tue Nov 03, 2009 3:21 pm Post subject: |
|
|
You may use the window handle (HWND) of each listbox. | Code: | Gui, Add, ListBox, AltSubmit HWNDbox_1 , No|Yes
Gui, Add, ListBox, r4 AltSubmit HWNDcrq_impact , 1-Major|2-Significant|3-Minor|4-Standard
Gui, Add, Button, , Test
Gui, Show, , Test listbox unselect
return
GuiClose:
ExitApp
ButtonTest:
PostMessage, 0x186, -1, 0,,ahk_id %box_1%
PostMessage, 0x186, -1, 0,,ahk_id %crq_impact%
Gui,Submit,NoHide
Return |
|
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Tue Nov 03, 2009 10:45 pm Post subject: |
|
|
| jaco0646 wrote: | You may use the window handle (HWND) of each listbox. | Code: | Gui, Add, ListBox, AltSubmit HWNDbox_1 , No|Yes
Gui, Add, ListBox, r4 AltSubmit HWNDcrq_impact , 1-Major|2-Significant|3-Minor|4-Standard
Gui, Add, Button, , Test
Gui, Show, , Test listbox unselect
return
GuiClose:
ExitApp
ButtonTest:
PostMessage, 0x186, -1, 0,,ahk_id %box_1%
PostMessage, 0x186, -1, 0,,ahk_id %crq_impact%
Gui,Submit,NoHide
Return |
|
Thank you. This works and is the best solution. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|