Jump to content

philipharvey

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by philipharvey

  1. I am trying to create a GUI that displays an image within a child GUI with a vertical scrollbar. The image is often taller than the screen size so needs to be able to scroll. I have tried using gafrosts code, and it mostly works (Thanks!) , the only problem I am still having is trying to figure out what to set the scroll range to in order that all the image is visible but not to have a lot of white space at the bottom of the image. Does anyone know how to calculate what the to set the scroll range to. e.g. If the child GUI is 400 high by 300 wide and the image is 550 high by 300 wide. What parameters should I use for _InitScrollDimensions? Does this depend on the placement of the child GUI within the main GUI? Or should I use _SetScrollRange? Thanks for any assistance with this. Code below: The code is a bit of a mess currently.... but if anyone else is doing something similar this my be of use. CODE#include <GUIConstants.au3> #include <Array.au3> #include <GUIScrollBars.au3> #include <File.au3> #include <FileGetExtProp.au3> Opt ("TrayIconHide",1) Opt ("WinTitleMatchMode", 4) $ButtonHPadding = 20 $ButtonVPaddingBelow = 10 $ButtonVPaddingAbove = 5 $ButtonHeight = 24 $ScrollbarWidth=16 $IntranetServer="http://your.intranet.server.com/" $NotifyFilename="today.gif" $NotifyFileServerLocation= $IntranetServer&$NotifyFilename $IntranetButtonLabel="&Lanch our Intranet" $TaskbarPosSize=WinGetPos("classname=Shell_TrayWnd") ;Find where and how big the task bar is so we don't overlap with it. Select Case $TaskbarPosSize[3]=@DesktopHeight ; Taskbar is vertical, so we can use the full height $WindowPaddingAbove = 4 ; allow just a few pixels padding. $WindowPaddingBelow = 4 ; allow just a few pixels padding. Case $TaskbarPosSize[1]=0 ;Taskbar is at the top $WindowPaddingAbove=$TaskbarPosSize[3]+4 $WindowPaddingBelow = 4 Case Else ; Not at the top or side, assume it's at the bottom. $WindowPaddingAbove=4 $WindowPaddingBelow =$TaskbarPosSize[3]+4 EndSelect ;find out how big the window border and the title bar are for calculations of the window size Const $SM_CYCAPTION=4 Const $SM_CXFIXEDFRAME=7 $wtit=DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CYCAPTION) $height_titlebar=$wtit[0]; 19 or 26 $border=DllCall('user32.dll', 'int', 'GetSystemMetrics', 'int', $SM_CXFIXEDFRAME) $window_border_size=$border[0]; 3 ;calculate how much space to leave around various parts of the GUI $VerticalWindowPadding=$WindowPaddingAbove+$WindowPaddingBelow $NotifyButtonPadding=$ButtonVPaddingAbove + $ButtonVPaddingBelow + $ButtonHeight $NotifyVerticalPadding = $NotifyButtonPadding+$height_titlebar+$window_border_size ;download the file to a temp location. File must have an image file extension otherwise the function _FileGetExtProp fails. $TodayGIFFile=_TempFile()&$NotifyFilename InetGet($NotifyFileServerLocation, $TodayGIFFile) ;Find how big the image is $TodayGifDimensions = _FileGetExtProp($TodayGIFFile, 26) $TodayGifDimensionsArray = StringSplit ($TodayGifDimensions, " x ", 1) If $TodayGifDimensionsArray[0]<>2 Then ; file is not a gif file, possibly it is a http error or there is no file MsgBox(0,"Intranet Notify Error","Intranet Notify was unable to connect to the Intranet Server.") FileDelete($TodayGIFFile) Exit Else $TodayGifWidth=$TodayGifDimensionsArray[1] $TodayGifHeight=$TodayGifDimensionsArray[2] EndIf $NotifyGUIHeight = $TodayGifHeight+ $NotifyVerticalPadding $UseableSpace=@DesktopHeight-$VerticalWindowPadding If ($NotifyGUIHeight > $UseableSpace) Then; Image is bigger than the usable screen size. $Scrolling=True $NotifyGUIWidth = $TodayGifWidth+$ScrollbarWidth ; add some space for the scroll bar $NotifyGUIInternalHeight= @DesktopHeight-$VerticalWindowPadding-$height_titlebar-$window_border_size ; use all available height $NotifyPicGUIHeight=$NotifyGUIInternalHeight - $NotifyButtonPadding Else ;Entire GUI will fix, no scrolling needed. Hurrah! $NotifyGUIInternalHeight= $TodayGifHeight+$NotifyButtonPadding $Scrolling=False $NotifyGUIWidth = $TodayGifWidth $NotifyPicGUIHeight=$TodayGifHeight EndIf ;Create the parent GUI with the two buttons. GUIRegisterMsg($WM_CREATE, "MY_WM_CREATE") GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE") $NotifyGUI= GUICreate("Today's News on the Intranet",$NotifyGUIWidth,$NotifyGUIInternalHeight,-1,-1,BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) GUISetBkColor (0xFFFFFF) GUISwitch($NotifyGUI) $ButtonVerticalPlacement=$NotifyGUIInternalHeight-$ButtonVPaddingBelow-$ButtonHeight $ButtonWidth=($TodayGifWidth-(3*$ButtonHPadding))/2 $LaunchIntranet = GUICtrlCreateButton ($IntranetButtonLabel , $ButtonHPadding, $ButtonVerticalPlacement,$ButtonWidth,$ButtonHeight) $GoToWindows = GUICtrlCreateButton ( "&Close", $ButtonWidth+(2*$ButtonHPadding), $ButtonVerticalPlacement,$ButtonWidth,$ButtonHeight) GUISetState() ;Create a child GUI just for the image. This GUI may need to scroll. GUIRegisterMsg($WM_CREATE, "MY_WM_CREATE") $NotifyPicGUI = GUICreate("NotifyPicGUI", $NotifyGUIWidth, $NotifyPicGUIHeight, 0, 0, $WS_CHILD,-1,$NotifyGUI) GUISetBkColor (0xFFFFFF) $NotifyPic = GuiCtrlCreatePic($TodayGIFFile,0,0,$TodayGifWidth,$TodayGifHeight) GUISetState() FileDelete($TodayGIFFile) If $Scrolling Then _InitScrollDimensions($NotifyGUIWidth,$NotifyGUIHeight,$NotifyGUIWidth,$TodayGIFHeight,0,0) GUIRegisterMsg($WM_VSCROLL, "MY_WM_VSCROLL") GUIRegisterMsg($WM_HSCROLL, "MY_WM_HSCROLL") _ShowScrollBar ($NotifyPicGUI, $SB_VERT,True) _EnableScrollBar($NotifyPicGUI, $SB_VERT,True) _EnableScrollBar($NotifyPicGUI, $SB_HORZ, False) _ShowScrollBar ($NotifyPicGUI, $SB_HORZ,False) EndIf While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $LaunchIntranet If NOT FileExists('C:\Program Files\Internet Explorer\iexplore.exe') Then MsgBox(0,"Intranet Notify Error","The Internet Explorer executable is missing from C:\Program Files\Internet Explorer\") ExitLoop EndIf Run('C:\Program Files\Internet Explorer\iexplore.exe -new ' & $IntranetServer) ExitLoop Case $msg = $GoToWindows ExitLoop EndSelect Wend
  2. Thanks for the pointer, it is getting quite close to what I am looking for. The only problem now is I can't figure out how to calculate what I should set the scroll range to so the image is fully displayed without white space. I'll go post about that in the above thread... Cheers
  3. I am trying to write what should be about the easiest application you can imagine for Autoit3. I want to display an image in a fixed sized GUI. The image is larger than the GUI (vertically only) so I want to add a vertical scroll bar. The problem is that the scroll bar does not function. I have tried many different ideas but seem to be hitting my head against a brick wall with this one. I'm hoping someone with some more GUI experience can help with this one. Here is one example of code I have tried: CODE$NotifyGUI=GUICreate("News",300,300,-1,-1,BitOr($WS_POPUPWINDOW,$WS_VSCROLL,$SS_NOTIFY )) $NotifyPic = GuiCtrlCreatePic("today.gif",0,0,280,800,BitOR($WS_VISIBLE,$SS_NOTIFY),$GUI_WS_EX_PARENTDRAG) I have also tried using Auto3Lib without success. Any pointers appreciated.
  4. I am working on how to get an image to display in a very simple GUI. The problem I have encountered is that when the image is bigger than the GUI, Autoit will down-scale the image to be the size of the control. What I want to do is to add scroll bars to the pic control so I can scroll around and look at the entire image without scaling. This doesn't sound too difficult but I haven't been able to figure out how to do this and have been searching a couple of days for the solution. If I use something like: $NotifyPic = GuiCtrlCreatePic("today.gif",0,0,100,200,$WS_VSCROLL) Then I get a scroll bar but the image is still scaled to fit the window so scrolling is not possible. Can anyone enlighten me? Thanks very much Phil
  5. Super news Jon, thanks for looking into this. Cheers Phil
  6. Hi ezzetabi. I wasn't meaning to jump down your throat, any help is always appreciated. Cheers Philip
  7. Hi ezzetabi. I realize I could write a function to do this, but what I was getting at was is this a bug in Autoit that could be fixed? Or perhaps a missing feature that could easily be added? Or perhaps someone knows how to do this but it isn't documented? Cheers Phil
  8. Is there a simple way to create a completly empty registry key in autoit? The only way I can figure to do this is to create a value and then delete it. e.g. RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Test","junk","REG_SZ","") RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Test","junk") If you simply do RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Test","","REG_SZ","") then the keys default value does not seem to get set (or rather not set) correctly. Cheers Philip
×
×
  • Create New...