Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Prevent window caption blinking on activation

Posted on 2003-11-23
7
Medium Priority
?
513 Views
Last Modified: 2007-12-19
I have an icon in system tray.
Double click on that icon fires an event in which I'm using me.show to make the window appear.
But when it appears, its not activated like the caption is grayed out and it blinks 3 times unless I click on it.
AppActivate solves the problem but I can't use it since I have multiple instances of my program running at the same time and they all have same caption while appactivate works on caption title so I want an alternate.

Note: setactivewindow, setforegroundwindow, setdesktopwindow, me.setfocus e.t.c nothing works.
0
Comment
Question by:Hasan_Khan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:ambientnet
ID: 9808411
Hasan,

This might work (if not, plz let me know):

''bas code:
Public Declare Function SetFocusAPI Lib "user32.dll" Alias "SetFocus" (ByVal hWnd As Long) As Long

''form code:

Dim retval As Long  ' return value
' Give your form's hWnd focus
retval = SetFocusAPI(me.hWnd)


If you have flashing problems, try this, too:

''bas code

Private Type FLASHWINFO
  cbSize As Long
  Hwnd As Long
  dwFlags As Long
  uCount As Long
  dwTimeout As Long
End Type

Private Const FLASHW_STOP = 0

Private Declare Function FlashWindowEx Lib "user32" _
   (FWInfo As FLASHWINFO) As Boolean

''form code:

Dim bRet As Boolean
Dim udtFWInfo As FLASHWINFO

Dim Hwnd as Long, Dim uCount As Long

hWnd = me.hWnd
uCount = 1

With udtFWInfo
   .cbSize = 20
   .Hwnd = hWnd
   .dwFlags = FLASHW_TRAY
   .uCount = uCount 'flash window x times
   .dwTimeout = 0
End With

bRet = FlashWindowEx(udtFWInfo)

~    http://www.freevbcode.com/ShowCode.Asp?ID=1447


hope this helps...

-m
0
 

Author Comment

by:Hasan_Khan
ID: 9808895
It doesn't blink anymore but still it ain't activated.
0
 

Author Comment

by:Hasan_Khan
ID: 9810237
I've found a perfect solution to the problem.
I temporarily add few white spaces at the end of the caption.
Do the AppActivate on it and then change it back.

Nothing else works for me.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:ambientnet
ID: 9811311
Hasan:

''bas
Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long

''form
SetForegroundWindow me.hWnd

may work...

-m
0
 
LVL 1

Expert Comment

by:ambientnet
ID: 9811318
Hasan:
     Ack, you've already tried that... nm... Perhaps use SetForegroundWindow in combination with the remove blinking code? I'm out of ideas.. :)

-m
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 9811407
Question closed and points refunded

PashaMod
CS Moderator
0
 

Author Comment

by:Hasan_Khan
ID: 9812986
ambientnet I've tried all the combinations with all the APIs but the problem got solved only by the way I mentioned above.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question