Set width of scrollbar

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

User avatar
mol
Posts: 3227
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 224 times
Been thanked: 127 times
Contact:

Set width of scrollbar

Post by mol » Mon Aug 26, 2019 6:34 am

Hi guys!
I need to increase the width of vertical scrollbar of grid.
Does somebody know how to do it?
Is it possible?

User avatar
AUGE_OHR
Posts: 77
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 2 times
Been thanked: 9 times

Post by AUGE_OHR » Sun Sep 01, 2019 6:06 am

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.

User avatar
mol
Posts: 3227
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 224 times
Been thanked: 127 times
Contact:

Post by mol » Sun Sep 01, 2019 8:12 am

Thanks.
But I don't know how to do it

KDJ
Posts: 223
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 262 times

Post by KDJ » Sun Sep 01, 2019 9:41 pm

Marek

In my opinion, this can't be done in HMG.

User avatar
mol
Posts: 3227
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 224 times
Been thanked: 127 times
Contact:

Post by mol » Mon Sep 02, 2019 5:51 am

I've searched for some solutions, but I'm not familiar with C

KDJ
Posts: 223
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 262 times

Post by KDJ » Mon Sep 02, 2019 8:50 pm

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?

User avatar
mol
Posts: 3227
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 224 times
Been thanked: 127 times
Contact:

Post by mol » Tue Sep 03, 2019 8:28 am

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 :-D

User avatar
mol
Posts: 3227
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 224 times
Been thanked: 127 times
Contact:

Post by mol » Tue Sep 03, 2019 10:49 am

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, :-D :-D
and, scrolling buttons (up and down) as small as standard scrollbar.
I'm building touch application, so these buttons should be bigger.

KDJ
Posts: 223
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 262 times

Post by KDJ » Tue Sep 03, 2019 5:42 pm

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


Post Reply