Celebrating the 22th anniversary of the UltraVNC: https://forum.uvnc.com/viewtopic.php?t=38031
Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Bluesky/AT Protocol: https://bsky.app/profile/ultravnc.bsky.social
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

Scroll bar handling

Any features you would like to see in UltraVNC? Propose it here
Post Reply
neitsch
Posts: 1
Joined: 2006-08-05 21:42

Scroll bar handling

Post by neitsch »

Hmm, the developer forums are locked down, and the bbcode is double-spacing my patches. Is this the right place to post this?

I fixed some things in UltraVNC 1.0.2 that weren't doing what I expected:

Don't show the scrollbars if things fit inside the window.
[syntax="c"]
--- ClientConnection.cpp 2006/08/05 18:05:00 1.1
+++ ClientConnection.cpp 2006/08/05 18:30:15
@@ -2103,15 +2103,26 @@
else
SetRect(&fullwinrect, 0, 0, m_si.framebufferWidth, m_si.framebufferHeight);

- AdjustWindowRectEx(&fullwinrect,
- GetWindowLong(m_hwnd, GWL_STYLE) & ~WS_VSCROLL & ~WS_HSCROLL,
- FALSE, GetWindowLong(m_hwnd, GWL_EXSTYLE));
- /*
+
+ if(m_hScrollBarVisible) {
+ fullwinrect.bottom += GetSystemMetrics(SM_CXHSCROLL);
+ }
+ if(m_vScrollBarVisible) {
+ fullwinrect.right += GetSystemMetrics(SM_CXVSCROLL);
+ }
+
+/*
AdjustWindowRectEx(&fullwinrect,
GetWindowLong(m_hwndMain, GWL_STYLE),
FALSE, GetWindowLong(m_hwndMain, GWL_EXSTYLE));
- */
+*/

+ AdjustWindowRectEx(&fullwinrect,
+ GetWindowLong(m_hwnd, GWL_STYLE) & ~WS_VSCROLL & ~WS_HSCROLL,
+ FALSE, GetWindowLong(m_hwnd, GWL_EXSTYLE));
+
+
+
m_fullwinwidth = fullwinrect.right - fullwinrect.left;
m_fullwinheight = (fullwinrect.bottom - fullwinrect.top);

@@ -2477,7 +2488,7 @@
rgbQ.r = ((((i >> m_myFormat.redShift) & m_myFormat.redMax) * 65535) + m_myFormat.redMax/2) / m_myFormat.redMax;
}

- for (i=0; i<256; i++)
+ for (int i=0; i<256; i++)
{
bi.color.rgbRed = rgbQ.r >> 8;
bi.color.rgbGreen = rgbQ.g >> 8;
@@ -5459,14 +5470,22 @@

#ifndef UNDER_CE
if (_this->InFullScreenMode() ||
- _this->m_winwidth >= _this->m_fullwinwidth &&
+ _this->m_winwidth >= _this->m_fullwinwidth) {
+ ShowScrollBar(hwnd, SB_HORZ, FALSE);
+ _this->m_hScrollBarVisible = FALSE;
+ } else {
+ ShowScrollBar(hwnd, SB_HORZ, TRUE);
+ _this->m_hScrollBarVisible = TRUE;
+ }
+
+ if(_this->InFullScreenMode() ||
_this->m_winheight >= (_this->m_fullwinheight + ((Rtb.bottom - Rtb.top) )) ) {
//_this->m_winheight >= _this->m_fullwinheight ) {
- ShowScrollBar(hwnd, SB_HORZ, FALSE);
ShowScrollBar(hwnd, SB_VERT, FALSE);
+ _this->m_vScrollBarVisible = FALSE;
} else {
- ShowScrollBar(hwnd, SB_HORZ, TRUE);
ShowScrollBar(hwnd, SB_VERT, TRUE);
+ _this->m_vScrollBarVisible = TRUE;
}
#endif

--- ClientConnection.h 2006/08/05 18:05:00 1.1
+++ ClientConnection.h 2006/08/05 18:01:54
@@ -482,6 +482,9 @@

// Window may be scrollable - these control the scroll position
int m_hScrollPos, m_hScrollMax, m_vScrollPos, m_vScrollMax;
+ // Whether the scroll bars are visible
+ BOOL m_hScrollBarVisible;
+ BOOL m_vScrollBarVisible;
// The current window size
int m_winwidth, m_winheight;
__int64 m_BytesSend;
[/code]

Scroll when mouse wheeling over the vertical scrollbar.

Code: Select all

--- ClientConnection.cpp	2006/08/05 18:42:15	1.2
+++ ClientConnection.cpp	2006/08/05 20:10:13	1.3
@@ -5597,7 +5597,20 @@
 					
 					// RealVNC 335 method
 				case WM_MOUSEWHEEL:
-					if (!_this->m_opts.m_ViewOnly)
+					if(DefWindowProc(hwnd, WM_NCHITTEST, 0,	lParam) == HTVSCROLL) {
+						int scrollDelta = -short(HIWORD(wParam));
+
+						UINT uScroll;
+						if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &uScroll, 0)) {
+							uScroll = 3;    /* default value */
+						}
+
+						if (uScroll == 0) {
+							return 0;
+						}
+
+						_this->ScrollScreen(0, scrollDelta / 10 * uScroll);
+					} else if (!_this->m_opts.m_ViewOnly)
 						_this->ProcessMouseWheel((SHORT)HIWORD(wParam));
 					return 0;
 [/syntax]

[mod=494,1154820132]replaced code by syntax=c[/mod]
Last edited by neitsch on 2006-08-05 23:22, edited 1 time in total.
Post Reply