Sign in to follow this  
Followers 0
Digisoul

question about _WinAPI_RoundRect

1 post in this topic

#1 ·  Posted (edited)

Hello ;

I am trying to simulate the Group control. I am bit successful to create it with the help of some examples that i found in the WINAPIEx library , but now I am facing a strange behavior, after successful creation of RoundRect, if I minimize the GUI and restore it again, the created Rect changes its size.

I am unable to understand why it’s happening on my side and not in the example.

here is my rough attempt:

#include <Constants.au3>

#include <FontConstants.au3>

#include <WinAPIEx.au3>

#include <WindowsConstants.au3>

Global Const $STM_SETIMAGE = 0x0172

Global Const $STM_GETIMAGE = 0x0173

Global $hForm, $Group1

; Create GUI

$hForm = GUICreate('MyGUI', 400, 400)

GUISetBkColor(0xffffff)

$Group1 = CreateFrame(50, 50, 200, 200)

;GUICtrlCreateLabel("This is a Test",20,20)

GUISetState()

Do

Until GUIGetMsg() = -3

Func CreateFrame($x, $y, $w, $h);,$MODE = 1)

Local $Pic = GUICtrlCreatePic('', $x, $y, $w, $h)

Local $hPic = GUICtrlGetHandle($Pic)

; Create bitmap

Local $hDev = _WinAPI_GetDC($hPic)

Local $hDC = _WinAPI_CreateCompatibleDC($hDev)

Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))

Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Border Color

Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))

_WinAPI_SetDCPenColor($hDC, 0xCCCCCC)

; Create Frame

;!!!!!!!Before compile load it from resource!!!!!!!

Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Pattern.bmp', $IMAGE_BITMAP, $w, $w, $LR_LOADFROMFILE)

;!!!!!!!Before compile load it from resource!!!!!!!

Local $hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)

Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)

Local $tRECT = _WinAPI_CreateRect(0, 0, $w, $h)

_WinAPI_RoundRect($hDC, $tRECT, 20, 20)

_WinAPI_SelectObject($hDC, $hObj)

_WinAPI_DeleteObject($hPattern)

_WinAPI_DeleteObject($hBrush)

; Merge bitmap

Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)

Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)

_WinAPI_DeleteObject($hPen)

_WinAPI_SelectObject($hDC, $hBitmap)

_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)

_WinAPI_ReleaseDC($hPic, $hDev)

_WinAPI_SelectObject($hDC, $hSv)

_WinAPI_DeleteObject($hSource)

_WinAPI_DeleteDC($hDC)

; Set bitmap to control

_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)

Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)

If $hObj <> $hBitmap Then

_WinAPI_DeleteObject($hBitmap)

Return SetError(1)

EndIf

;GUICtrlSetState($Pic,$gui_disable)

Return SetError(0,0,$Pic)

EndFunc ;==>CreateFrame

here is a bitmap that i am using as pattern

Posted Image

thanks

Edited by Digisoul

73 108 111 118 101 65 117 116 111 105 116

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