mfc >> flashwindowex()

by UGF1bA » Sun, 30 Jan 2005 16:19:01 GMT

Hi,

I am implementing a single instance MFC app and am following the guide from
http://support.microsoft.com/default.aspx?scid=kb;en-us;243953. What I also
want to do is, whenever an instance of my app is already running, I want to
flash the window. Here is part of the code from InitInstance():

...
if (g_SingleInstanceObj.IsAnotherInstanceRunning())
{
AfxMessageBox(_T("An instance already running."));

FLASHWINFO fwi;
fwi.cbSize = sizeof(FLASHWINFO);
fwi.hwnd = /* How do I get a handle of the running instance? */
fwi.dwFlags = FLASHW_ALL;
fwi.uCount = 25;
fwi.dwTimeout = 0;

FlashWindowEx(&fwi);

return FALSE;
}
...

I know I can call "FindWindow()" to get the HWND of the running instance,
but I am kind of hate of passing the "title" of the window. Is there any
other way to get HWND of the running instance besides calling "FindWindow()"?

Please advice, thanks!
-P


mfc >> flashwindowex()

by Scott McPhillips [MVP] » Sun, 30 Jan 2005 22:09:35 GMT





You can use FindWindow() without being dependent on the window title.
Give your main window a unique window's class name instead. (This is a
Win32 concept, not a C++ class name.) To do this you register the class
name with AfxRegisterClass() and then associate the classname with your
window in the struct that is passed to CMainFrame::PrecreateWindow().

--
Scott McPhillips [VC++ MVP]




mfc >> flashwindowex()

by UGF1bA » Mon, 31 Jan 2005 04:17:02 GMT

I tried what you suggested but it didn't work. My MFC app is dialog-based,
by the way. Would your solution also work for dialog-based MFC app or
there'll be a different solution?








flashwindowex()

by UGF1bA » Mon, 31 Jan 2005 04:45:01 GMT


Similar Threads

1. FlashWindowEx API function

Hi All,

Following example not working in .NET which works in VB6.



Private Const FLASHW_STOP As Integer = 0

Private Const FLASHW_CAPTION As Integer = &H1

Private Const FLASHW_TRAY As Integer = &H2

Private Const FLASHW_ALL As Integer = (FLASHW_CAPTION Or FLASHW_TRAY)

Private Const FLASHW_TIMER As Integer = &H4

Private Const FLASHW_TIMERNOFG As Integer = &HC

Private FLASHW_FLAGS As Integer

Private Structure FLASHWINFO

Dim cbSize As Integer

Dim hwnd As IntPtr

Dim dwFlags As Integer

Dim uCount As Integer

Dim dwTimeout As Integer

End Structure

Private Declare Function FlashWindowEx Lib "user32" (ByVal pflashwininfo As
FLASHWINFO) As Integer



Private Sub FlashBegin()

Dim fwi As FLASHWINFO

With fwi

.cbSize = Marshal.SizeOf(fwi)

.hwnd = Me.Handle

.dwFlags = FLASHW_FLAGS Or FLASHW_TIMER

.dwTimeout = 0

.uCount = 0

End With

intRetVal = FlashWindowEx(fwi)

End Sub



Can anyone tell me where is the mistake.

No error occured during the procedure call.



Thanks

Regards

Sakharam Phapale




2. FlashWindowEx does not work with Windows Classic theme

3. Missing: FlashWindowEx Lib "user32" (Info As FlashWInfo) As BOOL

Private Declare Function FlashWindowEx Lib "user32"
(Info As FlashWInfo) As BOOL returns that I'm missing
Windows API (win.tlb ?) in my VB6 ????

I'm running Win2k sp4. The Apiload.exe (dated -98) don't
recognise it either? I use several other user32 module
Windows API functions constantly. Should I update
something or what's this ??????

thanks,
johannes



4. Detect HasFocus and stop FlashWindowEx

5. FlashWindowEx could not be located......huh????

Greetings earthlings!
Problem:
Director executable file (win NT) running on a CD
containing references to dynamically loaded .swf files (importFileInto
method)
generates the following error:

"the procedure entry point FlashWindowEX could not be located in the dynamic
link library user32.dll"

Of course, the dang file won't run.
Any ideas - it works everywhere I've tested except  a particular NT4 SOE

John Ryan
MM certified developer
Melbourne Australia


6. Video hides when resize/fullscreen switch executed -- Solution FlashWindowEx ?

7. Is there any way to get an MDI child window to flash, like with FlashWindowEx()?

With FlashWindowEx(), I can make dialogs flash (like yahoo chat and stuff
like that).  Is there any way to get an MDI child window to flash in the
same way?  FlashWindowEx() doesn't work on child windows...


8. How do I stop FlashWindowEx when me.handle gets focus? - .NET Windows Forms