Sign in to follow this  
Followers 0
adz89

GUICtrlCreatePic Issues

16 posts in this topic

Right, I've been racking my brain for a little while about this now, I've created a GUI sample for a design project in uni, however I can't get the pic function to work. We are designing a screen that will show time, date and some events etc. The code is below, and its the two GUICtrlCreatePic function calls that are the issue. They don't do anything, at all!

#cs
This is a script to run and display a GUI for EG-M62 group project
It will call a window that will show the funtionality desired for the PC interaction of our product
#ce
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
$today= @YEAR & "/" & @MON & "/" & @MDAY
buildGUI()
while 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
  ExitLoop
Case $msg = $close
  $close_response = MsgBox(1,"Warning","Close without saving?")
  Select
  Case $close_response = 1
   ExitLoop
  EndSelect
Case $msg = $button
  progress("Saving")
  $ok_response = MsgBox(64,"Complete", "Please reinsert USB into the base of the light")
  Select
  Case $ok_response = 1
   ExitLoop
  EndSelect
Case $msg = $fact_reset
  MsgBox(48,"Warning","Pressing ok will reset all values to default, and erase any stored events")
  progress("Resetting all data")
  MsgBox(64,"Completed","Reset completed")
Case $msg = $update
  MsgBox(64,"Update","About to update the calendar files")
  progress("Updating; please wait")
Case $msg = $exitfilemenu
  $close_response = MsgBox(1,"Warning","Close without saving?")
  Select
  Case $close_response = 1
   ExitLoop
  EndSelect
Case $msg = $manualedit
  Run("notepad.exe")
Case $msg = $softupdate
  progress("Updating Software")
Case $msg = $aboutdisp
  MsgBox(64,"About","LiteTawe Configuration Software; Version 0.1 BETA")
Case $msg = $saveevent
  MsgBox(64,"Success","Event Saved")
EndSelect
 
WEnd
func buildGUI()
Global $button, $close, $fact_reset, $update, $exitfilemenu, $manualedit, $softupdate, $aboutdisp, $selecteddate, $eventname, $iconselect, $saveevent
$m=700
$n=600
GUICreate("Display Control",$m,$n)
GUISetState(@SW_SHOW)
$filemenu = GUICtrlCreateMenu("&File")
$advancedmenu = GUICtrlCreateMenu("&Advanced")
$aboutmenu = GUICtrlCreateMenu("&About")
$exitfilemenu = GUICtrlCreateMenuItem("Exit", $filemenu)
$manualedit = GUICtrlCreateMenuItem("Manual Edit",$advancedmenu)
$softupdate = GUICtrlCreateMenuItem("Update Software",$aboutmenu)
$aboutdisp = GUICtrlCreateMenuItem("About",$aboutmenu)
  $button = GUICtrlCreateButton("Ok", $m-166, $n-80, 75, 23)
$close = GUICtrlCreateButton("Close", $m-85, $n-80, 75, 23)
$fact_reset = GUICtrlCreateButton("Factory Reset", $m-85,$n-50,75,23)
$update = GUICtrlCreateButton("Update", $m-166,$n-50,75,23)
GUICtrlCreateLabel("Clock format set-up", $m-136,10)
$12hour = GUICtrlCreateRadio("12 Hour",$m-126,30)
$24hour = GUICtrlCreateRadio("24 Hour",$m-126,50)
$digital = GUICtrlCreateCheckbox("Digital",$m-126,70)
$analogue = GUICtrlCreateCheckbox("Analogue",$m-126,90)
GUICtrlCreateLabel("Add events to calendar",10,10)
$selecteddate = GUICtrlCreateMonthCal($today,10,30,230,165)
$eventname = GUICtrlCreateInput("",250,40,250,20)
GUICtrlCreateLabel("Event Name",260,20,100,20)
GUICtrlCreateLabel("Choose Icon",260,70,100,20)
  $iconselect = GUICtrlCreateButton("...",270,90,35,23)
$annual = GUICtrlCreateCheckbox("Annual Event",315,90)
$saveevent = GUICtrlCreateButton("Save Event",315,120,75,23)
GUICtrlSetState($digital,$GUI_CHECKED)
GUICtrlSetState($annual,$GUI_CHECKED)
GUICtrlSetState($12hour,$GUI_CHECKED)
GUICtrlCreatePic(@WorkingDir & "...\GUI\Screen.jpg",10,270,100,100)
GUICtrlCreatePic(@WorkingDir & "...\GUI\Info.jpg",$m-110,$n-113,100,100)
EndFunc
func progress($textstring)
ProgressOn("Progress", $textstring, "Working...")
For $i = 0 To 100
ProgressSet($i)
Sleep(5)
Next
ProgressSet(100, "Done!")
Sleep(500)
ProgressOff()
EndFunc

Self confessed noob...

Share this post


Link to post
Share on other sites



adz89,

Are you sure you have a valid path in those 2 statements? @WorkingDir defaults to the script folder and does not have a final "\" - so your path is currently "Script_Folder...\GUI\Info.jpg". Does not look very likely to work to me. ;)

When I put a valid path in those lines I get the images displayed - try doing the same. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@adz89

Why are you using @WorkingDir anyway? Do you know what a working directory is? You probably want @ScriptDir

Well I thought that would have been the way to go about it, I've come from a MATLAB programming background, so I'm having a bit of difficulty trying to get the syntax right.

I've adjusted the script to now read

GUICtrlCreatePic(@ScriptDir & "GUIScreen.jpg",10,270,100,100)
GUICtrlCreatePic(@ScriptDir & "GUIInfo.jpg",$m-110,$n-113,100,100)

but it still doesn't work...

Edited by adz89

Self confessed noob...

Share this post


Link to post
Share on other sites

The only thing I can say about this is, are you sure those are valid paths?

@ScriptDir returns the path your AU3 script is ran from.


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

The only thing I can say about this is, are you sure those are valid paths?

@ScriptDir returns the path your AU3 script is ran from.

Well I've created the GUI folder within the folder that the script is, and of course the correct file name/extension


Self confessed noob...

Share this post


Link to post
Share on other sites

adz89,

Just to be sure that you are using the correct paths, try running FileExists with the same strings as you use in the script and see if that returns 1. That will tell you if the script is looking in the right place. :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

adz89,

Just to be sure that you are using the correct paths, try running FileExists with the same strings as you use in the script and see if that returns 1. That will tell you if the script is looking in the right place. :)

M23

Well I added this;

$check = FileExists(@ScriptDir & "GUIScreen.jpg")
If $check = 1 Then
MsgBox(0,"Success","File Exists")
ElseIf $check = 0 Then
MsgBox(0,"Fail","File not found")
EndIf

and it said that the file exists.


Self confessed noob...

Share this post


Link to post
Share on other sites

adz89,

And yet using those same strings with GUICtrlCreatePic fails? :)

Try creating a GUI with only those 2 image controls within it and see if you can get them to work in that case. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

adz89,

And yet using those same strings with GUICtrlCreatePic fails? :)

Try creating a GUI with only those 2 image controls within it and see if you can get them to work in that case. ;)

M23

Ok will do, I'll let you know in due course


Self confessed noob...

Share this post


Link to post
Share on other sites

Ok, well still nothing happening...

Here is the code I used;

#include <GUIConstantsEx.au3>
buildGUI()
while 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
  ExitLoop
EndSelect
WEnd

func buildGUI()
$m=700
$n=600
GUICreate("Display Control",$m,$n)
GUISetState(@SW_SHOW)
GUICtrlCreatePic(@ScriptDir & "GUIScreen.jpg",10,270,100,100)
GUICtrlCreatePic(@ScriptDir & "GUIInfo.jpg",$m-110,$n-113,100,100)
EndFunc

Self confessed noob...

Share this post


Link to post
Share on other sites

adz89,

I created the same folder structure as you and my images showed up without problem using your code - so I have no idea what is going on. :)

Really clutching at straws here, but I take it the images do actually have some content that you can see against the GUI background? Do they show up in other apps such as Paint? Have you tried using other images in their place? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

adz89,

I created the same folder structure as you and my images showed up without problem using your code - so I have no idea what is going on. :)

Really clutching at straws here, but I take it the images do actually have some content that you can see against the GUI background? Do they show up in other apps such as Paint? Have you tried using other images in their place? ;)

M23

Well I'm out at the moment, but I'll try other images later, but the images can be open in picture viewer, and are both .jpg's...

I'll let you know how it goes with other images.


Self confessed noob...

Share this post


Link to post
Share on other sites

Ok, I got it working, not sure what the problem was though. I renamed the non-working pic from screen to disp_ex and left it as a jpg, and resaved the jpg file to be a bmp...

All working now though!

Thanks for the help guys, if anyone's interested I'll post the working, final script later!


Self confessed noob...

Share this post


Link to post
Share on other sites

adz89,

Glad you got it working despite my ineffective help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

adz89,

Glad you got it working despite my ineffective help. ;)

M23

It was the help that was ineffective, it was my programming skills! :)


Self confessed noob...

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

  • Similar Content

    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys this is my gui and i need the numeric value typed in the highlighted  inputbox. if this value is greater than 1 i need to perform some operations
      \
       
      Here is the summary about that field which i got from wininfo tool

      i tried writing the code as shown below.. but the msgbox is popping up empty value..when the same code is pasted under some button action i am able to access the value present in the field..but when placed alone as written in the attached script i am unable to fetch it... 

      here i am using the valu present in the field

      can you guys tell me what's wrong??? or how can i get that value?
       
      My_GUI.au3

    • Neonovaz
      By Neonovaz
      Hello
       
      Is there anyway to store word documents in Autoit GUI? For example I have a instruction sheet that I want to bundle up with the exe.

      So a user simply clicks the icon and the stored document will launch  (Something like how you can add objects like excel sheets in word documents )

      (I Know we can launch word files from script directory)

       
    • hemichallenger
      By hemichallenger
      Not sure if this is possible or if someone has already tackled this. Is it possible to embed PowerShell into a GUI? Autoit is great for quick function but sometime I need to run a command thru PowerShell. It be great to have PowerShell console embedded into the gui.
    • 0Ethan0
      By 0Ethan0
      Ahoy Autoit Community!
      After many trials and errors I am unable to solve a problem I am facing and would appreciate any kind of input or better yet a solution 
      The Premise: An embeded slideshow viewer that runs after double-clicking an item in a ListView (each item will generate a different slideshow images).
      The Setup: GUI with a ListView Control and a simple exit button.
      The Issue: Once double clicked the slide plays however the GUI "locks"/non responsive until the slide is over. Same thing if I click on the "Test" button.
      The Culprit: I believe since it's in the images loop it can't accept any other commands until that loop is over.
      The Wish: I want to be able to use the GUI functions (selecting other items, clicking on button etc.) while the slideshow plays.
      The Code (stripped and simplified as much as I could):
      #include <GuiListView.au3> #include <File.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{Esc}", "_Exit") Global $c=0 Global $ssGDI[3], $ssGraphic[2], $ssImage Global Const $bg_color = "000000" Global Const $ssW = 480, $ssH = 320 Global $aFiles = _FileListToArrayRec("d:\testStage\", "*.jpg;*.png;*.bmp;*.gif;*.JPG;*.PNG;*.BMP;*.GIF", $FLTAR_FILES, $FLTAR_NORECUR ,$FLTAR_SORT ,$FLTAR_FULLPATH ) $guiW = 1200 $guiH = 726 $mainWindow = GUICreate("Slideshow Viewer", $guiW, $guiH, -1, -1, $WS_POPUP) $Button1 = GUICtrlCreateButton("Exit", 0, 0, 50, 50) GUICtrlSetOnEvent($Button1, "_Exit") $Button1 = GUICtrlCreateButton("Test", 60, 0, 50, 50) GUICtrlSetOnEvent($Button1, "Test") Global $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280) _GUICtrlListView_SetColumnWidth ($ListView, 0, 100) _GUICtrlListView_SetColumnWidth ($ListView, 1, 100) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("Name 1|Category 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2", $ListView) screenshotWidgetInit($ssW,$ssH, 690, 100) GUISetState(@SW_SHOW, $mainWindow) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() EndSwitch WEnd Func Test() For $k = 1 To UBound($aFiles) - 1 screenshotWidgetTransition($aFiles[$k]) Next EndFunc Func ListView_Click() ConsoleWrite("Left Click") EndFunc Func ListView_DoubleClick() ConsoleWrite("Double Left Click") Test() EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $NM_CLICK ListView_Click () Case $event = $NM_DBLCLK ListView_DoubleClick () EndSelect EndSelect Return $GUI_RUNDEFMSG EndFunc Func screenshotWidgetTransition($image, $delay = 0, $speed = 1, $sleep = 2000) Local $a, $d = $c, $iX, $iY $ssImage = _GDIPlus_ImageLoadFromFile($image) $iX = _GDIPlus_ImageGetWidth($ssImage) $iY = _GDIPlus_ImageGetHeight($ssImage) $FDesktop=$ssH/$ssW $Fact =1 If $iX > $ssW And $FDesktop > ($iY/$iX) Then $Fact=$ssW/$iX ElseIf $iY > $ssH Then $Fact=$ssH/$iY EndIf $H1 = Round(($Fact * $iY),0) $W1 = Round(($Fact * $iX),0) _GDIPlus_GraphicsDrawImageRect($ssGraphic[$d], $ssImage,($ssW - $W1)/2, ($ssH - $H1) / 2,$W1,$H1) WinSetTrans($ssGDI[$d], "", 0) WinSetOnTop($ssGDI[$d], "", 1) For $a = 0 To 254 Step $speed WinSetTrans($ssGDI[$d], "", $a) Sleep($delay) Next WinSetTrans($ssGDI[$d], "", 254) WinSetOnTop($ssGDI[Not ($d)], "", 0) WinSetTrans($ssGDI[Not ($d)], "", 0) _GDIPlus_GraphicsClear($ssGraphic[Not ($d)]) $c = 1 - $d _GDIPlus_ImageDispose ($ssImage) ; very important to realease the pics Sleep($sleep) EndFunc ;==>screenshotWidgetTransition Func screenshotWidgetInit($ssW,$ssH,$ssX,$ssY) $ssGDI[2] = GUICreate("", $ssW, $ssH, $ssX, $ssY, $WS_POPUP, $WS_EX_MDICHILD, $mainWindow) $ssGDI[0] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) $ssGDI[1] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) ; GUISetBkColor("0x" & $bg_color, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[0]) GUISetState(@SW_SHOW, $ssGDI[1]) WinSetTrans($ssGDI[0], "", 0) WinSetTrans($ssGDI[1], "", 0) _GDIPlus_Startup() $ssGraphic[0] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[0]) $ssGraphic[1] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[1]) _GDIPlus_GraphicsClear($ssGraphic[0], "0xFF" & $bg_color) _GDIPlus_GraphicsClear($ssGraphic[1], "0xFF" & $bg_color) EndFunc ;==>screenshotWidgetInit Func _Exit() _GDIPlus_ImageDispose($ssImage) _GDIPlus_GraphicsDispose($ssGraphic[0]) _GDIPlus_GraphicsDispose($ssGraphic[1]) GUIDelete($ssGDI[0]) GUIDelete($ssGDI[1]) GUIDelete($ssGDI[2]) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit I hope someone can shed light on this; perhaps a different approach is needed?
      Thank you in advance!
      P.S.
      The script is patched from different scripts of different users in the forum - thank you again users!