Click here to Skip to main content
16,010,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Create CSocket object from SOCKET type variable Pin
Nish Nishant12-Sep-02 0:53
sitebuilderNish Nishant12-Sep-02 0:53 
GeneralVC & IIS Pin
zuken2111-Sep-02 23:29
zuken2111-Sep-02 23:29 
GeneralRe: VC & IIS Pin
Michael P Butler11-Sep-02 23:41
Michael P Butler11-Sep-02 23:41 
QuestionHow to print bitmap image file? Pin
Dudi Avramov11-Sep-02 23:19
Dudi Avramov11-Sep-02 23:19 
AnswerRe: How to print bitmap image file? Pin
Roger Allen12-Sep-02 1:41
Roger Allen12-Sep-02 1:41 
GeneralWrong behavior of the slider control Pin
ed welch11-Sep-02 23:09
ed welch11-Sep-02 23:09 
GeneralRe: Wrong behavior of the slider control Pin
jhwurmbach11-Sep-02 23:15
jhwurmbach11-Sep-02 23:15 
GeneralHappy to oblige.. Pin
ed welch11-Sep-02 23:58
ed welch11-Sep-02 23:58 
In fact I already have done this. I just copied this from the round slider project (by Daniel Frey) and removed the drawing code...

class CNiceSliderCtrl : public CSliderCtrl
{
public:
DECLARE_DYNAMIC(CNiceSliderCtrl)
CNiceSliderCtrl() : m_bDragging(false), m_bDragChanged(false) {}
protected:
//{{AFX_MSG(CRoundSliderCtrl)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
bool SetThumb(const CPoint& pt);
void PostMessageToParent(const int nTBCode) const;
bool m_bDragging;
bool m_bDragChanged;
};


#include "stdafx.h"
#include "NiceSlider.h"

IMPLEMENT_DYNAMIC(CNiceSliderCtrl, CSliderCtrl)


BEGIN_MESSAGE_MAP(CNiceSliderCtrl, CSliderCtrl)
//{{AFX_MSG_MAP(CNiceSliderCtrl)
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()


void CNiceSliderCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bDragging = true;
m_bDragChanged = false;
SetCapture();
SetFocus();
if (SetThumb(point))
{
m_bDragChanged = true;
PostMessageToParent(TB_THUMBTRACK);
}
}


void CNiceSliderCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_bDragging)
{
if (SetThumb(point))
{
m_bDragChanged = true;
PostMessageToParent(TB_THUMBTRACK);
}
}
else
{
CSliderCtrl::OnMouseMove(nFlags, point);
}
}

void CNiceSliderCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
if(m_bDragging)
{
m_bDragging = false;
::ReleaseCapture();
if (SetThumb(point))
{
PostMessageToParent(TB_THUMBTRACK);
m_bDragChanged = true;
}
if (m_bDragChanged)
{
PostMessageToParent(TB_THUMBPOSITION);
m_bDragChanged = false;
}
}
else
{
CSliderCtrl::OnLButtonUp(nFlags, point);
}
}


bool CNiceSliderCtrl::SetThumb(const CPoint& point)
{
const int nMin = GetRangeMin();
const int nMax = GetRangeMax()+1;
CRect rc;
GetChannelRect(rc);
double dPos;
if (GetStyle() & TBS_VERT)
{
dPos = (double)(point.y - rc.top)/(rc.bottom - rc.top);
}
else
{
dPos = (double)(point.x - rc.left)/(rc.right - rc.left);
}
double dCorrectionFactor = 0.5 *(1-dPos) - 0.5 *dPos;
int nNewPos = nMin + (nMax-nMin)*dPos + dCorrectionFactor;
const bool bChanged = (nNewPos != GetPos());
if(bChanged)
{
SetPos(nNewPos);
}
return bChanged;
}

void CNiceSliderCtrl::PostMessageToParent(const int nTBCode) const
{
CWnd* pWnd = GetParent();
if(pWnd) pWnd->PostMessage(WM_HSCROLL, (WPARAM)((GetPos() << 16) | nTBCode), (LPARAM)GetSafeHwnd());
}



GeneralWindows Date/Time Properties Pin
Jon Sagara11-Sep-02 22:52
Jon Sagara11-Sep-02 22:52 
GeneralRe: Windows Date/Time Properties Pin
Mike Eriksson12-Sep-02 4:38
Mike Eriksson12-Sep-02 4:38 
GeneralRe: Windows Date/Time Properties Pin
Mike Eriksson12-Sep-02 4:44
Mike Eriksson12-Sep-02 4:44 
GeneralRe: Windows Date/Time Properties Pin
Jon Sagara12-Sep-02 5:28
Jon Sagara12-Sep-02 5:28 
GeneralInstalling a device driver Pin
Anthony B.11-Sep-02 22:49
Anthony B.11-Sep-02 22:49 
GeneralPrinter driver question (repost) Pin
jancsi11-Sep-02 22:24
jancsi11-Sep-02 22:24 
GeneralRe: Printer driver question (repost) Pin
Roger Allen12-Sep-02 1:50
Roger Allen12-Sep-02 1:50 
GeneralMenu Problems Pin
DarrollWalsh11-Sep-02 21:12
DarrollWalsh11-Sep-02 21:12 
GeneralRe: Menu Problems Pin
jhwurmbach11-Sep-02 23:05
jhwurmbach11-Sep-02 23:05 
GeneralRe: Menu Problems Pin
DarrollWalsh12-Sep-02 6:56
DarrollWalsh12-Sep-02 6:56 
GeneralRe: Menu Problems Pin
jhwurmbach12-Sep-02 21:36
jhwurmbach12-Sep-02 21:36 
GeneralToolbars position on parent resize Pin
haroonaslam11-Sep-02 20:51
haroonaslam11-Sep-02 20:51 
General[SDK]SetWindowOrgEx and SetViewportOrgEx Pin
TKD11-Sep-02 20:41
TKD11-Sep-02 20:41 
GeneralRe: [SDK]SetWindowOrgEx and SetViewportOrgEx Pin
Ernest Laurentin12-Sep-02 4:54
Ernest Laurentin12-Sep-02 4:54 
GeneralRe: [SDK]SetWindowOrgEx and SetViewportOrgEx Pin
TKD12-Sep-02 5:37
TKD12-Sep-02 5:37 
GeneralRe: [SDK]SetWindowOrgEx and SetViewportOrgEx Pin
Ernest Laurentin12-Sep-02 8:46
Ernest Laurentin12-Sep-02 8:46 
GeneralRe: [SDK]SetWindowOrgEx and SetViewportOrgEx Pin
TKD12-Sep-02 17:35
TKD12-Sep-02 17:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.