Vertical scroll bar not responsive to mouse input.

  • Thread starter Thread starter The Bard of Chelsea
  • Start date Start date
T

The Bard of Chelsea

Guest
PROBLEM DESCRIPTION:

Attached find an excerpt from my code.

Scrolling using the mouse window works just fine. However, no matter what I do with the mouse, the contents of lpScrollInfo remain unchanged.

If I click on the vertical scroll or on one of the arrow buttons, nothing happens.

I can drag the thumb icon to a new position using the left mouse button, but as soon as I release said button, the thumb icon returns to its previous position. Also, while I am dragging the thumb icon, the text in the host window flickers but remains unchanged.

I have scoured the MSDN website and several C++ forums but have found no insight on this issue. Could someone please tell me what I am doing wrong?

Thank you for attending to this issue.

BACKGROUND INFO: I am running 64-bit Win 7 on an HP Zbook workstation. I am using Microsoft VS2015 C++ Express.


CODE SAMPLE:

switch(message)
.
.
//****message**********************************************************
case WM_INITDIALOG:
//-------------------------------------------------------------------
// Create vertical scroll bar.
//-------------------------------------------------------------------
GetClientRect(hDlg,&RectClient);
NumLinesDisplayedByWindow =
int(floor((RectClient.bottom-RectClient.top)/double(cyChar)));
lpScrollBarInfo = new SCROLLBARINFO;
lpScrollInfo = new SCROLLINFO;
hwndVScroll = CreateScrollBarVertical(hDlg,20,0);
lpScrollInfo->cbSize = sizeof(SCROLLINFO);
lpScrollInfo->fMask = SIF_ALL;
lpScrollInfo->nMin = 0;
lpScrollInfo->nMax = NumLines-NumLinesDisplayedByWindow;
lpScrollInfo->nPage = 0;
lpScrollInfo->nPos = 0;
lpScrollInfo->nTrackPos = 0;
SetScrollInfo(hDlg,SB_VERT,(LPCSCROLLINFO)lpScrollInfo,1);
lpScrollInfo->fMask = SIF_POS;
SetScrollInfo(hDlg,SB_VERT,(LPCSCROLLINFO)lpScrollInfo,1);
.
.
return ((INT_PTR)TRUE); // END case WM_INITDIALOG:

//****message**********************************************************
case WM_MOUSEWHEEL:
WheelDelta = -GET_WHEEL_DELTA_WPARAM(wParam)/120;
WheelDeltaLimit = int(ceil(NumLines*0.8));
WheelDelta = min(max(WheelDelta,-WheelDeltaLimit),WheelDeltaLimit);
LineNumber += WheelDelta;
LineNumber = min(max(LineNumber,0),max(NumLines-NumDisplayLines,0));
*szInstructionsDoc = 0;
for (k=LineNumber; k<min(NumLines,LineNumber+9); k++)
strcat(szInstructionsDoc,szInstructions[k]);
mbstowcs_s(&NumCharsConverted, wcstring, MsgLen
, szInstructionsDoc, strlen(szInstructionsDoc)+1);
SetDlgItemText(hDlg,IDC_INSTRUCTIONS,wcstring);
lpScrollInfo->nPos = LineNumber;
SetScrollInfo(hDlg,SB_VERT,(LPCSCROLLINFO)lpScrollInfo,1);
return (INT_PTR)TRUE; // END case WM_MOUSEWHEEL:

//****message**********************************************************
case WM_VSCROLL:
//-------------------------------------------------------------------
// Reposition trackbar marker position per direction of
// mousewheel movement.
//-------------------------------------------------------------------
lpScrollInfo->cbSize = sizeof(SCROLLINFO);
lpScrollInfo->fMask = SIF_ALL;
GetScrollInfo(hDlg,SB_VERT,(LPSCROLLINFO)lpScrollInfo);
LineNumber = lpScrollInfo->nPos;
*szInstructionsDoc = 0;
for (k=LineNumber; k<min(NumLines,LineNumber+9); k++)
strcat(szInstructionsDoc,szInstructions[k]);
mbstowcs_s(&NumCharsConverted, wcstring, MsgLen
, szInstructionsDoc, strlen(szInstructionsDoc)+1);
SetDlgItemText(hDlg,IDC_INSTRUCTIONS,wcstring);
lpScrollInfo->nPos = LineNumber;
SetScrollInfo(hDlg,SB_VERT,(LPCSCROLLINFO)lpScrollInfo,1);
GetClientRect(hDlg,&RectClient);
InvalidateRect(hDlg,&RectClient,true);
return (INT_PTR)TRUE; // END case WM_VSCROLL:
.
.

rwh

Continue reading...
 
Back
Top