したらばTOP ■掲示板に戻る■ 全部 1-100 最新50 | メール | |

管理人の独り言(プログラミング関連)

2483774さん:2010/07/23(金) 10:28:28
#include <iostream>
#include <windows.h>

#define nullptr NULL

//関数
auto WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)->int;
auto CleanMessage(int *ret)->bool;
auto CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)->LRESULT;

//実装
auto WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)->int{
WNDCLASSEX wc = {sizeof(wc)};
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbWndExtra = 0;
wc.cbClsExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO);
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
wc.lpszMenuName = nullptr;
wc.lpszClassName = TEXT("AA");
wc.hIconSm = nullptr;

ATOM aWnd = RegisterClassEx(&wc);
if(aWnd == INVALID_ATOM){
return -1;
}

//ウィンドウの大きさの計算 横:600 縦;300
const int clientwidth = 800;
const int clientheight = 600;
const int screenx = GetSystemMetrics(SM_CXSCREEN);
const int screeny = GetSystemMetrics(SM_CYSCREEN);

RECT windowRect;
windowRect.left = screenx / 2 - clientwidth / 2;
windowRect.right = screenx / 2 + clientwidth / 2;
windowRect.top = screeny / 2 - clientheight / 2;
windowRect.bottom = screeny / 2 + clientheight / 2;

AdjustWindowRectEx(&windowRect, WS_CAPTION | WS_SYSMENU, FALSE, 0);

HWND hWnd = CreateWindowEx(
0,
reinterpret_cast<LPCTSTR>(aWnd),
TEXT("WindowTitle!!"),
WS_CAPTION | WS_SYSMENU,
windowRect.left, windowRect.top,
windowRect.right - windowRect.left, windowRect.bottom - windowRect.top,
nullptr,
nullptr,
hInstance,
nullptr
);
if(hWnd == nullptr){
return -2;
}

ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);


static const DWORD waitTimes[] = {
16, 17, 17
};
int index = 0;
int retValue;
HDC hdcWin = GetDC(hWnd);
HDC hdcMem = CreateCompatibleDC(hdcWin);
HBITMAP hBitmapMem = CreateCompatibleBitmap(hdcWin, clientwidth, clientheight);
SelectObject(hdcMem, hBitmapMem);
DWORD old = timeGetTime();
int i = 0;

timeBeginPeriod(1);
for(;;){
if(CleanMessage(&retValue)){
break;
}

//ただただ面倒臭い処理
{
RECT rc;
rc.left = 0;
rc.right = clientwidth;
rc.top = 0;
rc.bottom = clientheight;
FillRect(hdcMem, &rc, reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)));
int j = 0;

BitBlt(hdcWin, 0, 0, clientwidth, clientheight, hdcMem, 0, 0, SRCCOPY);
}

std::cout << timeGetTime() - old << std::endl;

if(CleanMessage(&retValue)){
break;
}


新着レスの表示


名前: E-mail(省略可)

※書き込む際の注意事項はこちら

※画像アップローダーはこちら

(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)

掲示板管理者へ連絡 無料レンタル掲示板