关于window 窗口 映射问题?
程序代码:
#include<windows.h> #include<string.h> #include<stdlib.h> #include<stdio.h> LRESULT CALLBACK WndProc (HWND,UINT, WPARAM,LPARAM); int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevlnst, LPSTR lpszCmdLine,int nCmdShow) { HWND hwnd; MSG Msg; WNDCLASS wndclass; char lpszClassName[]="映射模式"; char lpszTitle[]="映射模式"; wndclass.style=0; wndclass.lpfnWndProc=WndProc; wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.hInstance=hInstance; wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground= GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName=NULL; wndclass.lpszClassName=lpszClassName; if(!RegisterClass(&wndclass)) { MessageBeep(0); return FALSE; } hwnd=CreateWindow ( lpszClassName, lpszTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); while (GetMessage(&Msg,NULL,0,0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } LRESULT CALLBACK WndProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { HDC hdc; PAINTSTRUCT ps; //HPEN hP; HBRUSH hB1,hB2; int nMode; switch(message) { case WM_CREATE: nMode=MM_TEXT; case WM_LBUTTONDOWN: nMode=MM_ISOTROPIC; //nMode=MM_LOMETRIC; InvalidateRect(hwnd,NULL,1); break; case WM_RBUTTONDOWN: nMode=MM_ANISOTROPIC; InvalidateRect(hwnd,NULL,1); break; case WM_PAINT: //hP=CreatePen(PS_DASHDOT,1,RGB(0,0,255)); //hB=CreateHatchBrush(HS_CROSS,RGB(0,255,0)); hdc=BeginPaint(hwnd,&ps); SetMapMode(hdc,nMode); SetWindowExtEx(hdc,150,150,NULL); SetViewportExtEx(hdc,150,100,NULL); //SetViewportOrgEx(hdc,150,60,NULL); hB1=GetStockObject(BLACK_BRUSH); hB2=GetStockObject(WHITE_BRUSH); SelectObject(hdc,hB1); Rectangle(hdc,0,0,150,150); SelectObject(hdc,hB2); Ellipse(hdc,0,0,150,150); EndPaint(hwnd,&ps); break; case WM_DESTROY: DeleteObject(hB1); DeleteObject(hB2); PostQuitMessage(0); break; default: return DefWindowProc(hwnd,message,wParam,lParam); } return 0; }初学win32编程,上面程序是通过左击和右击改变映射模式的,可是运行后发现没改变,不知道问题在哪?求大神帮忙看看
[ 本帖最后由 zcl2013c 于 2014-3-4 16:41 编辑 ]