Why would the VB6 exe not show up in the task bar

  • Follow


Folks

My very standard VB6 exe is not showing up on one users task bar in
Windows Vista.  The task bar being that area usually on the bottom of
your screen showing you all the open programs.

Any thoughts?  It works for me on a Vista VPC session as well as
Windows 7.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/6/2010 9:35:19 PM

"Tony Toews [MVP]" <ttoews@telusplanet.net> wrote in message 
news:ad0ak5hdrlrjr3dc1omare7bunc9fgd964@4ax.com...
> Folks
>
> My very standard VB6 exe is not showing up on one users task bar in
> Windows Vista.  The task bar being that area usually on the bottom of
> your screen showing you all the open programs.
>
> Any thoughts?  It works for me on a Vista VPC session as well as
> Windows 7.

Typically what affects forms appearing in the task bar is ShowInTaskbar 
property. I am not sure what's causing the problem that you mentioned.


0
Reply Nobody 1/6/2010 10:01:30 PM


"Nobody" <nobody@nobody.com> wrote:

>> My very standard VB6 exe is not showing up on one users task bar in
>> Windows Vista.  The task bar being that area usually on the bottom of
>> your screen showing you all the open programs.
>>
>> Any thoughts?  It works for me on a Vista VPC session as well as
>> Windows 7.
>
>Typically what affects forms appearing in the task bar is ShowInTaskbar 
>property. 

Oh, I never noticed that.  It appears all the other forms have that
property set to false which makes sense.

Now it might start to be making some sense if he can open another form
and then somehow close the main form without exiting the program.    

Thanks, this gives me a starting point rather than doubting his
sanity.   <smile> Actually he's very, very good.  We've worked
together off and on for about 10 years.  So his description of his
problem was utterly accurate.  It just didn't make any sense to me.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/7/2010 1:14:34 AM

Check also App.TaskVisible.


0
Reply Nobody 1/7/2010 1:39:06 AM

"Nobody" <nobody@nobody.com> wrote:

>Check also App.TaskVisible.

Didn't have any of that in the code.  But now I can duplicate his
results.

If you open another form and then click on an Exit command button on
the "main" form then the program exits.  The command button runs 
"End".

However if you open another form and close the "main" form using the x
to close button on the right hand side of title bar then just the form
closes.  The other form stays visible but as soon as click on another
Windows program the other form disappears.  And the VB6 exe still
resides in memory.

So I need to run End in the "main" forms Unload event, correct?

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/7/2010 2:44:17 AM

Tony Toews [MVP] wrote:
> "Nobody" <nobody@nobody.com> wrote:
>
>
> So I need to run End in the "main" forms Unload event, correct?
>

Never use "End" statement in a production application. Period. Fine!

Repeat: never use the "End" Statement as it performs minimal "clean-up" if
any.

To properly end a VB application before you close the parent From or exit
Sub Main, you should unload all forms, set any references still in scope to
Nothing, and disable any active Timers. At this point the application should
end on its own. If it doesn't then you are leaving something behind.

It is possible the O/S may eventually perform some clean-up for some system
resources, but you can't count on it, and if it doesn't then you will have a
memory leak.

-ralph






0
Reply Ralph 1/7/2010 2:59:21 AM

"Tony Toews [MVP]" <ttoews@telusplanet.net> wrote

> If you open another form and then click on an Exit command button on
> the "main" form then the program exits.  The command button runs
> "End".

I wonder how many people would use that route if they didn't call it
End, but instead provided an App.Crash method.  That is basically
what End does, crash the program.  As you see it can lead to a
multitude of problems.


> So I need to run End in the "main" forms Unload event, correct?

You should ensure no other code is running, and unload all forms.
That is the proper way to close the application.  Read the remarks
section in VB Help for the End keyword....

LFS


0
Reply Larry 1/7/2010 3:00:57 AM

"Larry Serflaten" <serflaten@usinternet.com> wrote:

>> If you open another form and then click on an Exit command button on
>> the "main" form then the program exits.  The command button runs
>> "End".
>
>I wonder how many people would use that route if they didn't call it
>End, but instead provided an App.Crash method.  That is basically
>what End does, crash the program.  As you see it can lead to a
>multitude of problems.

What problems did using End lead to in my case?  Seems to me that for
what I wanted it to do it worked.

Note that I can appreciate that I'm not supposed to use End.  It's
just that your last sentence doesn't make any sense to my scenario.

>> So I need to run End in the "main" forms Unload event, correct?
>
>You should ensure no other code is running, 

What circumstances would that happen?I don't have any forms running
with timers.

>and unload all forms.

Ok, found the sample code for that.

>That is the proper way to close the application.  Read the remarks
>section in VB Help for the End keyword....

Yup, nice generic warning comments.  It would've been nice for MS to
be a bit more specific.  Oh well.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/7/2010 3:31:13 AM

"Ralph" <nt_consulting64@yahoo.com> wrote:

>> So I need to run End in the "main" forms Unload event, correct?
>>
>
>Never use "End" statement in a production application. Period. Fine!
>
>Repeat: never use the "End" Statement as it performs minimal "clean-up" if
>any.

Ah, ok.     We use DoCmd.Quit all the time in the Access world. 

>To properly end a VB application before you close the parent From or exit
>Sub Main, you should unload all forms, set any references still in scope to
>Nothing, and disable any active Timers. At this point the application should
>end on its own. If it doesn't then you are leaving something behind.

Ok, I don't have any references or timers and I've found the necessary
code to close all forms.  Identical to what I' use in a somewhat
similar situation in Access where I want to ensure I close all
references to the backend database so I can compact the backend or
switch to a different backend.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/7/2010 3:33:59 AM

Tony Toews [MVP] wrote:
> "Ralph" <nt_consulting64@yahoo.com> wrote:
>
>>> So I need to run End in the "main" forms Unload event, correct?
>>>
>>
>> Never use "End" statement in a production application. Period. Fine!
>>
>> Repeat: never use the "End" Statement as it performs minimal
>> "clean-up" if any.
>
> Ah, ok.     We use DoCmd.Quit all the time in the Access world.
>

The DoCmd function is a VBA MSAccess extension. DoCmd.Quit is actually
calling the Host's "Quit" command which is the same as quiting MSAccess - in
which case MSAccess will close its Forms and release Objects, Resources,
&etc.

-ralph



-1
Reply Ralph 1/7/2010 4:17:33 AM

Tony Toews [MVP] submitted this idea :
> "Ralph" <nt_consulting64@yahoo.com> wrote:
>
>>> So I need to run End in the "main" forms Unload event, correct?
>> 
>> Never use "End" statement in a production application. Period. Fine!
>> 
>> Repeat: never use the "End" Statement as it performs minimal "clean-up" if
>> any.
>
> Ah, ok.     We use DoCmd.Quit all the time in the Access world. 

Extra credit reading: http://obob.com/cis58/evilend.html  :-)

-- 
..NET: It's About Trust!
http://vfred.mvps.org


0
Reply Karl 1/7/2010 10:28:29 PM

Karl E. Peterson <karl@exmvps.org> wrote:

>Extra credit reading: http://obob.com/cis58/evilend.html  :-)

Awesome.  That nicely explains the other comments in this thread.  

And I didn't realize that Bob O'Bob had a website.  <a minute later>
Darn, I wish he had more articles.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/8/2010 1:40:36 AM

Tony Toews [MVP] formulated on Thursday :
> Karl E. Peterson <karl@exmvps.org> wrote:
>
>> Extra credit reading: http://obob.com/cis58/evilend.html  :-)
>
> Awesome.  That nicely explains the other comments in this thread.  
>
> And I didn't realize that Bob O'Bob had a website.  <a minute later>
> Darn, I wish he had more articles.

Yeah, he has a way, alright...  :-)

-- 
..NET: It's About Trust!
http://vfred.mvps.org


0
Reply Karl 1/8/2010 2:45:12 AM

On Wed, 06 Jan 2010 14:35:19 -0700, "Tony Toews [MVP]"
<ttoews@telusplanet.net> wrote:

>Folks
>
>My very standard VB6 exe is not showing up on one users task bar in
>Windows Vista.  The task bar being that area usually on the bottom of
>your screen showing you all the open programs.
>
>Any thoughts?  It works for me on a Vista VPC session as well as
>Windows 7.

It will not show if the startup object is a module with a Sub Main in
it.
To be visible, the startup object has to be a form.

And the ShowInTaskBar has to be set a t TRUE, of course.

Anyway, that's just what happened to me. To fix it, I had to rewrite a
command line parser and all init function into the main form. Fun...
0
Reply deactivated 1/8/2010 4:18:02 AM

deactivated wrote:

>>My very standard VB6 exe is not showing up on one users task bar in
>>Windows Vista.  The task bar being that area usually on the bottom of
>>your screen showing you all the open programs.
>>
>>Any thoughts?  It works for me on a Vista VPC session as well as
>>Windows 7.
>
>It will not show if the startup object is a module with a Sub Main in
>it.
>To be visible, the startup object has to be a form.
>
>And the ShowInTaskBar has to be set a t TRUE, of course.
>
>Anyway, that's just what happened to me. To fix it, I had to rewrite a
>command line parser and all init function into the main form. Fun...

Hmm, actually I do have a Sub Main.   And if certain conditions are
met the program does some processing, including reading the command
line and exits without displaying any forms.    Assuming no errors of
course.

If other conditions are met then a form is displayed and other forms
can be displayed and so forth. 

So I didn't have to move anything to a form so I find your comment a
bit puzzling.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/8/2010 5:57:35 AM

"deactivated" wrote in message 
news:4b46b138.11165421@news.newshosting.com...
> On Wed, 06 Jan 2010 14:35:19 -0700, "Tony Toews [MVP]"
> <ttoews@telusplanet.net> wrote:
>
>>Folks
>>
>>My very standard VB6 exe is not showing up on one users task bar in
>>Windows Vista.  The task bar being that area usually on the bottom of
>>your screen showing you all the open programs.
>>
>>Any thoughts?  It works for me on a Vista VPC session as well as
>>Windows 7.
>
> It will not show if the startup object is a module with a Sub Main in
> it.
> To be visible, the startup object has to be a form.

That's not true unless you show the form modally.  Modal forms don't show in 
the taskbar unless you do sme API work to force it.

0
Reply Bob 1/8/2010 1:23:49 PM

On Thu, 07 Jan 2010 22:57:35 -0700, "Tony Toews [MVP]"
<ttoews@telusplanet.net> wrote:

>deactivated wrote:

>>It will not show if the startup object is a module with a Sub Main in
>>it.
>>To be visible, the startup object has to be a form.
>>
>>And the ShowInTaskBar has to be set a t TRUE, of course.
>>
>>Anyway, that's just what happened to me. To fix it, I had to rewrite a
>>command line parser and all init function into the main form. Fun...
>
>Hmm, actually I do have a Sub Main.   And if certain conditions are
>met the program does some processing, including reading the command
>line and exits without displaying any forms.    Assuming no errors of
>course.
>
>If other conditions are met then a form is displayed and other forms
>can be displayed and so forth. 
>
>So I didn't have to move anything to a form so I find your comment a
>bit puzzling.

Maybe I wasn't too clear...

The application I was making then had a Sub Main as startup up and
would call a form to show. That worked fine.

However, nothing was shown in the taskbar.

I added some code to display an icon in the taskbar but the client
wanted the program to show in the ALT-tab form where a user can
activate the application directly.

To do that, I had to make the start-up object the main form.

Unless you have some trick about that...?
0
Reply deactivated 1/8/2010 8:35:04 PM

On Fri, 8 Jan 2010 05:23:49 -0800, "Bob Butler" <noway@nospam.ever>
wrote:

>
>"deactivated" wrote in message 
>news:4b46b138.11165421@news.newshosting.com...

>> It will not show if the startup object is a module with a Sub Main in
>> it.
>> To be visible, the startup object has to be a form.
>
>That's not true unless you show the form modally. 

The form called from Sub Main was show modally and the application did
not show in the task bar.
Neither did it show in the ALT-tab form.

>Modal forms don't show in 
>the taskbar unless you do sme API work to force it.

err...did I miss something?

....what APIs ? I want to know...

0
Reply deactivated 1/8/2010 8:40:47 PM

deactivated formulated the question :
> The application I was making then had a Sub Main as startup up and
> would call a form to show. That worked fine.
>
> However, nothing was shown in the taskbar.
>
> I added some code to display an icon in the taskbar but the client
> wanted the program to show in the ALT-tab form where a user can
> activate the application directly.
>
> To do that, I had to make the start-up object the main form.
>
> Unless you have some trick about that...?

Sounds like a mess.  There's nothing magical about showing up in either 
the taskbar or the alt-tab order.  The rules for the latter are very 
clear-cut.  See http://vb.mvps.org/samples/AltTab for the algorithm.

-- 
..NET: It's About Trust!
http://vfred.mvps.org


0
Reply Karl 1/8/2010 9:07:09 PM

On Fri, 08 Jan 2010 13:07:09 -0800, Karl E. Peterson <karl@exmvps.org>
wrote:

>deactivated formulated the question :
>> The application I was making then had a Sub Main as startup up and
>> would call a form to show. That worked fine.
>>
>> However, nothing was shown in the taskbar.
>>
>> I added some code to display an icon in the taskbar but the client
>> wanted the program to show in the ALT-tab form where a user can
>> activate the application directly.
>>
>> To do that, I had to make the start-up object the main form.
>>
>> Unless you have some trick about that...?
>
>Sounds like a mess.  There's nothing magical about showing up in either 
>the taskbar or the alt-tab order.  The rules for the latter are very 
>clear-cut.  See http://vb.mvps.org/samples/AltTab for the algorithm.

404

http://vb.mvps.org/samples/AltTab/

That last slash is a bitch  ;-)
0
Reply deresoluted 1/8/2010 9:22:34 PM

"deactivated" wrote in message 
news:4b47973d.17716859@news.newshosting.com...
> On Fri, 8 Jan 2010 05:23:49 -0800, "Bob Butler" <noway@nospam.ever>
> wrote:
>
>>
>>"deactivated" wrote in message
>>news:4b46b138.11165421@news.newshosting.com...
>
>>> It will not show if the startup object is a module with a Sub Main in
>>> it.
>>> To be visible, the startup object has to be a form.
>>
>>That's not true unless you show the form modally.
>
> The form called from Sub Main was show modally and the application did
> not show in the task bar.
> Neither did it show in the ALT-tab form.

Right, that's what I said.  If you show it modally then it does not appear 
in the taskbar.  If you don't show the form modally then it will.  The 
problem is not that you are starting from Sub Main, it's that you are 
showing a modal form.

>>Modal forms don't show in
>>the taskbar unless you do sme API work to force it.
>
> err...did I miss something?
>
> ...what APIs ? I want to know...

This works for me, at least through Vista.  I haven't tried it on Win7 yet.

'API to force taskbar icon for modal form
Private Declare Function SetWindowLong Lib "user32" Alias _
  "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
  ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias _
  "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const WS_EX_APPWINDOW = &H40000
Private Const GWL_EXSTYLE = -20
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
  (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, _
  ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
  (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
  ByRef lParam As Any) As Long
Private Declare Function RegisterWindowMessage Lib "user32" _
  Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long

Private Sub AddToTaskBar()
Dim lStyle As Long
Dim lResult As Long
Dim lHook As Long
Dim lTrayhWnd As Long
Dim lTBhWnd As Long
lStyle = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
lResult = SetWindowLong(Me.hWnd, GWL_EXSTYLE, lStyle Or WS_EX_APPWINDOW)
lHook = RegisterWindowMessage("SHELLHOOK")
lTrayhWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
If lTrayhWnd <> 0 And lHook <> 0 Then
  lTBhWnd = FindWindowEx(lTrayhWnd, 0, "RebarWindow32", vbNullString)
  If lTBhWnd Then
    lTBhWnd = FindWindowEx(lTBhWnd, 0, "MSTaskSwWClass", vbNullString)
    If lTBhWnd Then
      lResult = PostMessage(lTBhWnd, lHook, 1, ByVal Me.hWnd)
    End If
  End If
End If
End Sub

Private Sub Form_Activate()
Static bDone As Boolean
If Not bDone Then
  bDone = True
  AddToTaskBar
End If
End Sub

0
Reply Bob 1/8/2010 9:57:02 PM

Karl E. Peterson <karl@exmvps.org> wrote:

>Sounds like a mess.  There's nothing magical about showing up in either 
>the taskbar or the alt-tab order.  The rules for the latter are very 
>clear-cut.  See http://vb.mvps.org/samples/AltTab for the algorithm.

Thanks Karl.  I'm gong to be needing that logic in a month or two.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/8/2010 9:58:52 PM

deresoluted laid this down on his screen :
> On Fri, 08 Jan 2010 13:07:09 -0800, Karl E. Peterson <karl@exmvps.org>
> wrote:
>
>> deactivated formulated the question :
>>> The application I was making then had a Sub Main as startup up and
>>> would call a form to show. That worked fine.
>>> 
>>> However, nothing was shown in the taskbar.
>>> 
>>> I added some code to display an icon in the taskbar but the client
>>> wanted the program to show in the ALT-tab form where a user can
>>> activate the application directly.
>>> 
>>> To do that, I had to make the start-up object the main form.
>>> 
>>> Unless you have some trick about that...?
>> 
>> Sounds like a mess.  There's nothing magical about showing up in either 
>> the taskbar or the alt-tab order.  The rules for the latter are very 
>> clear-cut.  See http://vb.mvps.org/samples/AltTab for the algorithm.
>
> 404
>
> http://vb.mvps.org/samples/AltTab/
>
> That last slash is a bitch  ;-)

Huh?  ("Works here.")

-- 
..NET: It's About Trust!
http://vfred.mvps.org


0
Reply Karl 1/8/2010 10:37:59 PM

on 1/8/2010, Tony Toews [MVP] supposed :
> Karl E. Peterson <karl@exmvps.org> wrote:
>
>> Sounds like a mess.  There's nothing magical about showing up in either 
>> the taskbar or the alt-tab order.  The rules for the latter are very 
>> clear-cut.  See http://vb.mvps.org/samples/AltTab for the algorithm.
>
> Thanks Karl.  I'm gong to be needing that logic in a month or two.

We developed that logic in NT 3.5 and Windows 3.1, so you'll have to 
let me know how that goes in Windwos 7... <gd&r>

-- 
..NET: It's About Trust!
http://vfred.mvps.org


0
Reply Karl 1/8/2010 10:39:53 PM

On Fri, 8 Jan 2010 13:57:02 -0800, "Bob Butler" <noway@nospam.ever>
wrote:

>
>
>"deactivated" wrote in message 
>news:4b47973d.17716859@news.newshosting.com...

>Right, that's what I said.  If you show it modally then it does not appear 
>in the taskbar.  If you don't show the form modally then it will.  The 
>problem is not that you are starting from Sub Main, it's that you are 
>showing a modal form.

I just tried it and you are right.
I have never tried calling a non-modal form from the sub Main....since
when the main form is unloaded, I set it to nothing explicitly...

One does learn every day.

>> ...what APIs ? I want to know...
>
>This works for me, at least through Vista.  I haven't tried it on Win7 yet.

This I will try....

>'API to force taskbar icon for modal form
>Private Declare Function SetWindowLong Lib "user32" Alias _
>  "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
>  ByVal dwNewLong As Long) As Long
>Private Declare Function GetWindowLong Lib "user32" Alias _
>  "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
>Private Const WS_EX_APPWINDOW = &H40000
>Private Const GWL_EXSTYLE = -20
>Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
>  (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, _
>  ByVal lpClassName As String, ByVal lpWindowName As String) As Long
>Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
>  (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
>  ByRef lParam As Any) As Long
>Private Declare Function RegisterWindowMessage Lib "user32" _
>  Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
>
>Private Sub AddToTaskBar()
>Dim lStyle As Long
>Dim lResult As Long
>Dim lHook As Long
>Dim lTrayhWnd As Long
>Dim lTBhWnd As Long
>lStyle = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
>lResult = SetWindowLong(Me.hWnd, GWL_EXSTYLE, lStyle Or WS_EX_APPWINDOW)
>lHook = RegisterWindowMessage("SHELLHOOK")
>lTrayhWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
>If lTrayhWnd <> 0 And lHook <> 0 Then
>  lTBhWnd = FindWindowEx(lTrayhWnd, 0, "RebarWindow32", vbNullString)
>  If lTBhWnd Then
>    lTBhWnd = FindWindowEx(lTBhWnd, 0, "MSTaskSwWClass", vbNullString)
>    If lTBhWnd Then
>      lResult = PostMessage(lTBhWnd, lHook, 1, ByVal Me.hWnd)
>    End If
>  End If
>End If
>End Sub
>
>Private Sub Form_Activate()
>Static bDone As Boolean
>If Not bDone Then
>  bDone = True
>  AddToTaskBar
>End If
>End Sub
>

0
Reply bitshifter 1/9/2010 3:12:35 AM

On Sat, 09 Jan 2010 03:12:35 GMT, bitshifter@sympatico.ca wrote:

>>This works for me, at least through Vista.  I haven't tried it on Win7 yet.
>
>This I will try....

....and it works really fine.
Another addition to my library of tricks from others...

Multi-tanks to you.

>>'API to force taskbar icon for modal form
>>Private Declare Function SetWindowLong Lib "user32" Alias _
>>  "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
>>  ByVal dwNewLong As Long) As Long
>>Private Declare Function GetWindowLong Lib "user32" Alias _
>>  "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
>>Private Const WS_EX_APPWINDOW = &H40000
>>Private Const GWL_EXSTYLE = -20
>>Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
>>  (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, _
>>  ByVal lpClassName As String, ByVal lpWindowName As String) As Long
>>Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
>>  (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
>>  ByRef lParam As Any) As Long
>>Private Declare Function RegisterWindowMessage Lib "user32" _
>>  Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
>>
>>Private Sub AddToTaskBar()
>>Dim lStyle As Long
>>Dim lResult As Long
>>Dim lHook As Long
>>Dim lTrayhWnd As Long
>>Dim lTBhWnd As Long
>>lStyle = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
>>lResult = SetWindowLong(Me.hWnd, GWL_EXSTYLE, lStyle Or WS_EX_APPWINDOW)
>>lHook = RegisterWindowMessage("SHELLHOOK")
>>lTrayhWnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
>>If lTrayhWnd <> 0 And lHook <> 0 Then
>>  lTBhWnd = FindWindowEx(lTrayhWnd, 0, "RebarWindow32", vbNullString)
>>  If lTBhWnd Then
>>    lTBhWnd = FindWindowEx(lTBhWnd, 0, "MSTaskSwWClass", vbNullString)
>>    If lTBhWnd Then
>>      lResult = PostMessage(lTBhWnd, lHook, 1, ByVal Me.hWnd)
>>    End If
>>  End If
>>End If
>>End Sub
>>
>>Private Sub Form_Activate()
>>Static bDone As Boolean
>>If Not bDone Then
>>  bDone = True
>>  AddToTaskBar
>>End If
>>End Sub
>>
>

0
Reply bitshifter 1/9/2010 3:21:45 AM

Karl E. Peterson <karl@exmvps.org> wrote:

>>> Sounds like a mess.  There's nothing magical about showing up in either 
>>> the taskbar or the alt-tab order.  The rules for the latter are very 
>>> clear-cut.  See http://vb.mvps.org/samples/AltTab for the algorithm.
>>
>> Thanks Karl.  I'm gong to be needing that logic in a month or two.
>
>We developed that logic in NT 3.5 and Windows 3.1, so you'll have to 
>let me know how that goes in Windwos 7... <gd&r>

Hehehehe.   All I really need is the list of active tasks.  I don't
care about the icons and such.  

What I'm really looking for is the ability to warn someone that
they're already running the Access app and are they sure they want to
run it a second time?  Or ensure they can't run it a second time.  Now
what is complicating things here is that it's easy to determine this
from inside the Access app as you can look at the current title and
compare it to other existing titles.  I want to do this external to
Access so I think I'm going to setup some kind of "learning mode" in
my VB6 exe.

That said I can also look to the see if the current Access FE has an
LDB file open.  Trouble is it appears I can't use that for ADP/ADEs.
So it gets complicated.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 1/10/2010 5:22:31 AM

Tony Toews [MVP] explained on 1/9/2010 :
> Karl E. Peterson <karl@exmvps.org> wrote:
>
>>>> Sounds like a mess.  There's nothing magical about showing up in either 
>>>> the taskbar or the alt-tab order.  The rules for the latter are very 
>>>> clear-cut.  See http://vb.mvps.org/samples/AltTab for the algorithm.
>>> 
>>> Thanks Karl.  I'm gong to be needing that logic in a month or two.
>> 
>> We developed that logic in NT 3.5 and Windows 3.1, so you'll have to 
>> let me know how that goes in Windwos 7... <gd&r>
>
> Hehehehe.   All I really need is the list of active tasks.  I don't
> care about the icons and such.

That AltTab sample actually has two modes of detection.  One provides 
all the tasks that show up in the AltTab dialog.  The other shows all 
the tasks that show up in the Applications tab of Task Manager.

> What I'm really looking for is the ability to warn someone that
> they're already running the Access app and are they sure they want to
> run it a second time?  Or ensure they can't run it a second time.  Now
> what is complicating things here is that it's easy to determine this
> from inside the Access app as you can look at the current title and
> compare it to other existing titles.  I want to do this external to
> Access so I think I'm going to setup some kind of "learning mode" in
> my VB6 exe.

You might find the FindPart example on my site useful.  It'll run 
through all the running tasks, looking for titles that partially match 
a given string.  Might at least be a good starting point.

-- 
..NET: It's About Trust!
http://vfred.mvps.org


0
Reply Karl 1/11/2010 8:46:40 PM

Karl E. Peterson wrote:
> Tony Toews [MVP] formulated on Thursday :
>> Karl E. Peterson <karl@exmvps.org> wrote:
>>
>>> Extra credit reading: http://obob.com/cis58/evilend.html  :-)
>>
>> Awesome.  That nicely explains the other comments in this thread. 
>> And I didn't realize that Bob O'Bob had a website.  <a minute later>
>> Darn, I wish he had more articles.
> 
> Yeah, he has a way, alright...  :-)
> 


thank you both.

Maybe one day there might be another appearance of VBCurmudgeon.com



	Bob
-- 
0
Reply Bob 4/8/2010 1:10:29 AM

Bob O`Bob wrote:
> Karl E. Peterson wrote:
>> Tony Toews [MVP] formulated on Thursday :
>>> Karl E. Peterson <karl@exmvps.org> wrote:
>>>
>>>> Extra credit reading: http://obob.com/cis58/evilend.html  :-)
>>>
>>> Awesome.  That nicely explains the other comments in this thread. And I 
>>> didn't realize that Bob O'Bob had a website.  <a minute later>
>>> Darn, I wish he had more articles.
>> 
>> Yeah, he has a way, alright...  :-)
>
> thank you both.
>
> Maybe one day there might be another appearance of VBCurmudgeon.com

I'd welcome that day, myself.  :-)

-- 
..NET: It's About Trust!
http://vfred.mvps.org


0
Reply Karl 4/8/2010 7:01:35 PM

Bob O`Bob <filterbob@yahoogroups.com> wrote:

>>>> Extra credit reading: http://obob.com/cis58/evilend.html  :-)
>>>
>>> Awesome.  That nicely explains the other comments in this thread. 
>>> And I didn't realize that Bob O'Bob had a website.  <a minute later>
>>> Darn, I wish he had more articles.
>> 
>> Yeah, he has a way, alright...  :-)
>> 
>
>
>thank you both.

You're welcome.

>Maybe one day there might be another appearance of VBCurmudgeon.com

Hehehehe  Looking forward to it.

Tony
-- 
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files 
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
0
Reply Tony 4/15/2010 7:10:03 PM

30 Replies
703 Views

(page loaded in 0.631 seconds)

Similiar Articles:































7/19/2012 3:18:32 PM


Reply: