#include"frame.h" #include"sprite.h" #include HBITMAP hmap; Frame::Frame() { //スタテックな領域に参照を保持しておく add(this); //ウインドウを登録する winc.style = CS_HREDRAW; winc.lpfnWndProc= WndProc; winc.cbClsExtra = winc.cbWndExtra = 0; winc.hInstance = GetModuleHandle(NULL); winc.hIcon = LoadIcon(NULL,IDI_APPLICATION); winc.hCursor = LoadCursor(NULL , IDC_ARROW); winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); winc.lpszMenuName = NULL; winc.lpszClassName = TEXT("start"); //うまくできたか確認を取る if(!RegisterClass(&winc)) exit(0); //ウインドウを作る hwnd = CreateWindow( TEXT("start") , TEXT("Start") , WS_CAPTION , 100 , 100 , 640 , 480 , NULL , NULL , GetModuleHandle(NULL) , NULL); this->onInit(); } Frame::~Frame() { ; } DWORD Frame::getID() { return this->id; } HWND Frame::getHwnd() { return this->hwnd; } void Frame::setID(DWORD id) { this->id = id; } void Frame::show() { ShowWindow(hwnd,SW_SHOW); } int Frame::onClick() { MessageBox(hwnd,TEXT("End"),TEXT("true"),MB_OK); PostQuitMessage(0); return 0; } void Frame::onPaint(PaintEvent e) { Sprite sprite; Sprite sprite2; Image bitmap; char ch[100]; DWORD te; te = timeGetTime(); sprite.loadImage("test.bmp"); sprite2.loadImage("test1.bmp"); sprite.add(&sprite2); // sprite.getImage().Plus(sprite.getlpImage(),sprite2.getlpImage()); sprite.draw(); StretchDIBits(e.hdc, 0, 0, 640, 480, 0, 0, 640, 480, sprite.getImage().getBitmapMap(), &sprite.getImage().getBitmapInfo(), DIB_RGB_COLORS, SRCCOPY ); } void Frame::onInit() { TIMECAPS caps; timeGetDevCaps(&caps,sizeof(TIMECAPS)); timeBeginPeriod(caps.wPeriodMin); } int Frame::EventRoop() { if(NULL != GetMessage(&msg,NULL,0,0)) { DispatchMessage(&msg); return 1; }else { return -1; } }