Sign in to follow this  
Followers 0
dirty

Draw picture functoin

2 posts in this topic

Why i cant get this function to work from another GUI ?

Both GUI's created in 1 script.

1st GUI Case for $Button will start and draw picture no problem.

But when i try to do it from another GUI "which is wrapped in Func name() outside of main While 1 main GUI loop" picture wont draw on main GUI.

All information does get transfered from secondary GUI to main GUI, but picture just wont draw.

It will be erased, but not drawn.

GUICtrlDelete ($Image) ;delete any previous images works fine and so is everything else when function is executed by a button in main GUI. But when same function called by a button from secondary GUI, it wont work :graduated:

Can you please look at this function and tell me why it wont work when i execute it from another GUI to show image on Main GUI ?

Thanks

Func DrawPicture()
Local $PATH,$IMG,$W,$H,$ImageWidth,$ImageHeight,$AreaWidth,$AreaHeight,$Scale,$NewImageWidth,$NewImageHeight
GUICtrlDelete ($Image) ;delete any previous images
$PATH = GUICtrlRead ($MainImagePath) ;returns full image path
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 = 355
$AreaHeight = 275
$Scale = _Min($AreaWidth / $ImageWidth, $AreaHeight / $ImageHeight)
$NewImageWidth = $ImageWidth * $Scale
$NewImageHeight = $ImageHeight * $Scale
$Image = GUICtrlCreatePic ($PATH,405,220,Round($NewImageWidth),Round($NewImageHeight)) ;355X275 is area for an image
EndFunc

Thanks in advance. I hope there is a solution.

Share this post


Link to post
Share on other sites



I doubt its the function, if it works when called from one part of your script, and not the other.

I propose the problem lies elsewhere in your script, and you should post it, or start looking for the problem yourself, outside of the function.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0