Jump to content
Sign in to follow this  
adz89

GUICtrlCreatePic Issues

Recommended Posts

adz89

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
Melba23

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
adz89

@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
AlmarM

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
adz89

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
Melba23

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

  • Like 1

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

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
Melba23

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

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
adz89

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
Melba23

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

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
adz89

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
Melba23

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

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  

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I have an inquiry and I hope to find the answer here
      I want to create a graphical user interface
      but I want to hide the system menu
      I mean the window menu
      Is this possible?
      If is possible please give me how to do that
      Thanks in advance
    • helmar
      By helmar
      I was playing around with simple GUI creation.  I tend to like parameter driven coding (in prior life (years ago) as Clipper/FoxPro/dBase coder).  Just wanted to see what I could do with a GUI.
      #Region options, includes Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode #include <GUIConstantsEx.au3> #EndRegion options, includes Global Const $nCols = 2, $nRows = 6, $nSpacer = 10, $nBtnWidth = 150, $nBtnHeight = 30 Global $xName = 0, $xID = 0 Global $nGUIWidth = ($nCols * $nBtnWidth) + (($nCols + 1) * $nSpacer) Global $nGUIHeight = ($nRows * $nBtnHeight) + (($nRows + 1) * $nSpacer) Global $hMainGUI = GUICreate("Calculated GUI", $nGUIWidth, $nGUIHeight, -1, -1) For $xRows = 1 to $nRows ;in this arrangement, tabbing is left to right, then next row For $xCols = 1 to $nCols ;reverse the order of this line with the prior line for top to bottom tabbing, then next col $xName += 1 $xID += 1 Global $Dummy = GUICtrlCreateButton("Button" & $xName, _ ($nBtnWidth * ($xCols - 1)) + (($xCols - 1) * $nSpacer) + $nSpacer, _ ($nBtnHeight* ($xRows - 1)) + (($xRows - 1) * $nSpacer) + $nSpacer, _ $nBtnWidth, _ $nBtnHeight) GUICtrlSetOnEvent($xID+2, "Handler") Next Next GUISetOnEvent($GUI_EVENT_CLOSE, "CloseApp") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func CloseApp() Exit EndFunc Func Handler() MsgBox(0,0,"Button " & @GUI_CtrlId - 2) EndFunc  
    • XinYoung
      By XinYoung
      For fun, I'm building an app that opens a webpage and refreshes it every 30 seconds.
      But once the script performs _IEAction($oIE, "refresh"), the GUI closes.
      Any help is appreciated.
       

      #include <ButtonConstants.au3>
      #include <EditConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <StaticConstants.au3>
      #include <WindowsConstants.au3>
      #include <WinAPIFiles.au3>
      #include <Array.au3>
      #include <File.au3>
      #include <Excel.au3>
      #include <DateTimeConstants.au3>
      #include <MsgBoxConstants.au3>
      #include <WinAPIShellEx.au3>
      #include <MsgBoxConstants.au3>
      #include <Date.au3>
      #include <ComboConstants.au3>
      #include <guimenu.au3>
      #include <IE.au3>
      HotKeySet("{F4}", "_Exit")
      ;Open the file(s) in the selected folder
      $extension = ".txt"
      $app2openWith = @SystemDir & "\notepad.exe"
      Func Begin()
          Global $loopTrick = 0
          #Region ### START Koda GUI section ### Form=c:\users\mchu\downloads\autoit\my code\form1.kxf
          Global $UI = GUICreate("Hit Em Up!", 256, 113, -1, -1)
          GUISetBkColor(0x000000)
          $menu = _GUICtrlMenu_GetSystemMenu($UI)
          _GUICtrlMenu_EnableMenuItem($menu, $SC_CLOSE, 1, False)
          Global $url = GUICtrlCreateInput("https://www.youtube.com/watch?v=dQw4w9WgXcQ", 81, 8, 160, 21)
          $Label1 = GUICtrlCreateLabel("Target:", 16, 8, 55, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          Global $StartBut = GUICtrlCreateButton("Start", 16, 40, 67, 25)
          GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif")
          GUICtrlSetBkColor(-1, 0x008000)
          $Label2 = GUICtrlCreateLabel("(Press F4 to Exit)", 96, 40, 8000, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          GUISetState(@SW_SHOW)
          #EndRegion ### END Koda GUI section ###
          While 1
              $UIfunc = GUIGetMsg()
              Select
                  Case $UIfunc = $GUI_EVENT_CLOSE
                      _Exit()
                  Case $UIfunc = $StartBut
                      If GUICtrlRead($url) = "" Then
                          MsgBox(48, "Um...", "Give me a target you idiot.")
                      Else
                          GUICtrlSetState($url, $GUI_DISABLE)
                          GUICtrlSetState($StartBut, $GUI_DISABLE)
                          Start()
                      EndIf
              EndSelect
          WEnd
      EndFunc   ;==>Begin
      Func Start()
          If $loopTrick = 0 Then
              Global $oIE = _IECreate(GUICtrlRead($url))
              _IELoadWait($oIE)
              Again()
          ElseIf $loopTrick = 1 Then
              Sleep(3000)
              _IEAction($oIE, "refresh")
              Sleep(3000)
              Start()
          EndIf
      EndFunc   ;==>Start
      Func Again()
          $loopTrick = 1
          Start()
      EndFunc   ;==>Again
      Func _Exit()
          Exit
      EndFunc   ;==>_Exit
    • kcvinu
      By kcvinu
      Hi all,
      I have a button created with _GUICtrlButton_Create function. I know that this function returns a handle of button instead of an ID. So i have obtain control ID by calling _WinAPI_GetDlgCtrlID function. After that i have tried the GUICtrlSetBkColor function. But it didnt worked. Any suggestions will be appreciated. Thanks in advance. 
      Note : - The window which carries this button is not created with native gui create function. Instead, it is created with CreateWindowEx api function.
    • kcvinu
      By kcvinu
      Hi all,
      I am playing with _GUICtrlButton_Create function. How can i change this button's (or the entire form's) font ?. The in-built GUICtrlSetFont function is not working even when i convert the control handle to control ID with _WinAPI_GetDlgCtrlID ( ) function.  Do i need to use CreateFont api finction and send WM_SETFONT message ? Or is there any other easy and safe ways to do this ?. Thanks in advance.
      Note : This window is created by CreateWindowEx function, not by GUICreate function. 
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.