Jump to content
Sign in to follow this  
R_P

Button in StatusBar

Recommended Posts

R_P

Clicking the OK button in the StatusBar does not work. Can you help me please?

Thank you.

#include <GuiStatusBar.au3>
#include <GUIConstants.au3>

$hGUI = GUICreate("test click statusbar", 500, 200)

$g_hStatus = _GUICtrlStatusBar_Create($hGUI)
Dim $aParts[3] = [75, 150, -1]
_GUICtrlStatusBar_SetParts($g_hStatus, $aParts)

$cBtnStatusBar = GUICtrlCreateButton('OK', 0, 0)
$_hndl = GUICtrlGetHandle($cBtnStatusBar)
_GUICtrlStatusBar_EmbedControl($g_hStatus, 1, $_hndl, 4)

GUISetState(@SW_SHOW)

While 1
   $idMsg = GUIGetMsg()
   Select
      Case $idMsg = $GUI_EVENT_CLOSE
         ExitLoop
      Case $idMsg = $cBtnStatusBar
         ConsoleWrite('StatusBar OK click' & @CRLF)
   EndSelect
WEnd

 

Share this post


Link to post
Share on other sites
R_P

works this

#include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <WinAPISysWin.au3>

$hGUI = GUICreate("test click statusbar", 500, 200)

$g_hStatus = _GUICtrlStatusBar_Create($hGUI)
Dim $aParts[3] = [75, 150, -1]
_GUICtrlStatusBar_SetParts($g_hStatus, $aParts)

$cBtnStatusBar = GUICtrlCreateButton('OK', 0, 0)
$_hndl = GUICtrlGetHandle($cBtnStatusBar)
$cBtnDummy = GUICtrlCreateDummy()
_GUICtrlStatusBar_EmbedControl($g_hStatus, 1, $_hndl, 4)

$wProcNew = DllCallbackRegister("_StatusBarWindowProc", "int", "hwnd;uint;wparam;lparam")
$wProcOld = _WinAPI_SetWindowLong($g_hStatus, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew))

GUISetState(@SW_SHOW)

While 1
   $idMsg = GUIGetMsg()
   Select
      Case $idMsg = $GUI_EVENT_CLOSE
         ExitLoop
      Case $idMsg = $cBtnDummy
         ConsoleWrite('StatusBar OK click' & @CRLF)
   EndSelect
WEnd

Func _StatusBarWindowProc($hWnd, $Msg, $wParam, $lParam)
    #forceref $hWnd, $Msg, $wParam, $lParam
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)

    Switch $Msg
        Case $WM_COMMAND
            Switch $lParam
                Case $_hndl
                    Switch $nNotifyCode
                        Case $BN_CLICKED
                            GUICtrlSendToDummy($cBtnDummy)
                    EndSwitch
            EndSwitch
        Case $WM_NCPAINT 
            _GUICtrlStatusBar_EmbedControl($g_hStatus, 1, $_hndl)
    EndSwitch
    Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam)
EndFunc

 

  • Thanks 1

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  

×