/* mapmode2.cpp example using anisotropic mapping mode */
#include <windows.h>
#include "mapmode2.h"
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine,
int nCmdShow)
{
HWND hWnd ; /* the window's "handle" */
MSG msg ; /* a message structure */
WNDCLASS wndclass ; /* window class structure */
char cBuf [128] ; /* character buffer */
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = NULL ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = "MYMENU" ;
wndclass.lpszClassName = "MyClass" ;
/* register the window class */
if (!RegisterClass (&wndclass))
return 0 ;
LoadString (hInstance, S_PROGRAMCAPTION, cBuf, sizeof (cBuf)) ;
hWnd = CreateWindow ("MyClass", cBuf, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ;
ShowWindow (hWnd, nCmdShow) ; /* display the window */
UpdateWindow (hWnd) ;
while (GetMessage (&msg, NULL, 0, 0)) /* message loop */
{
TranslateMessage (&msg) ; /* translate keyboard messages */
DispatchMessage (&msg) ; /* send message to WndProc() */
}
return (msg.wParam) ;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT wMessage,
WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps ;
static int nX, nY ;
switch (wMessage) /* process windows messages */
{
case WM_COMMAND:
switch (LOWORD(wParam)) /* menu items */
{
case IDM_QUIT: /* "Quit" menu item */
DestroyWindow (hWnd) ; /* destroy window, */
break ; /* terminating application */
}
break ;
case WM_SIZE: /* save client area size */
nX = LOWORD (lParam) ;
nY = HIWORD (lParam) ;
break ;
case WM_PAINT:
BeginPaint (hWnd, &ps) ;
SetMapMode (ps.hdc, MM_ANISOTROPIC) ;
SetViewportExtEx (ps.hdc, nX, nY, NULL) ; /* scale coordinates so... */
SetWindowExtEx (ps.hdc, 100, 100, NULL) ; /* client area is 100x100 */
/* note--logical y-axis still points down */
Ellipse (ps.hdc, 0, 0, 100, 100) ;
Rectangle (ps.hdc, 20, 20, 80, 80) ;
EndPaint (hWnd, &ps) ;
break ;
case WM_DESTROY: /* stop application */
PostQuitMessage (0) ;
break ;
default: /* default windows message processing */
return (DefWindowProc (hWnd, wMessage, wParam, lParam)) ;
}
return (0) ;
}