#include "stdafx.h"
#include "PPHtmlDrawer.h"
#include "atlconv.h" // for Unicode conversion - requires #include <afxdisp.h> // MFC OLE automation classes
#include <shellapi.h>
#pragma comment(lib, "comctl32.lib")
#pragma setlocale(_T("en"))
/*
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
*/
#define PPHTMLDRAWER_NO_HOVERLINK -2 //A hot area is not exist under the cursor
#define PPHTMLDRAWER_BREAK_CHARS _T(" -.,!:;)}]?") //A set of the chars to break line in the text wrap mode
enum {
MODE_DRAW = 0,
MODE_FIRSTPASS,
MODE_SECONDPASS
};
/*
#define m_szOffsetShadow.cx 4 //
#define m_szOffsetShadow.cy 4 //
#define m_szDepthShadow.cx 7 //
#define m_szDepthShadow.cy 7 //
#define PPHTMLDRAWER_SHADOW_COLOR RGB (64, 64, 64) //A gradient shadow's color
*/
/////////////////////////////////////////////////////////////////////////////
// CPPHtmlDrawer
CPPHtmlDrawer::CPPHtmlDrawer()
{
m_nNumPass = MODE_FIRSTPASS;
m_hInstDll = NULL;
m_bFreeInstDll = FALSE;
m_hDC = NULL;
m_hImageList = NULL;
m_csCallbackRepaint.hWnd = NULL;
m_csCallbackRepaint.nMessage = 0;
m_csCallbackRepaint.lParam = 0;
m_csCallbackRepaint.wParam = 0;
m_csCallbackLink.hWnd = NULL;
m_csCallbackLink.nMessage = 0;
m_csCallbackLink.lParam = 0;
m_csCallbackLink.wParam = 0;
// m_clrShadow = PPHTMLDRAWER_SHADOW_COLOR;
m_hLinkCursor = NULL; // No cursor as yet
m_nHoverIndexLink = PPHTMLDRAWER_NO_HOVERLINK;
SetListOfTags();
SetListSpecChars();
SetTableOfColors();
SetDefaultCursor();
EnableEscapeSequences();
SetMaxWidth(0);
// EnableTextWrap(FALSE); //A text warpping was disabled by default
// EnableTextWrap(TRUE); //A text warpping was disabled by default
SetImageShadow(4, 4);
SetTabSize(32);
SetDefaultCssStyles();
EnableOutput();
SetDisabledColor(::GetSysColor(COLOR_BTNSHADOW));
}
CPPHtmlDrawer::~CPPHtmlDrawer()
{
SetResourceDll(NULL);
if (NULL != m_hLinkCursor)
{
::DestroyCursor(m_hLinkCursor);
m_hLinkCursor = NULL;
}
if (NULL != m_hImageList)
::DeleteObject(m_hImageList);
}
void CPPHtmlDrawer::EnableOutput(BOOL bEnable /* = TRUE */)
{
m_bIsEnable = bEnable;
} //End of EnableOutput
void CPPHtmlDrawer::SetDisabledColor(COLORREF color)
{
m_crDisabled = color;
}
HICON CPPHtmlDrawer::GetIconFromResources(DWORD dwID, int nWidth /* = 0 */, int nHeight /* = 0 */) const
{
if (0 == dwID) return NULL;
// Find correct resource handle
#ifdef _MFC_VER
HINSTANCE hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(dwID), RT_GROUP_ICON);
#else
HINSTANCE hInstResource = ::GetModuleHandle(NULL);
#endif
// Set icon when the mouse is IN the button
HICON hIcon = (HICON)::LoadImage(hInstResource, MAKEINTRESOURCE(dwID), IMAGE_ICON, nWidth, nHeight, LR_DEFAULTCOLOR);
return hIcon;
}
HICON CPPHtmlDrawer::GetIconFromFile(LPCTSTR lpszPath, int nWidth /* = 0 */, int nHeight /* = 0 */) const
{
HICON hIcon = (HICON)::LoadImage(NULL, lpszPath, IMAGE_ICON, nWidth, nHeight, LR_LOADFROMFILE | LR_DEFAULTCOLOR);
return hIcon;
}
HICON CPPHtmlDrawer::GetIconFromDll(DWORD dwID, int nWidth /* = 0 */, int nHeight /* = 0 */, LPCTSTR lpszPathDll /* = NULL */) const
{
if (0 == dwID) return NULL;
HICON hIcon = NULL;
HINSTANCE hInstDll = NULL;
BOOL bNewDll = FALSE;
if (NULL == lpszPathDll)
{
if (NULL != m_hInstDll)
hInstDll = m_hInstDll;
}
else
{
//Load New Library
hInstDll = ::LoadLibraryEx(lpszPathDll, NULL, 0);
if (NULL != hInstDll)
bNewDll = TRUE;
}
if (NULL != hInstDll)
{
hIcon = (HICON)::LoadImage(hInstDll, MAKEINTRESOURCE(dwID), IMAGE_ICON, nWidth, nHeight, LR_DEFAULTCOLOR);
if (bNewDll)
::FreeLibrary(hInstDll);
}
return hIcon;
}
HBITMAP CPPHtmlDrawer::GetBitmapFromResources(DWORD dwID) const
{
if (0 == dwID) return NULL;
// Find correct resource handle
#ifdef _MFC_VER
HINSTANCE hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(dwID), RT_BITMAP);
#else
HINSTANCE hInstResource = ::GetModuleHandle(NULL);
#endif
// Load bitmap
HBITMAP hBitmap = (HBITMAP)::LoadImage(hInstResource, MAKEINTRESOURCE(dwID), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
return hBitmap;
}
HBITMAP CPPHtmlDrawer::GetBitmapFromFile(LPCTSTR lpszPath) const
{
HBITMAP hBitmap = (HBITMAP)::LoadImage(NULL, lpszPath, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
return hBitmap;
}
HBITMAP CPPHtmlDrawer::GetBitmapFromDll(DWORD dwID, LPCTSTR lpszPathDll /* = NULL */) const
{
if (0 == dwID) return NULL;
HBITMAP hBitmap = NULL;
HINSTANCE hInstDll = NULL;
BOOL bNewDll = FALSE;
if (NULL == lpszPathDll)
{
if (NULL != m_hInstDll)
hInstDll = m_hInstDll;
}
else
{
//Load New Library
hInstDll = ::LoadLibraryEx(lpszPathDll, NULL, 0);
if (NULL != hInstDll)
bNewDll = TRUE;
}
if (NULL != hInstDll)
{
hBitmap = (HBITMAP)::LoadImage(hInstDll, MAKEINTRESOURCE(dwID), IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
if (bNewDll)
::FreeLibrary(hInstDll);
}
return hBitmap;
}
CPPString CPPHtmlDrawer::GetStringFromResource(DWORD dwID) const
{
if (0 == dwID) return _T("");
CPPString str;
str.LoadString(dwID);
return str;
}
CPPString CPPHtmlDrawer::GetStringFromDll(DWORD dwID, LPCTSTR lpszPathDll /* = NULL */) const
{
if (0 == dwID) return _T("");
CPPString str = _T("");
HINSTANCE hInstDll = NULL;
BOOL bNewDll = FALSE;
if (NULL == lpszPathDll)
{
if (NULL != m_hInstDll)
hInstDll = m_hInstDll;
}
else
{
//Load New Library
hInstDll = ::LoadLibraryEx(lpszPathDll, NULL, 0);
if (NULL != hInstDll)
bNewDll = TRUE;
}
if (NULL != hInstDll)
{
#ifdef _UNICODE
#define CHAR_FUDGE 1 // one TCHAR unused is good enough
#else
#define CHAR_FUDGE 2 // two BYTES unused for case of DBC last char
#endif
// try fixed buffer first (to avoid wasting space in the heap)
TCHAR szTemp[256];
DWORD dwLen = ::LoadString(hInstDll, dwID, szTemp, (sizeof(szTemp) * sizeof(TCHAR)));
// If resource not found (or ::LoadString failure)
if (0 != dwLen)
{
if ((sizeof(szTemp) * sizeof(TCHAR)) - dwLen > CHAR_FUDGE)
{
str = szTemp;
} // if
else
{
// try buffer size of 512, then larger size until entire string is retrieved
int nSize = 256;
do
{
nSize += 256;
dwLen = ::LoadString(hInstDll, dwID, str.GetBuffer(nSize-1), nSize);
} while (nSize - dwLen <= CHAR_FUDGE);
str.ReleaseBuffer();
}
#undef CHAR_FUDGE
}
if (bNewDll)
::FreeLibrary(hInstDll);
}
return str;
}
///////////////////////////////////////////////////////////
// Get tooltip string for menu and toolbar items from the
// resources of the application.
//
// Parameters:
// nID - Resource ID of the string
// nNumParam - Which parameter will gets:
// 0=long,
// 1=short,
// 2=disable
//
//
// Format prompt string: long prompt \n short prompt \n disable prompt
////////////////////////////////////////////////////////////
CPPString CPPHtmlDrawer::GetResCommandPrompt(UINT nID, UINT nNumParam /* = 0 */)
{
CPPString str = GetStringFromResource(nID);
if (!str.IsEmpty())
{
int nFirst = 0;
int nLast = nFirst;
UINT nCount = 0;
while ((nCount <= nNumParam) && (nFirst < str.GetLength()))
{
nLast = str.Find(_T('\n'), nFirst);
if (nLast < 0)
{
//Char wasn't found
if (nCount == nNumParam)
str = str.Mid(nFirst, str.GetLength() - nFirst);
else
str.Empty();
return str;
}
else
{
//Char was found
if (nCount == nNumParam)
{
str = str.Mid(nFirst, nLast - nFirst);
return str;
}
else
{
nFirst = nLast + 1;
} //if
} //if
nCount ++;
} //whil
没有合适的资源?快使用搜索试试~ 我知道了~
VC tooltip 源代码
共79个文件
h:28个
cpp:26个
ico:9个
4星 · 超过85%的资源 需积分: 9 80 下载量 53 浏览量
2010-11-09
12:08:43
上传
评论
收藏 351KB RAR 举报
温馨提示
程序中演示了如何使用tooltip 并演示了tip提示框的各种应用场合和效果 对想了解tooltip编程技巧的童鞋有极大帮助 PS:源码中注释较少,刚学VC的童鞋阅读的时候可能有难度
资源推荐
资源详情
资源评论
收起资源包目录
VCtooltip_demo.rar (79个子文件)
[有用]VCtooltip_demo
StdAfx.h 1KB
PageSizes.cpp 4KB
TestPageGeneral.cpp 5KB
CPPTooltip_demo.rc 37KB
CPPTooltip_demo.dsw 555B
CPPTooltip_demo.ncb 225KB
PPTooltip.h 17KB
PPHtmlStatic.cpp 28KB
res
59.ico 14KB
smiles.bmp 7KB
Toolbar.bmp 1KB
CPPTooltip_demoDoc.ico 1KB
CPPTooltip_demo.rc2 407B
2.ico 3KB
codeproject.bmp 4KB
59.ico.bak 2KB
58.ico 2KB
globe.bmp 3KB
close_app.ico 5KB
1.ico 3KB
CPPTooltip_demo.ico 4KB
0095 - Mail.ico 7KB
blank1.ico 766B
map.BMP 58KB
Thumbs.db 24KB
PageStyles.h 1KB
CPPTooltip_demoDoc.h 2KB
CPPTooltip_demo.clw 15KB
CeXDib.cpp 9KB
TrayIconPosition.h 2KB
CustomizeTooltip.h 2KB
PageTestListTree.cpp 9KB
ColourPicker.cpp 10KB
PPHtmlDrawer.cpp 156KB
MainFrm.cpp 14KB
CustomizeTooltip.cpp 2KB
PageStyles.cpp 4KB
CPPTooltip_demo.dsp 11KB
CPPTooltip_demoView.cpp 12KB
CeXDib.h 2KB
CPPTooltip_demo.aps 184KB
CPPTooltip_demo.opt 57KB
CPPTooltip_demo.plg 6KB
PageTestImages.h 1KB
PPDrawManager.cpp 46KB
CPPTooltip_demoView.h 3KB
PageTestMisc.cpp 4KB
StdString.h 132KB
MainFrm.h 4KB
PageTestTable.cpp 5KB
PageTestMisc.h 2KB
PageBehaviours.h 2KB
PageBehaviours.cpp 5KB
CPPTooltip_demoDoc.cpp 2KB
ColourPicker.h 4KB
ColourPopup.h 5KB
PageShadow.cpp 4KB
PPTooltip.cpp 100KB
resource.h 5KB
PageTestListTree.h 2KB
CPPTooltip_demo.h 1KB
PageSizes.h 2KB
PageTestImages.cpp 4KB
TrayIconPosition.cpp 7KB
CPPTooltip_demo.cpp 4KB
TestPageGeneral.h 2KB
PageTestHyperlinks.cpp 3KB
ColourPopup.cpp 30KB
PPHtmlDrawer.h 22KB
PageColors.cpp 7KB
PageColors.h 2KB
PageCssStyles.h 1KB
StdAfx.cpp 217B
PPHtmlStatic.h 8KB
PPDrawManager.h 8KB
PageShadow.h 2KB
PageTestHyperlinks.h 2KB
PageTestTable.h 1KB
PageCssStyles.cpp 2KB
共 79 条
- 1
资源评论
- 少年阿七2016-05-25可以编译,可以使用,可以借鉴。
- moon89032015-04-15编译不通过,有问题
- lzsryxch2013-05-02CPPToolTip的,功能很强大,很多不常用
slvher
- 粉丝: 110
- 资源: 36
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- kernel-ml-6.8.8-1.el7.elrepo.x86-64.rpm
- Labview基本框架之状态机
- HM2309B-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- Git安全实践:保护你的代码仓库个人学习笔记.md
- 自动驾驶定位系列教程九:后端优化.pdf
- 三国志5威力加强版-windows
- HM2309A-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- HM2306-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- Git进阶技巧:提升团队协作效率个人学习笔记.md
- 自动驾驶定位系列教程八:建图系统结构优化.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功