Im noob in API, can u show me....

Im new in API using, and i have the program which opens a window page. I want to know how to make its background, special, an animated one...
this is where i am with the program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <windows.h>

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "Fereastra Raul.";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Fereastra Raul",    /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}


I would be so happy if u can modify my code and add the things needed please (i dont know the syntax and even if u tell me the syntax i dont know where to place it in program. PLEASE can u solve my problem ?)
nope...
if u cant help a dream come true, PLEASE dont make it worse Incubbus !?!
ur answer is like as a 8 yrs old kid one. and let me tell u tht a guy from general C++ gave me the syntax and he isnt good in API.
1) U are posting in windows on forum if u can solve some1s problem if u cant than PLEASE DONT POST!?!
2) I see tht the people on Windows are not so SMART as people in GENERAL C++, so ill ask again there.

P.S.: Incubbus, i really think that only thing you can do is say NOPE to every question which is VERY RUDE from some1.
cout<<"You are most rude person ive ever seen"
As mentioned in this thread: http://cplusplus.com/forum/general/28932/


- create a timer with CreateTimer
- the timer will genereate WM_TIMER messages
- when you receive a WM_TIMER message, update your background.

http://msdn.microsoft.com/en-us/library/ms644906(VS.85).aspx <--- CreateTimer.

For example:

1
2
3
4
5
6
7
// after your window is created:
CreateTimer( wnd, 1, 1000, 0 );
  // where 'wnd' is your HWND to your window
  // where '1' is a non-zero ID for this timer
  // where '1000' is the number of milliseconds the timer lasts
   //  (this timer will send WM_TIMER messages every second)
  // and '0' is unimportant (it's related to a callback system, but don't worry about it) 


Then you just catch WM_TIMER messages:

1
2
3
4
5
6
switch(message)
{
  case WM_TIMER:
    // this code will run every second
    //  update your background here
}



Of course updating the background / drawing is another topic entirely.
Of course, I can solve this problem... But YOU does not seem to have the motivation to do it on your own... and as You mentioned here:

jumper wrote:
I would be so happy if u can modify my code and add the things needed please (i dont know the syntax and even if u tell me the syntax i dont know where to place it in program. PLEASE can u solve my problem ?)


You are not willing to do anything to solve the problem...
So yes... it´s fun to make it worse, then ^-^...
I completely agree with Incubbus when I see posts like yours Jumper007. Before there were any replies I was about to answer that with all your 'please helps' if you wanted to learn how to do it you ought to spend about six months burried in one of Charles Petzold's "Programming Windows" books. After that, you wouldn't be in the dark as to where to put stuff...

 
i dont know the syntax and even if u tell me the syntax i dont know where to place it in program


i CANNOT do anything more as this code is not made by me!?! The code was generated by the C++ program, and i modifyed 2 things in it so i DONT KNOW ALMOST NOTHING about API or Windows Programming so im trying to learn... >.< !?!
This tutorial may help you:
http://www.winprog.org/tutorial/
ok, as i can see i wont be able to use windows programming soon... >.<
ill go back to usuall C++ programming.
goodbye. (i cant understand almost nothing from the syntax ... P.S.: im 15!?!)


--------------
Null, thx, really apreciated. :)
Last edited on
P.S.: im 15!?!
???... many people younget than you are more successfull than a lot of us^^...
@null: everybody like to use that link as a reference but for vc++ it doesn't work. and as far as i know, that's for c not c++
and as far as i know, that's for c not c++

Thats because WinAPI was written in C.

everybody like to use that link as a reference but for vc++ it doesn't work

What exactly doesn't work? You can't compile the code or something else?

You can also try one of these tutorials:
http://zetcode.com/tutorials/winapi/
http://msdn.microsoft.com/en-us/library/ff381399(v=VS.85).aspx
1
2
@Incubbus:
???... many people younget than you are more successfull than a lot of us^^...


Mate in my country we start studying computer sience at the age of 15. So as im in my first month of using C++, i think im better than the kids which are "younger and better". Got 2 words for ya: Suck IT!
oh.. yea i almost fogot>>
1
2
cout<<"I DONT GIVE 2 SHITS ON THOSE KIDS !?! (WHOEVER THEY ARE !?!)"
cout<<"..., yeah i said all what i tought it is ok, after u call me noob and say that u know better younger kids. OK IN MY COUNTRY AT THE AGE OF 15 IS FIRST AGE OF STUDYING COMPUTER SIENCE !?! SO GTFO!"
@jumper: i wanna suggest something for you. in order to get yourself better, you can't think in emotional way. what the other people said is actually a positive suggestion. for your own good, man... this is a discussion and not, somekinda, rubbish talk. we have to think ourself a calm-er ways. for short, this attitude will NOT solve anything, man. calm yourself and think wisely. what they're talking about 15 year old or younger is actually because they have a will to learn... a simple words, a will to learn. we all learning here, dude.

@null: yeah, it doesn't compile... (vc++ 08)
ok, im ok... now....
You could also create a separate thread, but that will increase overhead.
closed account (D80DSL3A)
What would you be using for the animation frames? Bitmap images?
If so, have you had any luck yet in getting any bitmap image drawn? This would be the 1st step.
Once you have this then you could use WM_TIMER messages, as explained by Disch above, to cycle through an array of bitmap images to produce the animation effect.
I would be happy to help you further with this, if that's what you are trying to do.

Note. The example given CreateTimer( wnd, 1, 1000, 0 ); would result in a timer message being placed on your programs message queue once per second.
This:CreateTimer( wnd, 1, 40, 0 ); would trigger timer messages every 40 milliseconds, giving a frame rate of 25 frames/second.
Last edited on
lol guys ... he thinks he's pro using cout << to give comebacks.

You can also get an API animation example from Google if you even botherd to look, this is a help forum not a 'doitformepl0xmanythx'.
Last edited on
Load the images into an array (probably HBITMAPs). Then, in each iteration of the timer, increment a counter & paint the corresponding image.
Topic archived. No new replies allowed.