#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 hPrevinst,
PSTR lpszCmdLine, int nCmdShow)
{
HWND hwnd ;
MSG Msg ;
WNDCLASS wndclass ;
char lpszTitle[]="My_Map_Mode";
char lpszClassName[]="影响模式";
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=(HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName= lpszClassName ;
if (!RegisterClass (&wndclass))
{
MessageBeep(0);
return FALSE;
}
hwnd = CreateWindow( lpszClassName, // window class name
lpszTitle, // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT,// initial x position
CW_USEDEFAULT,// initial y position
CW_USEDEFAULT,// initial x size
CW_USEDEFAULT,// initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
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 ;
HBRUSH hB1,hB2;
int nMode;
switch (message)
{
case WM_CREATE:
nMode=MM_TEXT;
case WM_LBUTTONDOWN:
nMode=MM_ISOTROPIC;
InvalidateRect(hwnd,NULL,1);
break;
case WM_RBUTTONDOWN:
nMode=MM_ANISOTROPIC;
InvalidateRect(hwnd,NULL,1);
break;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
SetMapMode(hdc,nMode);
SetWindowExtEx(hdc,150,150,NULL);//就是这2句,感觉和没用一样,学了几天
SetViewportExtEx(hdc,150,100,NULL);//的印象模式,还是不明白它们有什么作用
//把它们的参数全写成0,也没有什么变化,哪位好人给说几句把,
//它们有什么用啊,
SetViewportOrgEx(hdc,100,10,NULL);
hB1=(HBRUSH)GetStockObject(WHITE_BRUSH);
hB2=(HBRUSH)GetStockObject(BLACK_BRUSH);
SelectObject(hdc,hB1);
RoundRect(hdc,0,0,150,150,30,30);
SelectObject(hdc,hB2);
Ellipse(hdc,0,10,150,140);
EndPaint (hwnd, &ps) ;
break ;
case WM_DESTROY:
DeleteObject(hB1);
DeleteObject(hB2);
PostQuitMessage (0) ;
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
return 0 ;
}