Sign in to follow this  
Followers 0
erebus

Transparent Tabs and Readonly Editboxes

26 posts in this topic

Hello all,

I have two fast questions:

1) Is it possible to have two transparent tabs, over a background image/color on a GUI? I.e. in the following example, I want that gray color on the right of the tabs to be transparent.

#include <GUIConstants.au3>

GUICreate("", 650, 500, -1, -1, $WS_POPUPWINDOW)
GUISetBkColor(0x00E0FFFF)

GUICtrlCreateTab(10, 10, 200, 410)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabitem ("")

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEndoÝ÷ Ûb,Úh²Èëh«Þj·våÉçbµº1Â¥z+b²z-v+nW²¬m¡ªiyªà­¬ºÛhv+nW¨­é¨ºÇ'$²)â¶Ê²Ú)­ëÞ×(§/éjË^~º&×è­ìZ^ËnjYr!Æ«zåÊÚÆç%É,þ¸ ×%É,{az×±µªÞjíçÖèÆ0z÷«#§¶Úy¦åzÚ'$¢{azÇ+¢Y[j»y«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì()U%
ÉÑ ÅÕ½ÐìÅÕ½Ðì°ØÔÀ°ÔÀÀ°´Ä°´Ä°ÀÌØí]M}A=AUA]%9=¤)U%MÑ ­
½±½È ÁàÀÁÁ¤()U%
Ñɱ
ÉÑQ ÄÀ°ÄÀ°ÈÀÀ°ÐÄÀ¤)U%
ÑɱMÑ   ­
½±½È ´Ä°ÀÌØíU%}  -
=1=I}QI9MAI9P¤)U%
Ñɱ
ÉÑQ%Ñ´ ÅÕ½ÐíQÄÅÕ½Ðì¤)U%
Ñɱ
ÉÑQ%Ñ´ ÅÕ½ÐíQÈÅÕ½Ðì¤)U%
Ñɱ
ÉÑQ¥Ñ´ ÅÕ½ÐìÅÕ½Ðì¤((ÀÌØí¥ÐôU%
Ñɱ
ÉѥРÅÕ½ÐìÅÕ½Ðì°ÈÈÀ°ÈÔÀ°ÈÔØ°ÄØà° ¥Ñ=H ÀÌØíM}I=91d°ÀÌØí]M}YM
I=10°ÀÌØíM}UQ=YM
I=10°ÀÌØíM}5U1Q%1%9¤¤)U%
ÑɱMÑ   ­
½±½È ´Ä°Áá¤)U%
ÑɱMÑÑ ÀÌØí¥Ð°ÅÕ½Ðí± ± ÅÕ½Ðì¤()U%MÑMÑÑ ¤()]¡¥±Ä($ÀÌØíµÍôU%Ñ5Í ¤(%ÀÌØíµÍôÀÌØíU%}Y9Q}
1=MQ¡¸á¥Ð)]¹

Thank you,

Share this post


Link to post
Share on other sites



Noone?

Share this post


Link to post
Share on other sites

Hi

your second question

should be something like this

GUICtrlCreateEdit("", 10, 10, 480, 205, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL, $ES_MULTILINE))

so use $ES_READONLY

Best regards,

Emiel


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites

You have probably misread my post. Look at my code:

$edit = GUICtrlCreateEdit("", 220, 250, 256, 168, BitOR($ES_READONLY,$WS_VSCROLL,$ES_AUTOVSCROLL,$ES_MULTILINE))

I _do_ use $ES_READONLY. What I want is not to make that editbox only readonly, but also to disable mouse clicks (and copy paste) FROM it. Not IN it.

Share this post


Link to post
Share on other sites

Not possible? Even using a DLL or something?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You have probably misread my post. Look at my code:

$edit = GUICtrlCreateEdit("", 220, 250, 256, 168, BitOR($ES_READONLY,$WS_VSCROLL,$ES_AUTOVSCROLL,$ES_MULTILINE))

I _do_ use $ES_READONLY. What I want is not to make that editbox only readonly, but also to disable mouse clicks (and copy paste) FROM it. Not IN it.

GUICtrlSetState(-1,$GUI_DISABLE)

Might work, never tried it...

Edited by Paulie

Share this post


Link to post
Share on other sites

This is a known trick. However it doesn't work well for the following reasons:

1) If you disable the control, you can't click on the scrollbars.

2) If you disable the control, the text becomes gray.

So it's useless..

Thank you however. Anybody else?

Share this post


Link to post
Share on other sites

Use a static label control and your own scroll bars.

Share this post


Link to post
Share on other sites

Huh?

Can I have scrollbars on a static label control? Didn't know that! :}

Any example please?

Thank you for the tip!

Share this post


Link to post
Share on other sites

The best I ended up with was this, but it doesn't work:

#include <GUIConstants.au3>
GUICreate("",200,200)
GuiCtrlCreateLabel("sample sample sample sample sample sample sample sample sample sample sample sample sample sample sample sample sample sample sample sample sample sample ",10,10,100,100,BitOr($ES_AUTOVSCROLL,$WS_VSCROLL))
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
WEnd

Is this possible?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Hi,

1) I search for this solution to, but for now without any seccess :)

2) Try this out:

#include <GuiConstants.au3>

$Gui = GUICreate("Edit Context Menu Demo")

$Edit = GUICtrlCreateEdit("Test", 20, 20)
GUICtrlSetBkColor($Edit, 0xFFFFFF)
GUICtrlSendMsg($Edit, $EM_SETREADONLY, True, 0)

$ContextMenu    = GUICtrlCreateContextMenu()
$SelAll = GUICtrlCreateMenuItem("Select All", $ContextMenu)

GUISetState()

While 1
    If WinActive($Gui) Then
        ToggleHotKeys(0)
    Else
        ToggleHotKeys(1)
    EndIf
    $CurInfo = GUIGetCursorInfo($Gui)
    $Msg = GUIGetMsg()
    Select
        Case $Msg = -3
            Exit
        Case $CurInfo[3] = 1 And $CurInfo[4] = $Edit
            ShowMenu($Gui, $ContextMenu)
        Case $Msg = $SelAll
            GUICtrlSendMsg($Edit, $EM_SETSEL, 0, -1)
    EndSelect
WEnd

; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $nContextID)
    Local $hMenu = GUICtrlGetHandle($nContextID)
    
    $arPos = MouseGetPos()
    
    Local $x = $arPos[0]
    Local $y = $arPos[1]
    
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc

Func ToggleHotKeys($Pram=0)
    If $Pram = 1 Then
        HotKeySet("^c")
        HotKeySet("^{Insert}")
    Else
        HotKeySet("^c", "Dummy")
        HotKeySet("^{Insert}", "Dummy")
    EndIf
EndFunc

;Dummy function that will prevent the Copy process
Func Dummy()
    
EndFunc

Edit: Added missed function Dummy

Edited by MsCreatoR

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Or like this:

#include <GuiConstants.au3>
#NoTrayIcon
If StringInStr($CmdLineRaw, "/SetFocus=") Then
    $hWnd = HWnd(StringRegExpReplace($CmdLineRaw, '(?i)(.*)/SetFocus=', ''))
    ControlClick($hWnd, "", "Edit1", "Left", 1)
    Exit
EndIf

Opt("TrayIconHide", 0)

$Gui = GUICreate("Edit Context Menu Demo")

$Edit = GUICtrlCreateEdit("Test", 20, 20)
GUICtrlSetBkColor($Edit, 0xFFFFFF)
GUICtrlSendMsg($Edit, $EM_SETREADONLY, True, 0)

$ContextMenu    = GUICtrlCreateContextMenu()
$SelAll = GUICtrlCreateMenuItem("No Menu", $ContextMenu)

GUISetState()

While 1
    If WinActive($Gui) Then
        ToggleHotKeys(0)
    Else
        ToggleHotKeys(1)
    EndIf
    $CurInfo = GUIGetCursorInfo($Gui)
    $Msg = GUIGetMsg()
    Select
        Case $Msg = -3
            Exit
        Case $CurInfo[3] = 1 And $CurInfo[4] = $Edit
            ShowMenu($Gui, $ContextMenu)
    EndSelect
WEnd

; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $nContextID)
    Local $hMenu = GUICtrlGetHandle($nContextID)
    
    $arPos = MouseGetPos()
    
    Local $x = $arPos[0]
    Local $y = $arPos[1]
    
    _CallExternal("/SetFocus=" & $hWnd)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc

Func _CallExternal($Cmd)
    Local $RunLine = @AutoItExe & ' "' & @ScriptFullPath & '" ' & $Cmd
    If @Compiled Then $RunLine = @AutoItExe & ' ' & $Cmd
    Run($RunLine)
EndFunc

Func ToggleHotKeys($Pram=0)
    If $Pram = 1 Then
        HotKeySet("^c")
        HotKeySet("^{Insert}")
    Else
        HotKeySet("^c", "Dummy")
        HotKeySet("^{Insert}", "Dummy")
    EndIf
EndFunc

;Dummy function that will prevent the Copy process
Func Dummy()
    
EndFunc
Edited by MsCreatoR

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Excellent examples, thank you very much for this code.

Maybe some of the devs see this, because native support would be much better (and I have seen many people in this forum, seeking for such functionality).

Thank you again!

Edit: Unfortunately the control remains clickable... Any workaround for this?

Edited by erebus

Share this post


Link to post
Share on other sites

Excellent examples

Thanks :)

Unfortunately the control remains clickable

Clickable yes, but unworkable as well :)

You can just disable the control:

GUICtrlCreateMenuItem("No Menu", $ContextMenu)
GuiCtrlSetState(-1, $GUI_DISABLE)oÝ÷ Øêÿwr¢çÇ­Ö¬±ê^­«h¯­r"VÞ½êò²f¥)í«jǺÚ"µÍÕRPÝÜX]SY[R][J ][ÝÉ][ÝË    ÌÍÐÛÛ^Y[JBÝZPÝÙ]Ý]JLK  ÌÍÑÕRWÑTÐPJ

How to make that there will be no menu at all, unfortunately i do not known realy (for now) :P.


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Hello all,

I have two fast questions:

Thank you,

Does this slow reply help?

#include <GUIConstants.au3>
#include <guiedit.au3>

$Form1 = GUICreate("abcd", 650, 500, -1, -1, $WS_POPUPWINDOW)
GUISetBkColor(0x00E0FFFF)

$tab1 = GUICtrlCreateTab(10, 10, 200, 410,$TCS_FIXEDWIDTH)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabitem ("")  

$edit = GUICtrlCreateEdit("", 220, 250, 256, 168, BitOR($WS_VSCROLL,$ES_AUTOVSCROLL,$ES_MULTILINE))
;, BitOR($ES_READONLY,$WS_VSCROLL,$ES_AUTOVSCROLL,$ES_MULTILINE))
GUICtrlSetBkColor(-1, 0xFFFFFF)
$text = FileRead(@ScriptFullPath)
GUICtrlSetData($edit, $text)

$btn1 = GUICtrlCreateButton("disable copy",220,170,150,28)
$btn2 = GUICtrlCreateButton("allow copy",220,200,150,28)
GuictrlSendMsg($Tab1, $TCM_SETITEMSIZE, 0, _MakeLong(98, 20));

GUISetState()
$nocopy = False
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
    If $msg = $btn1 Then $nocopy = True
        
    If $msg = $btn2 Then $nocopy = False
    If $nocopy Then
      $CurInfo = ControlGetFocus("abcd")
            If BitOR(GUICtrlGetState($edit),$GUI_FOCUS) Then
                $sel = _GUICtrlEditGetSel($edit)
                _GUICtrlEditSetSel($edit,$sel[1],$sel[1])
                
            EndIf
            
    EndIf
    
WEnd


Func _MakeLong($l, $h)
    Return BitOR(BitAnd($l, 0xFFFF), BitShift(BitAnd($h, 0xFFFF), -16))
EndFunc; _MakeLong()

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Great example, thank you very much! :)

Share this post


Link to post
Share on other sites

Thanks martin, the issue with transparent (almost :) ) tabs background is solved!

But for the copy action the example is not very practical, because it increese CPU load when you click disable copy.


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Thanks martin, the issue with transparent (almost :) ) tabs background is solved!

But for the copy action the example is not very practical, because it increese CPU load when you click disable copy.

You're right. I left a line in the script which wasn't doing anything, so that didn't help.

This approach works better

#include <GUIConstants.au3>
#include <guiedit.au3>

$Form1 = GUICreate("abcd", 650, 500, -1, -1, $WS_POPUPWINDOW)
GUISetBkColor(0x00E0FFFF)

$tab1 = GUICtrlCreateTab(10, 10, 200, 410,$TCS_FIXEDWIDTH)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabitem ("")

$edit = GUICtrlCreateEdit("", 220, 250, 256, 168, BitOR($WS_VSCROLL,$ES_AUTOVSCROLL,$ES_MULTILINE))

$edit2 = GUICtrlCreateEdit("", 220, 10, 256, 158)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$text = FileRead(@ScriptFullPath)
GUICtrlSetData($edit, $text)

$btn1 = GUICtrlCreateButton("disable copy",220,170,150,28)
$btn2 = GUICtrlCreateButton("allow copy",220,200,150,28)
GuictrlSendMsg($Tab1, $TCM_SETITEMSIZE, 0, _MakeLong(98, 20));

GUISetState()
Global $nocopy = False
AdlibEnable("noedit",200)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit

    If $msg = $btn1 Then $nocopy = True

    If $msg = $btn2 Then $nocopy = False
    

WEnd

Func noedit()
    If $nocopy = False Then Return
    
    If ControlGetFocus("abcd","") = "Edit1" Then
        ControlFocus("abcd","",$btn1);don't allow $edit to keep focus
        Return
    EndIf

EndFunc



Func _MakeLong($l, $h)
    Return BitOR(BitAnd($l, 0xFFFF), BitShift(BitAnd($h, 0xFFFF), -16))
EndFunc; _MakeLong()

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

This approach works better

Yes, but still you can copy :P

If you select the text, the focus is lost, but then if you click right mouse button on the edit, then you see the menu, and the text is selected...

just change the function noedit() and it works even better :) - As you see, i switch the focus on dummy label, so the button is not involved now :)

#include <GUIConstants.au3>
#include <guiedit.au3>

$Form1 = GUICreate("abcd", 650, 500, -1, -1, $WS_POPUPWINDOW)
GUISetBkColor(0x00E0FFFF)

$tab1 = GUICtrlCreateTab(10, 10, 200, 410,$TCS_FIXEDWIDTH)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabitem ("")

$edit = GUICtrlCreateEdit("", 220, 250, 256, 168, BitOR($WS_VSCROLL,$ES_AUTOVSCROLL,$ES_MULTILINE))

$edit2 = GUICtrlCreateEdit("", 220, 10, 256, 158)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$text = FileRead(@ScriptFullPath)
GUICtrlSetData($edit, $text)

$btn1 = GUICtrlCreateButton("disable copy",220,170,150,28)
$btn2 = GUICtrlCreateButton("allow copy",220,200,150,28)
GuictrlSendMsg($Tab1, $TCM_SETITEMSIZE, 0, _MakeLong(98, 20));

$DummyLabel = GUICtrlCreateLabel("", 5000, 5000)

GUISetState()
Global $nocopy = False
AdlibEnable("noedit", 200)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit

    If $msg = $btn1 Then $nocopy = True

    If $msg = $btn2 Then $nocopy = False
    
WEnd

Func noedit()
    If $nocopy = False Then Return
    If ControlGetFocus($Form1) = "Edit1" Then
        ControlClick($Form1, "", $edit)
        ControlFocus($Form1, "", $DummyLabel);don't allow $edit to keep focus
    EndIf
EndFunc

Func _MakeLong($l, $h)
    Return BitOR(BitAnd($l, 0xFFFF), BitShift(BitAnd($h, 0xFFFF), -16))
EndFunc; _MakeLong()

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

It can be done also by playing with ClipPut() and ClipGet() a litle (if needed "not copy effect"):

#include <GuiConstants.au3>

GUICreate("GUI Edit Test")

$Edit = GUICtrlCreateEdit("This is a test", 80, 50, 270, 170, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
GUICtrlSetBkColor($Edit, 0xFFFFFF)

GUISetState()

$OldClipContent = ClipGet()

While 1
    If $OldClipContent <> ClipGet() Then ClipPut($OldClipContent)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

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  
Followers 0