Jump to content

How can i create a custom shaped GUI interface?


Recommended Posts

see my greatness :sweating: :sweating: :sweating:  :)

#include <WinAPI.au3>
#include <WinAPIeX.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>

Local $upperBody = 0, $e  = 0

$a = SubFunction__CpeateBalloonToolTipEX("dsgafhgadfhzdhzhdcxcxcxc", @DesktopWidth/2-55,@DesktopHeight/2, $upperBody)
$b = SubFunction__CpeateBalloonToolTipEX("dsgafhgadfhzdhzhdcxcxcxc", @DesktopWidth/2,@DesktopHeight/2+55, $upperBody)

While $e < 2
    $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $a[3];$GUI_EVENT_CLOSE
                    $e += GUIDelete ( $a[0] )
                Case $b[3];$GUI_EVENT_CLOSE
                    $e += GUIDelete ( $b[0] )
            EndSwitch


WEnd

Func SubFunction__CpeateBalloonToolTipEX($text, $pointX,$pointY, ByRef $upperBody)
    Local $R, $Rn2, $thick, $beakLenX, $beakLenY, $textOffset, $ToolTipDeltaY, $ToolTipButtonH, $ToolTipButtonW, $textStringHeightMax
    Local $ToolTipX, $ToolTipY, $ToolTipWidth, $ToolTipHeight, $ToolTipButtonY, $ToolTipLastButtonX, $ToolTipWidthRAW, $ToolTipHeightRAW, $ToolTipXRAW, $ToolTipYRAW
    Local $tip, $Btn_Func, $Btn_EditPattern, $Btn_Close, $hDC, $hBrush, $rgn1, $rgn2, $ctrl_pos, $ctrl_rgn, $ctrlAttay, $testGUI, $testLabel, $LabelSize, $aPoint[3][2]
    $R = 16
    $Rn2 = $R*2
    $thick = 24
    $beakLenX = 33
    $beakLenY = 33
    $textOffset = 8
    $ToolTipDeltaY = 0
    $ToolTipButtonH = 24
    $ToolTipButtonW = 24
    $testGUI = GUICreate("",16,16,0,0)
    $testLabel = GUICtrlCreateLabel("",0,0)
    Local $LabelSize[2] = [ 333, 33];_GetTabbedStringSizeEx($testLabel, $text)
    GUIDelete ( $testGUI )
    $textStringHeightMax = $LabelSize[1]+8
    $ToolTipX = 0
    If $pointY < $upperBody Then
        $ToolTipY = $upperBody - $pointY + $ToolTipDeltaY + $ToolTipButtonH/2 + 2
    Else
        $ToolTipY = $beakLenY + $ToolTipButtonH/2 + 2
    EndIf
    $ToolTipWidth = $LabelSize[0] + $R*2 + $textOffset*2
    $ToolTipHeight = $ToolTipY + $textStringHeightMax + 16
    $ToolTipButtonY = $ToolTipY - $ToolTipButtonH/2
    $ToolTipLastButtonX = $ToolTipWidth - $R - $ToolTipButtonW
    $ToolTipWidthRAW = $ToolTipWidth + $beakLenX
    $ToolTipHeightRAW = $ToolTipHeight
    $ToolTipXRAW = $pointX - $ToolTipWidthRAW
    If $ToolTipXRAW+$R < 0 Then $ToolTipXRAW = -$R
    $ToolTipYRAW = $pointY
    $upperBody = $ToolTipYRAW + $ToolTipDeltaY + $ToolTipHeight
    If ($ToolTipHeight - $R) < $thick Then
        $thick = $ToolTipHeight - $R
    EndIf

    #Region ### START Koda GUI section ### Form=
    $tip = GUICreate("Tip", $ToolTipWidthRAW, $ToolTipHeightRAW, $ToolTipXRAW, $ToolTipYRAW, BitOR($WS_POPUP,$DS_MODALFRAME,$DS_SETFOREGROUND),$WS_EX_TOPMOST)
    WinSetTrans($tip, "", 255)
    $Btn_Func = GUICtrlCreateButton("", $ToolTipLastButtonX-64, $ToolTipButtonY, $ToolTipButtonW, $ToolTipButtonH)
    SubFunction__GUICtrlSetImage($Btn_Func, "shell32.dll", 55*4-3, 0)
    $Btn_EditPattern = GUICtrlCreateButton("", $ToolTipLastButtonX-32, $ToolTipButtonY, $ToolTipButtonW, $ToolTipButtonH)
    SubFunction__GUICtrlSetImage($Btn_EditPattern, "shell32.dll", 42*4-3, 0)
    $Btn_Close = GUICtrlCreateButton("", $ToolTipLastButtonX, $ToolTipButtonY, $ToolTipButtonW, $ToolTipButtonH)
    SubFunction__GUICtrlSetImage($Btn_Close, "shell32.dll", 28*4-3, 0)
    GUICtrlCreateLabel("", $R+3, $ToolTipY + $ToolTipButtonH/2, $ToolTipWidth - $R - $R - 3, $textStringHeightMax, $SS_ETCHEDFRAME )
    GUICtrlCreateLabel($text, $R+8+2, $ToolTipY + $ToolTipButtonH/2+2, $ToolTipWidth - $R - $R - 8-5, $textStringHeightMax-5 )
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $hDC = _WinAPI_GetWindowDC($tip)
    $hBrush = _WinAPI_CreateSolidBrush(_WinAPI_GetSysColor($COLOR_ACTIVEBORDER))
    Dim $aPoint[3][2] = [[$ToolTipWidth-$R, $ToolTipY],[$pointX-$ToolTipXRAW, 0],[$ToolTipWidth-$R/2, $ToolTipY+$thick]]
    $rgn1 = _WinAPI_CreatePolygonRgn($aPoint)
    $rgn2 = _WinAPI_CreateRoundRectRgn($ToolTipX, $ToolTipY, $ToolTipWidth, $ToolTipHeight, $Rn2, $Rn2)
    _WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
    _WinAPI_DeleteObject($rgn2)
    $ctrl_pos = ControlGetPos($tip, "", $Btn_Func)
    $ctrl_rgn = _WinAPI_CreateRectRgn($ctrl_pos[0], $ctrl_pos[1], $ctrl_pos[0] + $ctrl_pos[2], $ctrl_pos[1] + $ctrl_pos[3])
    _WinAPI_CombineRgn($rgn1, $rgn1, $ctrl_rgn, $RGN_OR)
    $ctrl_pos = ControlGetPos($tip, "", $Btn_EditPattern)
    $ctrl_rgn = _WinAPI_CreateRectRgn($ctrl_pos[0], $ctrl_pos[1], $ctrl_pos[0] + $ctrl_pos[2], $ctrl_pos[1] + $ctrl_pos[3])
    _WinAPI_CombineRgn($rgn1, $rgn1, $ctrl_rgn, $RGN_OR)
    $ctrl_pos = ControlGetPos($tip, "", $Btn_Close)
    $ctrl_rgn = _WinAPI_CreateRectRgn($ctrl_pos[0], $ctrl_pos[1], $ctrl_pos[0] + $ctrl_pos[2], $ctrl_pos[1] + $ctrl_pos[3])
    _WinAPI_CombineRgn($rgn1, $rgn1, $ctrl_rgn, $RGN_OR)
    _WinAPI_FrameRgn ( $hDC, $rgn1, $hBrush, 1, 1 )
    _WinAPI_SetWindowRgn($tip, $rgn1)
    _WinAPI_DeleteObject($hBrush)
    _WinAPI_ReleaseDC($tip, $hDC)
    Dim $ctrlAttay[4] = [$tip,$Btn_Func,$Btn_EditPattern,$Btn_Close]
    Return $ctrlAttay
EndFunc

Func SubFunction__GUICtrlSetImage($hButton, $sFileIco, $iIndIco = 0, $iSize = 0)
    Switch $iSize
        Case 0
            $iSize = 16
        Case 1
            $iSize = 32
        Case Else
            $iSize = 16
    EndSwitch
    Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3, 6)
    _GUIImageList_AddIcon($hImage, $sFileIco, $iIndIco)
    _GUICtrlButton_SetImageList($hButton, $hImage,4)
    Return $hImage
EndFunc
Link to comment
Share on other sites

A layered window(using bitmaps created run-time or from hard-disk) would be recommended more over creating windows based on regions..

>This is an advanced example(don't forget to place this image in the script dir before running the script)

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.

Link to comment
Share on other sites

A layered window(using bitmaps created run-time or from hard-disk) would be recommended more over creating windows based on regions..

>This is an advanced example(don't forget to place this image in the script dir before running the script)

Regards :)

 

Very goooooooooooooooooooooooooooooooooooooooooooooooooooooooooooood

Thankssssssssssssssssssssssssssssssssssss

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...