|
I want to animate an object(lets say a square that continualy rotates around)
and then able to select it and drag it to a differnt posistion with a mouse/keyboard
I have a very basic understanding of mfc, my guess to go about this
is to use a loop in the ondraw section with the settimer function
but I get a bit confused on how the mouse/keyboard listner will be implemented
would anybody be kind enough on giving me a quick explaination or soloution to the above mentioned.
thank you
Simon
Simon
-- modified at 18:11 Tuesday 6th November, 2007
|
|
|
|
|
Simon, why did you cross post this into the Vista forum?
Don't you think books and articles on the internet are available that discuss and provide examples of animation? Probably even some on this site.
|
|
|
|
|
led mike wrote: Simon, why did you cross post this into the Vista forum?
Probably he wants his animation Vista compatible?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
For animate an object MSDN has an article that I think its helpful for you I think its name was Cube.
|
|
|
|
|
And to Drag-Drop a way to do it is:
1) When MouseDown save the point of the click and set a bool variable i.e. bAllowMoving to TRUE
2) OnMouseMove, ask bAllowMoving, if TRUE, update the saved point with the actual coordinates
3) When MouseUp, if the bAllowMoving is TRUE, get the last point of the click-release, move your object to that point, erase background and update window/view. And reset the bAllowMoving.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
NickYan wrote: i need to get those 2 separate codes into one source code...
What in the world does this mean?
NickYan wrote: ...which will ask the user to either convert from binary to decimal vice versa
You've coded all of this, yet you cannot figure out how to ask a question and call a different function depending on the answer.
printf("Convert to (b)in or (d)ecimal? ");
char c;
scanf("%c", &c);
if ('b' == c)
bintodec();
else if ('d' == c)
dectobin();
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: You've coded all of this, yet you cannot figure out how to ask a question and call a different function depending on the answer.
You seem surprised?
|
|
|
|
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int tobase=0;
int number =0;
int counter = 0;
int bin [25];
int quo = 1;
printf("Enter your number:");
scanf("%d",&number);
printf("Enter base to convert to: ");
scanf("%d",&tobase);
while (quo!= 0)
{
quo= number/tobase;
bin[counter] = number%tobase;
counter ++;
number=quo;
}
while (counter > 0)
{
printf( "%d", bin[counter-1]);
counter --;
}
system("PAUSE");
return 0;
}
how to make this code into a function?
|
|
|
|
|
i have tried to come up with my own way of having a code but its not working ...corect it please .
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* Function Prototypes */
int bintodec(int fmbase, int num);
int dectobin(int tobase, int num);
int main()
{
int num;
int fmbase;
int tobase;
int result;
int convert;
int counter = 0;
int bin [25];
int quo = 1;
printf("Enter 0 to convert to binary\n");
printf("Enter 1 to convert to decimal\n");
scanf("%d",&convert);
printf("Enter the value to be converted:");
scanf("%d",&num);
printf("Enter base to be converted from: ");
scanf("%d",&fmbase);
printf("Enter base to be converted to: ");
scanf("%d",&tobase);
if(convert ==0)
convert= dectobin();
else if (convert ==1)
convert= bintodec();
else
{
printf("Error in Input");
exit(1);
}
result = bintodec(fmbase,num);
printf("The result is:%d", result);
result = dectobin(tobase,num);
printf("The result is:%d", result);
int dectobin( int tobase, int num)
do (quo!= 0)
{
quo= num/tobase;
bin[counter] = num%tobase;
counter ++;
num=quo;
}
while (counter > 0)
{
printf( "%d", bin[counter-1]);
counter --;
}
int bintodec(int fmbase, int num)
{
int bin[256];
int counter ;
int counterR ;
int quo ;
int result =0;
int result1 =0;
int res[256];
int sum =0;
if(quo>0)
{
quo= num/10;
bin[counter] = num%10;
num=quo;
counter++;
}
while (counter>0)
{
result = pow(fmbase, (counter-1));
result1=result*bin[counter-1];
res[counterR]=result1;
counter--;
counterR++;
}
while (counterR > 0)
{
sum = sum + res[counterR-1];
counterR--;
}
return sum;
}
system("PAUSE");
return 0;
|
|
|
|
|
NickYan wrote: corect it please
ok
Correct it please.
|
|
|
|
|
NickYan wrote: how to make this code into a function?
Other than the function it already is in? Apply some logic here, Nick.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i know that i can do it but i need to write up a report with a set of headings in the assignment not only to get the code working and time is short 1 more day till its due
|
|
|
|
|
NickYan wrote: ...time is short 1 more day till its due
Good luck.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
thanks but you guys are suppose to help even if it is a little at least not only give advice .........
|
|
|
|
|
NickYan wrote: you guys are suppose to help
Helping you and doing it for you are two different things.
Why can you put together two functions, but not a third? That makes no sense, unless you've been sleeping in class.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
In dialog box if we have tab control we can have many pages. How to exchange message from one page to another?
|
|
|
|
|
The values should belong to the dialog and passed to each page. in each page you update the values in the dialog.
|
|
|
|
|
Thank you for your reply.
Could you explain more clear?
Supposed in page1 user input a number x=5, how to transfer it to page2?
|
|
|
|
|
|
|
Thank you very much, PJ Arends and Maximmilien.
I'll study it. Thanks.
|
|
|
|
|
How to attach source code?
My question can't say clear without source code.
|
|
|
|
|
I still have some questions.
|
|
|
|
|
Use the tags under the input text field hen you are posting.
this is "code" tag, used to highlight something
this is "pre", used to limite code snippets
you have less problems with lines length
and so on.
But please try to put code snippets, not whole sections of your programm
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
One possibility is to use the document. I think the MFC Document/View architecture is desiged such that you can use the document as a common place to hold the data. There might be times when the document needs to get data from the view, such as when the data is being saved, and that is possible but a little more complicated than you might hope. What you can do is that very time the page is changed, the old page could update the document and the new page can refresh the data from the document. I hope you understand.
|
|
|
|