Board index » delphi » Control Transparency, Scrollbars

Control Transparency, Scrollbars

Hi Everybody,

I am using Delphi 4 client/server edition. I have two queries.

1. i want to Hide/Remove Scrollbars from a control like TListBox which
appears automatic when the number of items increase and does not fit into
display height / width of control.

2. My second query is how can i set the background color Transparent of
controls like TMemo or RichEdit ( e.g. just like in MS ACCESS 97 the
background image is show through the control).

Thanks in Advance

Regards
Manoj

 

Re:Control Transparency, Scrollbars


Manoj,

  As for the scroll bars in a list box, create a descentant of TListBox and
override the CreateParams method to subtract the WS_VSCROLL and/or
WS_HSCROLL bits from the Params.Style. Example:

interface

type
  TMyTestListBox = class(TListBox)
    protected
      procedure CreateParams(var Params: TCreateParams); override;
  end;

implementation

procedure TMyTestListBox.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.Style:=Params.Style - WS_VSCROLL;
end;

end.

And for the transparent backgrounds look into the TCreateParams and paint
methods of the control you want to implement that on.  As well, look at the
inheritence of the control.  It may just be easier to look into third party
controls, unless it's a must know on the how's and why's.

Hope this helps,

Michael P. Bobowski
President
Delta Technical Solutions
Milwaukee, WI, USA
e-mail: mb...@execpc.com

Re:Control Transparency, Scrollbars


Please do not post your question to several of the newsgroups at once, it is against the forum guidelines (see
http://www.borland.com/newsgroups/) and just wastes resources (both server and human, somebody might spend time on answering a post that
has already been answered in another newsgroup).

For control-related questions the most appropriate group is delphi.vcl.components.using.

Quote
> 1. i want to Hide/Remove Scrollbars from a control like TListBox which
> appears automatic when the number of items increase and does not fit into
> display height / width of control.

Well, there is a ShowScrollbar API function, which you could use like this:

  ShowScrollbar( listbox1.handle, SB_VERT, 0 );

Problem is, the control will add the scrollbar back on the next addition of an item.
The listbox is a Windows standard control and i know no method to prevent it from
adding the scrollbar when it sees fit.

Quote
> 2. My second query is how can i set the background color Transparent of
> controls like TMemo or RichEdit ( e.g. just like in MS ACCESS 97 the
> background image is show through the control).

That is fairly hopeless with the standard TMemo and TRichedit controls, the Windows
controls they are based on have no provision to handle background bitmaps or
transparency. I don't know if version 2 or 3 of the richedit control has support
for this. Delphi does not come with wrappers for these versions but there are
3rd-party wrapper classes around for them, e.g. TRichedit98. Search the usual Delphi si
sites:

Delphi Super Page       http://sunsite.icm.edu.pl/delphi/
  US mirror site:       http://www.cdrom.com/pub/delphi_www/
  German mirror :        
http://ftp.uni-erlangen.de/pub/source/MIRRORS/sunsite.icm.edu.pl/pub/...
  Other mirrors :       http://ftp.sunet.se/delphi/
Torry's Delphi Pages    http://www.torry.ru/  
the Delphi Box          http://Inner-Smile.com .
                        http://www.delphisource.com/
The DELPHI Deli         http://www.delphix.com/
The Delphi EXchange     http://www.delphiexchange.com/

Quote

> Thanks in Advance

> Regards
> Manoj

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:Control Transparency, Scrollbars


Peter,

Quote
>Problem is, the control will add the scrollbar back on the next addition of
an item.
>The listbox is a Windows standard control and i know no method to prevent
it from
>adding the scrollbar when it sees fit.

    If you do the CreateParams the scrollbars don't come back unless you do
a recreate and have boolean switches to add or subtract the WS_VSCROLL /
WS_HSCROLL.  But I should have said to decend from TCustomListBox not
TListBox.  Just a note.

Mike

Other Threads