Sign in to follow this  
Followers 0

Toolbar Menu Button

9 posts in this topic

Hello Autoiters,

I've been dabbling in autoit again and was looking for a Toolbar Menu Button. I've hunted through the forums but I can't seem to find what I'm looking for. To give you an idea, it should behave like the blue refresh button in firefox. The question has been asked before however I didn't see a clear answer as to if this isn't supported now or whether it is in the beta version.

I was able to quickly hack something together to see if it was possible however the code looks pretty ugly. I've gone through the relevant styles and extended styles however I can't see a simple way to implement this through the button or label control. I used the GUICtrlCreateGraphics to ultimately code the button and I did see posts referring to using a picture as a button however what I really wanted to know is there a function I should be using that does this implements this like the GUICtrlCreateMenu function?



Share this post

Link to post
Share on other sites


im not sure if user32.dll can do the button you wan but i got the documentation to do it with the function


This is the call in VB :

Declare Function DrawFrameControl Lib "user32" Alias "DrawFrameControl" (ByVal hDC As Long, lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) As Long

This Is the Help For the Call

· hdc
Identifies the device context of the window in which to draw the control.

· lprc
Points to a RECT structure that contains the logical coordinates of the bounding rectangle for frame control.

· uType
Specifies the type of frame control to draw. This parameter can be one of the following values:
 Standard button
 Title bar
 Scroll bar

· uState
Specifies the initial state of the frame control. If uType is DFC_BUTTON, uState can be one of the following values:
 Three-state button
 Check box
 Push button
 Radio button
 Image for radio button (nonsquare needs image)
 Mask for radio button (nonsquare needs mask)

If uType is DFC_CAPTION, uState can be one of the following values:
 Close button
 Windows 95 only: Help button
 Maximize button
 Minimize button
 Restore button

If uType is DFC_MENU, uState can be one of the following values:
 Submenu arrow
 Check mark

If uType is DFC_SCROLL, uState can be one of the following values:
 Combo box scroll bar
 Down arrow of scroll bar
 Left arrow of scroll bar
 Right arrow of scroll bar
 Size grip in bottom-right corner of window
 Up arrow of scroll bar

The following style can be used to adjust the bounding rectangle of the push button:
 Bounding rectangle is adjusted to exclude the surrounding edge of the push button.

One or more of the following values can be used to set the state of the control to be drawn:
 Button is checked.
 Button has a flat border.
 Button is inactive (grayed).
 Button has a monochrome border.
 Button is pushed.
[b]Return Value By The Call is:[/b]

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

maybe you can do it with ObjCreate()

if you need more help ask! hehe B)

bye bye!

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Share this post

Link to post
Share on other sites

@Greenseed, how about showing us a short working script that shows the user how to impliment this.

SciTE for AutoItDirections for Submitting Standard UDFs


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


Share this post

Link to post
Share on other sites

I have created that a while ago.

It is also a fake one created with the GUICtrlCreate functions.

But it is a nice fake version.

I will search it on my PC and post it soon.

Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF

Share this post

Link to post
Share on other sites

im not able to make it work! but i think it maybe the location of the box!

anyway i think i should look like this for a UDF

this is a good start!

#include <guiconstants.au3>
Opt("CaretCoordMode", 1)       ;1=absolute, 0=relative
Opt("ExpandEnvStrings", 0)   ;0=don't expand, 1=do expand
Opt("MouseClickDelay", 10)   ;10 milliseconds
Opt("MouseClickDownDelay", 10) ;10 milliseconds
Opt("MustDeclareVars", 0)     ;0=no, 1=require pre-declare
Opt("PixelCoordMode", 1)       ;1=absolute, 0=relative
Opt("RunErrorsFatal", 0)       ;1=fatal, 0=silent set @error
Opt("SendAttachMode", 0)       ;0=don't attach, 1=do attach
Opt("SendCapslockMode", 1)   ;1=store and restore, 0=don't
Opt("SendKeyDelay", 8)       ;5 milliseconds
Opt("SendKeyDownDelay", 1)   ;1 millisecond
Opt("TrayIconDebug", 1)     ;0=no info, 1=debug line info
Opt("TrayIconHide", 0)       ;0=show, 1=hide tray icon
Opt("WinWaitDelay", 250)       ;250 milliseconds
Opt("WinDetectHiddenText", 0)  ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("WintitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=...
Opt("ColorMode", 0)

$MainGui = GUICreate("DrawCallWindows",200,100,400,300,$WS_SYSMENU)

While 1
    Case $msg = $GUI_EVENT_CLOSE
    Case $msg = $buttondo

func APIDrawButton($_XL,$_YT,$_XR,$_YB)
    $HandleIDDrawFrameCTRL = DllOpen(@SystemDir&"\user32.dll")
    $HandleIDRectangle = DllOpen(@SystemDir&"\GDI32.dll")
    $Rectangle = DllCall($HandleIDRectangle,"RECT","Rectangle" _ 
    ,"long","410" _ ; Left
    ,"long","310" _ ;Top
    ,"long","440" _ ;Right
    ,"long","340" )  ;Bottom
;if not @error then msgbox(0,"DEBUG", "No Error")

    DllCall($HandleIDDrawFrameCTRL,"none","DrawFrameControl" _
    ,"long", $maingui _ 
    ,"RECT",$rectangle _ 
    ,"long","DFC_BUTTON" _ 
if not @error then msgbox(0,"DEBUG", "No Error")

i hope it help! bye bye!

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Share this post

Link to post
Share on other sites

Thanks to everyone for pointing me in the right direction. I managed to get the code Greenseed posted working however it seems to only draw pictures of controls. I tried drawing different types of buttons however they were all the same. I played around with the hex numbers because DFC_BUTTON and the other constants didn't work unless they were entered in hex (I was guessing what was what). I did some searching and the "DrawEdge" function appears to be more suitable. Does anyone know which library function draws a picture like an icon or bitmap? I am assuming I will have to draw and implement the entire button function so I might as well do it in dllcall.

Heres the part of the code I managed to get working

func APIDrawButton($_XL,$_YT,$_XR,$_YB)

$Rectangle = DllStructCreate("int;int;int;int")

$hdc = DllCall("user32.dll", "hwnd", "GetDC", "hwnd", $MainGui)
$hdc = $hdc[0]

DllStructSetData($Rectangle, 1, 200)
DllStructSetData($Rectangle, 2, 200)
DllStructSetData($Rectangle, 3, 250)
DllStructSetData($Rectangle, 4, 250)

DllCall("user32.dll","none","DrawFrameControl", "hwnd", $hdc, "ptr", DllStructGetPtr($Rectangle), "int",0x0000, "int", 0x0002)
DllCall("user32.dll", "hwnd", "ReleaseDC", "hwnd", $MainGui, "hwnd", $hdc)


Share this post

Link to post
Share on other sites

#7 ·  Posted (edited)

i have never see the button refresh in firefox you talk about! if i understand correctely the button is in the Menu bar! if yes! i think you will have to make a just a button attach to nothing! and move the button to follow is posotion in the gui you created.

or maybe is not a button in firefox! but a Object like Wiget(not sure it wrote like this!) but take a look here:


bye bye! im very happy to be able to help you!

Edited by Greenseed

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Share this post

Link to post
Share on other sites

object dock sure has changed since i found it about two years ago...

they have developed a lot of new stuff



Share this post

Link to post
Share on other sites

hello again!

i've bean tryed to put the button in the sysmenu bar! my first attemp! was to put the button on the desktop! and after make button displace with maingui, with a function! but the button is not displayed on the desktop! maybe because active desktop! anyway!

my second attemp! is to create a splash screen! and put the button on it! everything work ok!

you just have to make the function who redraw splachscreen to the new windows position!

i hope it what you wan! bye bye

ho! by the way this is the little code for it!

func APIDrawButton($_XL,$_YT,$_XR,$_YB)
$SplashID = WinGetHandle ( "Splash")
$Rectangle = DllStructCreate("int;int;int;int")

$hdc = DllCall("user32.dll", "hwnd", "GetDC", "hwnd", $SplashID)
$hdc = $hdc[0]

DllStructSetData($Rectangle, 1, 0)
DllStructSetData($Rectangle, 2, 0)
DllStructSetData($Rectangle, 3, 100)
DllStructSetData($Rectangle, 4, 20)

DllCall("user32.dll","none","DrawFrameControl", "hwnd", $hdc, "ptr", DllStructGetPtr($Rectangle), "int",0x0000, "int", 0x0002)
DllCall("user32.dll", "hwnd", "ReleaseDC","hwnd", $SplashID, "hwnd", $hdc);  


ho yeah many thx! to make the dll call working! B)

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Share this post

Link to post
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
Sign in to follow this  
Followers 0