当前位置导航:炫浪网>>网络学院>>编程开发>>C++教程>>Visual C++教程

vc++程序-旋转的风车

    做了个小程序,供大家参考

 //源程序如下
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define PI 3.1415926

int nNum=0,nMaxNum=20;

LRESULT CALLBACK WindowProc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);
int WINAPI WinMain(
  HINSTANCE hInstance,      // handle to current instance
  HINSTANCE hPrevInstance,  // handle to previous instance
  LPSTR lpCmdLine,          // command line
  int nCmdShow              // show state
)

{
    HWND hwnd;
    MSG Msg;
    WNDCLASS wndclass;
    wndclass.cbClsExtra=0;
    wndclass.cbWndExtra=0;
    wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
    wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    wndclass.hInstance=hInstance;
    wndclass.lpfnWndProc=WindowProc;
    wndclass.lpszClassName="abc";
    wndclass.lpszMenuName=NULL;
    wndclass.style=0;

    RegisterClass(&wndclass);

    hwnd=CreateWindow("abc","旋转的风车",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,600,450,NULL,NULL,hInstance,NULL);

    ShowWindow(hwnd,SW_SHOWNORMAL);
    UpdateWindow(hwnd);

    while(GetMessage(&Msg,hwnd,NULL,0))
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return 0;
}

LRESULT CALLBACK WindowProc(
  HWND hwnd,      // handle to window
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
)
{
    HDC hdc;
    HBRUSH hBrush;
    HPEN hp;
    PAINTSTRUCT ps;
    int nCenterX,nCenterY;
    double fAngle;

    switch(uMsg)
    {
    case WM_PAINT:
        hdc=BeginPaint(hwnd,&ps);
        SetMapMode(hdc,MM_ANISOTROPIC);
        SetWindowExtEx(hdc,400,300,NULL);

共2页 首页 上一页 1 2 下一页 尾页 跳转到
相关内容
赞助商链接