| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 690 人关注过本帖
标题:论坛首页的风车程序连接有错怎么解决???????
只看楼主 加入收藏
wenyihui1234
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-4-7
收藏
 问题点数:0 回复次数:0 
论坛首页的风车程序连接有错怎么解决???????
#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);
        SetViewportExtEx(hdc,600,450,NULL);
        SetViewportOrgEx(hdc,300,200,NULL);

//        绘制外圆
        hp=CreatePen(PS_SOLID,1,RGB(255,0,255));
        SelectObject(hdc,hp);
        Ellipse(hdc,-100,-100,100,100);

//        绘制风车的叶片
//        绘制红色的叶片
        hBrush=CreateSolidBrush(RGB(255,0,0));
        SelectObject(hdc,hBrush);
        fAngle=2*PI/nMaxNum*nNum;
        nCenterX=(int)(50*cos(fAngle));
        nCenterY=(int)(50*sin(fAngle));
        Pie(hdc,nCenterX-50,nCenterY-50,nCenterX+50,nCenterY+50,(int)(nCenterX+50*cos(fAngle)),(int)(nCenterY+50*sin(fAngle)),(int)(nCenterX+50*cos(fAngle+PI)),(int)(nCenterY+50*sin(fAngle+PI)));

//        绘制蓝色的叶片
        hBrush=CreateSolidBrush(RGB(255,255,0));
        SelectObject(hdc,hBrush);
        nCenterX=(int)(50*cos(fAngle+2*PI/3));
        nCenterY=(int)(50*sin(fAngle+2*PI/3));
        Pie(hdc,nCenterX-50,nCenterY-50,nCenterX+50,nCenterY+50,(int)(nCenterX+50*cos(fAngle+2*PI/3)),(int)(nCenterY+50*sin(fAngle+2*PI/3)),(int)(nCenterX+50*cos(fAngle+PI+2*PI/3)),(int)(nCenterY+50*sin(fAngle+PI+2*PI/3)));
        
//        绘制黄色的叶片
        hBrush=CreateSolidBrush(RGB(0,255,255));
        SelectObject(hdc,hBrush);
        nCenterX=(int)(50*cos(fAngle+4*PI/3));
        nCenterY=(int)(50*sin(fAngle+4*PI/3));
        Pie(hdc,nCenterX-50,nCenterY-50,nCenterX+50,nCenterY+50,(int)(nCenterX+50*cos(fAngle+4*PI/3)),(int)(nCenterY+50*sin(fAngle+4*PI/3)),(int)(nCenterX+50*cos(fAngle+PI+4*PI/3)),(int)(nCenterY+50*sin(fAngle+PI+4*PI/3)));

        nNum++;
        Sleep(100);
        InvalidateRect(hwnd,NULL,1);
        EndPaint(hwnd,&ps);

        return 0;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hwnd,uMsg,wParam,lParam);
    }
    return 0;
}
搜索更多相关主题的帖子: 首页 windows 风车 handle 
2008-04-08 22:49
快速回复:论坛首页的风车程序连接有错怎么解决???????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050822 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved