I want to be able to change the image of an image shape by clicking on an button in my userform.
In the internet I found the function UserPicture, but the image simply stays the same.
Private Sub ChangeImage_Click()
ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Visible = True
ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Fill.UserPicture ("D:\User\Desktop\SolutionWrong.jpg")
End Sub
Private Sub HideImage_Click()
ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Visible = False
End Sub
When I click on the HideImage button, the shape becomes invisible, so my selection of the shape appears to be right.
I also tried
ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Fill.UserPicture "D:\User\SolutionWrong.jpg"
but this does not work either
Edit
Of course I checked the path to the new image, it's correct.
Siddharth Rout found the solution
I created the image by selecting picture from the insert menu, but it have to be created via Insert => Rectangular shape (no border). Now it can easily be accessed by using ActivePresentation.Slides("Slide1").Shapes("SolutionA_Image").Fill.UserPicture ("D:\User\SolutionWrong.jpg")
Related
I'm trying to code it so that i can create a picture box from a method in a class. However when my picture box is drawn it doesn't display any image, it only shows a white square of the specified dimensions in the specified location.
Here is the code which i am using to create said picture box:
Public Sub DrawEnemy(ByRef formInstance)
Dim enemypic As New PictureBox
enemypic.Image = Image.FromFile("C:\fboi1\Enemy.Png")
enemypic.Width = 64
enemypic.Height = 64
enemypic.Location = New Point(Me.EnemyPosX, EnemyPosY)
enemypic.Visible = True
formInstance.Controls.Add(enemypic)
End Sub
And here is where i am calling the method from:
Dim Enemy1 As New computerControlled(1, 1)
Enemy1.DrawEnemy(Me)
Please add the following code in your DrawEnemy() method:
enemypic.SizeMode = PictureBoxSizeMode.StretchImage
When i drag the console window suddenly the white box turns into the image i wanted.
Aha! This means the code is not causing the form to be repainted. We can trigger that by calling the Invalidate() function.
Public Sub DrawEnemy(formInstance As Form)
Dim enemypic As New PictureBox
enemypic.Image = Image.FromFile("C:\fboi1\Enemy.Png")
enemypic.Width = 64
enemypic.Height = 64
enemypic.Location = New Point(Me.EnemyPosX, EnemyPosY)
enemypic.Visible = True
formInstance.Controls.Add(enemypic)
formInstance.Invalidate()
End Sub
If you're calling this several times in a loop, you would instead handle this after the loop, where you also block repainting (to prevent flickering) until the loop is finished.
form.SuspendLayout()
For Each enemy In ...
'...
DrawEnemy(form)
Next
form.Invalidate()
form.ResumeLayout()
It's also possible you only need to Invalidate() the picturebox.
In an access form, I try to make a list field visible when the fokus is on another textfield in which new data should be filled in. The backround is that one should know the last data inputs to create a new one.
As a first step I tried to make the list (liste91) visible when clicking on a button, but I failed using the following code.
Private Sub Befehl97_Click()
Forms!projects!liste91.SetFocus
Me.liste91.visible = True
End Sub
I get error in the line Me.list91
what is wrong?
thank you for your help!
You can't set focus to something not yet visible. Just switch the order:
Private Sub Befehl97_Click()
Me.liste91.visible = True
Me.liste91.SetFocus
End Sub
I have copied a webcam image capture tutorial from the web. It works OK. I want to watch a changing scene and save a captured image to disk when I push a button on the form. The button push is detected, but I am unable to save an image. Here is the main code. I have tried two save methods but neither works. What am I missing?
Sub ProcessFrameAndUpdateGUI(sender As Object, arg As EventArgs)
imgOriginal = capWebcam.QueryFrame() 'get the next frame from the webcam
If (imgOriginal Is Nothing) Then 'if we didn't get a frame
Return
End If
If btnStackPressed = True Then 'is button pressed?
btnStackPressed = False 'clear the button
imgOriginal = capWebcam.QueryFrame() 'get the next frame from the webcam
End If
ibOriginal.Image = imgOriginal 'display the current image in the imagebox
cvSaveImage("C:\imagesaved.bmp", imgOriginal) 'save current image as bmp
imgOriginal.Save("C:/MyPic.jpg") 'save current image as jpg
End Sub
This is sort of an answer. I don't understand the underlying facts. I saw a post on another blog that said the failure to save might be due to a Windows security issue and recommended saving to another disk. This closes the issue for me.
imgOriginal.Save("C:\imgsaved.jpg") 'This doesn't work.
imgOriginal.Save("C:\Photo_temp\imgsaved.jpg") 'This works.
imgOriginal.Save("G:\Photo_temp\imgsaved.jpg") 'This works.
imgOriginal.Save("G:\imgsaved.jpg") 'This works.
I want to draw error icon in all the cell which are validated at a time in datageid in devExpres.
I was draw a error icon in cell but there is some problem,
1.Color of the cell is overwritted on the error icon.
2.Text of grid and error icon both are mixed that why text is not display excat.
I want perfect example. Is any one have solution?
This can be achieved using the CustomDrawEventHandler as shown below
Private Sub CustomDrawEventHandler(. ByVal .. As )
If IsError(...) Then
e.EditViewInfo.ErrorIconText = "IsNull"
e.EditViewInfo.ShowErrorIcon = True
e.EditViewInfo.FillBackground = True
e.EditViewInfo.ErrorIcon = DXErrorProvider.GetErrorIconInternal(ErrorType.Critical)
e.EditViewInfo.CalcViewInfo(e.Graphics)
End If
End Sub
For more info check this DevExpress Kb article:
http://www.devexpress.com/Support/Center/Example/Details/E1933
I'm writing a simple app that's going to have a tiny form sitting in one corner of the screen, updating itself.
I'd really love for that form to be transparent and to have the transparency be user-configurable.
Is there any easy way to achieve this?
You could try using the Opacity property of the Form. Here's the relevant snippet from the MSDN page:
private Sub CreateMyOpaqueForm()
' Create a new form.
Dim form2 As New Form()
' Set the text displayed in the caption.
form2.Text = "My Form"
' Set the opacity to 75%.
form2.Opacity = 0.75
' Size the form to be 300 pixels in height and width.
form2.Size = New Size(300, 300)
' Display the form in the center of the screen.
form2.StartPosition = FormStartPosition.CenterScreen
' Display the form as a modal dialog box.
form2.ShowDialog()
End Sub
Set Form.Opacity = 0.0 on page load
I set something like what your talking about on an app about a year ago. Using a While loop with a small Sleep you can setup a nice fading effect.
I don't know exactly what you mean by transparent, but if you use WPF you can set AllowTransparency = True on your form and then remove the form's style/border and then set the background to a color that has a zero alpha channel. Then, you can draw on the form all you want and the background will be see-through and the other stuff will be fully visible. Additionally, you could set the background to a low-opacity layer so you can half see through the form.
You can set the Form.Opacity property. It should do what you want.