biase Posted April 1, 2012 Share Posted April 1, 2012 I even tried _GuiCtrlToolbar_IsButtonPressed, but still failed. I Just need like If _WinAPI_LoWord($wParam) == $TRadio Then Msgbox(0, '', 'Radio') If _WinAPI_LoWord($wParam) == $TMovie Then Msgbox(0, '', 'Movie') This is all my code expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiToolbar.au3> #include <WindowsConstants.au3> Global $aStrings[5] Global $TRadio, $TTv, $TMovie, $TAbout, $TExit $hGUI = GUICreate("Multimedia", 623, 449, 192, 114) $hImageList = _GUIImageList_Create(32, 32, 5) _GUIImageList_AddIcon($hImageList, @ScriptDir & '\Iron_Radio.ico', '', True) _GUIImageList_AddIcon($hImageList, @ScriptDir & '\Iron_Tv.ico', '', True) _GUIImageList_AddIcon($hImageList, @ScriptDir & '\Iron_Movie.ico', '', True) _GUIImageList_AddIcon($hImageList, @ScriptDir & '\Iron_About.ico', '', True) _GUIImageList_AddIcon($hImageList, @ScriptDir & '\Iron_Exit.ico', '', True) $hToolBar = _GUICtrlToolbar_Create($hGUI, 0) _GUICtrlToolbar_SetImageList($hToolBar, $hImageList) ; Add strings $aStrings[0] = _GUICtrlToolbar_AddString($hToolBar, "Radio") $aStrings[1] = _GUICtrlToolbar_AddString($hToolBar, "Tv") $aStrings[2] = _GUICtrlToolbar_AddString($hToolBar, "Movie") $aStrings[3] = _GUICtrlToolbar_AddString($hToolBar, "About") $aStrings[4] = _GUICtrlToolbar_AddString($hToolBar, "Exit") _GUICtrlToolbar_AddButton($hToolBar, $TRadio, 0, $aStrings[0]) _GUICtrlToolbar_AddButton($hToolBar, $TTv, 1, $aStrings[1]) _GUICtrlToolbar_AddButton($hToolBar, $TMovie, 2, $aStrings[2]) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolBar, $TAbout, 3, $aStrings[3]) _GUICtrlToolbar_AddButton($hToolBar, $TExit, 4, $aStrings[4]) ; Register WM_COMMAND messages GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState() While 1 Sleep(10) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) ConsoleWrite(_WinAPI_LoWord($wParam) & @CRLF) EndFunc ;==>WM_COMMAND Link to comment Share on other sites More sharing options...
biase Posted April 2, 2012 Author Share Posted April 2, 2012 bump Link to comment Share on other sites More sharing options...
subzerostig Posted April 2, 2012 Share Posted April 2, 2012 Please read the forum rules on bumping topics before 24 hours is up. Do you need to recognise when your control is clicked? If so , use either guictrlgetmsg or oneventmode. There are 10 types of people in this world. Those that understand binary, and those that do not Link to comment Share on other sites More sharing options...
BrewManNH Posted April 2, 2012 Share Posted April 2, 2012 I would suggest looking at the help file for _GUICtrlToolBar_Create, the example in there should give you a good idea of how to use the toolbar buttons and how the window message should be interpreted. biase 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 2, 2012 Moderators Share Posted April 2, 2012 biase,Did you look at the Help file examples? I think not because you are not even registering the correct message! This works for me:expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiToolbar.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $iItem Global $aStrings[5] Global $aTitles[6] = ["Radio", "TV", "Movie", "", "About", "Exit"] ; We need the blank so the CIDs match the indices Global Enum $idRadio = 1000, $idTV, $idMovie, $idAbout, $idExit Global $aCID[6] $hGUI = GUICreate("Multimedia", 623, 449, 192, 114) $hImageList = _GUIImageList_Create(32, 32, 5) _GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_Radio.ico', '', True) _GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_TV.ico', '', True) _GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_Movie.ico', '', True) _GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_About.ico', '', True) _GUIImageList_AddIcon($hImageList, @ScriptDir & 'Iron_Exit.ico', '', True) $hToolBar = _GUICtrlToolbar_Create($hGUI, 0) _GUICtrlToolbar_SetImageList($hToolBar, $hImageList) ; Add strings $aStrings[0] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[0]) $aStrings[1] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[1]) $aStrings[2] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[2]) $aStrings[3] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[4]) ; Careful with the index numbering here $aStrings[4] = _GUICtrlToolbar_AddString($hToolBar, $aTitles[5]) _GUICtrlToolbar_AddButton($hToolBar, $idRadio, 0, 0) _GUICtrlToolbar_AddButton($hToolBar, $idTv, 1, 1) _GUICtrlToolbar_AddButton($hToolBar, $idMovie, 2, 2) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolBar, $idAbout, 3, 3) _GUICtrlToolbar_AddButton($hToolBar, $idExit, 4, 4) ; This dummy will fire when a button is clicked $cDummy = GUICtrlCreateDummy() GUISetState() ; Register WM_COMMAND messages GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummy ; The dummy was fired so read the index and show the button title MsgBox(0, "Clicked", $aTitles[GUICtrlRead($cDummy)]) EndSwitch WEnd ; WM_NOTIFY event handler Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tNMHDR, $hwndFrom, $code, $i_idNew, $dwFlags, $i_idOld Local $tNMTBHOTITEM $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom") $code = DllStructGetData($tNMHDR, "Code") Switch $hwndFrom Case $hToolbar Switch $code Case $NM_LDOWN ; A button was clicked so fire the dummy control with the index of the "hot" item $iClicked = _GUICtrlToolbar_CommandToIndex($hToolbar, $iItem) GUICtrlSendToDummy($cDummy, $iClicked) Case $TBN_HOTITEMCHANGE $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam) $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld") $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew") ; Note the "hot" item $iItem = $i_idNew $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFYYou may wonder why I went to all the trouble of using a dummy control rather then showing the MsgBox directly from the message handler - read the Help file page for GUIRegisterMsg to find out. M23 biase 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
biase Posted April 2, 2012 Author Share Posted April 2, 2012 Thanks for the reply guys... Melba, you're correct about not referring help file, i first search on the forum for toolbar.. my bad... learned my lesson today. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 2, 2012 Moderators Share Posted April 2, 2012 biase, Glad we got it working. And the Help file should always be your first port of call - we are very lucky to have such a good one. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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