Picture images not clearing

Post

Posted
Rating:
#1 (In Topic #1130)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
Hi Everyone

Hope someone can help me I seem to have a slight problem on my hands.

as you are all know I am writing a EPoS application in Gambas. so when I Press Sub total I get my Tender Menu (see below)

<IMG src="https://www.algpos.co.uk/gambas/NPoS_1.png"> </IMG>

so far this is all good. When the user Press F1 (Cash) they would see Image 2

<IMG src="https://www.algpos.co.uk/gambas/NPoS_2.png"> </IMG>

BUT if a user cancels this menu some of the images are not clearing (as you can see in image 3)

<IMG src="https://www.algpos.co.uk/gambas/NPoS_3.png"> </IMG>

I am using Picture1.picture = null (i did try the Picture.clear but Gambas was not happy with this even though the Help saying it clears the image)

Does anyone have any ideas what I would need to do so the images clear fully and the first menu is displayed again

Thanks for any advise anyone can offer men

Kind Regards

Andy
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
Did you refresh?

Code (gambas)

  1.   Picture1.Picture = Null
  2.   Picture1.Refresh
  3.  

Without seeing all the code it's hard to say.
Making .Picture = Null should work.
maybe your code is re-adding the picture somewhere?
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
I have just tried this and it works OK. Does Picture1 refer to a PictureBox?
Online now: No Back to the top

Post

Posted
Rating:
#4
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

cogier said

I have just tried this and it works OK. Does Picture1 refer to a PictureBox?

Yes sorry picture1 does refer to a picturebox.

I'll upload the code I'm using to clear the images when I'm in the office at 3pm (UK time today)
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
Here is some code you can try in a Graphical application that works OK at this end.

Code (gambas)

  1. PictureBox1 As PictureBox
  2. HBox1 As HBox
  3. ToggleButton1 As ToggleButton
  4.  
  5. Public Sub Form_Open()
  6.  
  7.   With Me
  8.     .Height = 250
  9.     .Width = 200
  10.     .Arrangement = Arrange.Vertical
  11.     .Padding = 5
  12.  
  13.   With PictureBox1 = New PictureBox(Me) As "PictureBox1"
  14.     .Expand = True
  15.     .Mode = PictureBox.Contain
  16.     .Picture = Picture["icon:/256/access"]
  17.  
  18.   With HBox1 = New HBox(Me)
  19.     .Width = 200
  20.     .Height = 28
  21.  
  22.   With ToggleButton1 = New ToggleButton(HBox1) As "ToggleButton1"
  23.     .Height = 28
  24.     .Width = 200
  25.     .Text = "&Delete image"
  26.  
  27.  
  28. Public Sub ToggleButton1_Click()
  29.  
  30.   If ToggleButton1.Value = True Then
  31.     PictureBox1.Picture = Null                ''Works fine
  32.     ToggleButton1.Text = "&Add picture"
  33.   Else
  34.     PictureBox1.Picture = Picture["icon:/256/access"]
  35.     ToggleButton1.Text = "&Delete image"
  36.  
  37.  
Online now: No Back to the top

Post

Posted
Rating:
#6
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

AndyGable said

cogier said

I have just tried this and it works OK. Does Picture1 refer to a PictureBox?
Yes sorry picture1 does refer to a picturebox.
I'll upload the code I'm using to clear the images when I'm in the office at 3pm (UK time today)

Apologies for the delay in sending this information I was sided tracked on another project

Below is the code i use to clear the labels / Pictures

Code (gambas)

  1. Public Sub ClearMenu()
  2.  
  3.     Global.MenuControl = ""
  4.  
  5.     With frmbackground
  6.         .labFunctionKeyF1.Caption = Null
  7.         .PicFunctionF1.Picture = Null
  8.         .PicFunctionF1.Refresh
  9.         .labFunctionKeyF1.Font.Size = 11
  10.  
  11.         .labFunctionKeyF2.Caption = Null
  12.         .PicFunctionF2.Picture = Null
  13.         .PicFunctionF2.Refresh
  14.         .labFunctionKeyF2.Font.Size = 11
  15.  
  16.         .labFunctionKeyF3.Caption = Null
  17.         .PicFunctionF3.Picture = Null
  18.         .PicFunctionF3.Refresh
  19.         .labFunctionKeyF3.Font.Size = 11
  20.  
  21.         .labFunctionKeyF4.Caption = Null
  22.         .PicFunctionF4.Picture = Null
  23.         .PicFunctionF4.Refresh
  24.         .labFunctionKeyF4.Font.Size = 11
  25.  
  26.         .labFunctionKeyF5.Caption = Null
  27.         .PicFunctionF5.Picture = Null
  28.         .PicFunctionF5.Refresh
  29.         .labFunctionKeyF5.Font.Size = 11
  30.  
  31.         .labFunctionKeyF6.Caption = Null
  32.         .PicFunctionF6.Picture = Null
  33.         .PicFunctionF6.Refresh
  34.         .labFunctionKeyF6.Font.Size = 11
  35.  
  36.         .labFunctionKeyF7.Caption = Null
  37.         .PicFunctionF7.Picture = Null
  38.         .PicFunctionF7.Refresh
  39.         .labFunctionKeyF7.Font.Size = 11
  40.  
  41.         .labFunctionKeyF8.Caption = Null
  42.         .PicFunctionF8.Picture = Null
  43.         .PicFunctionF8.Refresh
  44.         .labFunctionKeyF8.Font.Size = 11
  45.     End With

This is the code I am using to load the images in to the pictureboxes

Code (gambas)

  1. Public Sub GetQuickTenderDetails()
  2.  
  3.     Dim QuickTenderResult As Result
  4.     Dim $Query As String = ""
  5.  
  6.     $Query &= "Select "
  7.     $Query &= "keydescription, "
  8.     $Query &= "keyvalue, "
  9.     $Query &= "CAST(keyimage AS CHAR) AS keyimage "    
  10.     $Query &= "from quicktender "
  11.     $Query &= "where keyactive='1' "
  12.     $Query &= "order by keynumber ASC;"
  13.  
  14.     Dim I As Integer
  15.  
  16.     For I = 0 To 6
  17.         Global.QuickTenderName[I] = Null
  18.         Global.QuicktenderValue[I] = Null
  19.     Next
  20.  
  21.     ' ConnectToDatabase
  22.     QuickTenderResult = Global.$DBCon.Exec($Query)
  23.  
  24.     If QuickTenderResult.Available = True Then
  25.  
  26.         For I = 0 To 6
  27.             Global.QuickTenderName[I] = QuickTenderResult!keydescription
  28.             Global.QuicktenderValue[I] = QuickTenderResult!keyvalue
  29.             Global.QuickTenderImage[I] = QuickTenderResult!keyimage
  30.             QuickTenderResult.MoveNext
  31.         Next
  32.     End If
  33.  
  34.     ' Display Quick Tender options on the menu
  35.  
  36.     MenuDisplay.ClearMenu
  37.  
  38.     Global.MenuControl = "QuickTenderMenu"
  39.  
  40.     With frmbackground
  41.         If Global.QuickTenderName[0] <> "" Then
  42.             .labFunctionKeyF1.Caption = Global.QuickTenderName[0]
  43.             .labFunctionKeyF1.Font.Size = 25
  44.            
  45.             If Global.QuickTenderImage[0] <> "" Then
  46.                 Global.ImageFromString(Global.QuickTenderImage[0], frmbackground.PicFunctionF1)
  47.             Else
  48.                 frmbackground.PicFunctionF1.Picture = Null
  49.             End If
  50.         End If
  51.  
  52.         If Global.QuickTenderName[1] <> "" Then
  53.             .labFunctionKeyF2.Caption = Global.QuickTenderName[1]
  54.             .labFunctionKeyF2.Font.Size = 25
  55.  
  56.             If Global.QuickTenderImage[1] <> "" Then
  57.                 Global.ImageFromString(Global.QuickTenderImage[1], frmbackground.PicFunctionF2)
  58.             Else
  59.                 frmbackground.PicFunctionF2.Picture = Null
  60.             End If
  61.         End If
  62.            
  63.         If Global.QuickTenderName[2] <> "" Then
  64.             .labFunctionKeyF3.Caption = Global.QuickTenderName[2]
  65.             .labFunctionKeyF3.Font.Size = 25
  66.  
  67.             If Global.QuickTenderImage[2] <> "" Then
  68.                 Global.ImageFromString(Global.QuickTenderImage[2], frmbackground.PicFunctionF3)
  69.             Else
  70.                 frmbackground.PicFunctionF3.Picture = Null
  71.             End If
  72.  
  73.         End If
  74.            
  75.         If Global.QuickTenderName[3] <> "" Then
  76.             .labFunctionKeyF4.Caption = Global.QuickTenderName[3]
  77.             .labFunctionKeyF4.Font.Size = 25
  78.            
  79.             If Global.QuickTenderImage[3] <> "" Then
  80.                 Global.ImageFromString(Global.QuickTenderImage[3], frmbackground.PicFunctionF4)
  81.             Else
  82.                 frmbackground.PicFunctionF4.Picture = Null
  83.             End If
  84.            
  85.         End If
  86.        
  87.         If Global.QuickTenderName[4] <> "" Then
  88.             .labFunctionKeyF5.Caption = Global.QuickTenderName[4]
  89.             .labFunctionKeyF5.Font.Size = 25
  90.            
  91.             If Global.QuickTenderImage[4] <> "" Then
  92.                 Global.ImageFromString(Global.QuickTenderImage[4], frmbackground.PicFunctionF5)
  93.             Else
  94.                 frmbackground.PicFunctionF5.Picture = Null
  95.             End If
  96.            
  97.         End If
  98.        
  99.         If Global.QuickTenderName[5] <> "" Then
  100.             .labFunctionKeyF6.Caption = Global.QuickTenderName[5]
  101.             .labFunctionKeyF6.Font.Size = 25
  102.            
  103.             If Global.QuickTenderImage[5] <> "" Then
  104.                 Global.ImageFromString(Global.QuickTenderImage[5], frmbackground.PicFunctionF6)
  105.             Else
  106.                 frmbackground.PicFunctionF5.Picture = Null
  107.             End If
  108.            
  109.         End If
  110.        
  111.         If Global.QuickTenderName[6] <> "" Then
  112.             .labFunctionKeyF7.Caption = Global.QuickTenderName[6]
  113.             .labFunctionKeyF7.Font.Size = 25
  114.            
  115.             If Global.QuickTenderImage[6] <> "" Then
  116.                 Global.ImageFromString(Global.QuickTenderImage[6], frmbackground.PicFunctionF7)
  117.             Else
  118.                 frmbackground.PicFunctionF7.Picture = Null
  119.             End If
  120.            
  121.         End If
  122.  
  123.         .labFunctionKeyF8.Caption = "Cancel"
  124.         Global.pc = Picture.FromString(File.Load(Application.Path &/ "fkeys/cancel.bmp"))
  125.         .PicFunctionF8.Picture = Global.pc
  126.         .labFunctionKeyF8.Font.Size = 25
  127.     End With

And just incase it is needed here is the code I am using to load the acual image into the picturebox

Code (gambas)

  1. Public Function ImageFromString(ImageString As String, ImageFile As PictureBox)
  2.     If ImageString <> "" Then
  3.         ImageFile.Image = Image.FromString(FromBase64(ImageString))  
  4.     End If

I know this could be better written and optimized but at the moment I just want to sort the issues of the images not clearing.
Online now: No Back to the top
1 guest and 0 members have just viewed this.