![]() |
CXTPControlCustom within customize dialog |
Post Reply
|
| Author | |
Green
Newbie
Joined: 14 January 2005 Location: Russian Federation Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
Topic: CXTPControlCustom within customize dialogPosted: 25 January 2005 at 11:35am |
|
Hi! Is there any way to add CXTPControlCustom into the customize dialog? I try to do this using CommonControls sample but attempt was unsuccessful: 1. I try to add Slider control using toolbar as category: 2. I try to add Slider control manually: With best regards, |
|
![]() |
|
Green
Newbie
Joined: 14 January 2005 Location: Russian Federation Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
Posted: 26 January 2005 at 1:11am |
|
>> 1) command in the Slider category is shown as some unknown icon |
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 31 January 2005 at 5:41am |
|
Green, how do you see it? Imagine you already have m_wndSlider in toolbar and used drag another from customize dialog, so it must be second m_wndSlider with same handle? |
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Ark42
Senior Member
Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
Quote Reply
Posted: 31 January 2005 at 11:58am |
|
Here is a start, which I use, and is fully customizable and more or less seems to work the way it should: .h file: ////////////////////////////////////////////////////////// /////////////////// // CXTPSliderCtrl class CXTPSliderCtrl : public CSliderCtrl { DECLARE_DYNAMIC(CXTPSliderCtrl) protected: afx_msg BOOL OnEraseBkgnd(CDC* pDC) { return FALSE; } afx_msg void OnPaint(void); DECLARE_MESSAGE_MAP() }; ////////////////////////////////////////////////////////// /////////////////// // CXTPControlSlider class CXTPControlSlider : public CXTPControlCustom { DECLARE_XTP_CONTROL(CXTPControlSlider) public: CXTPControlSlider(); virtual void OnCalcDynamicSize(DWORD dwMode); virtual void Copy(CXTPControl* pControl, BOOL bRecursive = FALSE); virtual BOOL IsCustomizeDragOverAvail(CXTPCommandBar* pCommandBar, CPoint /*point*/, DROPEFFECT& dropEffect); int OnHookMessage(HWND hWnd, UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); CXTPSliderCtrl *GetSliderCtrl(void) { return &m_wndSlider; } protected: CWnd m_wndHookParent; CXTPSliderCtrl m_wndSlider; }; .cpp file: ////////////////////////////////////////////////////////// /////////////////// // CXTPSliderCtrl IMPLEMENT_DYNAMIC(CXTPSliderCtrl, CSliderCtrl) BEGIN_MESSAGE_MAP(CXTPSliderCtrl, CSliderCtrl) ON_WM_ERASEBKGND() ON_WM_PAINT() END_MESSAGE_MAP() void CXTPSliderCtrl::OnPaint(void) { PAINTSTRUCT ps; CDC *pDC = BeginPaint(&ps); CRect rect; GetClientRect(&rect); CXTMemDC *memDC = new CXTMemDC(pDC, rect); DefWindowProc(WM_PAINT, (WPARAM)memDC->m_hDC, 0); CXTPPaintManager *pPaintMgr = static_cast<CXTPMDIFrameWnd *>(AfxGetMainWnd())-&g t;GetCommandBars()->GetPaintManager(); if( GetStyle() & WS_DISABLED ) { COLORREF clr = pPaintMgr->GetXtremeColor(XPCOLOR_TOOLBAR_FACE); for( int y = rect.top; y < rect.bottom; y++ ) { for( int x = rect.left; x < rect.right; x++ ) { if( (x & 1) == (y & 1) ) { memDC->SetPixel(x, y, clr); } } } } memDC->Draw3dRect(&rect, pPaintMgr->GetXtremeColo r(COLOR_BTNSHADOW), pPaintMgr->GetXtremeColor(COLOR_BTNH IGHLIGHT)); delete memDC; EndPaint(&ps); } ////////////////////////////////////////////////////////// /////////////////// // CXTPControlSlider #define SLIDER_WIDTH 400 #define SLIDER_HEIGHT 30 #define SLIDER_HEIGHTROT 34 IMPLEMENT_XTP_CONTROL(CXTPControlSlider, CXTPControlCustom) CXTPControlSlider::CXTPControlSlider() : CXTPControlCustom() { m_dwFlags = 0; //remove nomovable flag m_wndHookParent.Create(_T("STATIC"), "", WS_CHILD, CRect(0, 0, 0, 0), AfxGetMainWnd(), 0); m_wndSlider.Create(TBS_HORZ | WS_CHILD, CRect(0, 0, SLIDER_WIDTH, SLIDER_HEIGHT), &m_wndHookParent, 0); SetControl(&m_wndSlider); XTPHookManager()->SetHook(m_wndHookParent.GetSafeHwnd(), this); } void CXTPControlSlider::OnCalcDynamicSize(DWORD dwMode) { if( dwMode & LM_VERTDOCK ) { m_wndSlider.SetWindowPos(NULL, 0, 0, SLIDER_HEIGHTROT, SLIDER_WIDTH, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); m_wndSlider.ModifyStyle(TBS_HORZ, TBS_VERT|TBS_LEFT); m_szControl = CSize(SLIDER_HEIGHTROT, SLIDER_WIDTH); } else { m_wndSlider.SetWindowPos(NULL, 0, 0, SLIDER_WIDTH, SLIDER_HEIGHT, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); m_wndSlider.ModifyStyle(TBS_VERT|TBS_LEFT, TBS_HORZ); m_szControl = CSize(SLIDER_WIDTH, SLIDER_HEIGHT); } } void CXTPControlSlider::Copy(CXTPControl* pControl, BOOL bRecursive) { ASSERT(DYNAMIC_DOWNCAST(CXTPControlSlider, pControl)); //avoid CXTPControlCustom copying m_pControlWnd CXTPControl::Copy(pControl, bRecursive); } BOOL CXTPControlSlider::IsCustomizeDragOverAvail(CXTPCommandBar* pCommandBar, CPoint /*point*/, DROPEFFECT& dropEffect) { return TRUE; } int CXTPControlSlider::OnHookMessage(HWND hWnd, UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult) { switch( nMessage ) { case WM_LBUTTONDOWN: case WM_LBUTTONUP: if( !IsCustomizeMode() ) { return FALSE; } case WM_RBUTTONDOWN: case WM_RBUTTONUP: { CPoint point(lParam); MapWindowPoints(hWnd, m_pParent->GetSafeHwnd(), &point, 1); GetParent()->SendMessage(nMessage, wParam, MAKELPARAM(point.x, point.y)); return TRUE; break; } case WM_MOUSEMOVE: { CPoint point(lParam); MapWindowPoints(hWnd, m_pParent->GetSafeHwnd(), &point, 1); GetParent()->SendMessage(nMessage, wParam, MAKELPARAM(point.x, point.y)); return FALSE; break; } case WM_HSCROLL: case WM_VSCROLL: { if( (HWND)lParam == m_wndSlider.GetSafeHwnd() ) { OnExecute(); return TRUE; } break; } } return FALSE; } |
|
![]() |
|
Green
Newbie
Joined: 14 January 2005 Location: Russian Federation Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
Posted: 01 February 2005 at 3:56am |
|
Hello guys! Thank you for response. |
|
![]() |
|
Green
Newbie
Joined: 14 January 2005 Location: Russian Federation Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
Posted: 01 February 2005 at 5:07am |
|
BTW, why does CXTPControlCustom::GetType() return xtpControlButton instead xtpControlCustom? In CommonControls sample add following line: int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl) |
|
![]() |
|
Ark42
Senior Member
Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
Quote Reply
Posted: 01 February 2005 at 11:53am |
|
Green: please post here to let me know if you improve upon this in any way. I use a lot of slider bars in my toolbars for some reason. It would be good to know if there are any significant bugs with this method of deriving from CXTPControlCustom. |
|
![]() |
|
Green
Newbie
Joined: 14 January 2005 Location: Russian Federation Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
Posted: 02 February 2005 at 2:42am |
|
Hello Arc42! It was just reserch how it is easy to build-in this library into our product. We decide to purchase library at last. But project will start little bit later. So, if any issues appear I will post them here. |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |