Jump to content
Sign in to follow this  
careca

Smoothing Rounded Corners GUI

Recommended Posts

Hi, found this code somewhere in the forum some time ago, my question is if it's possible to smooth out the corners because the pixels can be seen and it's a bit ugly imo.

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

Global $i_x1 =0, $i_y1=0, $i_x3=25, $i_y3=25
$hGUI = GUICreate("a",500,300,-1,-1,$WS_POPUP,$WS_EX_LAYERED)
GUISetBkColor(0x505050)
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255)
_GuiRoundCorners($hGUI, $i_x1, $i_y1, $i_x3, $i_y3)

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

Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
   Dim $pos, $ret, $ret2
   $pos = WinGetPos($h_win)
   $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
   If $ret[0] Then
      $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
      If $ret2[0] Then
         Return 1
      Else
         Return 0
      EndIf
   Else
      Return 0
   EndIf
EndFunc  ;==>_GuiRoundCorners

 


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

bump


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

This seems to be a little better - based on a script by UEZ

#include <WindowsConstants.au3>
#include <WinApi.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()
; Create GUI
Local $hGUI = GUICreate('Test', 500, 300, -1,-1,$WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
Local $idPic = GUICtrlCreatePic('', 0, 0, 500, 300)
Local $hPic = GUICtrlGetHandle($idPic)
Local $hGDIBmp = _GDIPlus_CreateBitmapRoundCornerRect()
_WinAPI_DeleteObject(GUICtrlSendMsg($idPic, 0x0172, $IMAGE_BITMAP, $hGDIBmp))
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3
_WinAPI_DeleteObject($hGDIBmp)
_GDIPlus_Shutdown()

Func _GDIPlus_CreateBitmapRoundCornerRect($iW = 500, $iH = 300, $iColorBg = 0xFF505050, $iColorBorder = 0xFF505050, $iRadius = 15, $bGDIBmp = 1)
    Local Const $iX = 0, $iY = 0, $iPenSize = 1
    Local Const $iWidth = $iW - $iPenSize, $iHeight = $iH - $iPenSize
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT)
    Local Const $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY, $iRadius * 2, $iRadius * 2, 270, 90)
    _GDIPlus_PathAddArc($hPath, $iX + $iWidth - ($iRadius * 2), $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 0, 90)
    _GDIPlus_PathAddArc($hPath,  $iX, $iY + $iHeight - ($iRadius * 2), $iRadius * 2, $iRadius * 2, 90, 90)
    _GDIPlus_PathAddArc($hPath,  $iX, $iY, $iRadius * 2, $iRadius * 2, 180, 90)
    _GDIPlus_PathCloseFigure($hPath)

    Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColorBg)
    _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush)
    Local Const $hPen = _GDIPlus_PenCreate($iColorBorder, $iPenSize)
    _GDIPlus_GraphicsDrawPath($hCtxt, $hPath, $hPen)

    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hCtxt)
    If $bGDIBmp Then
        Local $hGDIBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hGDIBmp
    EndIf
    Return $hBitmap
EndFunc

 

Share this post


Link to post
Share on other sites

Thank you.


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...