WinSail has added the animation control CAnimalCtrl, which can currently only play GIF files.
(1) The class definition is in the header file "MyFrame.h".
(2) The document name is: "Interface Control Class _CAnimalCtrl Animation Control Detailed Design.doc".
(3) Applying this control is very simple, generally only three lines of code are needed
// Allocate instance
CAnimalCtrl* pAnimalCtrl1 = new CAnimalCtrl(pDialog);
// Create control
pAnimalCtrl1->CreateObject(100, 100, 50, 50, NULL);
// Load GIF file
pAnimalCtrl1->LoadFile("Bmp\\Earth3.Gif");
After downloading WinSail and extracting it, run the Sai2000 program in sail3000. You can see a
rotating Earth in the upper right corner of the desktop.
It is recommended to adjust WinSail to 256 colors or "16 bits = 64K colors", at this time the color of the animation control is the most realistic.
Note: After using the animation control CAnimalCtrl, the Exe file increases by about 7K of code.
7 Example
#include <bios.h>
#include <Stdio.h>
#include <Stdlib.h>
#include <conio.h>
#include <dos.h>
#include <String.h>
#include <math.h>
#include <Symbol.H>
#include <MyFrame.h>
#include <gif.h>
#include <Lzw.h>
int far TransrateKey(CObject *)
{
return(0);
}
unsigned _stklen = 60u * 1024u;
// A callback function corresponding to a button in the animation control demonstration function
void far ClickButton1_DemoAnimalCtrl(CObject *pObj)
{
// Get the pointer to the parent window corresponding to the animation control
CDialog* pDialog = (CDialog *)pObj->GetParent();
// Get the pointer to the animation control
CAnimalCtrl* pAnimalCtrl = (CAnimalCtrl *)
pDialog->ObjectFromID(ANIMALBASE + 1 - 1);
// Select a new GIF file
char bufFile;
if (!AfxOpenFileDialog(TRUE, bufFile, NULL))
{
return;
}
// Load the new GIF file
pAnimalCtrl->LoadFile(bufFile);
// Since the size of each animation is different, the window must be refreshed again
pDialog->ShowWindow();
return;
}
// Animation control demonstration function
void far Demo_AnimalCtrl()
{
// Allocate dialog instance
CDialog* pDialog = new CDialog;
// Create dialog
pDialog->CreateWindow(0,0,640,480,"Animation Control Demonstration Program");
// Center the window
pDialog->Center();
// Allocate instance of animation control
CAnimalCtrl* pAnimalCtrl = new CAnimalCtrl(pDialog);
// Create animation control, the meaning of the width and height of this control is not significant.
pAnimalCtrl->CreateObject(5,30,40,100, NULL);
// Load animation GIF file
pAnimalCtrl->LoadFile("Bmp\\Earth3.gif");
// Set the ID number of the animation control
pAnimalCtrl->SetID(ANIMALBASE + 1 - 1);
// Allocate button instance
CButton* pButton1 = new CButton(pDialog);
// Create button
pButton1->CreateObject(500, 50, 80, 24, "Load");
// Set the callback function corresponding to the button
pButton1->SetFc(ClickButton1_DemoAnimalCtrl);
// Show dialog
pDialog->ShowWindow();
// Enter the message loop of the dialog
pDialog->DoModal();
// Delete dialog instance
delete pDialog;
// Function return
return;
}
int main(int argc, char** argv)
{
// Initialize WinSail system
if (!::InitSystem(argc, argv))
{
::CloseSystem();
return(0);
}
// Call animation demonstration program
::Demo_AnimalCtrl();
// Exit WinSail system
::CloseSystem();
return(1);
}
Download address of WinSail:
http://www.firstsail.com.cn/Software.html
[
Last edited by firstsail on 2008-10-5 at 17:53 ]