Modify

Opened 11 years ago

Closed 11 years ago

#58 closed Feature Request (Rejected)

Add a new button Type called Splitbutton

Reported by: ptrex Owned by:
Milestone: Component: AutoIt
Version: Severity:
Keywords: Splitbutton BS_SPLITBUTTON Cc:

Description

Addition of the "BS_SPLITBUTTON" type button.

http://msdn2.microsoft.com/en-us/library/bb775951(VS.85).aspx]

This makes it possible to combine a button with a dropdownlist style.

Attachments (0)

Change History (18)

comment:1 Changed 11 years ago by Gary

You realize that is a Vista only correct?

comment:2 Changed 11 years ago by ptrex

Gary,

I don't think you are correct.

MSDN says :
BS_SPLITBUTTON
Microsoft Windows Vista and Version 6.00. Creates a split button. A split button has a drop down arrow

Version 6.00 meaning : 6.0 Shlwapi.dll Windows XP and Windows Vista

At the moment I run a lot of applications using this buttontype on XP.

Correct ?

comment:3 Changed 11 years ago by Valik

  • Summary changed from Add a new button Type called Spitbutton to Add a new button Type called Splitbutton

comment:4 Changed 11 years ago by Valik

  • Keywords Splitbutton added; Spitbutton removed
  • Milestone 3.2.11.0 deleted
  • Version 3.2.10.0 deleted

comment:5 Changed 11 years ago by Valik

Does this need some sort of special handling? Why can't you just pass BS_SPLITBUTTON to GUICtrlCreateButton()?

comment:6 Changed 11 years ago by ptrex

Valik,

  1. I didn't try it because it was not listed in the options in the helpfile : GUI Control Styles Appendix
  1. When did try to add it in the GUICtrlCreateButton() it errored out saying ERROR: $BS_SPLITBUTTON: undeclared global variable
  1. When I searched the include files for the BS_SPLITBUTTON. It wasn't there.

Did I miss something ?

comment:7 Changed 11 years ago by ptrex

Valik,

Even if I would like to add this to the global constants include file. I can't find the Constants value ?!

Even not on the MSDN ?!

comment:8 Changed 11 years ago by Jos

The style is described in the MS sdk ver 6a:
Microsoft SDKs\Windows\v6.0A\Include\CommCtrl.h:7843:
#define BS_SPLITBUTTON 0x0000000CL

comment:9 Changed 11 years ago by ptrex

Jos,

I saw this constant, but this is not a cnnstant value that AU3 would accept.

How to translate this 0x0000000CL to a Hex value that AU3 can understand ?

Thanks

ptrex

comment:10 Changed 11 years ago by Jos

This should do it:
$BS_SPLITBUTTON = 0x0000000C

comment:11 Changed 11 years ago by ptrex

Jos,

I tried creating a button using this Constant value. But success.
Did you get it to show correctly ?

#include <GUIConstants.au3>

Global Const $BS_SPLITBUTTON = 0x0000000C

GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100,25,$BS_SPLITBUTTON)
$Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1)

GUISetState () ; will display an dialog box with 2 button

; Run the GUI until the dialog is closed
While 1

$msg = GUIGetMsg()
Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

Run('Notepad.exe') ; Will Run/Open Notepad

Case $msg = $Button_2

MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed

EndSelect

Wend

comment:12 Changed 11 years ago by ptrex

All

According to me the constant value should be

Const $BS_SPLITBUTTON = 0x5000000c

But anyhow it doesn't show up correctly ?!

regards

ptrex

comment:13 Changed 11 years ago by ptrex

OK
This gives somekind of button but not a splitbutton

Global Const $BS_SPLITBUTTON = 0x5000c

and this guves an other result but still not a splitbutton

Global Const $BS_SPLITBUTTON = 0x50000c

comment:14 Changed 11 years ago by ptrex

Maybe this bug has something to do with it ?

In a previous post I explained than when you create a MFC application with the March CTP of ‘Orcas’ and add a command or split button to a dialog, the .rc file is not compiled, because styles such as BS_COMMANDLINK are not found. My workaround for the moment was to redeclare them in the resource.h header. But that is not a good idea, because the IDE overwrites the file, removing what you put there. So, eventually, I brought that up to the VC++ team, and it seems that the March CTP has a problem with the resource headers, used by the resource compilers. In other words, at least commctrl.rc was not updated to contain the required definitions.

You can work around this in two better ways:

install the Windows RTM SDK, or
redefine the necessary styles in commctrl.rc
#if _WIN32_WINNT >= 0x0600 BUTTON STATE FLAGS#define BST_DROPDOWNPUSHED 0x0400 BUTTON STYLES#define BS_SPLITBUTTON 0x0000000CL#define BS_DEFSPLITBUTTON 0x0000000DL#define BS_COMMANDLINK 0x0000000EL#define BS_DEFCOMMANDLINK 0x0000000FL#endif

I decided to go for the second, and now the applications are successfully built. I have been told that the problem has been already fixed for the upcoming CTP/beta. The VC++ team will soon post about this on their blog too. I want to thank to Marian Luparu for the help with this matter.

For more information : http://mariusbancila.ro/blog/?cat=12

comment:15 Changed 11 years ago by Valik

You're making this a lot harder than it should be. Quite simply, AutoIt doesn't let you create a BS_SPLITBUTTON with it's native control types (I didn't think it would but I at least wanted you to try in case it did work). I think Gary added some button functions to the UDF library (They could be in the recent beta 3.2.11.0) so just use those to create your SplitButton.

comment:16 Changed 11 years ago by ptrex

Valik

As you could see I came to surprising results when testing.

But anyhow I will wait till the the next beta release is on my machine.

Regards

ptrex

comment:17 Changed 11 years ago by Gary / Valik

I did give it a try using the new functions of Gary. But not success.

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <WindowsConstants.au3>
#Include <GuiImageList.au3>

Opt("MustDeclareVars", 1)

Global $btn, $rdo, $chk, $iMemo

; Note the controlId from these buttons can NOT be read with GuiCtrlRead

_Main()

Func _Main()
	Local $hImage, $hGUI
	Const $BS_SPLITBUTTON = 0x0000000C
	Const $BS_DEFSPLITBUTTON  = 0x0000000D
	Const $BS_COMMANDLINK  = 0x0000000E
	Const $BS_DEFCOMMANDLINK  = 0x0000000F
	Const $BST_DROPDOWNPUSHED = 0x0400 
	
	$hGUI = GUICreate("Buttons", 400, 400)
	$iMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
	GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")

	$hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
	For $x = 6 To 11
		_GUIImageList_AddIcon($hImage, "shell32.dll", $x, True)
	Next

	$btn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 90, 50,BitOR($BST_DROPDOWNPUSHED,$BS_SPLITBUTTON))
	_GUICtrlButton_SetImageList($btn, $hImage)

	$rdo = _GUICtrlButton_Create($hGUI, "Radio1", 10, 60, 90, 50, $BS_AUTORADIOBUTTON)
	_GUICtrlButton_SetImageList($rdo, $hImage, 1)

	$chk = _GUICtrlButton_Create($hGUI, "Check1", 10, 120, 90, 50, $BS_AUTO3STATE)
	_GUICtrlButton_SetImageList($chk, $hImage)

	GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
	GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
	
	GUISetState()
	
	While 1
		Switch GUIGetMsg()
			Case $GUI_EVENT_CLOSE
				ExitLoop
		EndSwitch
	WEnd

	Exit
EndFunc   ;==>_Main


; Write a line to the memo control
Func MemoWrite($sMessage)
	GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
	#forceref $hWnd, $Msg, $wParam
	Local Const $BCN_HOTITEMCHANGE = -1249
	Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
	Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
	Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
	Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
	Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")
	Local $sText = ""
	
	Switch $nNotifyCode
		Case $BCN_HOTITEMCHANGE ; Win XP and Above
			If BitAND($dwFlags, 0x10) = 0x10 Then
				$sText = "$BCN_HOTITEMCHANGE - Entering: " & @CRLF
				
			ElseIf BitAND($dwFlags, 0x20) = 0x20 Then
				$sText = "$BCN_HOTITEMCHANGE - Leaving: " & @CRLF
			EndIf
			MemoWrite($sText & _
					"-----------------------------" & @CRLF & _
					"WM_NOTIFY - Infos:" & @CRLF & _
					"-----------------------------" & @CRLF & _
					"Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
					"CtrlID" & @TAB & ":" & $nID & @CRLF & _
					"CtrlHWnd:" & $hCtrl & @CRLF & _
					_GUICtrlButton_GetText($hCtrl) & @CRLF)
	EndSwitch
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

; React on a button click
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
	#forceref $hWnd, $Msg
	Local $nNotifyCode = BitShift($wParam, 16)
	Local $nID = BitAND($wParam, 0x0000FFFF)
	Local $hCtrl = $lParam
	Local $sText = ""
	
	Switch $hCtrl
		Case $btn, $rdo, $chk
			Switch $nNotifyCode
				Case $BN_CLICKED
					$sText = "$BN_CLICKED" & @CRLF
				Case $BN_PAINT
					$sText = "$BN_PAINT" & @CRLF
				Case $BN_PUSHED, $BN_HILITE
					$sText = "$BN_PUSHED, $BN_HILITE" & @CRLF
				Case $BN_UNPUSHED, $BN_UNHILITE
					$sText = "$BN_UNPUSHED" & @CRLF
				Case $BN_DISABLE
					$sText = "$BN_DISABLE" & @CRLF
				Case $BN_DBLCLK, $BN_DOUBLECLICKED
					$sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF
				Case $BN_SETFOCUS
					$sText = "$BN_SETFOCUS" & @CRLF
				Case $BN_KILLFOCUS
					$sText = "$BN_KILLFOCUS" & @CRLF
			EndSwitch
			MemoWrite($sText & _
					"-----------------------------" & @CRLF & _
					"WM_NOTIFY - Infos:" & @CRLF & _
					"-----------------------------" & @CRLF & _
					"Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
					"CtrlID" & @TAB & ":" & $nID & @CRLF & _
					"CtrlHWnd:" & $hCtrl & @CRLF & _
					_GUICtrlButton_GetText($hCtrl) & @CRLF)
			Return 0 ; Only workout clicking on the button
	EndSwitch
	; Proceed the default Autoit3 internal message commands.
	; You also can complete let the line out.
	; !!! But only 'Return' (without any value) will not proceed
	; the default Autoit3-message in the future !!!
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

I did try different constants values but no succces. There must be something else prevent the creation this button type ?

Regards,

ptrex

comment:18 Changed 11 years ago by Valik

  • Resolution set to rejected
  • Status changed from new to closed

Resolving this as rejected. It's highly unlikely we are going to add the control as a native function. Maybe if somebody gets it working correctly it can be added as a UDF but that's up to Gary. For now, closing this.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.