Click here to Skip to main content
15,891,607 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: getchar / putchar - how does it really works ? Pin
Richard MacCutchan16-Jun-19 5:48
mveRichard MacCutchan16-Jun-19 5:48 
GeneralRe: getchar / putchar - how does it really works ? Pin
Stefan_Lang16-Jun-19 21:29
Stefan_Lang16-Jun-19 21:29 
GeneralRe: getchar / putchar - how does it really works ? Pin
Richard MacCutchan16-Jun-19 21:48
mveRichard MacCutchan16-Jun-19 21:48 
GeneralRe: getchar / putchar - how does it really works ? Pin
leon de boer17-Jun-19 2:43
leon de boer17-Jun-19 2:43 
GeneralRe: getchar / putchar - how does it really works ? Pin
Stefan_Lang18-Jun-19 5:13
Stefan_Lang18-Jun-19 5:13 
QuestionChange Icon Pin
JM225113-Jun-19 18:12
JM225113-Jun-19 18:12 
AnswerRe: Change Icon Pin
Richard MacCutchan13-Jun-19 21:32
mveRichard MacCutchan13-Jun-19 21:32 
QuestionWM_MOUSEWHEEL message and the Touchpad : SOLVED thanks to Randor Pin
Richard MacCutchan13-Jun-19 4:28
mveRichard MacCutchan13-Jun-19 4:28 
I am processing the WM_MOUSEWHEEL messages in a C++ application,
C++
void CView::OnMouseWheel(
    HWND    hWnd,
    int	    xPos,
    int	    yPos,
    int	    zDelta,
    UINT    fwKeys
)
{
    zDelta /= WHEEL_DELTA;	// calculate the number of lines to move
    if (zDelta != 0)
    {
        // line up or down once per delta
        OnVScroll(hWnd, NULL, zDelta > 0 ? SB_LINEUP : SB_LINEDOWN, 3);
    }
}
</blockquote>

but when I use the touchpad nothing happens. Following the advice in the MSDN documentation I divide the zDelta value by 120 (WHEEL_DELTA) to calculate the (approximate) number of lines to scroll. The debugger shows that the resulting value is always zero. If I use my mouse and turn the wheel it scrolls correctly. The weird part is that using other applications (VS, Word, Chrome etc.) the touchpad works correctly. So I conclude that the code should somehow get some other information that identifies the touchpad, and adjusts the delta accordingly. Anyone else seen similar problems?

[edit]
Thanks to David D's sugestion I modified the code to accumulate deltas that are less than the value of WHEEL_DELTA, thus:
C++
static int myDelta = 0;
if (abs(zDelta) < WHEEL_DELTA)
{
    myDelta += zDelta;
    zDelta = myDelta;
}
zDelta /= WHEEL_DELTA;	// this value works better than WHEEL_DELTA;
if (zDelta != 0)
{
    myDelta = myDelta % WHEEL_DELTA;  // save the remainder for further movements
    // line up or down once per delta
    OnVScroll(hWnd, NULL, zDelta > 0 ? SB_LINEUP : SB_LINEDOWN, 3);
}

which works a treat.

Note that I use the value 3 for the number of lines to scroll. In a proper commercial application the code should use the value of the system parameter: SPI_GETWHEELSCROLLLINES.
[/edit]

modified 14-Jun-19 9:09am.

AnswerRe: WM_MOUSEWHEEL message and the Touchpad Pin
Gerry Schmitz13-Jun-19 9:26
mveGerry Schmitz13-Jun-19 9:26 
GeneralRe: WM_MOUSEWHEEL message and the Touchpad Pin
Richard MacCutchan13-Jun-19 21:19
mveRichard MacCutchan13-Jun-19 21:19 
GeneralRe: WM_MOUSEWHEEL message and the Touchpad Pin
Richard MacCutchan14-Jun-19 1:04
mveRichard MacCutchan14-Jun-19 1:04 
GeneralRe: WM_MOUSEWHEEL message and the Touchpad Pin
Gerry Schmitz15-Jun-19 5:36
mveGerry Schmitz15-Jun-19 5:36 
GeneralRe: WM_MOUSEWHEEL message and the Touchpad Pin
Richard MacCutchan15-Jun-19 6:58
mveRichard MacCutchan15-Jun-19 6:58 
QuestionRe: WM_MOUSEWHEEL message and the Touchpad Pin
David Crow13-Jun-19 10:45
David Crow13-Jun-19 10:45 
AnswerRe: WM_MOUSEWHEEL message and the Touchpad Pin
Richard MacCutchan13-Jun-19 21:20
mveRichard MacCutchan13-Jun-19 21:20 
AnswerRe: WM_MOUSEWHEEL message and the Touchpad Pin
Richard MacCutchan14-Jun-19 1:03
mveRichard MacCutchan14-Jun-19 1:03 
AnswerRe: WM_MOUSEWHEEL message and the Touchpad Pin
Randor 14-Jun-19 0:31
professional Randor 14-Jun-19 0:31 
GeneralRe: WM_MOUSEWHEEL message and the Touchpad Pin
Richard MacCutchan14-Jun-19 0:55
mveRichard MacCutchan14-Jun-19 0:55 
PraiseRe: WM_MOUSEWHEEL message and the Touchpad Pin
Randor 14-Jun-19 2:00
professional Randor 14-Jun-19 2:00 
GeneralRe: WM_MOUSEWHEEL message and the Touchpad Pin
Richard MacCutchan14-Jun-19 3:07
mveRichard MacCutchan14-Jun-19 3:07 
QuestionC++ Callback process is dea Pin
Member 1422104112-Jun-19 23:05
Member 1422104112-Jun-19 23:05 
AnswerRe: C++ Callback process is dea Pin
Victor Nijegorodov12-Jun-19 23:18
Victor Nijegorodov12-Jun-19 23:18 
GeneralRe: C++ Callback process is dea Pin
Member 1422104112-Jun-19 23:48
Member 1422104112-Jun-19 23:48 
SuggestionRe: C++ Callback process is dea Pin
David Crow13-Jun-19 7:45
David Crow13-Jun-19 7:45 
GeneralRe: C++ Callback process is dea Pin
Victor Nijegorodov13-Jun-19 10:24
Victor Nijegorodov13-Jun-19 10:24 

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.