Andreik Posted June 22, 2010 Share Posted June 22, 2010 I want to create a region with CreateRoundRectRgn() and then combine this region with an existent GUI using CombineRgn(). On the created region I will create a button and I want to destroy the region when user click on this button. My question: is possibly to destroy a region after this is combined with another existent GUI? When the words fail... music speaks. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 22, 2010 Share Posted June 22, 2010 Got a demo of what you tried? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Andreik Posted June 23, 2010 Author Share Posted June 23, 2010 (edited) I tried something like this:I want to create a special region under my main GUI, for application options. When I move the main GUI, this region to move instantly with my GUI[i tried WinMove() but is pretty ugly]. In this region will be a button called "Save options". When this will be pressed I need to destroy this region and to remain just my main GUI. Any suggestion is welcome. Edited June 23, 2010 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Zedna Posted June 23, 2010 Share Posted June 23, 2010 (edited) Look at ( my :-) ) example for _WinAPI_CreateRoundRectRgn() in helpfile. EDIT Here is the code: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; get height of window title and width of window frame - may be different when XP theme is ON/OFF Global $htit = _WinAPI_GetSystemMetrics($SM_CYCAPTION) Global $frame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) $gui = GUICreate("Test Windows regions", 350, 210) $btn_default = GUICtrlCreateButton("Default region", 100, 30, 150) $btn_round = GUICtrlCreateButton("Round region", 100, 60, 150) $btn_buble = GUICtrlCreateButton("Buble region ", 100, 90, 150) $btn_transparent = GUICtrlCreateButton("Transparent region", 100, 120, 150) $btn_exit = GUICtrlCreateButton("Exit", 100, 150, 150) GUISetState(@SW_SHOW) $pos = WinGetPos($gui) ; get whole window size (no client size defined in GUICreate) Global $width = $pos[2] Global $height = $pos[3] While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit ExitLoop Case $msg = $btn_default $rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height) _WinAPI_SetWindowRgn($gui, $rgn) Case $msg = $btn_round $rgn = _WinAPI_CreateRoundRectRgn(0, 0, $width, $height, $width / 3, $height / 3) _WinAPI_SetWindowRgn($gui, $rgn) Case $msg = $btn_buble $rgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $width / 2, $height / 2, $width / 2, $height / 2) ; left-top $rgn2 = _WinAPI_CreateRoundRectRgn($width / 2, 0, $width, $height / 2, $width / 2, $height / 2) ; right-top _WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR) _WinAPI_DeleteObject($rgn2) $rgn2 = _WinAPI_CreateRoundRectRgn(0, $height / 2, $width / 2, $height, $width / 2, $height / 2) ; left-bottom _WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR) _WinAPI_DeleteObject($rgn2) $rgn2 = _WinAPI_CreateRoundRectRgn($width / 2, $height / 2, $width, $height, $width / 2, $height / 2) ; right-bottom _WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR) _WinAPI_DeleteObject($rgn2) $rgn2 = _WinAPI_CreateRoundRectRgn(10, 10, $width - 10, $height - 10, $width, $height) ; middle _WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR) _WinAPI_DeleteObject($rgn2) _WinAPI_SetWindowRgn($gui, $rgn1) Case $msg = $btn_transparent _GuiHole($gui, 40, 40, 260, 170) EndSelect WEnd ; make inner transparent area but add controls Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh) Local $outer_rgn, $inner_rgn, $combined_rgn $outer_rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height) $inner_rgn = _WinAPI_CreateRectRgn($i_x, $i_y, $i_x + $i_sizew, $i_y + $i_sizeh) $combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($combined_rgn, $outer_rgn, $inner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($outer_rgn) _WinAPI_DeleteObject($inner_rgn) _AddCtrlRegion($combined_rgn, $btn_default) _AddCtrlRegion($combined_rgn, $btn_round) _AddCtrlRegion($combined_rgn, $btn_buble) _AddCtrlRegion($combined_rgn, $btn_transparent) _AddCtrlRegion($combined_rgn, $btn_exit) _WinAPI_SetWindowRgn($h_win, $combined_rgn) EndFunc ;==>_GuiHole ; add control's area to given region ; respecting also window title/frame sizes Func _AddCtrlRegion($full_rgn, $ctrl_id) Local $ctrl_pos, $ctrl_rgn $ctrl_pos = ControlGetPos($gui, "", $ctrl_id) $ctrl_rgn = _WinAPI_CreateRectRgn($ctrl_pos[0] + $frame, $ctrl_pos[1] + $htit + $frame, _ $ctrl_pos[0] + $ctrl_pos[2] + $frame, $ctrl_pos[1] + $ctrl_pos[3] + $htit + $frame) _WinAPI_CombineRgn($full_rgn, $full_rgn, $ctrl_rgn, $RGN_OR) _WinAPI_DeleteObject($ctrl_rgn) EndFunc ;==>_AddCtrlRegion Edited June 23, 2010 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Andreik Posted June 23, 2010 Author Share Posted June 23, 2010 I have a strange result, my GUI disappear: #include <WinAPI.au3> $MAIN = GUICreate("Test",400,400) $MENU = GUICtrlCreateMenu("Menu") $OPT = GUICtrlCreateMenuItem("Options",$MENU) GUISetState(@SW_SHOW,$MAIN) While True Switch GUIGetMsg() Case $OPT OptionsMenu($MAIN) Case -3 Exit EndSwitch Sleep(10) WEnd Func OptionsMenu($MAIN) Local $REGION Local $POS = WinGetPos($MAIN) $REGION = _WinAPI_CreateRectRgn($POS[0],$POS[1]+$POS[3]+10,$POS[0]+$POS[2],$POS[1]+$POS[3]+110) _WinAPI_SetWindowRgn($MAIN,$REGION) EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Yashied Posted June 23, 2010 Share Posted June 23, 2010 (edited) Why regions? expandcollapse popup#Include <GUIConstantsEx.au3> #Include <WindowsConstants.au3> $hOpt = 0 $hForm = GUICreate('MyGUI', 400, 400, 600, 100) $Menu = GUICtrlCreateMenu('Menu') $Opt = GUICtrlCreateMenuItem('Options', $Menu) GUIRegisterMsg($WM_ACTIVATE, 'WM_ACTIVATE') GUIRegisterMsg($WM_MOVE, 'WM_MOVE') GUISetState() While 1 $Msg = GUIGetMsg(1) Switch $Msg[0] Case -3 Switch $Msg[1] Case $hForm Exit Case $hOpt GUICtrlSetState($Opt, $GUI_Enable) GUIDelete($hOpt) $hOpt = 0 EndSwitch Case $Opt If Not $hOpt Then $Pos = WinGetPos($hForm) $hOpt = GUICreate('Options', 400, 100, $Pos[0], $Pos[1] + 439, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOWNOACTIVATE, $hOpt) GUICtrlSetState($Opt, $GUI_DISABLE) EndIf EndSwitch WEnd Func WM_ACTIVATE($hWnd, $iMsg, $wParam, $lParam) Switch BitAND($wParam, 0xFFFF) Case 1, 2 Switch $hWnd Case 0 Case $hForm If $hOpt Then GUISetState(@SW_RESTORE, $hOpt) GUISetState(@SW_RESTORE, $hForm) EndIf Case $hOpt GUISetState(@SW_RESTORE, $hForm) GUISetState(@SW_RESTORE, $hOpt) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_ACTIVATE Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam) $X = BitAND($lParam, 0xFFFF) If $X > 0x7FFF Then $X -= 0x10000 EndIf $Y = BitShift($lParam, 16) If $Y > 0x7FFF Then $Y -= 0x10000 EndIf Switch $hWnd Case 0 Case $hForm If $hOpt Then WinMove($hOpt, '', $X - 3, $Y + 390) EndIf Case $hOpt WinMove($hForm, '', $X -3, $Y - 460) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOVE Edited June 23, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Andreik Posted June 23, 2010 Author Share Posted June 23, 2010 Yeah, it's nice your example. If I cannot make with regions I will try your method. Thanks Yashied. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
GEOSoft Posted June 24, 2010 Share Posted June 24, 2010 You can just create it as a separate GUI and Show/Hide it with GUISetState. 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 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