Jump to content

ToolBar


tonedeaf
 Share

Recommended Posts

A preliminary UDF to create toolbar controls with AutoIt. This script example can add standard toolbar buttons defined in Comctl32.dll.

Support for adding custom Bitmap/Icons not added yet.

Posted Image

As I'm not too familiar with WIN32 Programming, any help/contribution for completing these features/adding new features will be highly appreciated.

With everyone's contribution, it would be possible to have a feature rich toolbar in AutoIt soon.

NOTE: I've removed the attachments as the toolbar functions are available with PaulIA's Auto3Lib. This library is well written and provides more features.

Edited by tonedeaf
Link to comment
Share on other sites

  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

maybe you can take a look at this

http://www.autoitscript.com/forum/index.php?showtopic=20798#

and this

http://www.autoitscript.com/forum/index.php?showtopic=20967#

hope that helps

you all should get together

8)

Those are menus, which have been pretty much worked out, although no standard udfs as of yet

Toolbars are whole different thing.

Just wondering why using CreateWindowEx instead of CreateToolbarEx

Haven't had time to try it with CreateToolbarEx but after adding an event handler with this one, once the buttons are pressed they stay down, except the 1st one.

Add a button to the form after creating the toolbar and the toolbar's 1st button won't be the default anymore.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

It looks like the toolbar buttons are not generating any messages when they are clicked. The only messages which are getting generated are $GUI_EVENT_PRIMARYDOWN (-7), $GUI_EVENT_PRIMARYUP (-8), and lot of Unknown (0) messages.

As per microsoft:

Each button in toolbar generates a standard command message which is sent back to the toolbar's parent.

This standard command message is specified in the idCommand member of TBBUTTON Structure when the button is created. The point is, that you can fill in any numeric value as idCommand when creating the toolbar button and when the button is clicked, the same value will be raised as a message.

That is why, we usually assign the same values to menu items and toolbar buttons which perform the same task. For eg. if I have a menu item Edit->Cut and I also have a toolbar button for Cut, I can assign a same idCommand value to both of them so that when anyone of them is clicked, the same function is called.

Now, AutoIt automatically assigns a idCommand to Menu items and looks like that behaviour cannot be overridden. I checked the messages generated by the menu items and they look like to be in some sort of sequential numbering.

And I am not able to do this for toolbar buttons. Even if I assign a random idCommand value to TBButton structure when creating a toolbar button, that value is not getting raised when the button is clicked.

Is this a limitation of AutoIt? or can it be done through some other method? I hope that advanced members can through some light on this issue.

Link to comment
Share on other sites

Issue resolved, see attachments:

Gary

are these missing commands

Case $mnuExit
        ;----------------------------------------------------------------------------------------------
            If $DebugIt Then    ConsoleWrite ("-->$mnuExit" & @LF)
        ;----------------------------------------------------------------------------------------------
        Case $mnuEdit
        ;----------------------------------------------------------------------------------------------
            If $DebugIt Then    ConsoleWrite ("-->$mnuEdit" & @LF)
        ;---------------------------------------------------------

all of the others have a command after the case??

8)

NEWHeader1.png

Link to comment
Share on other sites

are these missing commands

Case $mnuExit
       ;----------------------------------------------------------------------------------------------
            If $DebugIt Then    ConsoleWrite ("-->$mnuExit" & @LF)
       ;----------------------------------------------------------------------------------------------
        Case $mnuEdit
       ;----------------------------------------------------------------------------------------------
            If $DebugIt Then    ConsoleWrite ("-->$mnuEdit" & @LF)
       ;---------------------------------------------------------

all of the others have a command after the case??

8)

No missing commands, just no buttons were created for those, just menus, as you can see if you have menus, you also have to put them in the case of the WM_Command events.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Might want to change the constants to something like

Global Const $IDM_OPEN = 2000

Global Const $IDM_NEW = 2001

Global Const $IDM_SAVE = 2002

Global Const $IDM_CUT = 2003

Global Const $IDM_COPY = 2004

Global Const $IDM_PASTE = 2005

Global Const $IDM_UNDO = 2006

Global Const $IDM_REDO = 2007

and add in the wm_command

Case $button

;----------------------------------------------------------------------------------------------

If $DebugIt Then ConsoleWrite ("-->$button" & @LF)

;----------------------------------------------------------------------------------------------

Note:

What would be great is a method of generating a unique id from autoit that won't be reused during the application runtime

Just like when using the guictrlcreate's.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

If the toolbar buttons are the same as the menu options then another option would be to create the menu items and use that id for toolbar buttons

Example in attachment.

Edit: Removed Attachment

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Issue resolved, see attachments:

Gary

Thanks Gary,

I still don't understand the specific details about the _HiWord and _LoWord functions on wParam, but we need to hide this functionality in the UDF. The implementation should be completely transparent to user.

And looks like $IDM_COPY, $mnuCopy message is getting generated for each action on the window (Activate, Deactivate, Minimize, Restore and on clicking Button).

Using ImageList manipulation functions (Thanks: Holger), custom icons for toolbar images is now possible:

Posted Image

EDIT: Only one mode is possible for one toolbar at a time, standard buttons images (from comctl32.dll) and custom images cannot be combined.

Quoting MSDN:

The TB_SETIMAGELIST message cannot be combined with TB_ADDBITMAP.

When you create a toolbar with CreateToolbarEx or use TB_ADDBITMAP to add images, the toolbar manages the image list internally. Attempting to modify it with TB_SETIMAGELIST will have unpredictable consequences.

Edited by tonedeaf
Link to comment
Share on other sites

Thanks Gary,

I still don't understand the specific details about the _HiWord and _LoWord functions on wParam, but we need to hide this functionality in the UDF. The implementation should be completely transparent to user.

And looks like $IDM_COPY, $mnuCopy message is getting generated for each action on the window (Activate, Deactivate, Minimize, Restore and on clicking Button).

Figured out that if _HiWord is 0 then switch

Edit: Removed Attachment

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

This is pretty fun, nice work, folks!

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

:lmao:Toolbars in Rebar:

Posted Image

Rough script, I'll clean it later.

Cleaned up the Toolbar example some.

Edit: Removed Attachment

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I'm playing with the example, I get an off-by-one or off-by-two mistaken reply when clicking on the toolbar buttons, and it seems to be because the seperators are included in the indexed items. Is this something you've seen already?

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...