 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Clayton L. Wilson Guest
|
Posted: Tue Aug 05, 2003 12:16 am Post subject: Size of TScrollBar |
|
|
I'm using TScrollBars in my component. How do I ensure that the width equals
the Windows width (set in properties on the desktop) when Kind is
sbVertical, as well as the height when Kind is sbHorizontal? Thanks a bunch.
--
Clayton L. Wilson
|
|
| Back to top |
|
 |
Rob Kennedy Guest
|
Posted: Tue Aug 05, 2003 4:15 am Post subject: Re: Size of TScrollBar |
|
|
Clayton L. Wilson wrote:
| Quote: | I'm using TScrollBars in my component. How do I ensure that the width equals
the Windows width (set in properties on the desktop) when Kind is
sbVertical, as well as the height when Kind is sbHorizontal? Thanks a bunch.
|
GetSystemMetrics(sm_CXVScroll);
or
SystemParametersInfo(spi_GetNonClientMetrics, ...);
You'll also want to handle the wm_SettingChange window message so that
you can readjust the scroll-bar sizes when the user changes those settings.
--
Rob
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Tue Aug 05, 2003 5:07 am Post subject: Re: Size of TScrollBar |
|
|
Check my tip:
********************************
Delphi tip#52: to get the sizes of system controls
http://www.scalabium.com/faq/dct0052.htm
********************************
PS: you need the GetSystemMetrics function
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Clayton L. Wilson" <claytonwilson (AT) ev1 (DOT) net> wrote
| Quote: | I'm using TScrollBars in my component. How do I ensure that the width
equals
the Windows width (set in properties on the desktop) when Kind is
sbVertical, as well as the height when Kind is sbHorizontal? Thanks a
bunch.
--
Clayton L. Wilson
|
|
|
| Back to top |
|
 |
Rob Kennedy Guest
|
Posted: Tue Aug 05, 2003 11:05 pm Post subject: Re: Size of TScrollBar |
|
|
Clayton L. Wilson wrote:
| Quote: | Alright, GetSystemMetrics(sm_CXVScroll) was easy enough. No problems there.
As for wm_SettingChange, I have no idea how to implement.
|
First, add a message handler to your form to catch that message:
TForm1 = class(TForm)
protected
procedure WMSettingChange(var Message: TWMSettingChange); message
wm_SettingChange;
end;
Then, implement the procedure:
procedure TForm1.WMSettingChange;
begin
inherited;
end;
Finally, add code that will reread any system settings that your program
relies on, such as the size ofa scroll bar. The message is sent whenever
the user changes system settings, but the message does not include
*which* settings changed, so you have to read all of them.
I use the message to update several aspects of my programs: the
hot-tracking feature on page controls and list views, the
full-window-drag setting on splitters, dimensions of controls like
scroll bars, etc.
--
Rob
|
|
| Back to top |
|
 |
Rob Kennedy Guest
|
Posted: Wed Aug 06, 2003 4:00 am Post subject: Re: Size of TScrollBar |
|
|
Clayton L. Wilson wrote:
| Quote: | I added the code, but it's not running it. BTW, I'm writing a visual
component if that makes any difference.
|
Yeah, it probably will make a difference. That message is only set to
top-level windows. I forgot that this was the component-writing
newsgroup until it was too late.
I don't know whether Delphi will forward the message to child controls
as notification messages. For some messages, Delphi adds cn_Base to the
original message and broadcasts it to all the form's controls.
| Quote: | I did notice that when the app is running, the scrollbars get resized half
of the way. ie the width on sbVertical but not the height of the buttons.
Same with the sbHorizontal height.
|
The height of a button on a vertical scroll bar is given by the
sm_CYVScroll GetSystemMetrics flag. If the scroll bar is too short to
accomodate that height, then the buttons get shorter, but I think the
scroll bar takes care of that detail automatically.
--
Rob
|
|
| Back to top |
|
 |
Clayton L. Wilson Guest
|
Posted: Thu Aug 07, 2003 4:35 pm Post subject: Re: Size of TScrollBar |
|
|
Thanks for the help. I guess I don't really need that anyway. Besides,
what's the odds that a user will change the scrollbar size when my program
is running anyway?
"Rob Kennedy" <rkennedy (AT) example (DOT) com> wrote
| Quote: | Clayton L. Wilson wrote:
I added the code, but it's not running it. BTW, I'm writing a visual
component if that makes any difference.
Yeah, it probably will make a difference. That message is only set to
top-level windows. I forgot that this was the component-writing
newsgroup until it was too late.
I don't know whether Delphi will forward the message to child controls
as notification messages. For some messages, Delphi adds cn_Base to the
original message and broadcasts it to all the form's controls.
I did notice that when the app is running, the scrollbars get resized
half
of the way. ie the width on sbVertical but not the height of the
buttons.
Same with the sbHorizontal height.
The height of a button on a vertical scroll bar is given by the
sm_CYVScroll GetSystemMetrics flag. If the scroll bar is too short to
accomodate that height, then the buttons get shorter, but I think the
scroll bar takes care of that detail automatically.
--
Rob
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|