AutoHotkey Community

It is currently May 26th, 2012, 10:55 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: October 20th, 2009, 8:14 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
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 November 7th, 2009, 3:10 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2009, 8:29 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Here is a simpler method.
Code:
Gui, Show
SendInput {PgUp}   ; deselects a control when the text is highlighted after creating and showing it

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2009, 8:39 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
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?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 20th, 2009, 8:52 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
The message for single-selection list boxes is different.
Code:
PostMessage, 0x186, -1, 0, ListBox1  ; Deselect item.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 30th, 2009, 10:40 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 30th, 2009, 11:51 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
You added a comma.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 31st, 2009, 6:37 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2009, 4:10 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2009, 4:21 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2009, 11:45 pm 
Offline

Joined: July 4th, 2009, 6:53 pm
Posts: 36
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, JSLover, Kirtman, Leef_me, Maestr0, Miguel, XstatyK and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group