Zedna Posted May 13, 2006 Share Posted May 13, 2006 (edited) As helper for develop application forms fit to some resolution I created this little application.It has tray icon/menu and draw frame (with hole) that can be dragged on the screenand can be changed resolution of this frame.It's in Czech language, but it's simple to see it clear.Only little help (Czech to English): Obdelnik = RectangleZmena Rozliseni = Change of ResolutionNastaveni = OptionsBarva Okraje = Color of FrameSirka Okraje = Width of FrameZobrazit Obdelnik = Show rectangleUkladat Pozici = Save positionI used great _GUIHole code snippet from this forum There are some INI parameters, I want to add in future:- Options dialog (for change INI parametres when running)- XOR option to draw frame as XOR (with background color)- possibility add (from INI) custom resolutionsHere is whole stuff:Obdelnik.au3Obdelnik.icoobdelnik.ini:[Nastaveni] ZobrazitObdelnik=1 Rozliseni=800x600 SirkaOkraje=4 BarvaOkraje=0x000000 UkladatPozici=0 PoziceX=0 PoziceY=0I don't know why it's not possible to add attachment with INI extension EDIT: added some more translation help words Edited April 29, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted April 27, 2012 Author Share Posted April 27, 2012 (edited) New version 2.0 (12.9.2011) - added new resolutions, also wide ones - list of resolutions is now taken from INI file (ie. can be customized) - lastly used resolution is now saved to INI at end - About window isn't showed on main Windows' taskbar anymore - removed not functional menu item Options - little internal fix in drag&drop - compiled/compatible in/with AutoIt version 3.2.12.1 expandcollapse popup#AutoIt3Wrapper_Icon=obdelnik.ico #AutoIt3Wrapper_Res_Language=1029 #AutoIt3Wrapper_Res_Description=Obdélník #AutoIt3Wrapper_Res_Comment=Zobrazení obdélníku pro různá rozlišení #AutoIt3Wrapper_Res_FileVersion=2.0 #AutoIt3Wrapper_Res_LegalCopyright=Copyright © Petr Zedník 2006-2011 ;~ #AutoIt3Wrapper_Res_Field=Verze AutoIt|%AutoItVer% ://////=__= #AutoIt3Wrapper_run_obfuscator=y #Obfuscator_parameters=/SF /SV /CV=1 /CF=1 /CS=0 /CN=0 /OM #AutoIt3Wrapper_UseX64=n ;~ #AutoIt3Wrapper_UseUpx=n #include <Constants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> Const $RGN_AND = 1 Const $RGN_OR = 2 Const $RGN_XOR = 3 Const $RGN_DIFF = 4 Const $RGN_COPY = 5 Opt("GUIOnEventMode",1) Opt("TrayAutoPause",0) Opt("TrayMenuMode",1) ; no default menu (Paused/Exit) Global $akt_rozliseni Global $user32 = DllOpen("user32.dll") If @Compiled Then $ico = @ScriptName $ico_id = 0 Else $ico = "obdelnik.ico" $ico_id = -1 EndIf $pripona = StringRight(@ScriptName, 4) ; .exe nebo .au3 $ini = StringReplace(@ScriptName,$pripona,'.ini') $iniZobrazitObdelnik = IniRead($ini, "Nastaveni", "ZobrazitObdelnik", "1") $visible = $iniZobrazitObdelnik $iniRozliseni = IniRead($ini, "Nastaveni", "Rozliseni", "800x600") If Not StringInStr($iniRozliseni, 'x') Then $iniRozliseni = '800x600' $iniSirkaOkraje = IniRead($ini, "Nastaveni", "SirkaOkraje", "4") $iniBarvaOkraje = IniRead($ini, "Nastaveni", "BarvaOkraje", "0x000000") $iniUkladatPozici = IniRead($ini, "Nastaveni", "UkladatPozici", "0") $PoziceX = IniRead($ini, "Nastaveni", "PoziceX", "0") $PoziceY = IniRead($ini, "Nastaveni", "PoziceY", "0") $ZobrazitItem = TrayCreateItem("Zobrazit/Skrýt") TrayItemSetState($ZobrazitItem,$TRAY_DEFAULT) TrayCreateItem("") $rozliseni = IniReadSection($ini, "Rozliseni") If @error Then Dim $rozliseni[1][1] $rozliseni[0][0] = 0 Else For $i = 1 To $rozliseni[0][0] $rozliseni[$i][0] = TrayCreateItem(StringReplace($rozliseni[$i][1],'x',' x '),-1,-1,1) If $rozliseni[$i][1] = $iniRozliseni Then TrayItemSetState($rozliseni[$i][0], $TRAY_CHECKED) Next EndIf TrayCreateItem("") ;~ $NastaveniItem = TrayCreateItem("Nastavení") ;~ TrayItemSetState($NastaveniItem ,$TRAY_DISABLE) $OAplikaciItem = TrayCreateItem("O aplikaci") TrayCreateItem("") $KonecItem = TrayCreateItem("Konec") TraySetIcon($ico) TraySetState() TraySetClick(8) ; Pressing secondary mouse button ; pozn: skutecny rozmer se nastavi az v ZmenaRozliseni() $gui = GUICreate("Obdélník", 1, 1, $PoziceX, $PoziceY, $WS_POPUP, BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "Drag" ) GUISetBkColor($iniBarvaOkraje) $pom = StringSplit($iniRozliseni,'x') ZmenaRozliseni($pom[1], $pom[2]) If $iniZobrazitObdelnik = '1' Then GUISetState(@SW_SHOW, $gui) $about = GuiCreate("O aplikaci",210,150,-1,-1,BitOR($WS_CAPTION,$WS_SYSMENU),-1,$gui) ;$WS_EX_TOOLWINDOW GUISetIcon($ico, $ico_id, $about) GUISetOnEvent ($GUI_EVENT_CLOSE, "OAplikaciOK" ) GUICtrlCreateIcon ($ico,$ico_id,11,11) GUICtrlCreateLabel ("Obdélník 2.0",59,11,135,20) GUICtrlSetFont (-1,10, 800, 0, "Arial") ; bold GUICtrlCreateLabel ("(c) 2006-2011" & @CRLF & @CRLF & "Petr Zedník",59,30,135,40) $email = GUICtrlCreateLabel ("petr.zednik@volny.cz",59,70,135,15) GuiCtrlSetFont($email, 8.5, -1, 4) ; underlined GuiCtrlSetColor($email,0x0000ff) GuiCtrlSetCursor($email,0) GUICtrlSetOnEvent(-1, "OAplikaciEmail") $www = GUICtrlCreateLabel ("www.volny.cz/petr.zednik/",59,85,135,15) GuiCtrlSetFont($www, 8.5, -1, 4) ; underlined GuiCtrlSetColor($www,0x0000ff) GuiCtrlSetCursor($www,0) GUICtrlSetOnEvent(-1, "OAplikaciWWW") GUICtrlCreateButton ("OK",65,115,75,23,BitOr($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON)) GUICtrlSetState (-1, $GUI_FOCUS) GUICtrlSetOnEvent(-1, "OAplikaciOK") While 1 $msg = TrayGetMsg() Select Case $msg = $ZobrazitItem Zobrazit() ;~ Case $msg = $NastaveniItem ;~ Nastaveni() Case $msg = $OAplikaciItem OAplikaci() Case $msg = $KonecItem Ukonceni() EndSelect For $i = 1 To $rozliseni[0][0] If $msg = $rozliseni[$i][0] Then $pom = StringSplit($rozliseni[$i][1],'x',1) ZmenaRozliseni($pom[1],$pom[2]) EndIf Next WEnd Exit Func Zobrazit() MouseUp("primary") ; osetreni chyby pri doubleclick na default tray ikone & Drag $visible = Not $visible If $visible Then GUISetState(@SW_SHOW, $gui) Else GUISetState(@SW_HIDE, $gui) EndIf EndFunc Func ZmenaRozliseni($sirka, $vyska) TraySetToolTip('Obdélník ' & $sirka & ' x ' & $vyska) $akt_rozliseni = $sirka & 'x' & $vyska WinMove($gui, "", Default, Default, $sirka, $vyska) _GuiHole($gui, $iniSirkaOkraje, $iniSirkaOkraje, $sirka - 2 * $iniSirkaOkraje, $vyska - 2 * $iniSirkaOkraje) EndFunc Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh) Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn $pos = WinGetPos($h_win) $outer_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3]) $inner_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_sizew, "long", $i_y + $i_sizeh) $combined_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) DllCall("gdi32.dll", "long", "CombineRgn", "long", $combined_rgn[0], "long", $outer_rgn[0], "long", $inner_rgn[0], "int", $RGN_DIFF) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $combined_rgn[0], "int", 1) EndFunc ;~ Func Nastaveni() ;~ EndFunc Func OAplikaci() GUISetState(@SW_SHOW, $about) EndFunc Func OAplikaciOK() GUISetState(@SW_HIDE, $about) EndFunc Func OAplikaciEmail() Run(@ComSpec & " /c " & 'start mailto:petr.zednik@volny.cz?subject=Obdelnik', "", @SW_HIDE) EndFunc Func OAplikaciWWW() Run(@ComSpec & " /c " & 'start www.volny.cz/petr.zednik/', "", @SW_HIDE) EndFunc Func Ukonceni() If $iniUkladatPozici = '1' Then ; pokud se zmenila poloha okna, tak to zapsat do INI souboru ; pozn: toto nemuze byt v OnAutoItExit, protoze v tom okamziku uz je okno zavrene $pos = WinGetPos($gui) If @error <> 1 Then If $PoziceX <> $pos[0] Then IniWrite($ini, "Nastaveni", "PoziceX", $pos[0]) If $PoziceY <> $pos[1] Then IniWrite($ini, "Nastaveni", "PoziceY", $pos[1]) EndIf EndIf If $akt_rozliseni <> $iniRozliseni Then IniWrite($ini, "Nastaveni", "Rozliseni", $akt_rozliseni) DllClose($user32) Exit EndFunc Func Drag() DllCall($user32,"int","SendMessage","hWnd", $gui,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0) EndFunc Obdelnik.ini [Nastaveni] ZobrazitObdelnik=1 Rozliseni=1024x768 SirkaOkraje=4 BarvaOkraje=0x000000 UkladatPozici=0 PoziceX=0 PoziceY=0 [Rozliseni] Rozliseni=640x480 Rozliseni=800x600 Rozliseni=1024x600 Rozliseni=1024x768 Rozliseni=1152x864 Rozliseni=1280x768 Rozliseni=1280x800 Rozliseni=1280x960 Rozliseni=1280x1024 Rozliseni=1400x1050 Rozliseni=1440x900 Rozliseni=1600x900 Rozliseni=1600x1200 Rozliseni=1680x1050 Rozliseni=1920x1080 Rozliseni=1920x1200OBDELNIK.zip Edited April 27, 2012 by Zedna argumentum 1 Resources UDF ResourcesEx UDF AutoIt Forum Search 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