安卓app开发工具下载:为何在那个for里面如果改成i++,j++运算量大一点,就无法显示窗体了呢

来源:百度文库 编辑:高考问答 时间:2024/04/29 11:13:13
#include<windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
POINT pa;
BOOL b=false;
HRGN rgn;
PAINTSTRUCT ps;
HDC dcx,dcm,dcy;
int col,i,j,id;
HMENU menu;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.lpszMenuName=NULL;
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName="示例";
wndclass.style=CS_HREDRAW|CS_VREDRAW;
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return false;
}
hwnd=CreateWindow("示例","j",WS_OVERLAPPEDWINDOW,0,0,500,600,NULL,NULL,hInstance,NULL);
rgn=CreateRectRgn(0,0,0,0);
HANDLE bit;
bit=LoadImage(0,"1.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
dcm=CreateCompatibleDC(GetWindowDC(hwnd));
SelectObject(dcm,bit);
col=GetPixel(dcm,5,5);
for(i=0;i<500;i+=5)
for(j=0;j<600;j+=2)
if(GetPixel(dcm,i,j)!=col)
CombineRgn(rgn,rgn,CreateRectRgn(i,j,i+5,j+2),RGN_OR);
SetWindowRgn(hwnd,rgn,true);
ShowWindow(hwnd,nShowCmd);
UpdateWindow(hwnd);

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
switch(iMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_COMMAND:
switch(wParam)
{
case 11:PostQuitMessage(0);return 0;
case 12:MessageBox(hwnd,"哈哈","一",0);break;
}
case WM_RBUTTONDOWN:
menu=CreatePopupMenu();
AppendMenu(menu,MF_POPUP,12,"哈哈");
AppendMenu(menu,MF_POPUP,11,"退出");
TrackPopupMenu(menu,TPM_RIGHTBUTTON,LOWORD(lParam),HIWORD(lParam),0,hwnd,NULL);
return 0;
case WM_LBUTTONDOWN:
b=true;return 0;
case WM_LBUTTONUP:
b=false;return 0;
case WM_MOUSEMOVE:
if(b){
pa.x=LOWORD(lParam);pa.y=HIWORD(lParam);
ClientToScreen(hwnd,&pa);
SetWindowPos(hwnd,HWND_BOTTOM,pa.x-200,pa.y-200,500,600,SWP_NOZORDER);
SetTimer(hwnd,100,1000,NULL);}
return 0;

case WM_PAINT:
dcy=BeginPaint(hwnd,&ps);
BitBlt(dcy,0,0,500,500,dcm,0,0,SRCCOPY);
EndPaint(hwnd,&ps);
return 0;
case WM_TIMER:
KillTimer(hwnd,100);
}
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}