Menu

'FLASHWINFO' undeclared

2008-01-08
2012-09-26
  • Murray Hogg

    Murray Hogg - 2008-01-08

    I've been following the zetcode.com winapi tutorial and am currently working through the code examples on the following page;

    http://zetcode.com/tutorials/winapi/firststeps/

    Under the heading "Flashing a window" there is a piece of code intended to put a flashing window on screen. Said code is giving me compile problems as specified below. Code was cut and pasted from the above page with one alteration; the original code read only "#include" in the first line (omitting <windows.h>) which I remedied.

    However, at compile time the compiler reports;

    error: 'FLASHWINFO' undeclared (first use this function).

    Now, I though #include <windows.h> should take care of this - although being a WinAPI newb leaves me short on confidence. I was unable to locate any information on this in the FAQs or forum. Any suggestions as to what may be causing the above error message would be appreciated.

    Code and Compile Log are replicated below -- the problematic declaration (line 31) is commented as such;

    //----------------------------------------------------------

    include <windows.h>

    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

    int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow )
    {
    MSG msg ;
    WNDCLASS wc = {0};
    wc.lpszClassName = TEXT( "Flash" );
    wc.hInstance = hInstance ;
    wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
    wc.lpfnWndProc = WndProc ;
    wc.hCursor = LoadCursor(0,IDC_ARROW);

    RegisterClass(&wc);
    CreateWindow( wc.lpszClassName, TEXT("Flash"),
    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
    100, 100, 250, 180, 0, 0, hInstance, 0);

    while( GetMessage(&msg, NULL, 0, 0)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return (int) msg.wParam;
    }

    LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
    {
    FLASHWINFO fwi; // LINE 31:THE PROBLEMATIC DECLARATION!!! :o

    switch(msg)
    {
    case WM_CREATE:
    CreateWindow(TEXT("Button"), TEXT("Flash"),
    WS_CHILD | WS_VISIBLE,
    10, 10, 80, 25,
    hwnd, (HMENU) 1, NULL, NULL);
    break;

      case WM_COMMAND:
    
          fwi.cbSize = sizeof(fwi);
          fwi.dwFlags = FLASHW_ALL;
          fwi.dwTimeout = 0;
          fwi.hwnd = hwnd;
          fwi.uCount = 4;
    
          FlashWindowEx(&amp;fwi);
          break;
    
      case WM_DESTROY:
          PostQuitMessage(0);
          break;
    

    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    //----------------------------------------------------------

    Compile log is as follows;

    Compiler: Default compiler
    Building Makefile: "C:\Dev-Cpp\Projects\Winapi_tute\03-The_window\Makefile.win"
    Executing make...
    make.exe -f "C:\Dev-Cpp\Projects\Winapi_tute\03-The_window\Makefile.win" all
    g++.exe -c 06-Flash.cpp -o 06-Flash.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/additional"

    06-Flash.cpp: In function LRESULT WndProc(HWND__*, UINT, WPARAM, LPARAM)': 06-Flash.cpp:31: error:FLASHWINFO' undeclared (first use this function)
    06-Flash.cpp:31: error: (Each undeclared identifier is reported only once for each function it appears in.)
    06-Flash.cpp:31: error: expected `;' before "fwi"

    06-Flash.cpp:44: error: fwi' undeclared (first use this function) 06-Flash.cpp:45: error:FLASHW_ALL' undeclared (first use this function)
    06-Flash.cpp:50: error: `FlashWindowEx' undeclared (first use this function)

    make.exe: *** [06-Flash.o] Error 1

    Execution terminated

    //----------------------------------------------------------

     
    • Murray Hogg

      Murray Hogg - 2008-01-08

      Thanks very much for this helpful reply, Clifford.

      Problem resolved with the addition of the suggested compile option.

       
    • cpns

      cpns - 2008-01-08

      According to the documentation ( http://msdn2.microsoft.com/en-us/library/ms679348(VS.85).aspx ) it is supported only in 2K/XP/Vista. The default compatibility mode for the MinGW Win32 API is Win95/NT4 I think. (I believe Microsoft now set the default to Win2K in their SDK ).

      If you took a look in winuser.h you will see that the type is defined within conditional compilation.

      Add -DWINVER=0x0500 to your compile options to set the minimum to WIn2K. See: http://msdn2.microsoft.com/en-us/library/aa383745.aspx for details of the version macros. To ensure compatibility with all headers you may want to set NTDDI_VERSION, _WIN32_WINNT, _WIN32_IE (although I don't think the MinGW WIn32API uses NTDDI_VERSION currently, but for future compatibility you may still want to set it.).

      Note that doing this means your code will not run on Windows versions prior to XP.

      A note for next time: Solving this was a simple case of checking the documention or performing a text search of the headers to determine where it is defined and noting the conditional compilation.

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.