msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Deactivate Form

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB General Discussions
Author Message
Lorin



Joined: 04 Oct 2007
Posts: 312

PostPosted: Wed Feb 27, 2008 3:47 pm    Post subject: Deactivate Form Reply with quote

VB6SP6
Non-modal or a modal form that has a timer running to update data in at
richtextbox (launched from the main app form)
This process can be relativly long and causes the whole app to chug.
If the user has it visible then the user will tolerate the chug situation.
If the form is not topmost, then the process should stop updating and
therefore cease the chuging.
How do I determine programmatically when the form is topmost?
Other apps might sit on top of it too. No chuging then either.

tmrUpdate.enabled = Me.Topmost

would be nice.

Archived from group: microsoft>public>vb>general>discussion
Back to top
View user's profile Send private message
Jeff Johnson



Joined: 04 Oct 2007
Posts: 1327

PostPosted: Wed Feb 27, 2008 7:05 pm    Post subject: Re: Deactivate Form Reply with quote

"Lorin" wrote in message @microsoft.com...

> How do I determine programmatically when the form is topmost?

I think this is what you really want:
http://vbnet.mvps.org/code/subclass/activation.htm
Back to top
View user's profile Send private message
Lorin



Joined: 04 Oct 2007
Posts: 312

PostPosted: Wed Feb 27, 2008 4:28 pm    Post subject: Re: Deactivate Form Reply with quote

Subclassing freaks me out.
I need real world examples of safe subclassing.
When I have tried it in the past, the IDE would always crash since I was too
wound up in the code work to remember to stop the app properly.

"Jeff Johnson" wrote:

> "Lorin" wrote in message
> @microsoft.com...
>
> > How do I determine programmatically when the form is topmost?
>
> I think this is what you really want:
> http://vbnet.mvps.org/code/subclass/activation.htm
>
>
>
Back to top
View user's profile Send private message
Mike Williams



Joined: 04 Oct 2007
Posts: 1309

PostPosted: Thu Feb 28, 2008 1:01 am    Post subject: Re: Deactivate Form Reply with quote

"Lorin" wrote in message @microsoft.com...

> Subclassing freaks me out.

It's exciting! Keeps you on your toes! The VB IDE hates it, but compiled
apps love it! Where would we be today if the world explorers of old stayed
safely at home? America would still be in the hands of Gerinomo and his
brood (mind you, perhaps that would be a good thing!) and Captain Morgan
would never have invented his delicious rum! Go for it. Be one of life's
explorers!

> I need real world examples of safe subclassing.

http://www.vbaccelerator.com/home/vb/code/libraries/subclassing/SSubTimer/article.asp

Mike
Back to top
View user's profile Send private message
kpg*



Joined: 04 Oct 2007
Posts: 7

PostPosted: Wed Feb 27, 2008 5:44 pm    Post subject: Re: Deactivate Form Reply with quote

"Mike Williams" wrote in@TK2MSFTNGP02.phx.gbl:

> "Lorin" wrote in message
> @microsoft.com...
>
>> Subclassing freaks me out.
>
> It's exciting! Keeps you on your toes! The VB IDE hates it, but
> compiled apps love it! Where would we be today if the world explorers
> of old stayed safely at home? America would still be in the hands of
> Gerinomo and his brood (mind you, perhaps that would be a good thing!)
> and Captain Morgan would never have invented his delicious rum! Go for
> it. Be one of life's explorers!
>
>> I need real world examples of safe subclassing.
>
> http://www.vbaccelerator.com/home/vb/code/libraries/subclassing/SSubTim
> er/article.asp
>
> Mike


lol

Took me a while to realize I had to protect blocks of code
that subclassed whatever from the IDE. Setting a global
boolean on startup if in the IDE then testing that before
subclassing - my life has been better since.

kpg
Back to top
View user's profile Send private message
MikeD



Joined: 04 Oct 2007
Posts: 3348

PostPosted: Wed Feb 27, 2008 8:50 pm    Post subject: Re: Deactivate Form Reply with quote

"Jeff Johnson" wrote in message @corp.supernews.com...
> "Lorin" wrote in message
> @microsoft.com...
>
>> How do I determine programmatically when the form is topmost?
>
> I think this is what you really want:
> http://vbnet.mvps.org/code/subclass/activation.htm
>

Just an idea, but rather than subclassing, could you call
GetForeGroundWindow and compare that to the form's Hwnd property? Of course,
this would need done on a regular basis (such as in a Timer event).

--
Mike
Microsoft MVP Visual Basic
Back to top
View user's profile Send private message
Bob O`Bob



Joined: 04 Oct 2007
Posts: 1456

PostPosted: Wed Feb 27, 2008 6:23 pm    Post subject: Re: Deactivate Form Reply with quote

Lorin wrote:
> Subclassing freaks me out.
> I need real world examples of safe subclassing.
> When I have tried it in the past, the IDE would always crash since I was too
> wound up in the code work to remember to stop the app properly.


Why bother? Just *know* that it is a possible effect of stopping
subclassed code while in the IDE.

Make sure you really meant "save" or "don't save"
EVERY time you start a run.

So, sometimes you have to restart the IDE. Big Deal.

Computers are supposed to do YOUR bidding, not the other way 'round.



Bob
--
Back to top
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Wed Feb 27, 2008 8:55 pm    Post subject: Re: Deactivate Form Reply with quote

"Bob O`Bob" wrote

> Computers are supposed to do YOUR bidding, not the other way 'round.

Tell that to my local ATM machine!


LFS
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Wed Feb 27, 2008 7:29 pm    Post subject: Re: Deactivate Form Reply with quote

Lorin wrote:
> Non-modal or a modal form that has a timer running to update data in at
> richtextbox (launched from the main app form)
> This process can be relativly long and causes the whole app to chug.
> If the user has it visible then the user will tolerate the chug situation.
> If the form is not topmost, then the process should stop updating and
> therefore cease the chuging.
> How do I determine programmatically when the form is topmost?
> Other apps might sit on top of it too. No chuging then either.
>
> tmrUpdate.enabled = Me.Topmost
>
> would be nice.

Sounds like Mike's suggestion is best, here. Just slip it into your timer event.
What's taking the time isn't the timer interrupt, but what you're doing within that,
right?

Private Sub tmrUpdate_Timer()
If GetForegroundWindow() = Me.hWnd Then
' real work
End If
End Sub

???
--
..NET: It's About Trust!
http://vfred.mvps.org
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Wed Feb 27, 2008 8:04 pm    Post subject: Re: Deactivate Form Reply with quote

Karl E. Peterson wrote:
> Lorin wrote:
>> Non-modal or a modal form that has a timer running to update data in at
>> richtextbox (launched from the main app form)
>> This process can be relativly long and causes the whole app to chug.
>> If the user has it visible then the user will tolerate the chug situation.
>> If the form is not topmost, then the process should stop updating and
>> therefore cease the chuging.
>> How do I determine programmatically when the form is topmost?
>> Other apps might sit on top of it too. No chuging then either.
>>
>> tmrUpdate.enabled = Me.Topmost
>>
>> would be nice.
>
> Sounds like Mike's suggestion is best, here. Just slip it into your timer event.
> What's taking the time isn't the timer interrupt, but what you're doing within
> that, right?
>
> Private Sub tmrUpdate_Timer()
> If GetForegroundWindow() = Me.hWnd Then
> ' real work
> End If
> End Sub
>
> ???

PS... But *of course* I heartily agree with those in favor of learning to subclass,
too!
--
..NET: It's About Trust!
http://vfred.mvps.org
Back to top
View user's profile Send private message
MikeD



Joined: 04 Oct 2007
Posts: 3348

PostPosted: Thu Feb 28, 2008 12:59 am    Post subject: Re: Deactivate Form Reply with quote

"Karl E. Peterson" wrote in message @TK2MSFTNGP04.phx.gbl...
> Karl E. Peterson wrote:
>> Lorin wrote:
>>> Non-modal or a modal form that has a timer running to update data in at
>>> richtextbox (launched from the main app form)
>>> This process can be relativly long and causes the whole app to chug.
>>> If the user has it visible then the user will tolerate the chug
>>> situation.
>>> If the form is not topmost, then the process should stop updating and
>>> therefore cease the chuging.
>>> How do I determine programmatically when the form is topmost?
>>> Other apps might sit on top of it too. No chuging then either.
>>>
>>> tmrUpdate.enabled = Me.Topmost
>>>
>>> would be nice.
>>
>> Sounds like Mike's suggestion is best, here. Just slip it into your
>> timer event.
>> What's taking the time isn't the timer interrupt, but what you're doing
>> within
>> that, right?
>>
>> Private Sub tmrUpdate_Timer()
>> If GetForegroundWindow() = Me.hWnd Then
>> ' real work
>> End If
>> End Sub
>>
>> ???
>
> PS... But *of course* I heartily agree with those in favor of learning to
> subclass, too!


Doesn't sound as if Lorin is one of those people.

--
Mike
Microsoft MVP Visual Basic
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Wed Feb 27, 2008 11:01 pm    Post subject: Re: Deactivate Form Reply with quote

MikeD wrote:
>> PS... But *of course* I heartily agree with those in favor of learning to
>> subclass, too!
>
> Doesn't sound as if Lorin is one of those people.

Yeah, that's the general picture that's emerging, isn't it?
--
..NET: It's About Trust!
http://vfred.mvps.org

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB General Discussions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group