資源簡介
vc++ 運(yùn)用MFC實(shí)現(xiàn)基于AfxMessageBox的 自定義彈出窗
這是運(yùn)用MFC技術(shù)實(shí)現(xiàn)的基于AfxMessageBox的自定義彈出窗,與標(biāo)準(zhǔn)的 MessageBox 相比,MFC提供 AfxMessageBox 方法使我們編寫消息框變得更加容易。本彈出窗是經(jīng)過自定義擴(kuò)展的,過一段時(shí)間消息框就能自動(dòng)關(guān)閉

代碼片段和文件信息
//?Hyperlink.cpp?:?implementation?file
//?Download?by?http://www.codefans.net
//?Hyperlink?static?control.?Will?open?the?default?browser?with?the?given?URL
//?when?the?user?clicks?on?the?link.
//
//?Copyright?(C)?1997?-?1999?Chris?Maunder
//?All?rights?reserved.?May?not?be?sold?for?profit.
//
//?Thanks?to?P錶?K.?T鴑der?for?auto-size?and?window?caption?changes.
//
//?“GotoURL“?function?by?Stuart?Patterson
//?As?seen?in?the?August?1997?Windows?Developer‘s?Journal.
//?Copyright?1997?by?Miller?Freeman?Inc.?All?rights?reserved.
//?Modified?by?Chris?Maunder?to?use?TCHARs?instead?of?chars.
//
//?“Default?hand?cursor“?from?Paul?DiLascia‘s?Jan?1998?MSJ?article.
//
//?2/29/00?--?P.?Shaffer?standard?font?mod.
#include?“stdafx.h“
#include?
#include?“Hyperlink.h“
#include?
#include?“atlconv.h“????//?for?Unicode?conversion?-?requires?#include??//?MFC?OLE?automation?classes
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
#define?TOOLTIP_ID?1
/////////////////////////////////////////////////////////////////////////////
//?CHyperlink
CHyperlink::CHyperlink()
{
????m_hlinkCursor???????=?NULL;?????????????????//?No?cursor?as?yet
????m_crlinkColour??????=?RGB(??0???0?238);???//?Blue
????m_crVisitedColour???=?RGB(?85??26?139);???//?Purple
????m_crHoverColour?????=?RGB(255???0???0);???//?Red
????m_bOverControl??????=?FALSE;????????????????//?Cursor?not?yet?over?control
????m_bVisited??????????=?FALSE;????????????????//?Hasn‘t?been?visited?yet.
????m_nUnderline????????=?ulHover;??????????????//?Underline?the?link?
????m_bAdjustToFit??????=?TRUE;?????????????????//?Resize?the?window?to?fit?the?text?
????m_strURL.Empty();
????m_nTimerID??????????=?100;
}
CHyperlink::~CHyperlink()
{
????m_UnderlineFont.Deleteobject();
}
/////////////////////////////////////////////////////////////////////////////
//?CHyperlink?overrides
BOOL?CHyperlink::DestroyWindow()?
{
????KillTimer(m_nTimerID);
return?CStatic::DestroyWindow();
}
BOOL?CHyperlink::PreTranslateMessage(MSG*?pMsg)?
{
????m_ToolTip.RelayEvent(pMsg);
????return?CStatic::PreTranslateMessage(pMsg);
}
void?CHyperlink::PreSubclassWindow()?
{
????//?We?want?to?get?mouse?clicks?via?STN_CLICKED
????DWORD?dwstyle?=?Getstyle();
????::SetWindowLong(GetSafeHwnd()?GWL_style?dwstyle?|?SS_NOTIFY);
????
????//?Set?the?URL?as?the?window?text
????if?(m_strURL.IsEmpty())
????????GetWindowText(m_strURL);
????//?Check?that?the?window?text?isn‘t?empty.?If?it?is?set?it?as?the?URL.
????CString?strWndText;
????GetWindowText(strWndText);
????if?(strWndText.IsEmpty())?
????{
????????ASSERT(!m_strURL.IsEmpty());????//?Window?and?URL?both?NULL.?DUH!
????????SetWindowText(m_strURL);
????}
CFont*?pFont?=?GetFont();
if?(!pFont)
{
HFONT?hFont?=?(HFONT)GetStockobject(DEFAULT_GUI_FONT);
if?(hFont?==?NULL)
hFont?=?(HFONT)?GetStockobject(ANSI_VAR_FONT
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
-----------?---------??----------?-----??----
????????????????47011????????????????????18
評(píng)論
共有 條評(píng)論