|
-
September 8th, 2009, 03:06 AM
#1
Simplified code for slider control discussed in the previous posts
Hello everybody,
attached i send you a simplified code (VISUAL C++ 6.0) about the slider control ..... It shows the problem discussed with you in the previous posts ...
A snippet follows about the unresolved problem. It refers to a dialg with only one CSlider control.
The only aim of the slider is to choose values in the a range.
IMPLEMENTATION
THE OnHScroll function do some actions, in this example sends the string "0".
THE OnMouseWheel function sends the strings "1" or "2".
As you know in this situation the OnMouseWheel never wil be executed !!. It will be executed only and only the
OnHScroll function.
How is it possible do indipendent the two functions ?
In other words, the slider is there only to select values. Every time a value has been selected i must give the possibility to use the scrolling mouse ring to do other operations.
NOTE: there is a way to disconnect the mouse actions from OnHScroll ... it is to use EnableWindow(FALSE) inside the OnHScroll .... but ths works on for a time.
THANKS IN ADVANCE FOR YOUR HELP !
Vincenzo
// SliderControlDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SliderControl.h"
#include "SliderControlDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSliderControlDlg dialog
CSliderControlDlg::CSliderControlDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSliderControlDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSliderControlDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CSliderControlDlg: oDataExchange(CDataExchange* pDX)
{
CDialog: oDataExchange(pDX);
//{{AFX_DATA_MAP(CSliderControlDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSliderControlDlg, CDialog)
//{{AFX_MSG_MAP(CSliderControlDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_HSCROLL()
ON_WM_MOUSEWHEEL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSliderControlDlg message handlers
BOOL CSliderControlDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CSliderControlDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSliderControlDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSliderControlDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
MessageBox("0");
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
BOOL CSliderControlDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
// TODO: Add your message handler code here and/or call default
if(zDelta == -120) {MessageBox("1");}
if(zDelta == 120) {MessageBox("2");}
return CDialog::OnMouseWheel(nFlags, zDelta, pt);
}
-
September 8th, 2009, 07:49 AM
#2
Re: Simplified code for slider control discussed in the previous posts
17 posts and you still haven't figured out code tags? You might get some people to look at your code, but most will ignore it without code tags as it is nearly impossible to follow without formatting.
[code]
//code goes here
int main(void)
{
return EXIT_SUCCESS;
}
[/code]
Gives:
Code:
//code goes here
int main(void)
{
return EXIT_SUCCESS;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|