|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Hpw to make a VB6 form appears and gets focus every 15 secondsIn VB6, I need to make a form appears and got focus every, say 15 seconds. I
use code like following in the Timer event handler. But it doesn't appear after it lost focus (only blinking on the task bar). Do you know how to achieve the effect? Need to use Win32 API and WM_ACTIVATE? PostMessage or SendMessage? Private Sub Timer1_Timer() Me.Show ' Even this does not make it appear! Me.SetFocus End Sub Many thanks in advance. James James Ma wrote:
> In VB6, I need to make a form appears and got focus every, say 15 Microsoft, and many users, decided this to be RUDE behavior, by definition,> seconds. I use code like following in the Timer event handler. But it > doesn't appear after it lost focus (only blinking on the task bar). > Do you know how to achieve the effect? Need to use Win32 API and > WM_ACTIVATE? PostMessage or SendMessage? > > Private Sub Timer1_Timer() > Me.Show ' Even this does not make it appear! > Me.SetFocus > End Sub many years ago. To ignore that judgement, see http://vb.mvps.org/samples/ForceFore Thanks for your help.
I need the effect because I'm maintaining a project that uses Janus GridEX 2000 and the application is designed to run without human intervention. Somehow the Janus Grid's sort function can only work well when it's visible ang focused. That's why. I am not intended to annoy anyone, actually I was annoyed by the gird. Thanks and I'll try it. Show quoteHide quote "Karl E. Peterson" wrote: > James Ma wrote: > > In VB6, I need to make a form appears and got focus every, say 15 > > seconds. I use code like following in the Timer event handler. But it > > doesn't appear after it lost focus (only blinking on the task bar). > > Do you know how to achieve the effect? Need to use Win32 API and > > WM_ACTIVATE? PostMessage or SendMessage? > > > > Private Sub Timer1_Timer() > > Me.Show ' Even this does not make it appear! > > Me.SetFocus > > End Sub > > Microsoft, and many users, decided this to be RUDE behavior, by definition, > many years ago. To ignore that judgement, see > http://vb.mvps.org/samples/ForceFore > -- > Working without a .NET? > http://classicvb.org/ > > > James Ma wrote:
> Thanks for your help. -- > > I need the effect because I'm maintaining a project that uses Janus > GridEX 2000 and the application is designed to run without human > intervention. Somehow the Janus Grid's sort function can only work > well when it's visible ang focused. That's why. I am not intended to > annoy anyone, actually I was annoyed by the gird. Yes, we all have our "reasons." <g> Working without a .NET? http://classicvb.org/ James Ma wrote:
Show quoteHide quote > *In VB6, I need to make a form appears and got focus every, say 15
> seconds. I I am VB beginner > use code like following in the Timer event handler. But it doesn't > appear > after it lost focus (only blinking on the task bar). Do you know how > to > achieve the effect? Need to use Win32 API and WM_ACTIVATE? > PostMessage or > SendMessage? > > Private Sub Timer1_Timer() > Me.Show ' Even this does not make it appear! > Me.SetFocus > End Sub > > Many thanks in advance. > James * but i think u may do that by using 2 timers i tried and it worked try this Private Sub Form_Load() Me.Hide End Sub Private Sub Timer1_Timer() Timer1.Interval = 15000 Me.Show Me.SetFocus End Sub Private Sub Timer2_Timer() Timer2.Interval = 16000 ' change this interval to increase form show time Me.Hide End Sub ---- @_@ -- LoVe ScoRpiOn ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------ "James Ma" <Jame***@discussions.microsoft.com> wrote in message Who are you trying to annoy?news:B6E2088D-6F72-4209-8C87-3EB577D9C5ED@microsoft.com... > In VB6, I need to make a form appears and got focus every, say 15 seconds. Mike you?
Show quoteHide quote "Mike Williams" <M***@WhiskyAndCoke.com> wrote in message news:%23hdGzh7JGHA.584@tk2msftngp13.phx.gbl... > "James Ma" <Jame***@discussions.microsoft.com> wrote in message > news:B6E2088D-6F72-4209-8C87-3EB577D9C5ED@microsoft.com... > >> In VB6, I need to make a form appears and got focus every, say 15 >> seconds. > > Who are you trying to annoy? > > Mike > > try me.zorder
Show quoteHide quote "James Ma" <Jame***@discussions.microsoft.com> wrote in message news:B6E2088D-6F72-4209-8C87-3EB577D9C5ED@microsoft.com... > In VB6, I need to make a form appears and got focus every, say 15 seconds. > I > use code like following in the Timer event handler. But it doesn't appear > after it lost focus (only blinking on the task bar). Do you know how to > achieve the effect? Need to use Win32 API and WM_ACTIVATE? PostMessage or > SendMessage? > > Private Sub Timer1_Timer() > Me.Show ' Even this does not make it appear! > Me.SetFocus > End Sub > > Many thanks in advance. > James > Cool. The ForceFore also works but not as good as yours. Now I post my final
code to share with you. Private Sub Timer1_Timer() If Me.WindowState = vbMinimized Then Me.WindowState = vbNormal Me.ZOrder Me.SetFocus End Sub Thanks again. James Show quoteHide quote "Grant" wrote: > try me.zorder > > > > "James Ma" <Jame***@discussions.microsoft.com> wrote in message > news:B6E2088D-6F72-4209-8C87-3EB577D9C5ED@microsoft.com... > > In VB6, I need to make a form appears and got focus every, say 15 seconds. > > I > > use code like following in the Timer event handler. But it doesn't appear > > after it lost focus (only blinking on the task bar). Do you know how to > > achieve the effect? Need to use Win32 API and WM_ACTIVATE? PostMessage or > > SendMessage? > > > > Private Sub Timer1_Timer() > > Me.Show ' Even this does not make it appear! > > Me.SetFocus > > End Sub > > > > Many thanks in advance. > > James > > > > > James Ma wrote:
> Cool. The ForceFore also works but not as good as yours. Now I post Ah... I naturally assumed you had tried the native methods, and they> my final code to share with you. > > Private Sub Timer1_Timer() > If Me.WindowState = vbMinimized Then Me.WindowState = vbNormal > Me.ZOrder > Me.SetFocus > End Sub weren't working because your application didn't have focus at the time it attempted to steal it. Save ForceFore for times such as that.
Show quote
Hide quote
On Thu, 2 Feb 2006 10:10:41 -0800, "Karl E. Peterson" <k***@mvps.org> Surely the 'native' methods will not steal focus under XPwrote: >James Ma wrote: >> Cool. The ForceFore also works but not as good as yours. Now I post >> my final code to share with you. >> >> Private Sub Timer1_Timer() >> If Me.WindowState = vbMinimized Then Me.WindowState = vbNormal >> Me.ZOrder >> Me.SetFocus >> End Sub >Ah... I naturally assumed you had tried the native methods, and they >weren't working because your application didn't have focus at the time it >attempted to steal it. Save ForceFore for times such as that. - although they work under Win 9x J M must be using Win 9x (??) J French wrote:
Show quoteHide quote > On Thu, 2 Feb 2006 10:10:41 -0800, "Karl E. Peterson" <k***@mvps.org> SetForegroundWindow was actually redefined at the Windows98/2000 level,> wrote: > >> James Ma wrote: >>> Cool. The ForceFore also works but not as good as yours. Now I post >>> my final code to share with you. >>> >>> Private Sub Timer1_Timer() >>> If Me.WindowState = vbMinimized Then Me.WindowState = vbNormal >>> Me.ZOrder >>> Me.SetFocus >>> End Sub > >> Ah... I naturally assumed you had tried the native methods, and they >> weren't working because your application didn't have focus at the >> time it attempted to steal it. Save ForceFore for times such as >> that. > > Surely the 'native' methods will not steal focus under XP > - although they work under Win 9x so... > J M must be using Win 9x (??) That's one possibility (either NT4 or less, or Win95).http://vb.mvps.org/articles/ap199902.pdf Another is that some other window in his app/process has focus. Finally I find I have to use ForceFore.
You know what? Just now I tested the 3 methods (the ForceFore forks 2 methods) on several computers in my shop (winXP pros, Citrix on win2k, citrix on win2003), found only ForceFore can always work, but still a bit annoyed because it brings another 2 forms visible though not focused. But that is enough to solve my headache. So I decide to use ForceFore method finally. I guess that might be related to VB6SP6, since only I installed it on my machine. Thanks a lot to all of you. James Show quoteHide quote "Karl E. Peterson" wrote: > James Ma wrote: > > Cool. The ForceFore also works but not as good as yours. Now I post > > my final code to share with you. > > > > Private Sub Timer1_Timer() > > If Me.WindowState = vbMinimized Then Me.WindowState = vbNormal > > Me.ZOrder > > Me.SetFocus > > End Sub > > Ah... I naturally assumed you had tried the native methods, and they > weren't working because your application didn't have focus at the time it > attempted to steal it. Save ForceFore for times such as that. > -- > Working without a .NET? > http://classicvb.org/ > > > James Ma wrote:
> Finally I find I have to use ForceFore. So much for the Win95/NT4 theory! <g>> > You know what? Just now I tested the 3 methods (the ForceFore forks 2 > methods) on several computers in my shop (winXP pros, Citrix on > win2k, citrix on win2003), > found only ForceFore can always work, Just about. Not always. See http://vb.mvps.org/articles/ap199902.pdf forone more known exception. > still a bit annoyed because it brings another 2 forms visible though There must be a parent/child relation between them, then? That's not> not focused. "normal" behavior, but could be possible if that's the way your application is designed. > But that is enough to solve my headache. So I decide to The ability to push a window to the front was altered in Windows 98 and> use ForceFore method finally. I guess that might be related to > VB6SP6, since only I installed it on my machine. Windows 2000. VB really doesn't enter into the picture, unless you're seeing different results in the IDE versus an EXE. I built the ForceFore code and directly used the EXE to do the tests. So the
ForceFore form is fully seperated from the 2 forms that belong to another EXE. Show quoteHide quote "Karl E. Peterson" wrote: > > still a bit annoyed because it brings another 2 forms visible though > > not focused. > > There must be a parent/child relation between them, then? That's not > "normal" behavior, but could be possible if that's the way your application > is designed. > > The ability to push a window to the front was altered in Windows 98 and > Windows 2000. VB really doesn't enter into the picture, unless you're > seeing different results in the IDE versus an EXE. > -- James Ma wrote:
> I built the ForceFore code and directly used the EXE to do the tests. I honestly can't imagine why that may be. There's something else afoot.> So the ForceFore form is fully seperated from the 2 forms that belong > to another EXE. On Thu, 2 Feb 2006 11:05:57 -0800, "Karl E. Peterson" <k***@mvps.org> <snip>wrote: >The ability to push a window to the front was altered in Windows 98 and I'm sure there was a similar problem in NT before 1998>Windows 2000. VB really doesn't enter into the picture, unless you're >seeing different results in the IDE versus an EXE. Sadly my memory from 1996 is a little raddled .... JM must have owning or owned Forms being pushed up On Thu, 2 Feb 2006 10:56:17 -0800, "James Ma"
<Jame***@discussions.microsoft.com> wrote: >..., but still a bit annoyed I think you may be describing the "normal" (or abnormal depending on>because it brings another 2 forms visible though not focused. your POV) way VB links the zording of all top-level forms in an app. By default they're all "owned" by the non-visible "ThunderMain...whatever" class window, which links their z-order just like specifying the Ownerform arg with the Show statement. Same thing happens if you have multiple forms and click the taskbar button for one of them - they ~all~ get a zorder bump. However you can easily "fix" that behavior if you want by using the API to de-couple the ownership. Note this is for normal top-level forms, ~not~ MDI. 'declares.... Public Const GWL_HWNDPARENT = (-8) Public Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long 'usage... Private Sub Form_Load() SetWindowLong Me.hwnd, GWL_HWNDPARENT, 0 End Sub -Tom MVP - Visual Basic (please post replies to the newsgroup)
Do we have such a container control?
www Link in VB 6... Book for web dev with VS2005? Need help regarding the program... Please help me.. It's very Urgent missing reference Connection Recordset to FlexGrid Word find.selection on formatted text? Run-time error 3706 Monthview control - run time 380 invalid property value |
|||||||||||||||||||||||