Modify

Opened 11 years ago

Closed 11 years ago

#2493 closed Bug (Fixed)

Examples for _GUICtrlToolbar_GetMetrics, _GUICtrlToolbar_SetMetrics

Reported by: mlipok Owned by: Jpm
Milestone: 3.3.9.22 Component: Documentation
Version: 3.3.9.21 Severity: None
Keywords: Cc:

Description

Example from Helpfile is not good, because in my opinion it does not show clearly how the appearance of the toolbar.

Please make a better example that show how Toolbar visually changing.

#include <GuiToolbar.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $iMemo

Example()

Func Example()
	Local $hGUI, $hToolbar, $aMetrics
	Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp

	; Create GUI
	$hGUI = GUICreate("Toolbar", 400, 300)
	$hToolbar = _GUICtrlToolbar_Create($hGUI)
	$iMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
	GUICtrlSetFont($iMemo, 10, 400, 0, "Courier New")
	GUISetState()

	; Add standard system bitmaps
	Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
		Case 0
			_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
		Case 2
			_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
	EndSwitch

	; Add buttons
	_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
	_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
	_GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
	_GUICtrlToolbar_AddButtonSep($hToolbar)
	_GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

	MemoWrite("Before _GUICtrlToolbar_SetMetrics")

	Sleep(1000)
	GUISetState(@SW_LOCK)
	; Set control metrics
	MemoWrite("Step 1:")
	MemoWrite("$iXPad = 10")
	_GUICtrlToolbar_SetMetrics($hToolbar, 10, 0, 0, 0)
	GUISetState(@SW_UNLOCK)

	Sleep(1000)
	GUISetState(@SW_LOCK)
	; Set control metrics
	MemoWrite("Step 2:")
	MemoWrite("$iYPad = 10")
	_GUICtrlToolbar_SetMetrics($hToolbar, 0, 10, 0, 0)
	GUISetState(@SW_UNLOCK)

	Sleep(1000)
	GUISetState(@SW_LOCK)
	; Set control metrics
	MemoWrite("Step 3:")
	MemoWrite("$iXSpacing = 10")
	_GUICtrlToolbar_SetMetrics($hToolbar, 0, 0, 10, 0)
	GUISetState(@SW_UNLOCK)

	Sleep(1000)
	GUISetState(@SW_LOCK)
	; Set control metrics
	MemoWrite("Step 4:")
	MemoWrite("$iYSpacing = 10")
	_GUICtrlToolbar_SetMetrics($hToolbar, 0, 0, 0, 10)
	GUISetState(@SW_UNLOCK)

	Sleep(1000)
	GUISetState(@SW_LOCK)
	; Set control metrics
	MemoWrite("")
	MemoWrite("Step 5:")
	MemoWrite("$iXPad = 10")
	MemoWrite("$iYPad = 10")
	MemoWrite("$iXSpacing = 10")
	MemoWrite("$iYSpacing = 10")
	_GUICtrlToolbar_SetMetrics($hToolbar, 10, 10, 10, 10)
	GUISetState(@SW_UNLOCK)

	; Show control metrics
	$aMetrics = _GUICtrlToolbar_GetMetrics($hToolbar)
	MemoWrite("Button padding width ...: " & $aMetrics[0])
	MemoWrite("Button padding height ..: " & $aMetrics[1])
	MemoWrite("Button spacing width ...: " & $aMetrics[2])
	MemoWrite("Button spacing height ..: " & $aMetrics[3])

	; Loop until user exits
	Do
	Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
	GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Initially I prepared a better example as you can see, however, does not work.
Therefore, I wonder if this is not a bug in the UDF I mean GuiToolbar.au3.

ps.
The first problem noted AZJIO:
http://www.autoitscript.com/forum/topic/153782-help-filedocumentation-issues-discussion-only/page-7#entry1121228

Attachments (0)

Change History (3)

comment:1 Changed 11 years ago by mlipok

now I know more:

look in _GUICtrlToolbar_SetPadding():
in Remarks: "Padding is only applied to buttons that
have the $TBSTYLE_AUTOSIZE style."

First note:
$TBSTYLE_AUTOSIZE is no where defined, it seems that it is more about $BTNS_AUTOSIZE

But when I use:

	_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW, 0, $BTNS_AUTOSIZE)
	_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN, 0, $BTNS_AUTOSIZE)
	_GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE, 0, $BTNS_AUTOSIZE)
	_GUICtrlToolbar_AddButtonSep($hToolbar)
	_GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, 0, $BTNS_AUTOSIZE)

Despite this, using this example, can not see the visual change ToolBar Control.

comment:2 Changed 11 years ago by mlipok

I forgot to say that the same problem is in the example in the documentation functions: _GUICtrlToolbar_SetPadding ()

comment:3 Changed 11 years ago by Jpm

  • Milestone set to 3.3.9.22
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [9102] in version: 3.3.9.22

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 owner will remain Jpm.
Author


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

 
Note: See TracTickets for help on using tickets.