Page 1 of 2
Set width of scrollbar
Posted: Mon Aug 26, 2019 6:34 am
by mol
Hi guys!
I need to increase the width of vertical scrollbar of grid.
Does somebody know how to do it?
Is it possible?
Re: Set width of scrollbar
Posted: Sun Sep 01, 2019 6:06 am
by AUGE_OHR
Scrollbar of GRID (Listview) can only switch on/off and they internal.
i have try to change Color of those Scrollbar but was not able to get a handle
the only Way was to switch internal Scrollbar OFF and make own Scrollbar / Slider.
Re: Set width of scrollbar
Posted: Sun Sep 01, 2019 8:12 am
by mol
Thanks.
But I don't know how to do it
Re: Set width of scrollbar
Posted: Sun Sep 01, 2019 9:41 pm
by KDJ
Marek
In my opinion, this can't be done in HMG.
Re: Set width of scrollbar
Posted: Mon Sep 02, 2019 5:51 am
by mol
I've searched for some solutions, but I'm not familiar with C
Re: Set width of scrollbar
Posted: Mon Sep 02, 2019 8:50 pm
by KDJ
This can be done as follows:
1. Remove internal Scrollbar from ListView (grid) control. It does not require coding in C.
Code: Select all
//subclass ListView (grid):
EventCreate({ || GridEvents() }, hWndGrid, 0x83 /*WM_NCCALCSIZE*/)
FUNCTION GridEvents()
//remove internal Scrollbar
HMG_ChangeWindowStyle(EventHWND(), NIL, 0x00200000 /*WS_VSCROLL*/, NIL, .T.)
//or hide internal Scrollbar
//ShowScrollbar(EventHWND(), 1 /*SB_VERT*/, .F.);
RETURN NIL
2. Create your own Scrollbar control.
3. Handle Scrollbar control exceptions.
Unfortunately, in HMG can not remove the internal Scrollbar because WM_NCCALCSIZE message is not sent to events function.
And I don't know why!
Does anyone know?
Re: Set width of scrollbar
Posted: Tue Sep 03, 2019 8:28 am
by mol
I'm using my MiniGrid sample based on panel window.
I can hide scrollbars of this window by:
Code: Select all
HMG_ChangeWindowStyle(GetFormHandle(cFormName), NIL, WS_HSCROLL , .F.)
HMG_ChangeWindowStyle(GetFormHandle(cFormName), NIL, WS_VSCROLL , .F.)
I can create two buttons for sliding window up and down, but, I don't know how to assign scrolling to them

PS. Jestem po prostu za cienki do programowania windowsów

Re: Set width of scrollbar
Posted: Tue Sep 03, 2019 10:49 am
by mol
I've found a solution to create own scrollbar:
Code: Select all
pragma BEGINDUMP
#include "HMG_UNICODE.h"
#include <windows.h>
#include <commctrl.h>
#include "tchar.h"
#include "hbapi.h"
HB_FUNC( CREATEVERTICALSCROLLBAR )
{
HWND hwndParent;
HWND hWnd_Control;
hwndParent = (HWND) HMG_parnl (1);
RECT rect;
// Get the dimensions of the parent window's client area;
if (!GetClientRect(hwndParent, &rect))
HMG_retnl( NULL );
// Create the scroll bar.
hWnd_Control = CreateWindowEx(
0, // no extended styles
"SCROLLBAR", // scroll bar control class
(PTSTR) NULL, // no window text
WS_CHILD | WS_VISIBLE // window styles
| SBS_VERT, // horizontal scroll bar style
rect.left, // vertical position
rect.bottom - 200, // vertical position
rect.right, // width of the scroll bar
200, //sbHeight, height of the scroll bar
hwndParent, // handle to main window
(HMENU) NULL, // no menu
GetModuleHandle(NULL), //g_hInst, instance owning this window
(PVOID) NULL ); // pointer not needed
HMG_retnl ((LONG_PTR) hWnd_Control);
}
#PRAGMA ENDDUMP
This scroolbar width is 200 px.
But - it doesn't scroll my window,

and, scrolling buttons (up and down) as small as standard scrollbar.
I'm building touch application, so these buttons should be bigger.
Re: Set width of scrollbar
Posted: Tue Sep 03, 2019 5:42 pm
by KDJ
Marek
About Scrollbars read here:
https://docs.microsoft.com/en-us/window ... croll-bars
CreateWindowEx function (as wapi_CreateWindowEx) is implemented in hbwin library.
It also contains several Scrollbar functions.
Sources are in:
wapi_winuser_1.c
Re: Set width of scrollbar
Posted: Tue Sep 03, 2019 6:12 pm
by mol
Thanks!