PDA

Показать полную графическую версию : GUICtrlCreateLabel +$WS_VSCROLL не работает


Centrinar
15-05-2010, 23:37
GUICtrlCreateLabel("text", 40, 300, 300, 50,$ES_AUTOVSCROLL+$WS_VSCROLL). Должно получиться текст с вертикальной прокруткой но прокрутка почему то не работает, где ошибка?

FlatX007
16-05-2010, 00:26
Давно ли у лэйбла прокрутка ?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $Text = "12345"

$Form1 = GUICreate("", 208, 150)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 185, 89, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL))
$Button1 = GUICtrlCreateButton("Ok", 120, 112, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
For $i = 0 To 20
Sleep(100)
GUICtrlSetData($Edit1, $Text * Random(999, 999999), $Edit1)
Next
EndSwitch
WEnd

Creat0R
16-05-2010, 00:44
Должно получиться текст с вертикальной прокруткой »
Кто сказал? :)
Чтобы сделать “эффект” текста с прокруткой, нужно использовать Edit:

#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <EditConstants.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <WindowsConstants.au3>

$hGUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)("Scrollable Label Imitation Example", 300, 200)

$sLabelData = ""

For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 1 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) 50
$sLabelData &= "This is my Label Line #" & $i & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)

$nDummyCtrl = GUICtrlCreateLabel (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateLabel.htm)("", -100, -100)
$nCntxtMenu = GUICtrlCreateContextMenu (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateContextMenu.htm)($nDummyCtrl)
$nCopy_CntxtMenuItem = GUICtrlCreateMenuItem (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateMenuItem.htm)("Copy", $nCntxtMenu)

$nEdit = GUICtrlCreateEdit (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateEdit.htm)($sLabelData, 20, 20, 260, 150, BitOr (http://www.autoitscript.com/autoit3/docs/functions/BitOR.htm)(BitAND (http://www.autoitscript.com/autoit3/docs/functions/BitAND.htm)($GUI_SS_DEFAULT_EDIT, BitNOT (http://www.autoitscript.com/autoit3/docs/functions/BitNOT.htm)($WS_HSCROLL)), $ES_READONLY), $WS_EX_TRANSPARENT)
GUICtrlSetCursor (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetCursor.htm)($nEdit, 2)

GUIRegisterMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIRegisterMsg.htm)($WM_COMMAND, "WM_COMMAND")
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)(@SW_SHOW (http://www.autoitscript.com/autoit3/docs/macros.htm#@sw_show), $hGUI)

While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)()
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_SECONDARYDOWN
$aCursorInfo = GUIGetCursorInfo (http://www.autoitscript.com/autoit3/docs/functions/GUIGetCursorInfo.htm)($hGUI)

If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $aCursorInfo[4] = $nEdit Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
_ShowContextMenu($hGUI, $nCntxtMenu)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $nCopy_CntxtMenuItem
ClipPut (http://www.autoitscript.com/autoit3/docs/functions/ClipPut.htm)(GUICtrlRead (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlRead.htm)($nEdit))
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _ShowContextMenu($hWnd, $nContextID)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $hMenu = GUICtrlGetHandle (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlGetHandle.htm)($nContextID)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $arPos = MouseGetPos (http://www.autoitscript.com/autoit3/docs/functions/MouseGetPos.htm)()
DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $arPos[0], "int", $arPos[1], "hwnd", $hWnd, "ptr", 0)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) WM_COMMAND($hWnd, $nMsg, $wParam, $lParam)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $nNotifyCode = BitShift (http://www.autoitscript.com/autoit3/docs/functions/BitShift.htm)($wParam, 16)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $nID = BitAND (http://www.autoitscript.com/autoit3/docs/functions/BitAND.htm)($wParam, 0xFFFF)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $hCtrl = $lParam

Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nID
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $nEdit
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nNotifyCode
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $EN_CHANGE, $EN_UPDATE

Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $EN_SETFOCUS
ControlFocus (http://www.autoitscript.com/autoit3/docs/functions/ControlFocus.htm)($hWnd, "", $nDummyCtrl)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $EN_KILLFOCUS

EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)

Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $GUI_RUNDEFMSG
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)




© OSzone.net 2001-2012