Board index » cppbuilder » Scrollbars on MDI forms

Scrollbars on MDI forms


2006-08-28 11:12:12 PM
cppbuilder91
Hi
I'm sure this question has been asked many times, but does anyone know how
to get rid of the scrollbars that appear on MDI forms when MDI children are
moved outside the visible area. I've found lots of references to it on the
web, but mostly relating to delphi, visual basic, c# etc, but not
c++builder. I believe you have to call:
ShowScrollBar(Form->Handle, SB_BOTH, FALSE);
but I can't seem to find this function.
I'm running version 4.0 of c++builder.
Thanks
Dave
 
 

Re:Scrollbars on MDI forms

This newsgroup is about the C++ programming language, but your
question is about something different (using a VCL component?).
Please direct your browser at info.borland.com/newsgroups/ and
read the newsgroup descriptions and guidelines. This will help you
find the appropriate newsgroup for your question.
 

Re:Scrollbars on MDI forms

Big Bad Dave wrote:
Quote
Hi

I'm sure this question has been asked many times, but does anyone
know how to get rid of the scrollbars that appear on MDI forms when
MDI children are moved outside the visible area. I've found lots of
references to it on the web, but mostly relating to delphi, visual
basic, c# etc, but not c++builder. I believe you have to call:

ShowScrollBar(Form->Handle, SB_BOTH, FALSE);

but I can't seem to find this function.

I'm running version 4.0 of c++builder.

Thanks
Dave
The following works for me:
In the FormShow() function for the main window use the following to
sub-class the MDI client window.
if (ClientHandle) {
if (::GetWindowLong(ClientHandle,GWL_USERDATA) == 0) {
::SetWindowLong(ClientHandle,GWL_USERDATA,
::SetWindowLong(ClientHandle,GWL_WNDPROC,
reinterpret_cast<LONG>
(ClientWindowProc)));
}
}
Then all you need is ClientWindowProc(), which looks like this:
LRESULT CALLBACK ClientWindowProc(HWND hwnd,UINT msg,WPARAM
wparam,LPARAM lparam)
{
FARPROC f =
reinterpret_cast<FARPROC>(::GetWindowLong(hwnd,GWL_USERDATA));
switch (msg) {
case WM_NCCALCSIZE:
if (::GetWindowLong(hwnd,GWL_STYLE) & (WS_HSCROLL |
WS_VSCROLL)) {
::SetWindowLong(hwnd,GWL_STYLE,
::GetWindowLong(hwnd,GWL_STYLE) &
~(WS_HSCROLL | WS_VSCROLL));
}
break;
}
return ::CallWindowProc(f,hwnd,msg,wparam,lparam);
}
Hope this helps,
Chris Trengove
 

{smallsort}