News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Scrollbar ousts Statusbar

Started by bEaST2k, March 06, 2006, 02:26:52 PM

Previous topic - Next topic

bEaST2k

Hello everybody!

I'm currently writing an life (http://www.math.com/students/wonders/life/life.html) simulator. Now there is one thing that really makes me headache! For my application I'm using a simple window and in addition 2 scrollbars (horizontal and vertical). All I want to do is to add a statusbar at the bottom of my window. Let me tell you, it's not as easy as it seems to be  :wink. It doesn't matter if I call the CreateWindow-Function, with the statusbar class as argument, before or after I create the scrollbars; it's alwalys the same: the status bar is over the horizontal scrollbar and not at the bottom of my window! I'm really getting tired of this nuisance  :'(. Maybe, or better: hopefully, someone has an ray of hope for me!

Thank you!

Regards,
Fabian

PBrennick

Fabian,
I do not see any code I can look at to help you so I guess it is proprietary.  Well, here goes.  typically when you create a window, it might have several objects.  A menubar, a toolbar, a scrollbar and a text window.  What you have to do is make sure that the hieghts of your toolbar, scrollbar and a game area add up to the hieght of the window.  To me, it sounds like no room is left over after making the other objects to allow for the statusbar.  Decrease the size of your game area (where the game is played) so as to allow room for the statusbar.  Try decreasing the height of the game area by 12.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

donkey

A good idea with scroll bars at least is to make them a child of the window they are scrolling then forward the WM_SCROLL messages to the main window, you can also set the "clipping" order so that other children will not cover the scroll bar. I believe I did that in Res2Dlg in order to have a static control that scrolled an image. I will have to check the code when I get home but I have done this before and should have something for you.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

zcoder

I think what the problem is, is this(correct me if I am wrong)

He made a window that has the style of haveing Hcsroll and Vscroll's
and the Hscroll bar wants to be on the bottom edge of the window.
while at the same time the statusbar he added to this window wants
to be there too.

The only thing I can think of is to make a inner window that you can
Shorten the height on in the WM_SIZE area to be less the statusbar height
by getting the statusbar height using GetWindowRect then converting that
to Client cord's using ScreenToClient.

In other words the inner window that would have the scrollbars on it is
resized to the main apps client area minus the statusbar's height durring
WM_SIZE, when they resize the whole app.

Zcoder....
Back in 1979, My computer ran so fine.
And there was no such thing,
As a Microsoft Crashed Machine.
http://zcoder.110mb.com
http://www.dietzel.com/partner/idevaffiliate.php?id=345_6  Free Domain Names

bEaST2k

Quote from: PBrennick on March 06, 2006, 03:38:29 PM
Fabian,
I do not see any code I can look at to help you so I guess it is proprietary.

NO it isn't! But it is coded in C, so i thought not to bore you to death with foreign code listings  :wink.


Quote from: zcoder on March 07, 2006, 01:38:48 AM
I think what the problem is, is this(correct me if I am wrong)

He made a window that has the style of haveing Hcsroll and Vscroll's
and the Hscroll bar wants to be on the bottom edge of the window.
while at the same time the statusbar he added to this window wants
to be there too.

zcoder, that's exactly what I'm speaking about  :U.
I created a simple window with the WS_VSCROLL or WS_HSCROLL style and added a status bar at runtime. Now, as I maybe not pointed out clearly enough, the scroll bar is at the very bottom of the window. All my whishes as a programmer are, that's it vice versa (i.e. the status bar is at the very bottom of the window - not the scrollbar)!

Quote from: zcoder on March 07, 2006, 01:38:48 AM
The only thing I can think of is to make a inner window that you can
Shorten the height on in the WM_SIZE area to be less the statusbar height
by getting the statusbar height using GetWindowRect then converting that
to Client cord's using ScreenToClient.

In other words the inner window that would have the scrollbars on it is
resized to the main apps client area minus the statusbar's height durring
WM_SIZE, when they resize the whole app.

Please correct me if I am now wrong: Your advise for me is to create another window (child window), which owns the scroll bars and create the status bar in the main window. Hm, definitely a solution (this thought came to me too  :lol)! But it's not as easy... heavy code restructuring would be the answer. Also i've got hooked about this stuff now  :P!

Here a short code sniped i've created:


.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Comctl32.inc

includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib

WinMain proto :HINSTANCE,:HINSTANCE,:PSTR,:DWORD
WndProc proto :HWND,:UINT,:WPARAM,:LPARAM

.data
szWndClass db "Demonstration",0

.data?
hInstance dd ?
hStatusWnd dd ?
.code

start:

invoke GetModuleHandle,NULL
mov hInstance,eax

invoke InitCommonControls

  invoke WinMain,hInstance,NULL,NULL,SW_SHOWNORMAL
invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,szCmdLine:PSTR,iCmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hWnd:HWND

mov   wc.cbSize,sizeof WNDCLASSEX
mov   wc.style, CS_HREDRAW or CS_VREDRAW
mov   wc.lpfnWndProc,offset WndProc
mov   wc.cbClsExtra,NULL
mov   wc.cbWndExtra,NULL
push  hInstance
pop   wc.hInstance
mov   wc.hbrBackground,COLOR_WINDOW+1
mov   wc.lpszMenuName,NULL
mov   wc.lpszClassName,offset szWndClass
invoke LoadIcon,NULL,IDI_APPLICATION
mov   wc.hIcon,eax
mov   wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov   wc.hCursor,eax
invoke RegisterClassEx,addr wc

invoke CreateWindowEx,NULL,addr szWndClass,addr szWndClass,\
           WS_OVERLAPPEDWINDOW or WS_VSCROLL or WS_HSCROLL,CW_USEDEFAULT,\
           CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
           hInst,NULL
mov   hWnd,eax
invoke ShowWindow, hWnd,iCmdShow
invoke UpdateWindow, hWnd

.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.break .if (!eax)
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw

mov     eax,msg.wParam
ret
WinMain endp

WndProc proc hWnd:HWND,message:UINT,wParam:WPARAM,lParam:LPARAM

.if message ==WM_CREATE
invoke CreateStatusWindow,WS_CHILD+WS_VISIBLE,NULL,hWnd,2999 ; no need for beeing specific, just a demo
mov hStatusWnd,eax
.elseif message == WM_SIZE
            invoke SendMessage,hStatusWnd,WM_SIZE,0,0   ; resize the statusbar (wParam and lParam values are not important,
                                                        ; the default position of the status bar is at the "bottom" [notice the " " ^^])
.elseif message == WM_DESTROY
            invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,message,wParam,lParam
ret
.endif

xor eax,eax
ret
WndProc endp

end start


Just build it...

ml /c /coff /Cp /nologo demo.asm
link /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /OUT:"Demo.exe" Demo.obj


Regards,
Fabian

PBrennick

bEaST2k

\masm32\examples\exampl05\arrays contains a dummy app that shows you how 2 make what you need.  Execute the exe to see what I mean and then study the code to see how it is done.  Everything you need is there.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

bEaST2k

Quote from: PBrennick on March 08, 2006, 03:26:43 AM
bEaST2k

\masm32\examples\exampl05\arrays contains a dummy app that shows you how 2 make what you need.  Execute the exe to see what I mean and then study the code to see how it is done.  Everything you need is there.

Paul


Thanks, sounds interesting! I'll have a look on it...

bEaST2k

Quote from: PBrennick on March 08, 2006, 03:26:43 AM
bEaST2k

\masm32\examples\exampl05\arrays contains a dummy app that shows you how 2 make what you need.  Execute the exe to see what I mean and then study the code to see how it is done.  Everything you need is there.

Paul

Sorry, I can not see any code that has something to do with my problem :(.


BTW. The problem now vanished! I've created an child window an added 2 scroll bars to it.
My problem was (or is), that status bar controls are created in the client area
of the window, scroll bars however are created in the non-client area (managed by winDO(w)S).
One solution is to create an scroll bar 'control' (!) and position it over the status bar
manually. Dirty and not very elegant (doesn't look nice with visual themes enabled either!).

Thanks for your help anyway!

Regards,
Fabian

zcoder

Fabian,
I knew you would come to that conclusion as 2 controls can not
be in the same place and some controls look messy when you
try to move them baste on there actions.

Zcoder....
Back in 1979, My computer ran so fine.
And there was no such thing,
As a Microsoft Crashed Machine.
http://zcoder.110mb.com
http://www.dietzel.com/partner/idevaffiliate.php?id=345_6  Free Domain Names