LOULOU Posted December 31, 2006 Share Posted December 31, 2006 Is anayone has an example on how to create a toolbar in an existant gui created but autoit because it's veryu complex and i don't understand anything. Thanks in advance Link to comment Share on other sites More sharing options...
James Posted December 31, 2006 Share Posted December 31, 2006 Try using the example which is already with them. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
LOULOU Posted December 31, 2006 Author Share Posted December 31, 2006 Try using the example which is already with them.Yes but it's not the same thing, because in this example we use a created toolbar and what i want to do is creating a new toolbar Link to comment Share on other sites More sharing options...
James Posted December 31, 2006 Share Posted December 31, 2006 (edited) Then why don't you look at the script and take each part and see what it does? That way you can make changes to suit your needs. expandcollapse popup#include <A3LMenu.au3> #include <A3LToolbar.au3> #include <A3LToolTip.au3> #include <GUIStatusBar.au3> Opt("MustDeclareVars", 1) Opt("TrayIconHide" , 1) ; ==================================================================================================== ; AutoIt Version : 3.2.+ ; Author ........: Paul Campbell (PaulIA) ; Description ...: Simple NotePad demo. This demo utilizes several of the Auto3Lib modules. ; Notes .........: ; ==================================================================================================== Global $iEdit, $iClick , $iStatus Global $hGUI , $hFile , $hEdit , $hHelp , $hMain , $hToolbar, $hToolTip, $aLast[2] Global Enum $idNew=1000, $idOpen , $idSave, $idExit, $idCut , $idCopy , $idPaste , $idAbout ; ==================================================================================================== ; Main ; ==================================================================================================== CreateGUI() MainLoop() ; ==================================================================================================== ; Create the GUI ; ==================================================================================================== Func CreateGUI() Local $iH1, $iH2, $iH3, $aWidth[1]=[140], $aText[1]=[""] ; Create GUI $hGUI = GUICreate("Untitled - NotePad", 800, 500) ; Create File menu $hFile = _Menu_CreateMenu() _Menu_AddMenuItem($hFile, 0, "&New" , $idNew ) _Menu_AddMenuItem($hFile, 1, "&Open" , $idOpen ) _Menu_AddMenuItem($hFile, 2, "&Save" , $idSave ) _Menu_AddMenuItem($hFile, 3, "" , 0 ) _Menu_AddMenuItem($hFile, 4, "E&xit" , $idExit ) ; Create Edit menu $hEdit = _Menu_CreateMenu() _Menu_AddMenuItem($hEdit, 0, "&Cut" , $idCut ) _Menu_AddMenuItem($hEdit, 1, "C&opy" , $idCopy ) _Menu_AddMenuItem($hEdit, 2, "&Paste", $idPaste) ; Create Help menu $hHelp = _Menu_CreateMenu() _Menu_AddMenuItem($hHelp, 0, "&About", $idAbout) ; Create Main menu $hMain = _Menu_CreateMenu() _Menu_AddMenuItem($hMain, 0, "&File", 0, $hFile) _Menu_AddMenuItem($hMain, 1, "&Edit", 0, $hEdit) _Menu_AddMenuItem($hMain, 2, "&Help", 0, $hHelp) ; Set the window menu _Menu_SetMenu($hGUI, $hMain) ; Create Toolbar $hToolbar = _Toolbar_Create($hGUI) _Toolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR) _Toolbar_AddButtonStd($hToolbar, $STD_FILENEW , $idNew ) _Toolbar_AddButtonStd($hToolbar, $STD_FILEOPEN, $idOpen ) _Toolbar_AddButtonStd($hToolbar, $STD_FILESAVE, $idSave ) _Toolbar_AddButtonSep($hToolbar) _Toolbar_AddButtonStd($hToolbar, $STD_CUT , $idCut ) _Toolbar_AddButtonStd($hToolbar, $STD_COPY , $idCopy ) _Toolbar_AddButtonStd($hToolbar, $STD_PASTE , $idPaste) $iH1 = _API_GetWindowHeight($hToolbar) ; Create tooltips for the toolbar $hToolTip = _ToolTip_Create($hToolbar) AddTool($idNew , "New" ) AddTool($idOpen , "Open" ) AddTool($idSave , "Save" ) AddTool($idCut , "Cut" ) AddTool($idCopy , "Copy" ) AddTool($idPaste, "Paste") ; Create status bar $iStatus = _GUICtrlStatusBarCreate($hGUI, $aWidth, $aText) $iH2 = _API_GetWindowHeight($iStatus) ; Create edit control $iH3 = _API_GetClientHeight($hGUI) - $iH1 - $iH2 $iEdit = GUICtrlCreateEdit("", 0, $iH1, 800, $iH3, BitOR($ES_AUTOVSCROLL, $ES_MULTILINE, _ $ES_WANTRETURN, $WS_VSCROLL, $WS_CHILD, $WS_CLIPSIBLINGS)) GUICtrlSetFont($iEdit, 10, 400, 0, "Courier New") GUISetState() EndFunc ; ==================================================================================================== ; Main loop ; ==================================================================================================== Func MainLoop() GUIRegisterMsg($WM_COMMAND , "WM_COMMAND" ) GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") do Switch $iClick case $idNew DoFileNew() case $idOpen DoFileOpen() case $idSave DoFileSave() case $idExit Exit case $idCut DoEditCut() case $idCopy DoEditCopy() case $idPaste DoEditPaste() case $idAbout DoHelpAbout() EndSwitch $iClick = 0 UpdateState() until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ; ==================================================================================================== ; This code shows how to capture WM_COMMAND messages ; ==================================================================================================== Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) $iClick = _Lib_LoWord($iwParam) Return $GUI_RUNDEFMSG EndFunc ; ==================================================================================================== ; This code shows how to capture WM_CONTEXTMENU messages ; ==================================================================================================== Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) _Lib_ConsoleWrite("ContextMenu") Return $GUI_RUNDEFMSG EndFunc ; ==================================================================================================== ; Add a tool to the tooltip control ; ==================================================================================================== Func AddTool($iCommandID, $sText) Local $rRect $rRect = __Toolbar_GetRect($hToolbar, $iCommandID) _ToolTip_AddTool($hToolTip, $hToolbar, $sText, $iCommandID, $rRect) EndFunc ; ==================================================================================================== ; UpdateState ; ==================================================================================================== Func UpdateState() Local $bSelected, $hMenu, $aCaret, $sCaret ; See if any text is selected $bSelected = (ControlCommand("", "", $iEdit, "GetSelected") <> "") ; Update menu _Menu_SetMenuItemDisabled($hEdit, 0, not $bSelected) _Menu_SetMenuItemDisabled($hEdit, 1, not $bSelected) ; Update toolbar _Toolbar_SetStateEnabled($hToolbar, $idCopy, $bSelected) _Toolbar_SetStateEnabled($hToolbar, $idCut , $bSelected) ; Update status bar $aCaret = _Lib_GetCaretPos(GUICtrlGetHandle($iEdit)) if ($aCaret[0] <> $aLast[0]) or ($aCaret[1] <> $aLast[1]) then $sCaret = StringFormat("Row: %d Col: %d", $aCaret[1], $aCaret[0]) _GUICtrlStatusBarSetText($iStatus, $sCaret, 0) $aLast[0] = $aCaret[0] $aLast[1] = $aCaret[1] endif EndFunc ; ==================================================================================================== ; File|New ; ==================================================================================================== Func DoFileNew() GUICtrlSetData($iEdit, "") WinSetTitle("", "", "Untitled - NotePad") EndFunc ; ==================================================================================================== ; File|Open ; ==================================================================================================== Func DoFileOpen() Local $sFile, $sText $sFile = FileOpenDialog("Select File", "", "Text (*.txt)", 1 + 2) if @Error then Return $sText = FileRead($sFile) GUICtrlSetData($iEdit, $sText) WinSetTitle("", "", $sFile & " - NotePad") EndFunc ; ==================================================================================================== ; File|Save ; ==================================================================================================== Func DoFileSave() Local $sFile, $hFile $sFile = FileSaveDialog("Select File", "", "Text (*.txt)", 2 + 16) if @Error then Return $hFile = FileOpen($sFile, 2) FileWrite($hFile, GUICtrlRead($iEdit)) FileClose($hFile) WinSetTitle("", "", $sFile & " - NotePad") EndFunc ; ==================================================================================================== ; Edit|Copy ; ==================================================================================================== Func DoEditCopy() ControlSend("", "", $iEdit, "{CTRLDOWN}") ControlSend("", "", $iEdit, "{INS}" ) ControlSend("", "", $iEdit, "{CTRLUP}" ) EndFunc ; ==================================================================================================== ; Edit|Cut ; ==================================================================================================== Func DoEditCut() ControlSend("", "", $iEdit, "{SHIFTDOWN}") ControlSend("", "", $iEdit, "{DEL}" ) ControlSend("", "", $iEdit, "{SHIFTUP}" ) EndFunc ; ==================================================================================================== ; Edit|Paste ; ==================================================================================================== Func DoEditPaste() ControlSend("", "", $iEdit, "{SHIFTDOWN}") ControlSend("", "", $iEdit, "{INS}" ) ControlSend("", "", $iEdit, "{SHIFTUP}" ) EndFunc ; ==================================================================================================== ; Help|About ; ==================================================================================================== Func DoHelpAbout() _Lib_MsgBox(0, "Help", "Auto3Lib NotePad Demo") EndFunc That will only make the GUI no functions. Edited December 31, 2006 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
LOULOU Posted December 31, 2006 Author Share Posted December 31, 2006 Thanks, But what i want to do is creating a toolbar whith my owns icon present in an icon.dl and not with standrad buttom. How can I do ? Link to comment Share on other sites More sharing options...
GaryFrost Posted December 31, 2006 Share Posted December 31, 2006 Thanks,But what i want to do is creating a toolbar whith my owns icon present in an icon.dl and not with standrad buttom. How can I do ?Might want to take a look through http://www.autoitscript.com/forum/index.ph...st&p=146551 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 More sharing options...
James Posted December 31, 2006 Share Posted December 31, 2006 (edited) Ahh right. But you still want to use PaulIA's lib?I think it has something to do with:; Create Toolbar $hToolbar = _Toolbar_Create($hGUI) _Toolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR) _Toolbar_AddButtonStd($hToolbar, $STD_FILENEW , $idNew ) _Toolbar_AddButtonStd($hToolbar, $STD_FILEOPEN, $idOpen ) _Toolbar_AddButtonStd($hToolbar, $STD_FILESAVE, $idSave ) _Toolbar_AddButtonSep($hToolbar) _Toolbar_AddButtonStd($hToolbar, $STD_CUT , $idCut ) _Toolbar_AddButtonStd($hToolbar, $STD_COPY , $idCopy ) _Toolbar_AddButtonStd($hToolbar, $STD_PASTE , $idPaste) $iH1 = _API_GetWindowHeight($hToolbar)You might need to modify the LToolbar.au3 file and see whether it has set the icons ready for you.Secure Edited December 31, 2006 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PaulIA Posted December 31, 2006 Share Posted December 31, 2006 Assigning custom icons to the toolbar is very simple. You can add an icon from a file using the AddBitmap function. This function allows you to load icons from an external file or from the predefined list of icons in the system (which is what the demo does). Take a look at the _Toolbar_AddBitmap call and read the documentation provided in the UDF. If you can't get it to work, post a small example of what you are trying to do in the Auto3Lib thread. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
PaulIA Posted January 8, 2007 Share Posted January 8, 2007 Just a follow up in case anybody else needs the same functionality... The Auto3Lib Notepad demo has been updated to show how to use custom bitmaps in a Toolbar. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
LOULOU Posted January 8, 2007 Author Share Posted January 8, 2007 Just a follow up in case anybody else needs the same functionality...The Auto3Lib Notepad demo has been updated to show how to use custom bitmaps in a Toolbar.Thanks Paul I will try. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now