Windows CE描画プロセス



BeginPaintの動作1.無効領域を有効領域2にする.転送WM_ERASEBACKGROUNDメッセージ、バックグラウンドを再描画3.WM_のみPAINTコール
4.EndPaint(hWnd,&ps)とダブルペア
 
 
//Message dispatch table for MainWindowProc
WM_PAINT, DoPaintMain,
 
in,hシフト
LRESULT DoPaintMain (HWND, UINT, WPARAM, LPARAM);
//定点設定の仕組み
typedef struct tagPOINTS2{    SHORT   x;    SHORT   y;} POINTS2;
 
 
 
LRESULT DoPaintMain (HWND hWnd, UINT wMsg, WPARAM wParam, 
LPARAM lParam) {


//********************* ***********************//
//http://genewince.blogspot.com/2008/03/evc-4-resource.html     bmp   
DWORD a;
ULONG b;
LPVOID c;
PUCHAR d;
HANDLE e;
PAINTSTRUCT ps;
RECT rect;
HDC hdc;
BITMAP bm;

GetUpdateRect(hWnd,&rect,1);
HBITMAP hBitmap2 = SHLoadDIBitmap(TEXT("//Storage Card//33332.bmp"));
//HBITMAP hBitmap2;
//hBitmap2 = LoadBitmap(hInst,(LPCTSTR)IDB_BITMAP1);

GetClientRect (hWnd, &rect);//
hdc = BeginPaint(hWnd,&ps);

if (Pressing){ Rectangle(hdc,pt.x,pt.y,cur_pt.x,cur_pt.y); //
old_pt.x=cur_pt.x;
old_pt.y=cur_pt.y;
}
if(old_pt.x==cur_pt.x && old_pt.y==cur_pt.y){
Rectangle(hdc,pt.x,pt.y,cur_pt.x,cur_pt.y);
}

HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hBitmap2);

GetObject(hBitmap2, sizeof(BITMAP), &bm);//

// BitBlt(hdc , rect.left , rect.top , bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);//SRCCOPY
StretchBlt(hdc , rect.left , rect.top , (bm.bmWidth)/1, (bm.bmHeight)/1, hdcMem, 0, 0, bm.bmWidth,bm.bmHeight, SRCCOPY);//SRCCOPY
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);

// EndPaint(hWnd, &ps);
// return 0;
//********************* ***********************//

//********************* ***********************//
SetPixel(hdc,400,400,RGB(0x00,0x00,0xFF));
//********************* ***********************//

//********************* ***********************//
//
POINT pts[2];
pts[0].x=20;
pts[0].y=20;
pts[1].x=200;
pts[1].y=150;
Polyline(hdc, pts ,2);
HPEN hPen = CreatePen(PS_DASH,1,RGB(0xff,0x88,0x0));
SelectObject(hdc, hPen);
MoveToEx(hdc,150,150,NULL);
LineTo(hdc,500,160);

//********************* ***********************//

//********************* ********************//

HBRUSH hBrush;
hBrush = CreateSolidBrush(RGB(0xAA,0x55,0x55));
SelectObject(hdc, hBrush);
Rectangle(hdc,200,200,550,500);//
hBrush = CreateSolidBrush(RGB(0x22,0xAA,0x33));
SelectObject(hdc, hBrush);
Ellipse(hdc,300,100,500,300);//
hBrush = CreateSolidBrush(RGB(0x22,0x2A,0xAA));
SelectObject(hdc, hBrush);
RoundRect(hdc,0,300,200,500,50,30);//
hBrush = CreateSolidBrush(RGB(0xdd,0x6A,0xAA));
SelectObject(hdc, hBrush);
POINT ppt[3];
ppt[0].x=60;
ppt[0].y=60;
ppt[1].x=20;
ppt[1].y=100;
ppt[2].x=100;
ppt[2].y=100;
Polygon(hdc,ppt,3);//

TRIVERTEX vert[2];
GRADIENT_RECT gRect;
RECT prect = {100 , 300 , 300 ,500};

vert[0].x=prect.left;
vert[0].y=prect.top;
vert[0].Red=0xAC00;
vert[0].Green=0xF300;
vert[0].Blue=0x8100;
vert[0].Alpha=0x0000;

vert[1].x=prect.right;
vert[1].y=prect.bottom;
vert[1].Red=0xA300;
vert[1].Green=0x5700;
vert[1].Blue=0xD500;
vert[1].Alpha=0x0000;

gRect.UpperLeft=1;
gRect.LowerRight=0;

GradientFill(hdc,vert,2,&gRect,1,GRADIENT_FILL_RECT_H);

//********************* ********************//


//**************** **************//

TCHAR szOut[256];
a=sizeof(DOUBLE);
wsprintf(szOut,TEXT("a=%d"),a);
ExtTextOut(hdc,200,200,0,NULL,szOut,lstrlen(szOut),NULL);
//**************** ***************//
// PAINTSTRUCT ps;
// RECT rect;
// HDC hdc;
RECT rectText = rect;
rectText.left=0;
rectText.top=0;
// Get the size of the client rectangle
GetClientRect (hWnd, &rect);
SetBkMode (hdc, TRANSPARENT);
hdc = BeginPaint (hWnd, &ps);

DrawText (hdc, TEXT (" "), -1, &rectText, DT_SINGLELINE);


EndPaint (hWnd, &ps);

return 0;

}