Set width of scrollbar

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Set width of scrollbar

Post 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?
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Set width of scrollbar

Post 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.
have fun
Jimmy
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Set width of scrollbar

Post by mol »

Thanks.
But I don't know how to do it
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: Set width of scrollbar

Post by KDJ »

Marek

In my opinion, this can't be done in HMG.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Set width of scrollbar

Post by mol »

I've searched for some solutions, but I'm not familiar with C
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: Set width of scrollbar

Post 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?
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Set width of scrollbar

Post 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 :-D
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Set width of scrollbar

Post 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, :-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: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: Set width of scrollbar

Post 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
Post Reply