![]()
これまでに縦横比を保ったままウインドウの中央に画像を表示できるようになった。しかしウインドウのサイズを変更するとこのようになってしまう。これは以前に描画のちらつきをなくすためWM_ERASEBKGNDメッセージを無効化し、背景の描画がされないようにしたためだ。
#include "atlmisc.h"
//余白描画
HBRUSH hBrush;
hBrush = ::GetSysColorBrush(COLOR_WINDOW);
if(nX == 0)
{
//上下の余白
dc.FillRect(&CRect(0,0,nWindowWidth,nY),hBrush);
dc.FillRect(&CRect(0,nY + nHeight,nWindowWidth,nWindowHeight),hBrush);
}
else
{
//左右の余白
dc.FillRect(&CRect(0,0,nX,nWindowHeight),hBrush);
dc.FillRect(&CRect(nX + nWidth,0,nWindowWidth,nWindowHeight),hBrush);
}
::DeleteObject(hBrush);
