Sign in to follow this  
Followers 0
Dancellot

_GUICtrlToolbar_Create in Windows 7

3 posts in this topic

#1 ·  Posted (edited)

Folks,

Somebody knows why _GUICtrlToolbar_Create UDF does not function correctly under Windows 7? At toolbar buttons presses, the msgboxes works perfectly in the code below running under Windows XP:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <StaticConstants.au3>
#include <file.au3>
#include <EditConstants.au3>
#Include <GuiEdit.au3>
#Include <Misc.au3>
#include <GuiListView.au3>
#Include <GuiToolBar.au3>
#Include <GuiImageList.au3>
 
Opt('MustDeclareVars', 0)
Opt("GUIOnEventMode", 1)
Opt("trayicondebug", 1)
 
Global $principal, $msg, $ajudaitem2, $ajudaitem1, $sairitem, $menu, $ajuda, $iItem
;~ Variaveis da toolbar
Global $astring[4]
Global Enum $job = 1000, $edit, $del, $clone
 
$principal = GUICreate("Jobs", 600, 300, -1, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
 
$toolbar = _GUICtrlToolbar_Create ($principal)
_GUICtrlToolbar_SetExtendedStyle($toolbar, $TBSTYLE_EX_DRAWDDARROWS)
 
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 88)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 88)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 88)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 88)
 
_GUICtrlToolbar_SetImageList($toolbar, $hImage)
_GUICtrlToolbar_SetHotImageList($toolbar, $hImage)
 
$astring[0] = _GUICtrlToolbar_AddString ($toolbar, "&New")
$astring[1] = _GUICtrlToolbar_AddString ($toolbar, "&Edit")
$astring[2] = _GUICtrlToolbar_AddString ($toolbar, "&Del")
$astring[3] = _GUICtrlToolbar_AddString ($toolbar, "&Clone")
 
$newjob_t = _GUICtrlToolbar_AddButton($toolbar, $job, 0 , $astring[0])
$editjob_t = _GUICtrlToolbar_AddButton($toolbar, $edit, 1, $astring[1])
$deljob_t = _GUICtrlToolbar_AddButton($toolbar, $del, 2, $astring[2])
$clonejob_t = _GUICtrlToolbar_AddButton($toolbar, $clone, 3, $astring[3])
 
$menu = GUICtrlCreateMenu("File")
GUICtrlCreateGroup("Jobs", 5, 55, 340, 125)
 
$joblist = GUICtrlCreateListView("Name|Time|Repeat|Status", 10, 70, 330, 103, -1, 0x00000025)
 
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
 
GUISetState()
 
While 1
Sleep(10)
WEnd
 
Func quit()
Exit
EndFunc
 
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
#forceref $hWndGUI, $MsgID, $wParam
Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld
Local $tNMTOOLBAR, $tNMTBHOTITEM, $hMenu
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
$idFrom = DllStructGetData($tNMHDR, "IDFrom")
$code = DllStructGetData($tNMHDR, "Code")
Switch $hwndFrom
  Case $toolbar
   Switch $code
    Case $NM_LDOWN
     Select
      Case $iItem = $job
       msgbox(0, "", "New", 2)
      Case $iItem = $edit
       msgbox(0, "", "Edit", 2)
      Case $iItem = $del
       msgbox(0, "", "Del", 2)
      Case $iItem = $clone
       msgbox(0, "", "Clone", 2)
     EndSelect
    Case $TBN_HOTITEMCHANGE
     $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
     $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
     $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
     $iItem = $i_idNew
   EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY

Thx...

Edited by Dancellot

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It's a x64 vs x86 issue. That script works fine if you run it under x86 (add #AutoIt3Wrapper_UseX64=n at the top of your script, you need SciTE4AutoIt3 for that to work) or run it with a recent AutoIt beta (they fixed structs).

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

Thx Admiral, working perfectly now...

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