Jump to content

Is there an easy way to do curved corners on Input controls?


4Eyes
 Share

Recommended Posts

As per the Topic Title... Is there an easy way to do curved corners on Input controls like the attached pic?

I'm thinking I might be able to use a graphic control with transparency that would have the outline and the 'outside' of the curves (sorry, hard to explain) draw in the colour of the background. The trouble with this is that it is not dynamic and doesn't cope with textured backgrounds.

Any clues?

Regards,

4Eyes

InputControlWithCurvedCorners.bmp

Link to comment
Share on other sites

I spend such little time in Example scripts anymore that I can't remember specifc scripts but that's the place to search for custom GUI scripts. Here are a couple to get you started.

http://www.autoitscript.com/forum/index.php?showtopic=102961&view=findpost&p=729998

http://www.autoitscript.com/forum/index.php?showtopic=106784&view=findpost&p=753514

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

George,

Thank you for your reply. Some interesting reading in there but I think I've come up with something that suits my purposes except for a textured background. I've tidied the graphic and attached here again. Change the surrounding colour to suit whatever GUI it goes into.

I must say I'm quite pleased!

Regards,

4Eyes

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

Global $gui, $inpPassword, $pic

$gui = GUICreate("A", 450, 350, -1, -1)

$inpPassword = GUICtrlCreateInput("", 60, 100, 170, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlSetState($inpPassword, $GUI_FOCUS)

$pic = GUICtrlCreatePic("InputControlWithCurvedCorners.bmp", 52, 95, 181, 30, "", $WS_EX_TRANSPARENT)

GUISetState()

; Loop until user exits
do
until GUIGetMsg() = $GUI_EVENT_CLOSE

InputControlWithCurvedCorners.bmp

Link to comment
Share on other sites

Hmmm... obviously, not enough coffee. The above example works until you hover over the input control. I've spent most of today trying to fix it inc the hover UDF but nogo.

I'm not sure of the etiquette of whether I should bump my own thread or start another so please excuse my ignorance.

I have another question... can I change the colour of the outline (or bounding box if you like) of an input control?

The reason I ask this is that if I can then I could set it to the background colour of my gui and effectively it is invisible.

Ta,

4Eyes

Link to comment
Share on other sites

Beats me, I rarely try to skin out GUIs

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

use an edit instead

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

Global $gui, $inpPassword, $pic

$gui = GUICreate("A", 450, 350, -1, -1)

$inpPassword = GUICtrlCreateedit("", 60, 100, 170, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlSetState($inpPassword, $GUI_FOCUS)

$pic = GUICtrlCreatePic("InputControlWithCurvedCorners.bmp", 52, 95, 181, 30, "", $WS_EX_TRANSPARENT)

GUISetState()

; Loop until user exits
do
until GUIGetMsg() = $GUI_EVENT_CLOSE
Link to comment
Share on other sites

use an edit instead

That seems to have the same problem. As soon as you hover over it there is a problem.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

That seems to have the same problem. As soon as you hover over it there is a problem.

Here is a partial solution, by modifying one of Yashied's posts.

#Include <GUIConstantsEx.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>
#Include <GDIPlus.au3>

Global Const $sPng = 'editmask.png'

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sPng)

$hMain = GUICreate('Test', 250, 250, 400, 400)
GUISetBkColor(0xF0B7FD)
$Button = GUICtrlCreateButton('OK', 93, 216, 70, 23)
GUISetState()
GUICtrlCreateInput("",70,98,160,25)
$hPopup = GUICreate('', 199, 48 ,400+ 50,400+86, $WS_POPUP, $WS_EX_LAYERED)
GUISetState()
winsetontop($hPopup,"",1)
GUIRegisterMsg($WM_MOVE, "WM_MOVE")
winmove($hMain,"",401,400)

$Trans = 255

_SetBitmap($hPopup, $hImage, 255)
Do
 sleep(80)
Until GUIGetMsg() = -3

_GDIPlus_Shutdown()

Func _SetBitmap($hWnd, $hImage, $iOpacity)

    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, 'X', _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, 'Y', _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, 'Alpha', $iOpacity)
    DllStructSetData($tBlend, 'Format', 1)
    _WinAPI_UpdateLayeredWindow($hWnd, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)

    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)

EndFunc ;==>_SetBitmap

Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
    Case $hMain
    WinMove($hPopup, '', BitAND($lParam, 0xFFFF) + 50, BitShift($lParam, 16) + 86)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc ;==>WM_MOVE

post-3602-12743900083249_thumb.png

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.
Link to comment
Share on other sites

martin,

Thank you. That works quite well.

The mask graphic you used gives me another idea too. I can make the colour of the 'outside of the input control the same as the gui to make it go away, or I can have a nice bezel in a different colour around the input control.

Great stuff.

Regards,

4Eyes

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...