Thread: AnimateWindow && Dev-C++ problems

  1. #1
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378

    AnimateWindow && Dev-C++ problems

    So i'm trying to use the AnimateWindow() function to animate a static control i have, but the compiler is spouting out errors like thats its job. ^_^ i've downloaded the v3.6 win api from devpaks.org and i've linked libuser32.a to my project, but it still acts like it doesn't know what i'm talking about. my code is:
    Code:
    case ID_BUTTON1:
                     {
                          AnimateWindow(GetDlgItem(hwnd, ID_LEFT), 1000, AW_SLIDE | AW_VER_POSITIVE);
                     }
                     break;
    and the errors are
    main.c: In function `WndProc':

    main.c:153: error: `AW_SLIDE' undeclared (first use in this function)
    main.c:153: error: (Each undeclared identifier is reported only once
    main.c:153: error: for each function it appears in.)
    main.c:153: error: `AW_VER_POSITIVE' undeclared (first use in this function)
    also, i found a post that had a similar problem on the board and they defined the functions and such so i copied this code:
    Code:
    #define AW_HOR_POSITIVE 0x00000001 
    #define AW_HOR_NEGATIVE 0x00000002 
    #define AW_VER_POSITIVE 0x00000004 
    #define AW_VER_NEGATIVE 0x00000008 
    #define AW_SLIDE 0x00040000 
    
    typedef BOOL (WINAPI *lpfnAnimateWindow)(HWND hwnd, DWORD dwTime, DWORD dwFlags); 
    lpfnAnimateWindow AnimateWindow;
    and then it compiled just fine, but if i try to run it it crashes when i press the button.


    ideas? thanks
    Last edited by willc0de4food; 03-13-2006 at 03:19 AM.
    Registered Linux User #380033. Be counted: http://counter.li.org

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>i've downloaded the v3.6 win api<<

    Good.

    >>a similar problem on the board and they defined the functions<<

    Almost there. If you open up winuser.h and see how those are defined, you'll see they are defined within a preprocessor conditional block (WINVER as the condition), so to use them you need to #define WINVER 0x0500 (at least - see Using the Windows Headers) for your project.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    weird...i tried defining winver in my program and it said it was already defined in winuser.h, but it was defined as 0x0400 so i just changed the 4 to a 5 and it compiles. however, it doesn't animate the window. i created the controls and load the images in them in the WM_CREATE case
    Code:
    bRpsLR[0] = (HBITMAP)LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(RPS_LEFT), IMAGE_BITMAP, 200, 150, 0);
    bRpsLR[1] = (HBITMAP)LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(RPS_RIGHT), IMAGE_BITMAP, 200, 150, 0);
    for (i = 0; i < 2; i++)
    {
        SendMessage(GetDlgItem(hwnd, i+407), STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)bRpsLR[i]);
    }
    and that works. and when i check GetLastError() it tells me "AnimateWindow failed with error 0: The operation completed successfully." so i'm thinking i'm not doing something right..? lol

    thanks :]



    // i just tried changing my AW_SLIDE | AW_VER_POSITIVE to AW_HIDE | AW_CENTER and that worked. what i want it to do is even though the control is already there, i'd like it to go away and then slide in from the top. ? lol
    Last edited by willc0de4food; 03-13-2006 at 11:13 AM.
    Registered Linux User #380033. Be counted: http://counter.li.org

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>it said it was already defined<<

    You're getting an error about it already being defined because you're probably attempting to define it after winuser.h is #included rather than before. It's always a much better idea to define such macros on a per project basis rather than just shoving in a #define somewhere in your code where you think it might be appropriate.

    To do this with dev-cpp go into project options-->parameters and set the macro in the compiler field with the -D switch, eg.
    Code:
    -DWINVER=0x0500
    If you still get the error about its prior definition (I doubt you will, though) then you can undefine it first with the -U switch.

    >>so i just changed the 4 to a 5<<

    This is a very bad idea - you shouldn't go changing stuff in these headers unless you've identified a bug and intend to submit a patch which I am reasonably certain won't be the case here. If you absolutely must make changes then at least keep a copy of the original so you can restore it/use it if need be.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    sweet.

    i undid the change i made in my winuser.h file and added the parameter to the compiler and it compiles. thanks for the help
    Registered Linux User #380033. Be counted: http://counter.li.org

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. Programming With Dev C++
    By v01d in forum C++ Programming
    Replies: 3
    Last Post: 09-14-2007, 01:51 AM
  3. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  4. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 05:48 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM