dirty Posted November 5, 2011 Share Posted November 5, 2011 Picture is created in a function called when user clicks on Listviewitem. Here is how it gets called: If $GUIGetMsg = $GetClickedItem Then ;Show Selected If $GetClickedItem = 0 Then ElseIf $GetClickedItem = "" Then ElseIf $GetClickedItem > "" Then DisplaySelected() EndIf EndIf Func DisplaySelected() ;many lines of code to format the string from selected listviewitem to isolate path to picture DrawPicture() Endfunc Here is the Picture Function Func DrawPicture();Drap picture Local $PATHCheck,$PATHEMPTY,$PATHFILEERROR,$PATH,$IMG,$W,$H Local $ImageWidth,$ImageHeight,$AreaWidth,$AreaHeight,$Scale,$NewImageWidth,$NewImageHeight GUICtrlDelete($Image) ;delete any previous images $PATHCheck = GUICtrlRead($MainImagePath) ;returns full image path $PATHEMPTY = (@TempDir & "\NoPicture.jpg") $PATHFILEERROR = (@TempDir & "\PictureError.jpg") If $PATHCheck = "" Then ;No Image $PATH = (@TempDir & "\NoPicture.jpg") ElseIf $PATHCheck > "" And FileExists($PATHCheck) = 0 Then $PATH = (@TempDir & "\PictureError.jpg") ElseIf $PATHCheck > "" And FileExists($PATHCheck) = 1 Then $PATH = $PATHCheck EndIf If Not @error Then _GDIPlus_Startup() $IMG = _GDIPlus_ImageLoadFromFile($PATH) $W = _GDIPlus_ImageGetWidth($IMG) $H = _GDIPlus_ImageGetHeight($IMG) _GDIPlus_ImageDispose($IMG) _GDIPlus_Shutdown() ;MsgBox(0,$PATH,$W & @CRLF & $H) ;size of an amage EndIf $ImageWidth = $W $ImageHeight = $H $AreaWidth = 440 $AreaHeight = 325 $Scale = _Min($AreaWidth / $ImageWidth, $AreaHeight / $ImageHeight) $NewImageWidth = $ImageWidth * $Scale $NewImageHeight = $ImageHeight * $Scale $Image = GUICtrlCreatePic($PATH, 505, 410, Round($NewImageWidth), Round($NewImageHeight)) ;This one is global ;GUICtrlSetResizing (-1,1) EndFunc ;==>DrawPicture I dont understand why: if GUICtrlSetResizing (-1,1) is used in DrawPicture() right after its created is not working Is there a way to change it ? I thinki need to change how the positioning of the picture is effected by resized gui, but i dont know how to do that. $Image = GUICtrlCreatePic($PATH, 505, 410, Round($NewImageWidth), Round($NewImageHeight)); This cant be right, 505 and 410 change when u resize window, so how do i change those while window is getting resized and other components such as big vertical button on the right also get scaled ? Watch this video and see http://www.youtube.com/watch?v=K0E3JoMkoPM Link to comment Share on other sites More sharing options...
martin Posted November 5, 2011 Share Posted November 5, 2011 Initial question - Why is the position of the created Pic fixed when the window is a varying size? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
dirty Posted November 6, 2011 Author Share Posted November 6, 2011 because original gui was not resistible, but not it is and i dont know how to make it follow the gui size changes. Link to comment Share on other sites More sharing options...
martin Posted November 7, 2011 Share Posted November 7, 2011 You need to set the position of the image depending on the position of other controls. If you have a handler for WM_SIZE then you can calculate new positions every time the window is resized. (Or WM_EXITSIZEMOVE maybe). Since I can't remember your window layout I'm not sure of some details. If the original pic resizes ok and the problem only occurs when you replace it then before you delete the old pic get its position and size and use that for the new pic. Or, instead of deleting the pic and creating a new one just set the new image to the pic using GuiCtrlSetImage. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
dirty Posted November 7, 2011 Author Share Posted November 7, 2011 can u give me an example of 1st part of your reply with WM_SIZE Or WM_EXITSIZEMOVE, am not sure how to start. I also did try creating new one instead of deleting the old and then recreating it, but the problem was that the old picture would not be deleted and the new one gets created on top (not good) so i ended up deleting the control. Link to comment Share on other sites More sharing options...
martin Posted November 8, 2011 Share Posted November 8, 2011 I expect searching would find a few examples, but Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
dirty Posted November 8, 2011 Author Share Posted November 8, 2011 (edited) i am not trying to resize child and parent window together, i am resizing control that is displayed in one window (no children yet, my code has not found its significant other) so what ever is posted there is little off topic, but thanks i can learn allot from that link for future projects Edited November 8, 2011 by dirty 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