Jump to content

Toolbar Menu Button


mocro
 Share

Recommended Posts

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?

Thanks,

Mocro

Link to comment
Share on other sites

hi!

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

DllOpen()
DllCall()
DllClose()

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:
DFC_BUTTON
 Standard button
DFC_CAPTION
 Title bar
DCF_MENU
 Menu
DFC_SCROLL
 Scroll bar

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

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

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

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

The following style can be used to adjust the bounding rectangle of the push button:
DFCS_ADJUSTRECT
 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:
DFCS_CHECKED
 Button is checked.
DFCS_FLAT
 Button has a flat border.
DFCS_INACTIVE
 Button is inactive (grayed).
DFCS_MONO
 Button has a monochrome border.
DFCS_PUSHED
 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.

Link to comment
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)
Opt("GUICoordMode",0)

$MainGui = GUICreate("DrawCallWindows",200,100,400,300,$WS_SYSMENU)
$ButtonDo=GUICtrlCreateButton("Do",80,40,30,25)
GUISetState()



While 1
    
    $MSG=GUIGetMsg()
    
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $buttondo
        APIDrawButton(1,1,1,1)
        GUISetState(@SW_SHOW,$maingui)
    Endselect
    
WEnd





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" _ 
    ,"long","DFCS_BUTTONPUSH")
    
    DllClose($HandleIDDrawFrameCTRL)
    DllClose($HandleIDRectangle)
    
if not @error then msgbox(0,"DEBUG", "No Error")
    
endfunc

i hope it help! bye bye!

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

Link to comment
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)

endfunc
Link to comment
Share on other sites

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:

ObjectDesktop

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

Edited by Greenseed

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

Link to comment
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)
SplashTextOn("Splash","",100,20,150,5,17)
$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);  

endfunc

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

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

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...