Hi windows API programmers,
I'm so close to making my vertical scrollbar to work properly, except for:
After pushing or dragging the scrollbar the window scrolls properly until I let go of the mouse. When I let go the window scrolls another unit to which I don't want to happen. I want to have the scrollbar place the window where it was set rather than 1 unit up or down.
Another odd thing is the WM_VSCROLL message is called once when the mouse is down and once when the mouse is up. I think if I can make it only call it for mousedown then it would fix this problem.
Suggestions? Thanks. -
case WM_VSCROLL:
-
{
-
int nScrollCode = (int)LOWORD(wParam);
-
int nPos = (short int)HIWORD(wParam);
-
controlVbar(nScrollCode, nPos);
-
-
if(curScrollPos!=oldScrollPos && curScrollPos > 0 && curScrollPos < 100)
-
{
-
ScrollWindowEx(hwndMain, 0, oldScrollPos-curScrollPos, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN);
-
RedrawWindow(hwndMain, NULL, NULL, RDW_ERASE | RDW_INVALIDATE );
-
-
}
-
}
-
break;
-
The following is the controlVbar function called from the above line 5. -
void mainWindow::controlVbar(int nScrollCode, int nPos)
-
{
-
-
switch (nScrollCode)
-
{
-
// Include code that checks for other values of nScrollCode.
-
// ...
-
case SB_THUMBTRACK:
-
{
-
oldScrollPos=curScrollPos;
-
curScrollPos=nPos;
-
SetScrollPos(hwndMain, SB_VERT, nPos, TRUE);
-
}
-
break;
-
-
case SB_LINEUP:
-
{
-
if(curScrollPos > 0)
-
{
-
oldScrollPos=curScrollPos;
-
curScrollPos=oldScrollPos-1;
-
}
-
SetScrollPos(hwndMain, SB_VERT, curScrollPos, TRUE);
-
}
-
break;
-
-
case SB_LINEDOWN:
-
{
-
oldScrollPos=curScrollPos;
-
if(curScrollPos < 100)
-
{
-
oldScrollPos=curScrollPos;
-
curScrollPos=oldScrollPos+1;
-
}
-
SetScrollPos(hwndMain, SB_VERT, curScrollPos, TRUE);
-
}
-
break;
-
-
}
-
-
-
}
-
2 2297
to complete this with an answer I figured out:
first make 3 global int -
int oldScrollPos=0;
-
int curScrollPos=1;
-
int lastScroll;
-
Then add these functions: - void msWheel(HWND hwnd, int zDelta)
-
{
-
if(zDelta > 0)
-
zDelta=120;
-
else
-
zDelta=-120;
-
-
oldScrollPos=curScrollPos;
-
if(curScrollPos <= 680 && zDelta < 0)
-
curScrollPos+=120;
-
else if(curScrollPos > 680 && zDelta < 0)
-
curScrollPos=799;
-
-
if(curScrollPos > 120 && zDelta > 0)
-
curScrollPos+=-120;
-
else if(curScrollPos < 120 && zDelta > 0)
-
curScrollPos=1;
-
-
SetScrollPos(hwnd, SB_VERT, curScrollPos, TRUE);
-
-
if(curScrollPos!=lastScroll && curScrollPos > 0 && curScrollPos < 800)
-
{
-
ScrollWindowEx(hwnd, 0, oldScrollPos-curScrollPos,
-
NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN);
-
RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE );//| RDW_ALLCHILDREN
-
-
lastScroll=curScrollPos;
-
-
}
-
-
}
-
-
void controlVbar(int nScrollCode, int nPos, HWND hwnd)
-
{
-
-
switch (nScrollCode)
-
{
-
// Include code that checks for other values of nScrollCode.
-
// ...
-
case SB_THUMBTRACK:
-
{
-
oldScrollPos=curScrollPos;
-
curScrollPos=nPos;
-
SetScrollPos(hwnd, SB_VERT, nPos, TRUE);
-
}
-
break;
-
-
case SB_LINEUP:
-
{
-
if(curScrollPos > 0)
-
{
-
oldScrollPos=curScrollPos;
-
if(curScrollPos > 10)
-
curScrollPos=oldScrollPos-10;
-
else
-
curScrollPos=1;
-
}
-
SetScrollPos(hwnd, SB_VERT, curScrollPos, TRUE);
-
}
-
break;
-
-
case SB_LINEDOWN:
-
{
-
oldScrollPos=curScrollPos;
-
if(curScrollPos < 800)
-
{
-
oldScrollPos=curScrollPos;
-
curScrollPos=oldScrollPos+10;
-
}
-
SetScrollPos(hwnd, SB_VERT, curScrollPos, TRUE);
-
}
-
break;
-
-
}
-
-
if(curScrollPos!=lastScroll && curScrollPos > 0 && curScrollPos < 800)
-
{
-
ScrollWindowEx(hwnd, 0, oldScrollPos-curScrollPos,
-
NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN);
-
RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE );//| RDW_ALLCHILDREN
-
-
lastScroll=curScrollPos;
-
}
-
-
-
}
-
Then to call those functions add these cases in your CALLBACK switch: -
case WM_VSCROLL:
-
{
-
int nScrollCode = (int)LOWORD(wParam);
-
int nPos = (short int)HIWORD(wParam);//short int?
-
controlVbar(nScrollCode, nPos, hwnd);
-
}
-
break;
-
case WM_MOUSEWHEEL:
-
msWheel(hwnd, GET_WHEEL_DELTA_WPARAM(wParam));
-
-
-
break;
-
To create the scrollbar I added the vertical scrollbar style on the parent dialog.
then did this code in the main: -
SCROLLINFO si = {sizeof(SCROLLINFO),
-
SIF_PAGE|SIF_POS|SIF_RANGE|SIF_TRACKPOS, 1, 799, 0, 0,
-
0};
-
SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Roderik |
last post by:
Hi,
At http://archytas.nl/ there appears to be a horizontal scrollbar when
using Mozilla Firebird (not in IE). The website (container DIV) should
be 770 px wide, so there shouldn't be any reason...
|
by: Jeje |
last post by:
Hi everybody,
I have an issue using the scrollbar under Internet explorer 6, WinXP
and transitional.dtd.
Here's my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
|
by: markusszil |
last post by:
Hello all
I have a fairly simple listbox into which I add, insert, and remove strings
It has the following property settings
HorizontalScrollbar - true
HorizontalExtent -
ScrollAlwaysVisible...
|
by: Sujan |
last post by:
Hello all,
Is it possible to remove scrollbar(s) without using frames. Is there
any code which could be applied in body tag to remove scrollbar(s).
Thanks in adv,
Sujan
|
by: Spondishy |
last post by:
Hi,
I am using the following in my stylesheet to center divs in firefox.
html>body {
font-size: 13px;
}
div.centerdiv
{
| |
by: Coder |
last post by:
my question is not only specific to C#. In most of the visual environments
we use textboxes, buttons etc..
Exp: In C# i have a textbox (multiline textbox). Suppose that, application
is...
|
by: weston |
last post by:
I'm making a foray into trying to create custom vertical scrollbars and
sliders, and thought I had a basic idea how to do it, but seem to be
having some trouble with the implementation.
My...
|
by: hsriat |
last post by:
How can I temporarily disable vertical scrollbar?
I have replaced confirmation boxes and alert boxes with inlay popup DIVs. But while they are on the screen, I need to disable scrollbar of the...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |