I used API function CreateToolbarEx to create a toolbar in my MDI application, I handled WM_SIZE to resize my toolbar everytime windows is resized, but when I compiled and run, they did appear but NOT RESPONDED, I mean when the mouse is over the toolbar buttons or when I click on them.
In addition to, when I choose create new child window in the menuitem, the toolbar's gone. I didn't see it anymore.

Somebody helps me :confused:
Posted on 2004-04-28 16:20:59 by santa
Hi,

I used API function CreateToolbarEx to create a toolbar in my MDI application, I handled WM_SIZE to resize my toolbar everytime windows is resized, but when I compiled and run, they did appear but NOT RESPONDED, I mean when the mouse is over the toolbar buttons or when I click on them.

You resize your toolbar but you don't resize the client window. You have to move the client window vertically and also decrease its height (i.e. take into account the toolbar height).


In addition to, when I choose create new child window in the menuitem, the toolbar's gone. I didn't see it anymore.
Somebody helps me :confused:

When ever you use EBX, EDI, ESI in a window procedure, you have to preserve them first and restore them after you are done. In your WM_PAINT

PUSH EDI
PUSH ESI

your stuff here

POP ESI
POP EDI

I hope this helps

Regards,

akyprian
Posted on 2004-04-29 02:22:33 by akyprian
Hi akyprian,

When ever you use EBX, EDI, ESI in a window procedure, you have to preserve them first and restore them after you are done.


Why not EVER use

Dummy proc uses ebx edi esi arg:dword


????

:stupid:
Posted on 2004-04-29 02:52:26 by PhoBos
Hi PhoBos,



Why not EVER use

Dummy proc uses ebx edi esi arg:dword


????


I do use it only sometimes bacause:



Dummy proc uses ebx edi esi arg:dword
.if umsg==
.ElseIf uMsg==
.ElseIf uMsg==
.EndIf
ret
Dummy endp



virtually produces this:


Dummy proc arg:dword
PUSH ESI
PUSH EBX
PUSH EDI
.if umsg==
.ElseIf uMsg==
.ElseIf uMsg==
.EndIf
POP EDI
POP EBX
POP ESI
ret
Dummy endp


Why should I preserve and restore all three registers no matter what uMsg is ????(I may not use all three registers in all messages-this is more often than not)

This leads to a speed penalty but I agree that is smaller code.

So, I use both methods accordingly.

I hope it is clear

Regards,

akyprian
Posted on 2004-04-29 03:05:13 by akyprian
Thanks Akyprian
I fixed it

Santa :alright:
Posted on 2004-04-29 14:59:45 by santa
Hi,

I don't like it very much!

Think more about your WM_SIZE.

Regards,

akyprian
Posted on 2004-04-29 15:26:41 by akyprian
Hi Akyprian
You mean I should make it more flexible like this



.elseif (uMsg == WM_SIZE)
;---------------------------------
; resize toolbar
;---------------------------------
invoke SendMessage, hToolbar, TB_AUTOSIZE, 0, 0
invoke DefFrameProc, hWnd, hMDIClient, uMsg, wParam, lParam
;---------------------------------
; resize MDI client area
;---------------------------------
; get height of toolbar
invoke GetWindowRect, hToolbar, ADDR rect
mov edx, rect.bottom
sub edx, rect.top
push edx
invoke GetWindowRect, hMDIClient, ADDR rect
pop edx
mov eax, rect.bottom
sub eax, edx ; edx = height of toolbar
mov ecx, rect.right
sub ecx, rect.left
invoke MoveWindow, hMDIClient, 0, edx, ecx, eax, TRUE
Posted on 2004-04-29 16:20:27 by santa
There is a problem here:

invoke GetWindowRect, hMDIClient, ADDR rect


You should use:

Invoke GetClientRect, mainwindowhanlde, ADDR rect


Regards,

akyprian
Posted on 2004-04-29 17:08:57 by akyprian
oh, right
Thanks Akyprian :D
Posted on 2004-04-29 17:24:38 by santa