Hi everybody,

There a lot said in this forum about toolbar but I can't find or maybe just not figure out how to place it properly in the window. I created a toolbar in my listview window. trouble is it covers up the list view column headers. I also have a status bar and processing this message:

.elseif uMsg==WM_SIZE

invoke GetClientRect,hWndStatus,ADDR rect
mov eax,rect.bottom
mov sbh,eax

mov eax,lParam
mov edx,eax
and eax,0ffffh
shr edx,16

sub edx,sbh
mov wHgt,edx
mov wWid,eax

invoke SendMessage,hToolBar,TB_AUTOSIZE,0,0

invoke MoveWindow,hWndStatus,0,wWid,sbh,wHgt,TRUE
invoke MoveWindow,hList,0,0,wWid,wHgt,TRUE

I'm confused about how to handle this new toolbar addition. TB_AUTOSIZE doesn't help this problem. Any help or suggestions appreciated.

best regards,

czDrillard
Posted on 2002-01-20 15:55:28 by czDrillard
Some days ago I replied a similar post, read it here, so I don't have to rewrite all the stuff here :grin:.
Posted on 2002-01-20 16:23:48 by LuHa
your toolbar isnt what you will need to adjust, you will need to adjust the size of the listview. so instead of your listview sizes something like 0,0,400,250 you need to set the top of your listview to the bottom size of the toolbar. so something like 0,32,400,250. well at least this is the way i do it.
Posted on 2002-01-20 16:51:12 by smurf
Hi,

I had the same problem and handled it this way.
To start with, the toolbar is created as a child on a rebar,
so after the rebar is created with:



invoke CreateWindowEx, NULL, ADDR RebarClassName,\
NULL, WS_VISIBLE or WS_CHILD or WS_BORDER,\
0, 0, 0, 0,\
hWnd, NULL, hInstance, NULL
mov hWnd_Rebar, eax

The height of the toolbar/rebar is set with:


; set minimum height of child window (toolbar)
; in the rebar control
mov rbi.cyMinChild, 34


This is then used in the WM_SIZE routine:


.ELSEIF uMsg==WM_SIZE

mov eax, rbi.cyMinChild
add eax, 8 ; may need to play with this value

mov ebx, lParam
mov edx, ebx
and ebx, 0ffffh ; width from WM_SIZE message
shr edx, 16 ; height from WM_SIZE message

sub edx, eax ; proper height of listview less the rebar

invoke MoveWindow, hListView,0,eax,ebx,edx,TRUE

; Note - in the following statement, nWidth / nHeight
; don't seem to matter, perhaps because of TBSTYLE_AUTOSIZE,
; so either one works - just need to get a repaint
invoke MoveWindow, hWnd_Rebar,0,0,0,0,TRUE
invoke MoveWindow, hWnd_Rebar,0,0,ebx,eax,TRUE


Then you'll probably want a double buffering Paint routine to prevent the listview flickering. Hope this helps.

Cheers,
Kayaker
Posted on 2002-01-20 18:32:26 by Kayaker
Thanx for replies :) but I think I don't understand the basic concept of WM_SIZE. I read all the threads LuHa and tried following your code Kayaker but got nowhere. Please look at the attached a picture of my window and you can see the print button hiding behind. I think I should move the listview window down or less height but how to do this?




best regards,

czDrillard
Posted on 2002-01-20 23:57:17 by czDrillard
when you created you listview like this:


invoke CreateWindowEx, 0,
ADDR ListViewClass,
0,
WS_CHILD + WS_VISIBLE + LV_REPORT,
0,0,120,30, ;<-- change the 2nd number in list from zero to something like 32
hWin,
ButtonID,
hInstance,
NULL
mov hButton,eax


this will work. i really dont think you will need all that extra resizing code unless you want the toolbar to grow when you change the size of you main window.
Posted on 2002-01-21 00:04:31 by smurf
CreateWindowExA...
0,0,120,30, ;<-- change the 2nd number in list from zero to something like 32

That doesn't work for me. Well, it does, but the toolbar just doesn't show up properly if I don't specifically define where I want the listview in the MoveWindow call. I notice from the bmp you posted you seem to be using a regular toolbar, not one with the TBSTYLE_FLAT style, and I guess without a rebar as well, so the code I posted isn't entirely appropriate.

But what smurf said should work, or maybe in your original code again change the Y parameter in the listview MoveWindow call, the 3rd parameter, to offset for the height of the toolbar. This is really all I'm doing, just playing with the Y position until the pixels behave themselves.

Kayaker
Posted on 2002-01-21 02:07:30 by Kayaker
It seems that your toolbar's parent is the list view, not your main window, as it should be. Try change it.
Posted on 2002-01-21 02:35:57 by LuHa
Big thanx to everybody :)

After one day of struggle (and such a simple thing it is) I used infos from Kayaker and Smurf like this and toolbar works:

invoke MoveWindow,hList,0,31,wWid,wHgt,TRUE

and like LuHa said I use the wrong parent window. The problem is because the program runs in the system tray and the window is not created until popup menu item is clicked. So I end with a handle from main window which is never called to show then handle from list main then handle from when window created. This sounds like to many windows and maybe it is but it works.

Btw, when I enter a bunch of data in my listview the tool bar stays but the status bar disappears. If I resize the window everything looks properly? Should I call re paint after entering data?

Also why would mov tbb.fsStyle,TBSTYLE_FLAT cause an assebler error? I want flat style buttons.

best regards,

czDrillard
Posted on 2002-01-22 17:38:20 by czDrillard
when you create your toolbar like this:

        INVOKE CreateToolbarEx, hWin,

WS_CHILD + WS_VISIBLE + TBSTYLE_FLAT, ;<--- place it here instead of you structure
CID_TOOLBAR,
6,
hInstance,
BMP_TOOLBAR,
ADDR ToolbarButtons,
12,;16,
50,20,50,20,
SIZEOF TBBUTTON
MOV hToolbar,eax


i dont know why you get an error, thats strange. anyways i tested the TBSTYLE_FLAT and put it in my structure instead of when i create the toolbar and it had no effect. so i placed in my styles paramater when i created the toolbar.
Posted on 2002-01-22 19:13:30 by smurf
Hi smurf,

That works and creates flat toolbar but it is not grey. very pale and washed out. Strange? Any Ideas?

best regards,

czDrillard
Posted on 2002-01-23 00:32:04 by czDrillard
hmm the only thing i can think of is that when you created your main window you gave it an oddball color. the color of the toolbar should be the same color as lets say a dialog box.

so look back and see what you origanally set your color to. mine is set to:

mov wc.hbrBackground,HOLLOW_BRUSH

if the color was the same before you added your text and changed afterwards, i dont have the slightest clue.
Posted on 2002-01-23 01:15:07 by smurf
Btw, when I enter a bunch of data in my listview the tool bar stays but the status bar disappears. If I resize the window everything looks properly? Should I call re paint after entering data?


i was just reading through this post and noticed i missed this question. you should be able to fix you problem with this:

sub wHgt,31

invoke MoveWindow,hList,0,31,wWid,wHgt,TRUE
Posted on 2002-01-23 15:45:53 by smurf
Thanx smurf,

I think I understand now how the movewindow api resizes the windows. All this works good now. I'm still puzzled about the color of the buttons. It looks like the tool bar not painted at all. If I put my mouse over it the left and bottom button lines appear on a white background. I use mov wc.hbrBackground,COLOR_WINDOW+1 in my main window proc. everything else status bar, list view scroll bars look ok. Just the tool bar. I'm using CreateToolBarEx not CreateWindowEx and not using any predefined bitmaps. If I leave out TBSTYLE_FLAT and just use:
mov tbb.fsState, TBSTATE_ENABLED
mov tbb.fsStyle,TBSTYLE_BUTTON
invoke SendMessage,hToolBar,TB_ADDBUTTONS,1,ADDR tbb
I get regular clunky buttons.

best regards,

czDrillard
Posted on 2002-01-24 01:32:01 by czDrillard
As reported on MSDN the TBSTYLE_FLAT style makes both buttons and toolbar transparent. If you want to use a flat toolbar create a rebar (aka coolbar) and then put your flat toolbar inside one of its bands.
Posted on 2002-01-24 08:27:16 by LuHa
Thanx LuHa,

I will do this :)

best regards,

czDrillard
Posted on 2002-01-24 08:57:46 by czDrillard