1. Since I don't know DirectX or OpenGL or other graphics libraries (I'm not the GUI guy), I can only tell you that you could do this by blitting and applying world transformations. The topic is not trivial and I am not going to post the entire code to do it here, so it is up to you to google the topics out, unless others feel they can and are willing to write the code for you or maybe they know a good graphics library that can do it nice and simple for you in a few lines of code.
2. That is a custom window, most likely. You create a custom control by registering a window class with RegisterClassEx(). The call requires that you provide a window procedure; it is this window procedure the one in charge of drawing the control whenever the WM_PAINT message is received.
If the above is over your head, I recommend that you study the basics of Windows Programming. The one book I wholeheartedly recommend is Programming Windows, 5th edition by Charles Petzold. After reading this massive book, read about GDI+.
1. How you do it depends on what you're using. Doing it via hardware acceleration is extremely efficient, but the resulting code is very complex. Doing it in software with transformation matrices is much simpler, and still fairly efficient. I have some code I could show you that does this but it wasn't really meant for mortals to see.
#1 I'm not making game or any graphic application, I'm making simple chat program and I wanna make something to tell user that program is getting info from database, something like progressbar, does I need to use DirectX or OpenGL anyway? or I can draw image from file or something and then rotate it?
#2 well, and how can I make it change image when my mouse is over it/when I click on it? and how to add function when I click on "custom window" ? can u show me some example?
edit: maybe I can use WM_RBUTTONDOWN but I;m not sure :P
well, my english is not that good to start learning from english books, I'm currently learning from some books in my language, but I'm not sure there are that things I want to do
@helios
I really have no idea what do u mean with that hardware/software programming, I'm just learning win32 API, and telling me things like that makes me just more confused because I'm programming for about 3-4 months and with API i'm working for about 3/4 of month right now
I wanna make something to tell user that program is getting info from database
In that case, simply load several bitmaps and display them one at a time, forming an animation.
I really have no idea what do u mean with that hardware/software programming, I'm just learning win32 API, and telling me things like that makes me just more confused because I'm programming for about 3-4 months and with API i'm working for about 3/4 of month right now
You can draw using the BitBlt() function and world transformations that rotate the viewport. You can repeat this operation using a timer to create the illusion of movement (an animation). Will I be showing code? No, sorry. No time for this and it is not the simplest anyway.
If I remember correctly, there is no native "mouse over" window message, is there? I remember that the common controls library introduced this with the look and feel of Office 97, and to receive this non-stock window message requires a call to the common control library. Or am I off here? (Experts out there please comment).
As for programming the button's functionality, you can use WM_LBUTTONDOWN and WM_LBUTTONUP messages to initiate action. The rule is: A WM_LBUTTONUP message triggers action only if there was a corresponding WM_LBUTTONDOWN. This disallows incorrect action triggering when you do the mouse down outside the button and then the mouse up inside the button.
What helios meant: You did not post in the beginners forum, so we the experts assumed you knew about this particular topic (software programming versus hardware programming). He is not saying that you need to post there, he is saying that we (the experts) assume certain things when you post outside the beginners forum.
No, it shouldn't slow down your application much if you program the right way: Multithreaded. While your UI thread is animating the application with the bitmaps, another thread, the worker thread, is obtaining data from the database.
If this is over your head, then I'm sorry to say you probably won't have much success at all in your endeavor because you cannot have the animation AND the data fetched at the same time without multiple threads.
so I'll load 1 of 5 images every 0.5sec? won't it drastically slow an application?
Even if you were to actually load the bitmap, display it, and free it every frame, this shouldn't take longer than a few milliseconds. I don't think it would be much slower than computing actual rotations in software.
However, it's much faster to load all five bitmaps in one go and display them as necessary. The other way wouldn't make sense unless you were really hurting for memory, which you aren't.
When you get your image, perform all the transformations on it -- software will do fine -- and cache the results, so that you have N images which, if displayed in sequence, perform the rotation animation.
You'll probably want to use a Timer to generate events to tell your window to update the image currently displayed (and hence, the current amount of "rotation").
Threads are required, Duoas. If the UI thread runs the data-fetching code, no animations will be processed because the WM_TIMER message won't be pumped. The animation will therefore freeze until the data-fetching code finishes. A new thread MUST be used if you want a smooth animation while the data is being obtained.
It can still be done without threads if the database code can be structured to give control back to the event loop occasionally. Threads tend to get messy when combined with GUI code.
I beg to differ: Code become messy when you combine with UI code. No separation. A worker thread is rather simple if done right, and a simple window message can be posted from it to the UI thread to signal completion. UI threads pump messages, so a user-defined message is the most natural and unintrusive way of communicating with a UI thread.
But I guess it all comes down to the coder's skill. Although I clearly prefer a separate thread, I acknowledge helios' approach is also possible.