-
Array of showing / hidden windows..
With a little help, I came up with this idea to keep a list of "Once
visible to user then programatically hidden" windows and "currently
visible to user" windows.. each set will be in a listbox and double
clicking one or the other swaps it along with it's visibility. The way
I'm attempting to implement this is to use EnumWindows to get all of the
windows and then in the use the EnumWindowsProc to distinguish between
them. I'm having trouble figuring out the best way to get only the
visible windows. If I use:
If IsVisibleWindow then.. I can enumerate and fill one list with
only the visible windows.. If I use If IsVisibleWindow = False then.. It
fills with EVERYTHING.. all the hidden system windows, while this is a
cool concempt and is quite fun to see all the hidden windows, it doesn't
suit my purpose. Someone suggested reading all the visible windows into
an array and redimensioning the array each time a window is added or
removed, but I'd rather write the code and let my EnumWindowsProc take
care of it.. Can someone shed some light on this for me or give me some
more info? I've read all the Examples on VbNet and Karl Peterson's
sight.. still no help.. anyone?
TIA
Matt
-
Re: Array of showing / hidden windows..
Hmm.. spent too much time on the EnumWindowsProc.. I've heard the term
pushing and popping items from an array.. could some one give me an
example of this? I have the following function that fills a listbox with
the captions of all visible windows and adds them to an array.. I'd like
to be able to double click on an entry and make the windows Hidden
using: ShowWindow(List1.ItemData(List1.ListIndex), SW_HIDE) and in the
process, remove that string from my array and add it to a second listbox
and write a second array for the hidden windows.. here is what I have so
far:
Public Function FillVisible(lst As ListBox) As Long
lst.Clear
Call EnumWindows(AddressOf VisibleWindowsProc, lst.hWnd)
Dim ary1() As String
Dim arySize As Integer
Dim Count As Integer
arySize = lst.ListCount - 1
ReDim Preserve ary1(arySize)
For Count = 1 To arySize
ary1(Count) = lst.List(Count)
Debug.Print ary1(Count)
Next
FillVisible = lst.ListCount
End Function
Any suggestions are welcome.. this is the first I've played with
callbacks so I could be doing this all wrong..
TIA
Matt
-
Re: Array of showing / hidden windows..
Hmm.. spent too much time on the EnumWindowsProc.. I've heard the term
pushing and popping items from an array.. could some one give me an
example of this? I have the following function that fills a listbox with
the captions of all visible windows and adds them to an array.. I'd like
to be able to double click on an entry and make the windows Hidden
using: ShowWindow(List1.ItemData(List1.ListIndex), SW_HIDE) and in the
process, remove that string from my array and add it to a second listbox
and write a second array for the hidden windows.. here is what I have so
far:
Public Function FillVisible(lst As ListBox) As Long
lst.Clear
Call EnumWindows(AddressOf VisibleWindowsProc, lst.hWnd)
Dim ary1() As String
Dim arySize As Integer
Dim Count As Integer
arySize = lst.ListCount - 1
ReDim Preserve ary1(arySize)
For Count = 1 To arySize
ary1(Count) = lst.List(Count)
Debug.Print ary1(Count)
Next
FillVisible = lst.ListCount
End Function
Any suggestions are welcome.. this is the first I've played with
callbacks so I could be doing this all wrong..
TIA
Matt
-
Re: Array of showing / hidden windows..
I would consider using a collection or a dictionary. When you use an array,
you cannot remove an array element and have everything shift to fill the
hole. You simply set the nth element to vbNullString and you have to check
for vbNullString ("") when loading the list boxes. If you used a
collection or a dictionary you can yank an item out of the middle, and it
will fill in the whole for you.
The other option would be to use a user-defined array. Have two items in
the UDT. First is the window name, the second is a boolean flag for which
listbox the item appears in. Then all you do is set the flag to True or
False depending on which window you want it to appear in.
--
Eric D. Burdo, Red-Leif International
VB Programmer and Consultant
<http://www.redleif.com>
"Matt Williamson" <"N0 $paM-Mattwil"@pce.net> wrote in message
news:38E0467A.D91BC11F@pce.net...
> Hmm.. spent too much time on the EnumWindowsProc.. I've heard the term
> pushing and popping items from an array.. could some one give me an
> example of this? I have the following function that fills a listbox with
> the captions of all visible windows and adds them to an array.. I'd like
> to be able to double click on an entry and make the windows Hidden
> using: ShowWindow(List1.ItemData(List1.ListIndex), SW_HIDE) and in the
> process, remove that string from my array and add it to a second listbox
> and write a second array for the hidden windows.. here is what I have so
> far:
>
> Public Function FillVisible(lst As ListBox) As Long
>
> lst.Clear
> Call EnumWindows(AddressOf VisibleWindowsProc, lst.hWnd)
>
> Dim ary1() As String
> Dim arySize As Integer
> Dim Count As Integer
>
> arySize = lst.ListCount - 1
> ReDim Preserve ary1(arySize)
>
> For Count = 1 To arySize
> ary1(Count) = lst.List(Count)
> Debug.Print ary1(Count)
> Next
>
> FillVisible = lst.ListCount
> End Function
>
> Any suggestions are welcome.. this is the first I've played with
> callbacks so I could be doing this all wrong..
>
> TIA
>
> Matt
>
-
Re: Array of showing / hidden windows..
I would consider using a collection or a dictionary. When you use an array,
you cannot remove an array element and have everything shift to fill the
hole. You simply set the nth element to vbNullString and you have to check
for vbNullString ("") when loading the list boxes. If you used a
collection or a dictionary you can yank an item out of the middle, and it
will fill in the whole for you.
The other option would be to use a user-defined array. Have two items in
the UDT. First is the window name, the second is a boolean flag for which
listbox the item appears in. Then all you do is set the flag to True or
False depending on which window you want it to appear in.
--
Eric D. Burdo, Red-Leif International
VB Programmer and Consultant
<http://www.redleif.com>
"Matt Williamson" <"N0 $paM-Mattwil"@pce.net> wrote in message
news:38E0467A.D91BC11F@pce.net...
> Hmm.. spent too much time on the EnumWindowsProc.. I've heard the term
> pushing and popping items from an array.. could some one give me an
> example of this? I have the following function that fills a listbox with
> the captions of all visible windows and adds them to an array.. I'd like
> to be able to double click on an entry and make the windows Hidden
> using: ShowWindow(List1.ItemData(List1.ListIndex), SW_HIDE) and in the
> process, remove that string from my array and add it to a second listbox
> and write a second array for the hidden windows.. here is what I have so
> far:
>
> Public Function FillVisible(lst As ListBox) As Long
>
> lst.Clear
> Call EnumWindows(AddressOf VisibleWindowsProc, lst.hWnd)
>
> Dim ary1() As String
> Dim arySize As Integer
> Dim Count As Integer
>
> arySize = lst.ListCount - 1
> ReDim Preserve ary1(arySize)
>
> For Count = 1 To arySize
> ary1(Count) = lst.List(Count)
> Debug.Print ary1(Count)
> Next
>
> FillVisible = lst.ListCount
> End Function
>
> Any suggestions are welcome.. this is the first I've played with
> callbacks so I could be doing this all wrong..
>
> TIA
>
> Matt
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|