Sign in to follow this  
Followers 0
Keniger

GuiCtrlCreateInput and Image

8 posts in this topic

#1 ·  Posted (edited)

Is there any way to create an image which can be EDITED ?

I dont like normal style of GuiCtrlCreateInput, it looks ugly.

I want do something like that :

p6p9sd.jpg

How can I do it ?

Is there any possible way to do this ?

I thought about GuiCtrlCreateLabel, and ex style, but nothing ;c Label cant be edited or Im newbie :_:

Any suggestion ?

Edited by Keniger

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Keniger,

How about this: ;)

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

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0)
GUICtrlSetDefColor(0xFFFFFF)
GUISetFont(12, Default, Default, "Consolas")

GUICtrlCreateLabel("Username", 10, 10, 240, 20)
$cInput_UN = GUICtrlCreateInput("", 10, 40, 240, 30)
GUICtrlSetFont(-1, 12, 600)
GUICtrlSetBkColor(-1, 0x606060)

GUICtrlCreateLabel("Password", 10, 80, 240, 20)
$cInput_PW = GUICtrlCreateInput("", 10, 110, 240, 30, BitOR($ES_PASSWORD, $GUI_SS_DEFAULT_INPUT ))
GUICtrlSetFont(-1, 12, 600)
GUICtrlSetBkColor(-1, 0x606060)

GUICtrlCreateLabel("", 10, 150, 60, 30)
GUICtrlSetBkColor(-1, 0x808080)
$cLogIn = GUICtrlCreateButton("LogIn", 11, 151, 58, 28)
GUICtrlSetBkColor(-1, 0)

GUICtrlCreateLabel("", 80, 150, 170, 30)
GUICtrlSetBkColor(-1, 0x808080)
$cReset = GUICtrlCreateButton("Hardware ID Reset", 81, 151, 168, 28)
GUICtrlSetBkColor(-1, 0)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd
Any good?  :)

 

M23

Edited by Melba23
Amended code - for the better I hope!
1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ye its nice M23, but I still no1 answer that :

Image as input :D Or Input over image :P

if I can't do that I'll use ur example. Thanks ! AGAIN :3

@EDIT

Btw, this white lines are so f***ng ugly ;c

 

@EDIT2

Okay I resolve mine problem :P Just in loop I add some functions and label can be edited :3

Edited by Keniger

Share this post


Link to post
Share on other sites

Em for everyone who want to do the same just set Extended style to 0 

Like :

GuiCtrlCreateInput("", 65, 311, 252, 34, 0, 0)

GuiCtrlSetBkColo(-1, 0xFFFFFF)

And input will be black without grids :D

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You want an Input over an Image, thats possible with reference from here

For the following code to execute properly you would need the latest BETA version of Autoit.

In the stable release more than two RichEdit controls are not supported.

After you download & install the latest BETA press ALT + F5 to run Autoit Beta from SciTe

The Following Script

  • Two transparent RichEdit controls (merely Input controls).
  • Gradient as their background (patterns & bitmaps could be used).
  • An example for encorporating Image as the background.
#include-once
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Main()

Func Main()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 200, 150, -1, -1, $WS_POPUP, $WS_EX_COMPOSITED)
    GUISetBkColor(0x363731)

    GUISetFont(12, Default, Default, "Consolas")
    GUICtrlSetDefColor(0xFFFFFF)

    GUICtrlCreateLabel("Username", 10, 5, 240, 15)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    ;create GRADIENT Backgrounds for the Input
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "PhoenixXL_729" & @CRLF & _
            "Press Esc To Exit", 10, 25, 100, 15, $ES_AUTOHSCROLL, $WS_EX_TRANSPARENT)
    CreateBackground_Static($hGui, 10, 25, 100, 15, 0xAAFFB84D, 0x77FFB84D, 0) ;create horizontal gradient background for transparent richedit controls.

    GUICtrlCreateLabel("Password", 10, 60, 240, 15)
    $hRichEdit2 = _GUICtrlRichEdit_Create($hGui, "********", _
            10, 80, 100, 15, BitOR($ES_AUTOHSCROLL, $ES_PASSWORD), $WS_EX_TRANSPARENT)
    CreateBackground_Static($hGui, 10, 80, 100, 15, 0xAAF0F0F0, 0x77FFF0F0, 0) ;create horizontal gradient background for transparent richedit controls.


    ;Create a IMAGE Background for this Label.
    GUICtrlCreatePic(StringReplace(@AutoItExe, "Autoit3.exe", "Examples\GUI\msoobe.jpg"), 8, 120, 35, 20)
    GUICtrlSetState(-1, $GUI_DISABLE)

    $iExit = GUICtrlCreateLabel("Exit", 10, 120)
    GUICtrlSetState(-1, $GUI_ONTOP)

    GUICtrlSetFont(-1, 9)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    GUISetState()

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $iExit
                ExitLoop
        EndSwitch
    WEnd

    _GUICtrlRichEdit_Destroy($hRichEdit)
    _GUICtrlRichEdit_Destroy($hRichEdit2)
    GUIDelete()

EndFunc   ;==>Main

Func CreateBackground_Static($hWnd, $iX, $iY, $iWidth = -1, $iHeight = -1, $iColor_Start = 0xAA000000, $iColor_End = 0x70000000, $iMode = 1)

    _GDIPlus_Startup()

    If $iWidth < 0 Then $iWidth = _WinAPI_GetWindowWidth($hWnd)
    If $iHeight < 0 Then $iHeight = _WinAPI_GetWindowHeight($hWnd)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic)
    _GDIPlus_GraphicsDispose($hGraphic)

    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    ;**********************
    ; Create Line Brush Using minimum number of settings- Brush size same size as Rectangle to fill
    $hBrushLin = GDIPlus_CreateLineBrushFromRect(0, 0, $iWidth, $iHeight, -1, -1, $iColor_Start, $iColor_End, 1)

    ;Fill a rectangle using the above brush
    _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iWidth, $iHeight, $hBrushLin)
    ;***************************

    Local Const $_STM__SETIMAGE = 0x0172, $_SS__BITMAP = 0x0E
    $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)

    $iRet = GUICtrlCreatePic('', $iX, $iY, $iWidth, $iHeight, $_SS__BITMAP)
    Local Const $__IMAGE_BITMAP = 0
    GUICtrlSendMsg(-1, $_STM__SETIMAGE, $__IMAGE_BITMAP, $hHBitmap)

    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_Shutdown()

    GUICtrlSetState(-1, $GUI_DISABLE)

    Return $iRet
EndFunc   ;==>CreateBackground_Static

Func GDIPlus_CreateLineBrushFromRect($iX, $iY, $iWidth, $iHeight, $aFactors, $aPositions, _
        $iArgb1 = 0xFF0000FF, $iArgb2 = 0xFFFF0000, $LinearGradientMode = 0x00000001, $WrapMode = 0)

    Local $tRect, $pRect, $aRet, $tFactors, $pFactors, $tPositions, $pPositions, $iCount

    If $iArgb1 = -1 Then $iArgb1 = 0xFF0000FF
    If $iArgb2 = -1 Then $iArgb2 = 0xFFFF0000
    If $LinearGradientMode = -1 Then $LinearGradientMode = 0x00000001
    If $WrapMode = -1 Then $WrapMode = 1

    $tRect = DllStructCreate("float X;float Y;float Width;float Height")
    $pRect = DllStructGetPtr($tRect)
    DllStructSetData($tRect, "X", $iX)
    DllStructSetData($tRect, "Y", $iY)
    DllStructSetData($tRect, "Width", $iWidth)
    DllStructSetData($tRect, "Height", $iHeight)

    ;Note: Withn _GDIPlus_Startup(), $ghGDIPDll is defined
    $aRet = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushFromRect", "ptr", $pRect, "int", $iArgb1, _
            "int", $iArgb2, "int", $LinearGradientMode, "int", $WrapMode, "int*", 0)

    If IsArray($aFactors) = 0 Then Dim $aFactors[4] = [0.0, 0.4, 0.6, 1.0]
    If IsArray($aPositions) = 0 Then Dim $aPositions[4] = [0.0, 0.3, 0.7, 1.0]

    $iCount = UBound($aPositions)
    $tFactors = DllStructCreate("float[" & $iCount & "]")
    $pFactors = DllStructGetPtr($tFactors)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tFactors, 1, $aFactors[$iI], $iI + 1)
    Next
    $tPositions = DllStructCreate("float[" & $iCount & "]")
    $pPositions = DllStructGetPtr($tPositions)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tPositions, 1, $aPositions[$iI], $iI + 1)
    Next

    $hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "hwnd", $aRet[6], _
            "ptr", $pFactors, "ptr", $pPositions, "int", $iCount)
    Return $aRet[6] ; Handle of Line Brush
EndFunc   ;==>GDIPlus_CreateLineBrushFromRect 

What you ask seems much similar to what I did some time ago. Maybe you are worried of the Scroll in Input controls in the same way, if yes look at my signature.

Thumbs up if helped. Ask if you have any queries.

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

Here another way to do it (code by Großvater):

;coded by Großvater
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Const $IMAGE_BITMAP = 0x0000
Const $STM_SETIMAGE = 0x0172
Const $STM_GETIMAGE = 0x0173

GUICreate("Dummy")
$au3path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
$Pic = $au3path & "\Examples\GUI\msoobe.jpg"
$idPIC = GUICtrlCreatePic($Pic, 0, 0, 198, 18)
$hBitmap = GUICtrlSendMsg($idPIC, $STM_GETIMAGE, $IMAGE_BITMAP, 0)
$aR = DllCall("Gdi32.dll", "Handle", "CreatePatternBrush", "Handle", $hBitmap)
$hBrush = $aR[0]

$hGUI = GUICreate("Test", 400, 100)
$idINP = GUICtrlCreateInput("Test", 20, 20, 200, 20)
;~ GUICtrlSetState(-1, $GUI_DISABLE)
$hINP = GUICtrlGetHandle($idINP)
$InputColor = 0xFFFFFF

GUICtrlCreateInput("", 20, 60, 200, 20)

GUIRegisterMsg($WM_CTLCOLOREDIT, "ColorInput")
;~ If @OSBuild > 5999 Then GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

GUISetState()

While True
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            _WinAPI_DeleteObject($hBitmap)
            DllCall("Gdi32.dll", "BOOL", "DeleteObject", "Handle", $hBrush)
            Exit
    EndSwitch
WEnd

Func ColorInput($hWnd, $iMsg, $wParam, $lParam)
    If $lParam = $hINP Then
        DllCall("Gdi32.dll", "UINT", "SetTextColor", "Handle", $wParam, "UInt", $InputColor)
        DllCall("Gdi32.dll", "Int", "SetBkMode", "Handle", $wParam, "Int", 1)
        Return $hBrush
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc

Func WM_ERASEBKGND($hWnd, $iMsg, $wParam, $lParam)
    _WinAPI_RedrawWindow($hGUI, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW))
    Return 1
EndFunc

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Sorry, for posting in this old topic.

Melba, your example is really cool but is there a way to have them keep the click animation?

And i can't click the buttons unless i remove the label.

Edited by bleh

Share this post


Link to post
Share on other sites

bleh,

Of course, just disable the labels behind the buttons:

GUICtrlCreateLabel("", 10, 150, 60, 30)
GUICtrlSetBkColor(-1, 0x808080)
GUICtrlSetState(-1, $GUI_DISABLE)

When AutoIt comes across overlapping controls it reacts to neither as it cannot be sure which the user meant to action. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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