请教一个"标题具有五彩色变化的窗口"的VC++程序

kinglovar 2004-04-06 11:25:52
//怎么我运行的时候会出错呢?这是什么回事啊,请指教.我是包含少了一个头文件
//了吗?还是怎么了?
//错误提示是:
/*--------------------Configuration: MultiClrdCaption - 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/MultiClrdCaption.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

MultiClrdCaption.exe - 4 error(s), 0 warning(s)*/


#include<afxwin.h>
#include<afxext.h>
class CMyApp : public CWinApp{
public:
virtual BOOL InitInstance();
};

class CMyWnd : public CFrameWnd{
protected:
void PaintTitleBar(BOOL bActive);
afx_msg void OnNcPaint();
afx_msg BOOL OnNcActivate(BOOL bActive);
DECLARE_MESSAGE_MAP();
};

BOOL CMyApp::InitInstance(){
CMyWnd *pWnd = new CMyWnd;
pWnd->Create(NULL,"having fine colors windows caption");
pWnd->ShowWindow(SW_SHOW);
pWnd->UpdateWindow();
m_pMainWnd=pWnd;
return true;
}

CMyApp MyApp;
BEGIN_MESSAGE_MAP(CMyWnd,CWnd)
ON_WM_NCPAINT()
ON_WM_NCACTIVATE()
END_MESSAGE_MAP()

void CMyWnd::PaintTitleBar(BOOL bActive){
CWindowDC dc(this);
CRect rc;
GetWindowRect(rc);
UINT nWidth=rc.Width();
UINT nXFrame=GetSystemMetrics(SM_CXSIZEFRAME);
UINT nYFrame=GetSystemMetrics(SM_CYSIZEFRAME);
UINT nYCaption=GetSystemMetrics(SM_CYCAPTION);
COLORREF cr;
if(bActive){
cr=GetSysColor(COLOR_ACTIVECAPTION);
for(UINT j=nYFrame;j<=nYFrame+nYCaption;j++){
for(UINT i=nXFrame;i<=nWidth/2;i++){
UINT nLen=nWidth/2-nXFrame+1;
if (dc.GetPixel(i,j)==cr){
dc.SetPixelV(i,j,RGB(255-255*(i-nXFrame)/nLen,255*(i-nXFrame)/nLen,0));
}
}
for (i=nWidth/2+1;i<=nWidth-nXFrame;i++){
UINT nLen=nWidth/2-nXFrame-1+1;
if(dc.GetPixel(i,j)==cr){
dc.SetPixelV(i,j,RGB(0,255-255*(i-nWidth/2-1)/nLen,255*(i-nWidth/2-1)/nLen));
}
}
}
}else{
cr=GetSysColor(COLOR_INACTIVECAPTION);
for(UINT j=nYFrame;j<=nYFrame+nYCaption-1;j++){
for(UINT i=nXFrame;i<=nWidth/2;i++){
UINT nLen=nWidth/2-nXFrame;
if(dc.GetPixel(i,j)==cr){
dc.SetPixelV(i,j,RGB(192*(i-nXFrame)/nLen,192*(i-nXFrame)/nLen,192*(i-nXFrame)/nLen));
}
}
for(i=nWidth/2+1;i<=nWidth-nXFrame;i++){
UINT nLen=nWidth/2-nXFrame-1;
if(dc.GetPixel(i,j)==cr){
dc.SetPixelV(i,j,RGB(192-192*(i-nWidth/2)/nLen,192-192*(i-nWidth/2)/nLen,192-192*(i-nWidth/2)/nLen));
}
}
}
}
}

void CMyWnd::OnNcPaint(){
CFrameWnd::OnNcPaint();
if(::GetActiveWindow()==GetSafeHwnd())
PaintTitleBar(TRUE);
else
PaintTitleBar(FALSE);
}

BOOL CMyWnd::OnNcActivate(BOOL bActive){
CFrameWnd::OnNcActivate(bActive);
if(bActive){
PaintTitleBar(TRUE);
return FALSE;
}else{
PaintTitleBar(FALSE);
return FALSE;
}
}
...全文
61 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
kinglovar 2004-04-10
为什么没什么人答我的,为什么啊,我真想知道我是错在哪里啊
回复
kinglovar 2004-04-07
bluebohe(薄荷) (MVP),我照了你这样做,但是还是不行啊,为什么?
kpld8888(kpld) ,你说的太简单啦,我不明白啊,请你说详细一点,好吗?
回复
bluebohe 2004-04-06
Settings的C/C++选项卡的Code Generation的Use Run-time liberary改成Debug Multithreaded
回复
kpld8888 2004-04-06
链接选项中改一下:
/subsystem:windows
还要加入libcmtd.lib
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告
暂无公告