Форумчанин
Регистрация: 03.01.2015
Сообщений: 160
|
Ошибки в коде
Добрый день!
Помогите, пожалуйста. Запускаю проект и выдает непонятные ошибки. Подскажите, что не так?
Код:
#include <Windows.h>
#include<windowsx.h>
#include<CommCtrl.h>
#include<tchar.h>
#include<Psapi.h>
#include<strsafe.h>
#include<sstream>
#include<gdiplus.h>
#include<gdiplusflat.h>
#include<memory>
#include"Math.h"
using namespace Gdiplus;
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct);
void OnDestroy(HWND hwnd);
void Draw();
void Think(HWND hwnd);
HWND mainWnd;
Bitmap* Bm;
int totalFrames;
int currentFrame;
Image* gif;
HDC ToDraw = NULL;
struct State
{
PointF Position;
float Angle;
float deltaFrame;
};
State AnimStates[5];
int setState = 1;
int currFrame = 0;
int lastStateFrame = 0;
PointF Cntr(500, 300);
PointF Pivot(500, 300 + 250);
int wndX = 0;
int wndY = 0;
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
GdiplusStartupInput GDIPSI{ 0 };
GDIPSI.GdiplusVersion = 1;
GDIPSI.SuppressBackgroundThread = FALSE;
GDIPSI.DebugEventCallback = NULL;
GDIPSI.SuppressExternalCodecs = FALSE;
ULONG_PTR TokenGDI;
GdiplusStartup(&TokenGDI, &GDIPSI, NULL);
State NwState1;
NwState1.Position = PointF(500, 300);
NwState1.Angle = 0;
NwState1.deltaFrame = 0;
AnimStates[0] = NwState1;
State NwState2;
NwState2.Position = PointF(500, 250);
NwState2.Angle = 25;
NwState2.deltaFrame = 25;
AnimStates[1] = NwState2;
State NwState3;
NwState3.Position = PointF(500, 250);
NwState3.Angle = 0;
NwState3.deltaFrame = 25;
AnimStates[2] = NwState3;
State NwState4;
NwState4.Position = PointF(500, 300);
NwState4.Angle = -25;
NwState4.deltaFrame = 25;
AnimStates[3] = NwState4;
State NwState5;
NwState5.Position = PointF(500, 300);
NwState5.Angle = 0;
NwState5.deltaFrame = 25;
AnimStates[4] = NwState5;
WNDCLASSEX wcex = { sizeof(WNDCLASSEX) };
wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wcex.lpfnWndProc = WndProc;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = TEXT("NewWndClass");
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (RegisterClassEx(&wcex) == 0)
return -1;
LoadLibrary(TEXT("ComCtl32.dll"));
LoadLibrary(TEXT("Msftedit.dll"));
mainWnd = CreateWindowEx(0, TEXT("NewWndClass"), TEXT("Lab2"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (mainWnd == NULL)
return -1;
ShowWindow(mainWnd, nCmdShow);
SetTimer(mainWnd, 1, 50, NULL);
Bm = new Bitmap(L"C:\\Program Files (x86)\\1131.jpg");
MSG msg;
BOOL bRet;
Cntr = PointF(500, 300);
for (;;) {
while (!PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
Think(mainWnd);
}
bRet = GetMessage(&msg, NULL, 0, 0);
if (bRet == -1) {
}
else if (bRet == FALSE) {
break;
}
else if (true) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
delete Bm;
GdiplusShutdown(TokenGDI);
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
HANDLE_MSG(hWnd, WM_CREATE, OnCreate);
HANDLE_MSG(hWnd, WM_DESTROY, OnDestroy);
case WM_TIMER:{
if (totalFrames != 0){
currFrame++;
ToDraw = GetDC(mainWnd);
gif->SelectActiveFrame(&FrameDimensionTime, currentFrame++);
if (currentFrame >= totalFrames){
currentFrame = 0;
}
Draw();
ReleaseDC(mainWnd, ToDraw);
}
}
case WM_SIZE: {
RECT wndSz;
if (mainWnd != NULL) {
GetClientRect(mainWnd, &wndSz);
wndX = wndSz.right - wndSz.left;
wndY = wndSz.bottom - wndSz.top;
}
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
int frame = 250;
float CurrAngle = 0;
PointF PointsChasis[13] = {
PointF(260, 250) + Cntr,
PointF(260, 210) + Cntr,
PointF(250, 200) + Cntr,
PointF(180, 200) + Cntr,
PointF(160, 180) + Cntr,
PointF(140, 170) + Cntr,
PointF(100, 160) + Cntr,
PointF(50, 160) + Cntr,
PointF(-50, 200) + Cntr,
PointF(-120, 200) + Cntr,
PointF(-125, 205) + Cntr,
PointF(-130, 210) + Cntr,
PointF(-130, 250) + Cntr
};
PointF PointsWindow_Back[6] = {
PointF(78, 198) + Cntr,
PointF(176, 198) + Cntr,
PointF(160, 182) + Cntr,
PointF(140, 172) + Cntr,
PointF(100, 162) + Cntr,
PointF(78, 162) + Cntr
};
PointF PointsWindow_Front[4] = {
PointF(72, 162) + Cntr,
PointF(50, 162) + Cntr,
PointF(-42, 198) + Cntr,
PointF(72, 198) + Cntr
};
PointF PointsWindow_Front_0[4] = {
PointF(72, 162) + Cntr,
PointF(50, 162) + Cntr,
PointF(-42, 198) + Cntr,
PointF(72, 198) + Cntr
};
PointF PointsWindow_Front_1[4] = {
PointF(72, 190) + Cntr,
PointF(50, 190) + Cntr,
PointF(-42, 198) + Cntr,
PointF(72, 198) + Cntr
};
//End
PointF PointsWindow_Front_bck[4] = {
PointF(72, 162) + Cntr,
PointF(50, 162) + Cntr,
PointF(-42, 198) + Cntr,
PointF(72, 198) + Cntr
};
PointF PointsDoor_Back[7] = {
PointF(77, 250) + Cntr,
PointF(150, 250) + Cntr,
PointF(150, 177) + Cntr,
PointF(140, 172) + Cntr,
PointF(100, 162) + Cntr,
PointF(77, 162) + Cntr
};
PointF PointsDoor_Front[5] = {
PointF(72, 162) + Cntr,
PointF(50, 162) + Cntr,
PointF(-42, 198) + Cntr,
PointF(-42, 250) + Cntr,
PointF(72, 250) + Cntr
};
PointF PointsLight_Front[4] = {
PointF(-130, 210) + Cntr,
PointF(-130, 222) + Cntr,
PointF(-105, 222) + Cntr,
PointF(-105, 210) + Cntr
};
PointF PointsLight_Back[4] = {
PointF(260, 210) + Cntr,
PointF(260, 222) + Cntr,
PointF(235, 222) + Cntr,
PointF(235, 210) + Cntr
};
PointF other[4]{
Cntr,
PointF(-90 + 25, 220 + 25) + Cntr,
PointF(170 + 25, 220 + 25) + Cntr,
Pivot
};
PointF Tween(const PointF &A, const PointF &B, float t) {
return PointF(A.X*(1.f - t) + B.X*t, A.Y*(1.f - t) + B.Y*t);
}
Продолжение кода ниже
|