ahmet Posted July 6, 2011 Share Posted July 6, 2011 I tried to set a window's region using GdipCreateRegionPath, but it isn't working. Is it impossibble to set window's region returned from that function? I have used by Authenticity.Here is what I have tried:expandcollapse popup#include <GDIP.au3> #Include <WinAPI.au3> ;~ #include<Array.au3> Global $width[3]=[800,600,200], $height[3]=[400,400,200], $radius=20 Global $num_of_rgns=7, $rgns[$num_of_rgns+1] _GDIPlus_Startup() $main=GUICreate("Test",800,400) #region CreatePath $hPath=_GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath,$radius,$radius,2*$radius,2*$radius,180,90) _GDIPlus_PathAddArc($hPath,$width[1]-3*$radius,$radius,2*$radius,2*$radius,270,90) _GDIPlus_PathAddArc($hPath,$width[1]-$radius,4*$radius,2*$radius,2*$radius,-180,-90) _GDIPlus_PathAddArc($hPath,$width[0]-3*$radius,($height[0]-$height[2])/2+$radius,2*$radius,2*$radius,-90,90) _GDIPlus_PathAddLine($hPath,$width[0]-$radius,($height[0]-$height[2])/2+2*$radius,$width[0]-$radius,$height[0]/2) ;mirror path $hClone=_PathMirrorX($hPath,$height[0]/2) _GDIPlus_PathReverse($hPath) _GDIPlus_PathAddPath($hPath,$hClone);,False) #endregion CreatePath $hGraphic=_GDIPlus_GraphicsCreateFromHWND($main) $r1=_GDIPlus_RegionCreateFromPath($hPath) $bounds=_GDIPlus_RegionGetBounds($r1,$hGraphic) $data=_GDIPlus_RegionGetDataSize($r1) ConsoleWrite("$data=" & $data & @CRLF) ;~ _ArrayDisplay($bounds) ConsoleWrite("Infinite " & _GDIPlus_RegionIsInfinite($r1,$hGraphic) & @CRLF) ;~ $r=_GDIPlus_RegionCreateFromHrgn($r1) ;~ ConsoleWrite("$r=" & $r & @CRLF) _WinAPI_SetWindowRgn($main, $r1) GUISetState() While 1 ;~ _GDIPlus_GraphicsFillRegion($hGraphic,$r1) ;~ _GDIPlus_GraphicsDrawPath($hGraphic,$hPath) Switch GUIGetMsg() Case -3 ExitLoop EndSwitch WEnd _GDIPlus_RegionDispose($r1) ;~ _GDIPlus_RegionDispose($r) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hClone) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown() Func _PathMirrorX($hPath,$nOffset) $path_data=_GDIPlus_PathGetData($hPath) ConsoleWrite(UBound($path_data) & @CRLF) For $i=1 To UBound($path_data)-1 ;~ ConsoleWrite("Old=" & $path_data[$i][1] & @CRLF) $path_data[$i][1]=2*$nOffset-$path_data[$i][1] ;~ ConsoleWrite("New=" & $path_data[$i][1] & @CRLF) Next $new_path=_GDIPlus_PathCreate2($path_data) Return $new_path EndFunc Link to comment Share on other sites More sharing options...
taietel Posted July 10, 2011 Share Posted July 10, 2011 (edited) I'm not very familiar with GDI+, but now the region is visible.You have to get the handle of that region (see the <<<<<<<<<<<<<<<< in the script) expandcollapse popup#include <GDIP.au3> #Include <WinAPI.au3> ;~ #include<Array.au3> Global $width[3]=[800,600,200], $height[3]=[400,400,200], $radius=20 Global $num_of_rgns=7, $rgns[$num_of_rgns+1] _GDIPlus_Startup() $main=GUICreate("Test",800,400) GUISetState() #region CreatePath $hPath=_GDIPlus_PathCreate() _GDIPlus_PathAddArc($hPath,$radius,$radius,2*$radius,2*$radius,180,90) _GDIPlus_PathAddArc($hPath,$width[1]-3*$radius,$radius,2*$radius,2*$radius,270,90) _GDIPlus_PathAddArc($hPath,$width[1]-$radius,4*$radius,2*$radius,2*$radius,-180,-90) _GDIPlus_PathAddArc($hPath,$width[0]-3*$radius,($height[0]-$height[2])/2+$radius,2*$radius,2*$radius,-90,90) _GDIPlus_PathAddLine($hPath,$width[0]-$radius,($height[0]-$height[2])/2+2*$radius,$width[0]-$radius,$height[0]/2) ;mirror path $hClone=_PathMirrorX($hPath,$height[0]/2) _GDIPlus_PathReverse($hPath) _GDIPlus_PathAddPath($hPath,$hClone);,False) #endregion CreatePath $hGraphic=_GDIPlus_GraphicsCreateFromHWND($main) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $SmoothingModeAntiAlias) $r1=_GDIPlus_RegionCreateFromPath($hPath) $bounds=_GDIPlus_RegionGetBounds($r1,$hGraphic) $data=_GDIPlus_RegionGetDataSize($r1) ConsoleWrite("$data=" & $data & @CRLF) ;~ _ArrayDisplay($bounds) ConsoleWrite("Infinite " & _GDIPlus_RegionIsInfinite($r1,$hGraphic) & @CRLF) ;~ $r=_GDIPlus_RegionCreateFromHrgn($r1) ;~ ConsoleWrite("$r=" & $r & @CRLF) _GDIPlus_GraphicsDrawPath($hGraphic, $hPath) _WinAPI_SetWindowRgn($main, $r1);<<<<<<<<<<<<<<<<<<<< this is not working because $r1 has to be the handle to that region While 1 ;~ _GDIPlus_GraphicsFillRegion($hGraphic,$r1) ;~ _GDIPlus_GraphicsDrawPath($hGraphic,$hPath) Switch GUIGetMsg() Case -3 ExitLoop EndSwitch WEnd _GDIPlus_RegionDispose($r1) ;~ _GDIPlus_RegionDispose($r) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hClone) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown() Func _PathMirrorX($hPath,$nOffset) $path_data=_GDIPlus_PathGetData($hPath) ConsoleWrite(UBound($path_data) & @CRLF) For $i=1 To UBound($path_data)-1 ;~ ConsoleWrite("Old=" & $path_data[$i][1] & @CRLF) $path_data[$i][1]=2*$nOffset-$path_data[$i][1] ;~ ConsoleWrite("New=" & $path_data[$i][1] & @CRLF) Next $new_path=_GDIPlus_PathCreate2($path_data) Return $new_path EndFunc Edited July 10, 2011 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
ahmet Posted July 10, 2011 Author Share Posted July 10, 2011 In your example the rgion isn't visible, but the path is . I just have searched and found _GDIPlus_RegionGetHRgn() that did the job. I haven't seen it a couple days ago. Thanks for looking. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now