Что нового

Многозакладочность в редакторе на основе Scintilla

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Что - то ни как не могу понять как организовать многозакладочность, контрол Scintilla не подчиняется Tab'ам и накладывается поверх :scratch:

Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#include <GuiTab.au3>

$hForm = GUICreate('Test', 600, 450, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$iFile = GUICtrlCreateMenu('Файл')
GUICtrlCreateMenuItem('Новый', $iFile)
GUICtrlCreateMenuItem('Открыть', $iFile)
GUICtrlCreateMenuItem('Сохранить', $iFile)
GUICtrlCreateMenuItem('Сохранить как...', $iFile)
GUICtrlCreateMenuItem('', $iFile)
GUICtrlCreateMenuItem('Выход', $iFile)
GUICtrlCreateMenu('Правка')

$hEdit = SCIControl($hForm, @ScriptDir & '\SciLexer.dll')
SciSetBkColor($hEdit, 0xF0F4F9)
SciSetMarginWidth($hEdit, 35, 0x000000, 0xC0C0C0)
SciSetMarkerPanel($hEdit, 15)
SciSetActiveLineColor($hEdit, 0xFFFED8)

GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
GUIRegisterMsg($WM_SIZING, 'WM_SIZING')
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
GUISetState(@SW_SHOW, $hForm)

While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
Wend

Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $iPos = _WinAPI_GetPosFromRect(DllStructCreate($tagRECT, $lParam))
            WinMove($hEdit, '', 0, 0, $iPos[2] - 7, $iPos[3] - 53)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $iPos = WinGetPos($hWnd)
            WinMove($hEdit, '', 0, 0, $iPos[2] - 7, $iPos[3] - 53)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam)
            DllStructSetData($tMMI, 'MinTrackSize', 500, 1)
            DllStructSetData($tMMI, 'MinTrackSize', 400, 2)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func SCIControl($hWnd, $sSciLexerDll)
	Local $hModule = _WinAPI_LoadLibraryEx($sSciLexerDll)
	Local $iPos = WinGetPos($hWnd)
	Local $hSci = _WinAPI_CreateWindowEx($WS_EX_CLIENTEDGE, 'Scintilla', 'SciControl', BitOR($WS_CHILD, $WS_VISIBLE), _
					0, 0, $iPos[2], $iPos[3], $hWnd, 0, _WinAPI_GetModuleHandle(0), 0)
	If ((@error) Or (Not IsHWnd($hSci))) Then
        Return SetError(1, 0, -1)
    EndIf
	Return $hSci
EndFunc

Func SciSetBkColor($hWnd, $iColor)
    _SendMessage($hWnd, 2052, 32, _WinAPI_SwitchColor($iColor))
	_SendMessage($hWnd, 2050, 0, 0)
EndFunc

Func SciSetMarginWidth($hWnd, $iMargin, $iColorNumber, $iColor)
	_SendMessage($hWnd, 2242, 0, $iMargin)
	_SendMessage($hWnd, 2052, 33, _WinAPI_SwitchColor($iColor))
	_SendMessage($hWnd, 2051, 33, _WinAPI_SwitchColor($iColorNumber))
EndFunc

Func SciSetMarkerPanel($hWnd, $iMargin)
	_SendMessage($hWnd, 2244, 2, 0xFE000000)
	_SendMessage($hWnd, 2242, 2, $iMargin)
	_SendMessage($hWnd, 2246, 2, True)
EndFunc

Func SciSetActiveLineColor($hWnd, $iColor)
    _SendMessage($hWnd, 2098, _WinAPI_SwitchColor($iColor), 0)
    _SendMessage($hWnd, 2096, 1, 0)
EndFunc


Архив: SciLexer
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Видимо только так:

Код:
Case $iTab
			If GUICtrlRead($iTab) = 1 Then
				WinSetState($hSci, '', @SW_HIDE)
			Else
				WinSetState($hSci, '', @SW_SHOW)
			EndIf
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Конечно не так просто и придётся контролировать все вкладки и Scintilla контролы, но это лучше чем ни чего, спасибо :smile:


Добавлено:
Сообщение автоматически объединено:

Принцип понял, дело за массивом..

Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#include <GuiTab.au3>

$hForm = GUICreate('Test', 600, 450, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$iFile = GUICtrlCreateMenu('Файл')
GUICtrlCreateMenuItem('Новый', $iFile)
GUICtrlCreateMenuItem('Открыть', $iFile)
GUICtrlCreateMenuItem('Сохранить', $iFile)
GUICtrlCreateMenuItem('Сохранить как...', $iFile)
GUICtrlCreateMenuItem('', $iFile)
$iExit = GUICtrlCreateMenuItem('Выход', $iFile)
GUICtrlCreateMenu('Правка')

$hTab = GUICtrlCreateTab(0, 0, 600, 450)
$iItem1 = GUICtrlCreateTabItem('Test')
$hEdit = SCIControl($hForm, @ScriptDir & '\SciLexer.dll')
SciSetBkColor($hEdit, 0xF0F4F9)
SciSetMarginWidth($hEdit, 40, 0x000000, 0xC0C0C0)
SciSetMarkerPanel($hEdit, 15)
SciSetActiveLineColor($hEdit, 0xFFFED8)
$iItem2 = GUICtrlCreateTabItem('*')

GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
GUIRegisterMsg($WM_SIZING, 'WM_SIZING')
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
GUISetState(@SW_SHOW, $hForm)

While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE, $iExit
			Exit
		Case $hTab
            If GUICtrlRead($hTab) = 1 Then
               ; WinSetState($hEdit, '', @SW_HIDE)
				ControlHide($hEdit, '', '')
            Else
                ;WinSetState($hEdit, '', @SW_SHOW)
				ControlShow($hEdit, '', '')
            EndIf
	EndSwitch
Wend

Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $iPos = _WinAPI_GetPosFromRect(DllStructCreate($tagRECT, $lParam))
            WinMove($hEdit, '', 0, 20, $iPos[2] - 7, $iPos[3] - 73)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $iPos = WinGetPos($hWnd)
            WinMove($hEdit, '', 0, 20, $iPos[2] - 7, $iPos[3] - 73)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam)
            DllStructSetData($tMMI, 'MinTrackSize', 500, 1)
            DllStructSetData($tMMI, 'MinTrackSize', 400, 2)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func SCIControl($hWnd, $sSciLexerDll)
	Local $hModule = _WinAPI_LoadLibraryEx($sSciLexerDll)
	Local $iPos = WinGetPos($hWnd)
	Local $hSci = _WinAPI_CreateWindowEx($WS_EX_CLIENTEDGE, 'Scintilla', 'SciControl', BitOR($WS_CHILD, $WS_VISIBLE), _
					0, 0, $iPos[2], $iPos[3], $hWnd, 0, _WinAPI_GetModuleHandle(0), 0)
	If ((@error) Or (Not IsHWnd($hSci))) Then
        Return SetError(1, 0, -1)
    EndIf
	Return $hSci
EndFunc

Func SciSetBkColor($hWnd, $iColor)
    _SendMessage($hWnd, 2052, 32, _WinAPI_SwitchColor($iColor))
	_SendMessage($hWnd, 2050, 0, 0)
EndFunc

Func SciSetMarginWidth($hWnd, $iMargin, $iColorNumber, $iColor)
	_SendMessage($hWnd, 2242, 0, $iMargin)
	_SendMessage($hWnd, 2052, 33, _WinAPI_SwitchColor($iColor))
	_SendMessage($hWnd, 2051, 33, _WinAPI_SwitchColor($iColorNumber))
EndFunc

Func SciSetMarkerPanel($hWnd, $iMargin)
	_SendMessage($hWnd, 2244, 2, 0xFE000000)
	_SendMessage($hWnd, 2242, 2, $iMargin)
	_SendMessage($hWnd, 2246, 2, True)
EndFunc

Func SciSetActiveLineColor($hWnd, $iColor)
    _SendMessage($hWnd, 2098, _WinAPI_SwitchColor($iColor), 0)
    _SendMessage($hWnd, 2096, 1, 0)
EndFunc



Добавлено:
Сообщение автоматически объединено:

Вроде сделал :smile:

Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#include <GuiTab.au3>

Global $__aTabStintilla[1][2] = [[0, 0]]
Global $hModule = _WinAPI_LoadLibraryEx(@ScriptDir & '\SciLexer.dll')

$hForm = GUICreate('Test', 600, 450, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$iFile = GUICtrlCreateMenu('Файл')
$iNew = GUICtrlCreateMenuItem('Новый', $iFile)
GUICtrlCreateMenuItem('Открыть', $iFile)
GUICtrlCreateMenuItem('Сохранить', $iFile)
GUICtrlCreateMenuItem('Сохранить как...', $iFile)
GUICtrlCreateMenuItem('', $iFile)
$iExit = GUICtrlCreateMenuItem('Выход', $iFile)
GUICtrlCreateMenu('Правка')

$hTab = _GUICtrlTab_Create($hForm, 0, 0, 600, 450, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
AddSciControl($hTab, 'Без названия')

GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUIRegisterMsg($WM_SIZING, 'WM_SIZING')
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
GUISetState(@SW_SHOW, $hForm)

While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE, $iExit
			_GUICtrlTab_Destroy($hTab)
			_WinAPI_FreeLibrary($hModule)
			Exit
		Case $iNew
            AddSciControl($hTab, 'Без названия')
	EndSwitch
Wend

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $iCode, $tNMHDR, $hWndTab
    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hTab
            Switch $iCode
				Case $NM_CLICK
					For $i = 1 To $__aTabStintilla[0][0]
		                If (_GUICtrlTab_GetCurSel($hTab) == ($i - 1)) Then
			                ControlShow($__aTabStintilla[$i][1], '', '')
		                Else
			                ControlHide($__aTabStintilla[$i][1], '', '')
		                EndIf
	                Next
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $iPos = _WinAPI_GetPosFromRect(DllStructCreate($tagRECT, $lParam))
			WinMove($hTab, '', 0, 0, $iPos[2], $iPos[3])
			For $i = 1 To $__aTabStintilla[0][0]
                WinMove($__aTabStintilla[$i][1], '', 0, 20, $iPos[2] - 7, $iPos[3] - 73)
			Next
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $iPos = WinGetPos($hWnd)
			WinMove($hTab, '', 0, 0, $iPos[2], $iPos[3])
            For $i = 1 To $__aTabStintilla[0][0]
                WinMove($__aTabStintilla[$i][1], '', 0, 20, $iPos[2] - 7, $iPos[3] - 73)
			Next
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam)
            DllStructSetData($tMMI, 'MinTrackSize', 500, 1)
            DllStructSetData($tMMI, 'MinTrackSize', 400, 2)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func AddSciControl($hWnd, $sText)
	$__aTabStintilla[0][0] += 1
	ReDim $__aTabStintilla[$__aTabStintilla[0][0] + 1][Ubound($__aTabStintilla, 2)]
	$__aTabStintilla[$__aTabStintilla[0][0]][0] = _GUICtrlTab_InsertItem($hWnd, $__aTabStintilla[0][0], $__aTabStintilla[0][0] & '  ' & $sText)
	$__aTabStintilla[$__aTabStintilla[0][0]][1] = SCIControl($hWnd)
	SciSetBkColor($__aTabStintilla[$__aTabStintilla[0][0]][1], 0xF0F4F9)
    SciSetMarginWidth($__aTabStintilla[$__aTabStintilla[0][0]][1], 40, 0x000000, 0xC0C0C0)
    SciSetMarkerPanel($__aTabStintilla[$__aTabStintilla[0][0]][1], 15)
    SciSetActiveLineColor($__aTabStintilla[$__aTabStintilla[0][0]][1], 0xFFFED8)
	Local $iPos = WinGetPos($hWnd)
	WinMove($__aTabStintilla[$__aTabStintilla[0][0]][1], '', 0, 20, $iPos[2] - 7, $iPos[3] - 73)
	_GUICtrlTab_SetCurSel($hWnd, ($__aTabStintilla[0][0] - 1))
	For $i = 1 To $__aTabStintilla[0][0]
		If (_GUICtrlTab_GetCurSel($hWnd) == ($i - 1)) Then
			ControlShow($__aTabStintilla[$i][1], '', '')
		Else
			ControlHide($__aTabStintilla[$i][1], '', '')
		EndIf
	Next
EndFunc

Func SCIControl($hWnd)
	Local $iPos = WinGetPos($hWnd)
	Local $hSci = _WinAPI_CreateWindowEx(BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOPMOST), 'Scintilla', 'SciControl', BitOR($WS_CHILD, $WS_VISIBLE, $WS_TABSTOP), _
					0, 0, $iPos[2], $iPos[3], $hWnd, 0, _WinAPI_GetModuleHandle(0), 0)
	If ((@error) Or (Not IsHWnd($hSci))) Then
        Return SetError(1, 0, -1)
    EndIf
	Return $hSci
EndFunc

Func SciSetBkColor($hWnd, $iColor)
    _SendMessage($hWnd, 2052, 32, _WinAPI_SwitchColor($iColor))
	_SendMessage($hWnd, 2050, 0, 0)
EndFunc

Func SciSetMarginWidth($hWnd, $iMargin, $iColorNumber, $iColor)
	_SendMessage($hWnd, 2242, 0, $iMargin)
	_SendMessage($hWnd, 2052, 33, _WinAPI_SwitchColor($iColor))
	_SendMessage($hWnd, 2051, 33, _WinAPI_SwitchColor($iColorNumber))
EndFunc

Func SciSetMarkerPanel($hWnd, $iMargin)
	_SendMessage($hWnd, 2244, 2, 0xFE000000)
	_SendMessage($hWnd, 2242, 2, $iMargin)
	_SendMessage($hWnd, 2246, 2, True)
EndFunc

Func SciSetActiveLineColor($hWnd, $iColor)
    _SendMessage($hWnd, 2098, _WinAPI_SwitchColor($iColor), 0)
    _SendMessage($hWnd, 2096, 1, 0)
EndFunc
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Немного доработал пример...

Добавлен перенос по словам, создание вкладки по двойному клику в пустом месте таба, и удаление вкладки по двойному клику на вкладке:

Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#include <GuiTab.au3>

Global $iDblClk_Flag = 0
Global $iDblClk_Timer = 0
Global $iDblClk_Time = RegRead('HKEY_CURRENT_USER\Control Panel\Mouse', 'DoubleClickSpeed')
If $iDblClk_Time = '' Then $iDblClk_Time = 600

Global $aLast_MousePos[2]

Global $__aTabStintilla[1][2] = [[0, 0]]
Global $hModule = _WinAPI_LoadLibraryEx('SciLexer.dll')

$hForm = GUICreate('Scintilla with tabs Demo', 600, 450, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$iFile = GUICtrlCreateMenu('Файл')
$iNew = GUICtrlCreateMenuItem('Новый', $iFile)
GUICtrlCreateMenuItem('Открыть', $iFile)
GUICtrlCreateMenuItem('Сохранить', $iFile)
GUICtrlCreateMenuItem('Сохранить как...', $iFile)
GUICtrlCreateMenuItem('', $iFile)
$iExit = GUICtrlCreateMenuItem('Выход', $iFile)
GUICtrlCreateMenu('Правка')

$hTab = _GUICtrlTab_Create($hForm, 0, 0, 600, 450, BitOR($WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
AddSciControl($hTab, 'Без названия')

GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUIRegisterMsg($WM_SIZING, 'WM_SIZING')
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')

GUISetState(@SW_SHOW, $hForm)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $iExit
            _GUICtrlTab_Destroy($hTab)
            _WinAPI_FreeLibrary($hModule)
            Exit
        Case $iNew
            AddSciControl($hTab, 'Без названия')
		Case $GUI_EVENT_PRIMARYDOWN
			$aCurrent_MousePos = MouseGetPos()
			
			If $iDblClk_Flag = 0 Then
				$iDblClk_Timer = TimerInit()
				$iDblClk_Flag = 1
				$aLast_MousePos = MouseGetPos()
			ElseIf $aCurrent_MousePos[0] = $aLast_MousePos[0] And $aCurrent_MousePos[1] = $aLast_MousePos[1] And TimerDiff($iDblClk_Timer) <= $iDblClk_Time Then
				$iDblClk_Flag = 0
				$iDblClk_Timer = 0
				
				$iOpt = Opt('MouseCoordMode', 2)
				$aMPos = MouseGetPos()
				$aHitTest = _GUICtrlTab_HitTest($hTab, $aMPos[0], $aMPos[1])
				Opt('MouseCoordMode', $iOpt)
				
				If $aHitTest[0] <> -1 Then
					If $__aTabStintilla[0][0] > 1 Then
						DeleteSciControl($hTab, _GUICtrlTab_GetCurSel($hTab))
					EndIf
				Else
					$iAdd = 1
					$tPoint = _WinAPI_GetMousePos()
					$hCtrl = _WinAPI_WindowFromPoint($tPoint)
					
					For $i = 1 To $__aTabStintilla[0][0]
						If $hCtrl = $__aTabStintilla[$i][1] Then
							$iAdd = 0
							ExitLoop
						EndIf
					Next
					
					If $iAdd Then AddSciControl($hTab, 'Без названия')
				EndIf
			ElseIf $iDblClk_Flag = 1 Then
				$iDblClk_Flag = 0
				$iDblClk_Timer = 0
			EndIf
    EndSwitch
Wend

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $iCode, $tNMHDR, $hWndTab
    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hTab
            Switch $iCode
				Case $NM_CLICK
                    For $i = 1 To $__aTabStintilla[0][0]
                        If (_GUICtrlTab_GetCurSel($hTab) == ($i - 1)) Then
                            ControlShow($hWnd, '', $__aTabStintilla[$i][1])
							ControlFocus($hWnd, '', $__aTabStintilla[$i][1])
                        Else
                            ControlHide($hWnd, '', $__aTabStintilla[$i][1])
                        EndIf
                    Next
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $iPos = _WinAPI_GetPosFromRect(DllStructCreate($tagRECT, $lParam))
            WinMove($hTab, '', 0, 0, $iPos[2], $iPos[3])
            For $i = 1 To $__aTabStintilla[0][0]
                WinMove($__aTabStintilla[$i][1], '', 0, 20, $iPos[2] - 15, $iPos[3] - 73)
            Next
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $iPos = WinGetPos($hWnd)
            WinMove($hTab, '', 0, 0, $iPos[2], $iPos[3])
            For $i = 1 To $__aTabStintilla[0][0]
                WinMove($__aTabStintilla[$i][1], '', 0, 20, $iPos[2] - 15, $iPos[3] - 73)
            Next
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm
            Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam)
            DllStructSetData($tMMI, 'MinTrackSize', 500, 1)
            DllStructSetData($tMMI, 'MinTrackSize', 400, 2)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func AddSciControl($hWnd, $sText)
    $__aTabStintilla[0][0] += 1
    ReDim $__aTabStintilla[$__aTabStintilla[0][0] + 1][Ubound($__aTabStintilla, 2)]
    $__aTabStintilla[$__aTabStintilla[0][0]][0] = _GUICtrlTab_InsertItem($hWnd, $__aTabStintilla[0][0], $__aTabStintilla[0][0] & '  ' & $sText)
    $__aTabStintilla[$__aTabStintilla[0][0]][1] = SCIControl($hWnd)
	_SendMessage( $__aTabStintilla[$__aTabStintilla[0][0]][1], 2268, 1, 0) ;$SCI_SETWRAPMODE = 2268
    SciSetBkColor($__aTabStintilla[$__aTabStintilla[0][0]][1], 0xF0F4F9)
    SciSetMarginWidth($__aTabStintilla[$__aTabStintilla[0][0]][1], 40, 0x000000, 0xC0C0C0)
    SciSetMarkerPanel($__aTabStintilla[$__aTabStintilla[0][0]][1], 15)
    SciSetActiveLineColor($__aTabStintilla[$__aTabStintilla[0][0]][1], 0xFFFED8)
    Local $iPos = WinGetPos($hWnd)
    WinMove($__aTabStintilla[$__aTabStintilla[0][0]][1], '', 0, 20, $iPos[2] - 15, $iPos[3] - 73)
    _GUICtrlTab_SetCurSel($hWnd, ($__aTabStintilla[0][0] - 1))
    For $i = 1 To $__aTabStintilla[0][0]
        If (_GUICtrlTab_GetCurSel($hWnd) == ($i - 1)) Then
            ControlShow($hWnd, '', $__aTabStintilla[$i][1])
			ControlFocus($hWnd, '', $__aTabStintilla[$i][1])
        Else
            ControlHide($hWnd, '', $__aTabStintilla[$i][1])
        EndIf
    Next
EndFunc

Func DeleteSciControl($hWnd, $iIndex)
	Local $aTmp[$__aTabStintilla[0][0]+1][Ubound($__aTabStintilla, 2)]
	_WinAPI_DestroyWindow($__aTabStintilla[$iIndex+1][1])
	_GUICtrlTab_DeleteItem($hWnd, $iIndex)
	_GUICtrlTab_ClickTab($hTab, $iIndex-1)
	
	For $i = 1 To $__aTabStintilla[0][0]
        If $iIndex <> ($i - 1) Then
			$aTmp[0][0] += 1
			
			For $j = 0 To Ubound($__aTabStintilla, 2)-1
				$aTmp[$aTmp[0][0]][$j] = $__aTabStintilla[$i][$j]
			Next
        EndIf
    Next
	
	ReDim $aTmp[$aTmp[0][0]+1][Ubound($__aTabStintilla, 2)]
	$__aTabStintilla = $aTmp
EndFunc

Func SCIControl($hWnd)
    Local $iPos = WinGetPos($hWnd)
    Local $hSci = _WinAPI_CreateWindowEx(BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOPMOST), 'Scintilla', 'SciControl', BitOR($WS_CHILD, $WS_VISIBLE, $WS_TABSTOP), _
		0, 0, $iPos[2], $iPos[3], $hWnd, 0, _WinAPI_GetModuleHandle(0), 0)
    If ((@error) Or (Not IsHWnd($hSci))) Then
        Return SetError(1, 0, -1)
    EndIf
    Return $hSci
EndFunc

Func SciSetBkColor($hWnd, $iColor)
    _SendMessage($hWnd, 2052, 32, _WinAPI_SwitchColor($iColor))
    _SendMessage($hWnd, 2050, 0, 0)
EndFunc

Func SciSetMarginWidth($hWnd, $iMargin, $iColorNumber, $iColor)
    _SendMessage($hWnd, 2242, 0, $iMargin)
    _SendMessage($hWnd, 2052, 33, _WinAPI_SwitchColor($iColor))
    _SendMessage($hWnd, 2051, 33, _WinAPI_SwitchColor($iColorNumber))
EndFunc

Func SciSetMarkerPanel($hWnd, $iMargin)
    _SendMessage($hWnd, 2244, 2, 0xFE000000)
    _SendMessage($hWnd, 2242, 2, $iMargin)
    _SendMessage($hWnd, 2246, 2, True)
EndFunc

Func SciSetActiveLineColor($hWnd, $iColor)
    _SendMessage($hWnd, 2098, _WinAPI_SwitchColor($iColor), 0)
    _SendMessage($hWnd, 2096, 1, 0)
EndFunc


Если бы $NM_DBLCLK обрабатывался в WM_NOTIFY, то не нужно было бы извращаться через $GUI_EVENT_PRIMARYDOWN :(.
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Немного поправил.
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
А у Вас заработал этот пример? У меня нет...

Код:
_GUICtrlToolbar_AddButton($hToolbar, $ID_FILENEW, $STD_FILENEW)
_GUICtrlToolbar_AddButton($hToolbar, $ID_FILENEW, ^ ERROR

Не могу найти ни в одной инклуде константу $STD_FILENEW
 

AZJIO

Меценат
Меценат
Сообщения
2,879
Репутация
1,194
Viktor1703
У меня на 3.3.9.5 работает.
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Нашёл, на 160 строке в самом примере, но Autoit говорит что она не объявлена и выдаёт ошибку, хотя

Код:
Global Enum $ID_FILENEW = 2000, $ID_FILEOPEN, ....


Вообщем еле запустил.

Ужасно..., даже сам Stintilla не показывается на вкладках, лучше буду свой собирать, а то тут править очень много.
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Viktor1703 [?]
Ужасно..., даже сам Stintilla не показывается на вкладках, лучше буду свой собирать, а то тут править очень много.
Если установлен AutoIt 3.3.8.1 то не нужно ничего править.
Но ты видимо ищешь причину чтобы написать своё, и я это понимаю, я сам такой :IL_AutoIt_1:.
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Просто не хочется разбираться в чужом скрипте, "Ужасно" - это я к тому что мне много придётся перелопатить и понять в нём, легче написать своё ну и конечно если что-то не получится то буду смотреть решение в этом примере, но править его под себя - не хочу :smile:
 

gregaz

AutoIT Гуру
Сообщения
1,166
Репутация
299
Может кому понадобится простое решение(без "прибамбасов"):
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#include <GuiTab.au3>

Global $a_Tab[1][2] = [[0, 0]]
Global $i_ActiveTab_Index

_WinAPI_LoadLibraryEx(@ScriptDir & '\SciLexer.dll')

$h_Form = GUICreate('Scintilla with tabs Demo', 600, 450)

$_BtNew = GUICtrlCreateButton('New', 0, 0, 40, 20)
$_BtUndo = GUICtrlCreateButton('Undo', 40, 0, 40, 20)
$_BtRedo = GUICtrlCreateButton('Redo', 80, 0, 40, 20)

$_Tab=GUICtrlCreateTab (5, 25, 590, 400)

NewTab($h_Form, $_Tab, "Untitled ")
GUICtrlCreateTabItem("")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
		   Exit
        Case $_BtNew
           NewTab($h_Form, $_Tab, "Untitled ")
		Case $_Tab
			GotoTab($h_Form, $_Tab)
		Case $_BtUndo
			_SendMessage($a_Tab[$i_ActiveTab_Index][1], 2176, 0, 0)
		Case $_BtRedo
			_SendMessage($a_Tab[$i_ActiveTab_Index][1], 2011, 0, 0)
	EndSwitch
Wend

Func GotoTab($hWnd,$Tab)
	Local $iTabIndex=GUICtrlRead($Tab)+1
	If $i_ActiveTab_Index Then
		ControlHide($hWnd, '', $a_Tab[$i_ActiveTab_Index][1])
		ControlShow($hWnd, '', $a_Tab[$iTabIndex][1])
	EndIf
	$i_ActiveTab_Index=$iTabIndex
EndFunc

Func NewTab($hWnd, $hTab, $sText)
	$a_Tab[0][0] += 1
	ReDim $a_Tab[$a_Tab[0][0] + 1][Ubound($a_Tab, 2)]
	If $i_ActiveTab_Index Then
		ControlHide($hWnd, '', $a_Tab[$i_ActiveTab_Index][1])
	EndIf
	$i_ActiveTab_Index=$a_Tab[0][0]
	$a_Tab[$a_Tab[0][0]][0]=GUICtrlCreateTabItem($sText & $a_Tab[0][0])
	$a_Tab[$a_Tab[0][0]][1]=SCIControl($hWnd, 5, 47,590, 390)
	 _GUICtrlTab_SetCurSel($hTab, $a_Tab[0][0] -1)
	DllCall("User32.Dll", "int", "SendMessageA", "hwnd", $a_Tab[$a_Tab[0][0]][1], "int", 2181, "int", 0, "str",  $sText & $a_Tab[0][0])
EndFunc

Func SCIControl($hWnd, $X, $Y, $W, $H)
    Local $hSci = _WinAPI_CreateWindowEx($WS_EX_CLIENTEDGE, 'Scintilla', 'SciControl', BitOR($WS_CHILD, $WS_VISIBLE), _
                   $X, $Y, $W, $H, $hWnd, 0, _WinAPI_GetModuleHandle(0), 0)
    If ((@error) Or (Not IsHWnd($hSci))) Then
        Return SetError(1, 0, -1)
    EndIf
    Return $hSci
EndFunc
 
Верх