Topic1:

Well I have been piddling with this for ohh, two days now,
and I just cant seem to get it right. Well here for your
laughing pleasure is some code:



.elseif Msg == WM_CREATE
; create the toolbar (ID of 300)
invoke CreateToolbarEx, hWnd, WS_CHILD or WS_VISIBLE or WS_CLIPCHILDREN or TBSTYLE_FLAT, 300, 3, 0, 0, 0, 0, 16, 16, 0, 0, sizeof TBBUTTON
mov hToolBar, eax
invoke ShowWindow, hToolBar, SW_SHOWNORMAL


Set up a toolbar. Common stuff.



; load the bitmap strip from resource
invoke LoadBitmap, hInstance, 501
mov hBitMap, eax

; register bitmap strip with toolbar
mov tba.nID, eax
mov tba.hInst, 0
invoke SendMessage, hToolBar, TB_ADDBITMAP, 1, ADDR tba


Loads a bitmap strip from resource and registers it with
the toolbar.

At this point, I did have a macro to add some toolbar
buttons and seperators. After some re-thinking
however (since the window is not visible yet) I am not
really concerned about speed so I thought I would code
it for space.

So far I have this for a proc:



; #########################################################################
AddToolButton proc phToolBar:dword, piBitmap:dword, pidCommand:dword, pfsStyle:dword
local tbb :TBBUTTON

invoke RtlZeroMemory, ADDR tbb, SIZEOF tbb
mov tbb.fsState, TBSTATE_ENABLED

push pfsStyle
push pidCommand
push piBitmap

pop tbb.iBitmap
pop tbb.idCommand
pop eax
[COLOR=red]mov tbb.fsStyle, byte ptr eax[/COLOR]

invoke SendMessage, phToolBar, TB_ADDBUTTONS, 1, ADDR tbb
ret
AddToolButton endp


However this generates errors at the line in red. Try as
I might, I just cant seem to get the cast right. Nor (since
the field is defined as a byte) can I push and pop it into
there.

Is there something obvious I am missing? I plan on
piddling with this some more, but I am running out of my
admittantly small knowledge of asm.

Topic2:
This one is a little more sticky (I think). Well as the above code points out, the bitmap strip for the buttons is being loaded as a resource. I noticed something trying the code out on a couple of different machines.

On my 98 box, the color of the menu bars (and buttons) is #C0C0C0. However on my 2k machine its #D4D0C8. While this is ok (I guess), the buttons draw incorrectly on one machine or the other depending on which value I use. Is there an API or SendMessage value I glossed over to set the transparent color of the toolbar?

Thanks in advance for all replies.
Graebel
:rolleyes:
Posted on 2002-07-11 15:06:24 by Graebel
in the red line you are trying to move directly from one memory location to another ....that's not possible on the x86
instead use


mov cl,byte ptr [eax]
mov tbb.fsStyle,cl


AFAIK Windows handles the transparency automatically
Posted on 2002-07-11 15:51:40 by MArtial_Code
Thanks MArtial =)
After just a little fiddling, that code snip worked great. Discovered I needed to use lea and not just poke it on in there :P


AFAIK Windows handles the transparency automatically


Maybe, maybe. If so then Win2k does it wrong. On my 98 box the buttons come out nice and clean. On 2k they are a darker shade of gray. Normally I wouldnt care if its just a slight shade off, but its real noticable when you make the buttons disabled.

I did find the API CreateMappedBitmap which looks like it was made for just this sort of thing, but when I tried to use it the application ends up with a "cant read from memory" error or something. Oh well, at least I have it half working now :grin:
Posted on 2002-07-11 16:24:11 by Graebel