Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: Window Blink/Flash

  1. #1
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Window Blink/Flash

    does anyone have any idea on how to get your window to blink or flash on the startmenu just like when people message you on MSN or AIM??

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    Yes, but only on Windows:

    Qt Code:
    1. #include <Windows.h>
    2. ...
    3. FLASHWINFO finfo;
    4. finfo.cbSize = sizeof( FLASHWINFO );
    5. finfo.hwnd = this->winId();
    6. finfo.uCount = 20; // Flash 20 times
    7. finfo.dwTimeout = 400; // Duration in milliseconds between flashes
    8. finfo.dwFlags = FLASHW_TRAY; //Flash only taskbar button
    9. ::FlashWindowEx( &finfo );
    To copy to clipboard, switch view to plain text mode 

    Here, "this" is a QMainWindow derivate, so winId will work. It won't work on a regular widget so be careful to call FlashWindowEx from the main window only.

    I believe this can also be done on Mac. The result will be the app icon bouncing in the dock. I don't know how yet...

    On how many platforms do you plan to run your app?

    Regards

  3. The following user says thank you to marcel for this useful post:

    VireX (14th April 2007)

  4. #3
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Window Blink/Flash

    Thanks, I'll see if this works, I been looking for that struct in MSDN docs. Hard to find :S...
    Although MAc and Linux may be an idea for way later its the last thing on my mind.

  5. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    On Mac:

    Qt Code:
    1. #include <Notification.h>
    2. ...
    3. NMRecPtr notifRequestData = new NMRecPtr;
    4. notifRequestData->nmMark = 1; //Make the app icon bounce
    5. notifRequestData->nmIcon = NULL;
    6. notifRequestData->nmSound = NULL;
    7. notifRequestData->nmStr = NULL;
    8. notifRequestData->nmResp = NULL;
    9.  
    10. NMInstall( notifRequestData );
    To copy to clipboard, switch view to plain text mode 


    Make sure to use NMRemove when you're done using the NMRecPtr and delete it.

    Note that you have to do this separately for Mac and Win because Qt does not have support for user notification.

    Regards.

  6. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    Quote Originally Posted by VireX View Post
    Thanks, I'll see if this works, I been looking for that struct in MSDN docs. Hard to find :S...
    Although MAc and Linux may be an idea for way later its the last thing on my mind.
    It works, I just tested it!

  7. #6
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Window Blink/Flash

    No It doesn't work, because including windows.h not only causes many compiler errors in my project, but for some reason, windows.h does not recognize FLASHWINFO... It's quite weird. It's in MSDN so I don't see why it isn't working.

  8. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    Could you show me your #include section?
    I tested it here and it works.

  9. #8
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Window Blink/Flash

    This is quite awkward. Is FLASHWINFO new or something?
    Because my compiler does NOT recognize FLASHWINFO (even on a plain Win32 API project), meaning that it probably is not defined in my windows.h

    Could it be because I use Dev-Cpp with mingw?

  10. #9
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    FlashWindowEx and FLASHWINFO are in Winuser.h, which is included by Windows.h.

    Compiler errors caused by header inclusion order can be solved quite easy...

  11. #10
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    Quote Originally Posted by VireX View Post
    This is quite awkward. Is FLASHWINFO new or something?
    Because my compiler does NOT recognize FLASHWINFO (even on a plain Win32 API project), meaning that it probably is not defined in my windows.h

    Could it be because I use Dev-Cpp with mingw?
    I am not that familiar with mingw. Try looking for Winuser.h and see if they are defined there. If they are, then just include Winuser.h.

    I guess it worked for be because I'm using VS 2003.

  12. #11
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Window Blink/Flash

    Qt 4.3 introduces QApplication::alert().
    J-P Nurmi

  13. #12
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    Quote Originally Posted by jpn View Post
    Qt 4.3 introduces QApplication::alert().
    If VireX wants to use it, no problem here...

  14. #13
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Window Blink/Flash

    Well thats pretty obvious. #include <windows.h>, thats my only include, and it WOULD work if it was truly defined in winuser.h, and since it is a simple plain Win32 project, there is no mistake or mixup with Qt. It's definitely a problem with my windows.h or Dev-C++ in general. Either that or FLASHWINFO doesn't exist.

    Qt 4.3 is not out yet. The only download is qt-win-opensrc... it's not the mingw version so I cannot get it to work.
    Last edited by VireX; 14th April 2007 at 08:45.

  15. #14
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    Have you included the windows api src in your mingw install?
    I just downloaded it from http://prdownloads.sf.net/mingw/w32a...ar.gz?download

    I can find in there both windows.h and winuser.h and FlashWindowEx is defined in winuser.h.

    Maybe your mingw install is not OK.

    Edit:
    Dev-c++ should have an include path option. Make sure the path for the windows api is added there.

    Regards.
    Last edited by marcel; 14th April 2007 at 09:03.

  16. #15
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Window Blink/Flash

    My winuser.h has FLASHWINFO defined, and it is included.
    If it wasn't included I would have more errors than just FLASHWINFO.

    Compiler errors:

    g++.exe -c flashtest.cpp -o flashtest.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include"

    flashtest.cpp: In function `LRESULT WindowProcedure(HWND__*, UINT, WPARAM, LPARAM)':
    flashtest.cpp:90: error: `FLASHWINFO' undeclared (first use this function)
    flashtest.cpp:90: error: (Each undeclared identifier is reported only once for each function it appears in.)

    flashtest.cpp:90: error: expected `;' before "finfo"
    flashtest.cpp:91: error: `finfo' undeclared (first use this function)
    flashtest.cpp:92: error: invalid use of `this' in non-member function
    flashtest.cpp:95: error: `FLASHW_ALL' undeclared (first use this function)

    flashtest.cpp:95: error: `FLASHW_TIMERNOFG' undeclared (first use this function)
    flashtest.cpp:96: error: `FlashWindowEx' undeclared (first use this function)

    make.exe: *** [flashtest.o] Error 1

    Qt Code:
    1. case IDBUTTON:{
    2. Sleep(1000);
    3. MessageBox(hwnd, (LPCTSTR)"test!", (LPCTSTR)"test!", MB_OK|MB_ICONEXCLAMATION);
    4. FLASHWINFO finfo;
    5. finfo.cbSize = sizeof( FLASHWINFO );
    6. finfo.hwnd = hwnd;
    7. finfo.uCount = 20; // Flash 20 times
    8. finfo.dwTimeout = 400; // Duration in milliseconds between flashes
    9. finfo.dwFlags = FLASHW_ALL|FLASHW_TIMERNOFG; //Flash only taskbar button
    10. FlashWindowEx( &finfo );
    11. break;
    12. }
    To copy to clipboard, switch view to plain text mode 

    Oh btw you guys should rly consider removing the line number from geshi filter, annoying...

    But this error, look how ridiculous this is:
    #include <winuser.h>
    MOUSEMOVEPOINT mmp;
    Last edited by VireX; 14th April 2007 at 17:26.

  17. #16
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Window Blink/Flash

    I got it to work when using:
    #define _WIN32_WINNT 0x0501
    #define WINVER 0x0501

  18. #17
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    Nice... I wasn't sure where the error came from...

  19. #18
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Window Blink/Flash

    Tried to develop some sort of efficient way to do this:
    Because FLASHWINFO only works if WINNT is greater than 0x0500! Meaning its an XP/2k-Only feature... Therefore, I had to get the version info. Which works fine, but FLASHWINFO still says "undeclared first use this function". Quite odd... any other ideas?

    Qt Code:
    1. #include <windows.h>
    2. int GetWinXP(){
    3. OSVERSIONINFO osVer;
    4. int xp = 0;
    5. osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    6. if(GetVersionEx(&osVer) != 0){
    7. if(osVer.dwPlatformId == VER_PLATFORM_WIN32_NT){
    8. xp = 1;
    9. }
    10. }
    11. return xp;
    12. }
    13. void CLobby::SendMsg(){ // A SLOT()
    14. QString qsMsg;
    15. // do some Qt Stuff
    16. MsgSend->clear();
    17. if(GetWinXP() == 1){
    18. #undef _WIN32_WINNT
    19. #undef WINVER
    20. #define _WIN32_WINNT 0x0501
    21. #define WINVER 0x0501
    22. #include <winuser.h>
    23. FLASHWINFO finfo;
    24. finfo.cbSize = sizeof( FLASHWINFO );
    25. finfo.hwnd = this->winId();
    26. finfo.uCount = 20; // Flash 20 times
    27. finfo.dwTimeout = 400; // Duration in milliseconds between flashes
    28. finfo.dwFlags = 1|2|12; //Flash only taskbar button
    29. FlashWindowEx( &finfo );
    30. }
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 

  20. #19
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window Blink/Flash

    Maybe because Windows.h includes winuser.h before you def and undef the windows versions.

    What version of windows do you have?

    Regards.

  21. #20
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Window Blink/Flash

    WinXP of course the best windows.

Similar Threads

  1. Independant window in an application
    By titoo in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2007, 11:07
  2. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  3. Replies: 3
    Last Post: 23rd July 2006, 18:02
  4. Move window in Clone Mode
    By ultrabrite in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 18:22
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.