| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 501 人关注过本帖
标题:为什么我开始运行这个程序的时候 缺生成不了
只看楼主 加入收藏
xy01802314
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-6-24
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
为什么我开始运行这个程序的时候 缺生成不了
#include <afxwin.h>
#include <math.h>

class CMyWnd : public CFrameWnd
{
public:
CMyWnd();

protected:
afx_msg void OnPaint();
afx_msg void OnSize(UINT uType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnTimer(UINT_PTR nIdEvent);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
DECLARE_MESSAGE_MAP()

private:
CDC m_memDC;
};


class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance()
{
m_pMainWnd = new CMyWnd;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
m_pMainWnd->SetTimer(10, 1000, NULL);
return TRUE;
}
};

CMyApp myApp;

BEGIN_MESSAGE_MAP(CMyWnd, CFrameWnd)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_TIMER()
END_MESSAGE_MAP()

int CMyWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
CDC * pDC = GetDC();
this->m_memDC.CreateCompatibleDC(pDC);
ReleaseDC(pDC);
return 0;
}

BOOL CMyWnd::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}

void CMyWnd::OnSize(UINT uType, int cx, int cy)
{
CBitmap tmp;
CDC * pDC = GetDC();

tmp.CreateCompatibleBitmap(pDC, cx, cy);
m_memDC.SelectObject(&tmp);
tmp.DeleteObject();
CBrush brush(RGB(255,255,255));
m_memDC.FillRect(CRect(0, 0, cx, cy),&brush);
ReleaseDC(pDC);
}

CMyWnd::CMyWnd()
{
Create(NULL, _T ("MFC时钟"));
}

void CMyWnd::OnTimer(UINT_PTR nIdEvent)
{
Invalidate();
}


void CMyWnd::OnPaint()
{
RECT rect;
GetClientRect(&rect);

POINT mid;
mid.x = rect.right / 2;
mid.y = rect.bottom / 2;
int l, t, r, b;
double rr;
if(rect.right > rect.bottom) {
l = (rect.right - rect.bottom) / 2;
t = 0;
r = rect.bottom + l;
b = rect.bottom;
rr = b/2;
} else {
l = 0;
t = (rect.bottom - rect.right) / 2;
r = rect.right;
b = rect.right + t;
rr = r/2;
}

m_memDC.Ellipse(l, t, r, b);
m_memDC.SetPixel(mid.x, mid.y, RGB(0, 0, 0));

const double PI = 4.0 * atan( 1.0 );
const double AG = 180.0 / PI;
POINT p1, p2, p3;
int len;

#pragma warning(push)
#pragma warning(disable:4244)

for(int i = 0; i < 360; i += 6)
{
if(i % 30 == 0)
len = rr/10;
else
len = rr/20;
p1.x = (rr-len)*cos(i/AG) + mid.x;
p1.y = (rr-len)*sin(i/AG) + mid.y;
p2.x = rr*cos(i/AG) + mid.x;
p2.y = rr*sin(i/AG) + mid.y;

m_memDC.MoveTo(p1.x, p1.y);
m_memDC.LineTo(p2.x, p2.y);
}

SYSTEMTIME st;
GetLocalTime(&st);

double h, m, s;
s = st.wSecond;
m = st.wMinute + s/60;
h = st.wHour + m/60;

p1.x = 0.8*rr*cos((s*6-90)/AG) + mid.x;
p1.y = 0.8*rr*sin((s*6-90)/AG) + mid.y;
m_memDC.MoveTo(p1.x, p1.y);
m_memDC.LineTo(mid.x, mid.y);

CRgn rgn1, rgn2;
CBrush br(RGB(0, 0, 0));

p1.x = 0.8*rr*cos((m*6-90)/AG) + mid.x;
p1.y = 0.8*rr*sin((m*6-90)/AG) + mid.y;
p3.x = -0.1*rr*cos((m*6-90)/AG) + mid.x;
p3.y = -0.1*rr*sin((m*6-90)/AG) + mid.y;

p2.x = 0.1*rr*cos((m*6-75)/AG) + mid.x;
p2.y = 0.1*rr*sin((m*6-75)/AG) + mid.y;
m_memDC.BeginPath();
m_memDC.MoveTo(p3.x, p3.y);
m_memDC.LineTo(p2.x, p2.y);
m_memDC.LineTo(p1.x, p1.y);
p2.x = 0.1*rr*cos((m*6-105)/AG) + mid.x;
p2.y = 0.1*rr*sin((m*6-105)/AG) + mid.y;
m_memDC.MoveTo(p3.x, p3.y);
m_memDC.LineTo(p2.x, p2.y);
m_memDC.LineTo(p1.x, p1.y);
m_memDC.EndPath();
rgn1.CreateFromPath(&m_memDC);


p1.x = 0.7*rr*cos((h*30-90)/AG) + mid.x;
p1.y = 0.7*rr*sin((h*30-90)/AG) + mid.y;
p3.x = -0.1*rr*cos((h*30-90)/AG) + mid.x;
p3.y = -0.1*rr*sin((h*30-90)/AG) + mid.y;

p2.x = 0.1*rr*cos((h*30-60)/AG) + mid.x;
p2.y = 0.1*rr*sin((h*30-60)/AG) + mid.y;
m_memDC.BeginPath();
m_memDC.MoveTo(p3.x, p3.y);
m_memDC.LineTo(p2.x, p2.y);
m_memDC.LineTo(p1.x, p1.y);
p2.x = 0.1*rr*cos((h*30-120)/AG) + mid.x;
p2.y = 0.1*rr*sin((h*30-120)/AG) + mid.y;
m_memDC.MoveTo(p3.x, p3.y);
m_memDC.LineTo(p2.x, p2.y);
m_memDC.LineTo(p1.x, p1.y);
m_memDC.EndPath();
rgn2.CreateFromPath(&m_memDC);
(&rgn1, &rgn2, RGN_OR);
m_memDC.FillRgn(&rgn2, &br);

#pragma warning(pop)
CPaintDC(this).BitBlt(rect.left, rect.top, rect.right, rect.bottom, &m_memDC, 0, 0, SRCCOPY);
}
搜索更多相关主题的帖子: private include public 
2014-06-24 08:05
xy01802314
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-6-24
收藏
得分:0 
-------------Configuration: Cpp1 - Win32 Debug--------------------
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Cpp1.exe : fatal error LNK1120: 3 unresolved externals
执行 link.exe 时出错.

Cpp1.exe - 1 error(s), 0 warning(s)
2014-06-24 08:06
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9025
专家分:54030
注 册:2011-1-18
收藏
得分:20 
error LNK2001: unresolved external symbol _main
------ 你创建的是控制台程序,但看你的代码嘛,又不是

error LNK2001: unresolved external symbol __beginthreadex
------ MSDN如是说:Libraries
Multithreaded versions of the C run-time libraries only.
To use _beginthread or _beginthreadex, the application must link with one of the multithreaded C run-time libraries.

其实,你解决了第一个问题后,第二个问题就不存在了
2014-06-24 09:33
xy01802314
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-6-24
收藏
得分:0 
回复 3 楼 rjsp
怎么解决呀
2014-06-24 10:25
快速回复:为什么我开始运行这个程序的时候 缺生成不了
数据加载中...
 
   



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

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