源码实现
模板类函数指针
1 |
typedef int (T::*pfun)(void*, float); |
命名空间宏定义
1 2 |
#define BEGIN_NAME_SPACE(namespace_XXXX) namespace namespace_XXXX{ #define END_NAME_SPACE(namespace_XXXX) } |
与或判断选项开关
1 2 3 4 5 6 7 8 9 10 |
#define BKF_MAKEKEY(bold, underline, italic, adding) \ (WORD)((adding << 8) \ | (bold ? BKF_BOLD : 0) \ | (underline ? BKF_UNDERLINE : 0) \ | (italic ? BKF_ITALIC : 0)) #define BKF_ISBOLD(key) ((key & BKF_BOLD) == BKF_BOLD) #define BKF_ISUNDERLINE(key) ((key & BKF_UNDERLINE) == BKF_UNDERLINE) #define BKF_ISITALIC(key) ((key & BKF_ITALIC) == BKF_ITALIC) #define BKF_GETADDING(key) (key >> 8) |
判断Windows安装某款字体
- 这里的实现是通过判断注册表来判断是否安装了某款字体。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
static BOOL IsFontExist(LPCTSTR lpFontName) { CRegKey RegOp; TCHAR szValue[MAX_PATH] = _T(""); DWORD dwSize = MAX_PATH; if (ERROR_SUCCESS == RegOp.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"), KEY_READ) && ERROR_SUCCESS == RegOp.QueryStringValue(lpFontName, szValue, &dwSize)) { return TRUE; } return FALSE; } |
应用
lbtoast_menu.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
#ifndef LBTOAST_MENU_H #define LBTOAST_MENU_H #define WM_HIDE_DLG WM_USER + 100 class CLbToastMenu : public CBkDialogViewEx { public: CLbToastMenu(); void PopUp(HWND hwnd, CPoint pt); void OnHideMenu(); bool IsShowing(); enum { IDC_LIST_CTRL = 1000, IDC_MENE_ITEM_1 = 1010, IDC_MENU_NORMAL_BG = 1011, IDC_MENU_HOVER_BG = 1012, }; enum action { kShowType = 1, KClickType, KActionErrorType, }; enum click { kPlaceholderType = 0, kOkType, kCloseType, kNoPopType, kClickErrorType, }; public: BK_NOTIFY_MAP(IDC_RICHVIEW_WIN_EX) BK_LISTWND_NOTIFY_BEGIN(IDC_LIST_CTRL) BK_LISTWND_LISTITEM_MOUSEHOVER(OnListItemMouseHover) BK_LISTWND_LISTITEM_MOUSELEAVE(OnListItemMouseLeave) BK_LISTWND_LISTITEM_LBUTTONUP(OnListItemLButtonUp) BK_LISTWND_NOTIFY_END() BK_NOTIFY_MAP_END() BEGIN_MSG_MAP_EX(CLbToastMenu) MSG_BK_NOTIFY(IDC_RICHVIEW_WIN_EX) MSG_WM_INITDIALOG(OnInitDialog) MSG_WM_NCACTIVATE(OnNcActivate) MSG_WM_DESTROY(OnDestroy) CHAIN_MSG_MAP(CBkDialogViewEx) END_MSG_MAP() protected: void OnListItemMouseHover(int nListItem); void OnListItemMouseLeave(int nListItem); void OnListItemLButtonUp(int nListItem); BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam); BOOL OnNcActivate(BOOL bActive); void OnDestroy(); void SetClipboardNoPop(); private: HWND m_hParentWnd; }; #endif // LBTOAST_MENU_H |
lbtoast_menu.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
#include "stdafx.h" #include "lbtoast_menu.h" #include "lbtoast_record.h" #include <functional> #include "bkres/bkres.h" #include "bkwin/CBkDialogViewImplEx.h" #include "publish/framework/KRegister2.h" CLbToastMenu::CLbToastMenu() : CBkDialogViewEx(IDR_DLG_SETTING) { SetDrawBorder(FALSE); EnableShadow(FALSE); } void CLbToastMenu::PopUp(HWND hWnd, CPoint pt) { m_hParentWnd = hWnd; if (!IsWindow()) { CreateEx(hWnd); } MoveWindow(pt.x, pt.y, 70, 36, FALSE); SetWindowPos(hWnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); ::SetForegroundWindow(m_hWnd); SendMessage(WM_PAINT); } void CLbToastMenu::OnListItemMouseHover(int nListItem) { SetListItemChildCtrlVisible( IDC_LIST_CTRL, nListItem, IDC_MENU_HOVER_BG, TRUE); } void CLbToastMenu::OnListItemMouseLeave(int nListItem) { SetListItemChildCtrlVisible( IDC_LIST_CTRL, nListItem, IDC_MENU_HOVER_BG, FALSE); } void CLbToastMenu::OnListItemLButtonUp(int nListItem) { SetClipboardNoPop(); ShowWindow(SW_HIDE); ::SendMessage(m_hParentWnd, WM_HIDE_DLG, 0, 0); lbtoast::ReportClipbooardAction( action::KClickType, click::kNoPopType, 1, 0); } BOOL CLbToastMenu::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) { return TRUE; } BOOL CLbToastMenu::OnNcActivate(BOOL bActive) { SetMsgHandled(FALSE); if (!bActive) { ShowWindow(SW_HIDE); } return TRUE; } void CLbToastMenu::OnDestroy() { SetMsgHandled(FALSE); } void CLbToastMenu::OnHideMenu() { ShowWindow(SW_HIDE); } void CLbToastMenu::SetClipboardNoPop() { CRegKey reg; LONG ret = reg.Open(HKEY_CURRENT_USER, L"SOFTWARE\\liebao", KEY_SET_VALUE); if (ret != ERROR_SUCCESS) { return; } reg.SetDWORDValue(L"clipassistant", 0); } bool CLbToastMenu::IsShowing() { if (IsWindow() == NULL) { return false; } return true; } |
弹出窗口
关于定时器
监听不到想监听的消息
- 需要在对应的消息映射函数里面加上
SetMsgHandled(FALSE);
这句话。 - 因为有的消息处理里面,设置了TRUE,默认不让bkwin接收到这个消息。
本文为原创文章,版权归Aet所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ C++程序高级调试与优化_第一篇07/20
- ♥ C++14_第二篇06/29
- ♥ Boost 程序库完全开发指南:容器算法数学文件08/24
- ♥ C++并发编程_概念了解05/07
- ♥ Effective C++_第五篇07/02
- ♥ STL_了解05/02
热评文章
- * 暂无