Hey guys, just got to the point of creating the main toolbar for my Main window and what can I say, ouch!!!
What is the best/preferred way to create a toolbar and attach it to your window?
I saw the CreateToolbarEx() API call, thats a bit of an undertaking for sure, Wondering if there is a better way to do this.
Also, can you create toolbars in resource files and then use that resource as your toolbar for the window? If so how would you pull that off
thanx
(Sorry, years of MFC have basically made me stupid when it comes to real programming!!)
What is the best/preferred way to create a toolbar and attach it to your window?
I saw the CreateToolbarEx() API call, thats a bit of an undertaking for sure, Wondering if there is a better way to do this.
Also, can you create toolbars in resource files and then use that resource as your toolbar for the window? If so how would you pull that off
thanx
(Sorry, years of MFC have basically made me stupid when it comes to real programming!!)
Hi
I'd suggest doing a search on this board for 'toolbar' to start with, there was a couple of examples given lately if you want to make an Explorer style TBSTYLE_FLAT toolbar:
http://www.asmcommunity.net/board/index.php?topic=2483&highlight=toolbar
I don't really know what the best/easiest way would be, but I think using CreateToolbarEx gives you the most flexibility in using the newest features of the latest Comctl32.dll versions they come up with.
Cheers,
Kayaker
I'd suggest doing a search on this board for 'toolbar' to start with, there was a couple of examples given lately if you want to make an Explorer style TBSTYLE_FLAT toolbar:
http://www.asmcommunity.net/board/index.php?topic=2483&highlight=toolbar
I don't really know what the best/easiest way would be, but I think using CreateToolbarEx gives you the most flexibility in using the newest features of the latest Comctl32.dll versions they come up with.
Cheers,
Kayaker
I havent heard of too many ways of making toolbars, and CreateToolbarEx() seems to be one of the simpler.
However, you could make your own custom toolbar control. Its a bit of work, but alot to be learned from: registering windows (the control), alot of GDI to make it look stylish, and some basic code to handle what messages get sent when a button gets clicked.
PS: What part of London you from? I grew up in Westmount (next to the Beer Store).
NaN
However, you could make your own custom toolbar control. Its a bit of work, but alot to be learned from: registering windows (the control), alot of GDI to make it look stylish, and some basic code to handle what messages get sent when a button gets clicked.
PS: What part of London you from? I grew up in Westmount (next to the Beer Store).
NaN
Rockinronstar,
Have a look at the apLib example that comes with MASM32 (\example3\ if I remember well).
It has pretty code to display toolbars with pics, etc...
Regards,
Have a look at the apLib example that comes with MASM32 (\example3\ if I remember well).
It has pretty code to display toolbars with pics, etc...
Regards,
Hey NaN, I am at Huron/Adelaide area
I grew up in new brunswick and moved to London for a job at Digital Illusions, a game development company here.
We are the ones who made Shrek for X-Box
cyl
I grew up in new brunswick and moved to London for a job at Digital Illusions, a game development company here.
We are the ones who made Shrek for X-Box
cyl
Really cool :)
I never knew there was one in town... I will have to check you guys out when i come home to visit the family..
NaN
I never knew there was one in town... I will have to check you guys out when i come home to visit the family..
NaN
CreateToolbar isn't very hard to use. This starter assumes the command identifiers are defined as menu items in the .RC file, and it uses "standard" small buttons.
Create the toolbar after CreateWindowEX:
And move it when needed:
Tooltips can be handled as follows. Define the text in the .RC file, giving each item a value 1000 more than the corresponding menu item:
And include the following code:
:)
tbBtns TBBUTTON <STD_FILEOPEN, 1002, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0>
TBBUTTON <STD_HELP, 1910, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0>
TBBUTTON <0, 0, 0, TBSTYLE_SEP, 0, 0>
TBBUTTON <STD_DELETE, 1010, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0>
...
Create the toolbar after CreateWindowEX:
invoke CreateToolbarEx, hMain, WS_CHILD + WS_VISIBLE + TBSTYLE_TOOLTIPS,
241, 11, HINST_COMMCTRL, IDB_STD_SMALL_COLOR,
ADDR tbBtns, 4, 16, 16, 16, 16, SIZEOF (TBBUTTON)
mov hTB, eax
And move it when needed:
.elseif uMsg == WM_SIZE
invoke SendMessage, hTB, TB_AUTOSIZE, 0, 0
Tooltips can be handled as follows. Define the text in the .RC file, giving each item a value 1000 more than the corresponding menu item:
STRINGTABLE
BEGIN
2002,"Input"
2010,"Exit"
2910,"Help"
END
And include the following code:
tbTips db 16 dup (0)
...
.elseif uMsg == WM_NOTIFY
mov eax, lParam
mov eax, (NMHDR PTR [eax]).code
.if eax == TTN_NEEDTEXT
mov eax, lParam
mov eax, (NMHDR PTR [eax]).idFrom
add eax, 1000
invoke LoadString, hInst, eax, ADDR tbTips, 16
mov eax, lParam
mov (TOOLTIPTEXT PTR [eax]).lpszText, OFFSET tbTips
.endif
:)