I'm trying to load some youtube videos to a AxShockwave control in VB.net but so far it does not load
I've tryed to use rlVideo.Movie = "..." and rlVideo.LoadMovie(0,"...") (rlVideo being the AxShockwave control)
And yes the url is http://youtube.com/v/xxxxxx
I can't set the movie property in the designer because It's dinamically loaded onto the app any ideas?
I've removed the Control from the designer and create a new instace of the control every time I change the video
Of course I delete the previous instance of the Control
For example
Dim prevControl() As Control = Me.Controls.Find("flashVideoPlayer", True)
Try
tbVideo.Controls.Remove(prevControl(0))
Catch ex As Exception
End Try
Dim video As AxShockwaveFlash = New AxShockwaveFlash()
video.Name = "flashVideoPlayer"
Dim strMovie As String = CType(ComboBox1.SelectedItem, ComboBoxItem).Value.ToString.Replace("watch?v=", "v/")
video.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
video.Location = New Point(0, 27)
video.Size = New Size(tbVideo.Width, tbVideo.Height - 27)
tbVideo.Controls.Add(video)
video.LoadMovie(0, strMovie)
Related
I am trying to release the file lock on some images so i can move them into an archive folder.
The program loops through the images and adds pictureboxes to a flowlayout panel. After the operation is completed i dispose of the flowlayout panel, and then archive the files.
It is my understanding that disposing the panel will dispose of the picture boxes inside of it, however when i try the move operation i get a IOException Access Denied.
Code:
Dim ImagesInFolder As New List(Of Image)()
For Each JPEGImages As String In Directory.GetFiles(ExportDir.FullName, "*.jpg")
ImagesInFolder.Add(Image.FromFile(JPEGImages))
Next
Dim x As Integer = 0
Dim y As Integer = 0
For i As Integer = 0 To ImagesInFolder.Count - 1
Dim _image As New PictureBox()
_image.Location = New Point(x, y)
x += 50
_image.Image = ImagesInFolder(i)
_image.Size = New Size(50, 50)
_image.SizeMode = PictureBoxSizeMode.StretchImage
FlowLayoutPanel1.Controls.Add(_image)
Next
Later in the application:
FlowLayoutPanel1.Dispose()
Directory.Move(CurrentFolder, ArchiveFolder)
The problem is Because of loading image using Image.FromFile(file).
When you load image using Image.FromFile(file) the file will be locked.
To avoid locking file you can load your images using Image.FromStream.
Code:
Dim filePath = "path to your image file"
Dim contentBytes = File.ReadAllBytes(filePath)
Dim memoryStream As New MemoryStream(contentBytes)
Dim image= Image.FromStream(memoryStream)
YourPictureBox.Image = image
Here is the code:
Private WithEvents modderInfoGroup As New NSGroupBox
modderInfoGroup.Text = ""
modderInfoGroup.Location = New Point(3, 3)
modderInfoGroup.Size = New Size(512, 424)
modderInfoGroup.DrawSeperator = True
modderInfoGroup.Title = currentModder
modderInfoGroup.SubTitle = "Modder Information"
modderInfoGroup.Anchor = AnchorStyles.Top Or AnchorStyles.Left Or AnchorStyles.Bottom Or AnchorStyles.Right
myTabPage.Controls.Add(modderInfoGroup)
myTabPage.Name = "modder" & modderNumber
When creating the Control dynamically is defaults to Top and Left but i want it to set it to all 4 edges. Anyone got a fix?
This is a Windows Form(WinForm) in Visual Studio 2015.
If you are trying to fill the space of the container control, then the property you want to set is the Dock property:
modderInfoGroup.Dock = DockStyle.Fill
The anchor property was working, but the initial size didn't match the size of the client area of the parent control. To make that work, you would have to set the size to that client size:
modderInfoGroup.Location = Point.Empty
modderInfoGroup.Size = MyTabPage.ClientSize
from a question here : Question
Dim forms As Collections.Generic.IEnumerable(Of frmMain) = Application.OpenForms.OfType(Of frmMain).Where(Function(frm) frm.Visible)
For Each f As Form In forms
f.Location = New Point(0, 0) ' set coordinate as needed
Next
UPDATE the above code gets all visible forms but since its generic, all the visible forms appear on one place..
let's say, I have 3 markers.. named camera1 camera2 camera3..
on Form_Load I will click those 3 markers, and a supposed video feed will appear (in this case, each with a new instance of form2)
this is my code in which does what I want, only problem is, I want it to be reusable for the future of dynamically adding more rather than this, predefined.
Dim f2c1 As New Form2
Dim f2c2 As New Form2
Dim f2c3 As New Form2
If f2c1.Visible = True Then
f2c1.Location = camera1.LocalPosition + New Point(20, -240)
End If
If f2c2.Visible = True Then
f2c2.Location = camera2.LocalPosition + New Point(20, -240)
End If
If f2c3.Visible = True Then
f2c3.Location = camera3.LocalPosition + New Point(20, -240)
End If
that code, is this.. If I click the marker, drag the map. video feed form2 stays with them.
I want it on a function or sub that will do this..
'Public Sub when I drag the map()
'every form visible
'will follow -- let's say, will follow what marker clicked them
ask me if you need anything.. thanks
I did some workaround
Dim mList As New List(Of String)
marker.ToolTipMode = MarkerTooltipMode.Always 'as an indetifier of each markers as
marker.ToolTipText = dtrow("MarkerName") 'I have added it to a for each
Try
For Each m In mList 'get items from the list
If item.ToolTipText = m Then 'check same name
Dim f As New Form2
With f
If .Visible = True Then
.Hide()
Else
.Show()
Dim p As New Point
p = item.LocalPosition + New Point(20, -240)
.Location = p 'after I click form will appear right next to them
.Text = m
End If
End With
Exit Sub
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
this is still not the ideal thing that is on my mind, but this practically answers my question for the moment.
When using the axAcroPdfLib.AxAcroPDF control in my Windows Forms application, I'm not able to reload the same image. The image is initially loaded with the LoadFile() method.
Upon using the LoadFile() method again on the same path AFTER saving changes to the PDF, the control becomes blank (no PDF shown).
If I set the src property of the control to the path, I get a message saying the file does not begin with '%PDF-'. But it does. I opened it with Word and it clearly begins with %PDF-. It's not corrupt or locked either.
I've even tried closing, disposing, or setting it to Nothing, and then completely re-instantiating it as I did the first time it's loaded - no effect. The window closes and shows with the control blank.
Loading a different file via the above methods has the same effect - blank.
Using Windows 7 64-bit, VS 2010, VB.NET.
The code is below. For right now, I'm just trying to draw a simple line on it.
Private Sub _btnBarCode_Click(ByVal sender As Object, ByVal e As EventArgs) Handles _btnBarCode.Click
Dim pdfReader As iTextSharp.text.pdf.PdfReader = Nothing
Try
pdfReader = New iTextSharp.text.pdf.PdfReader(File.ReadAllBytes(_path))
Using fs As New FileStream(_path, FileMode.Create, FileAccess.Write)
Using pdfStamper = New iTextSharp.text.pdf.PdfStamper(pdfReader, fs)
Dim pdfPage As iTextSharp.text.pdf.PdfContentByte = pdfStamper.GetOverContent(1)
Using barCodeForm As New FBarCode
barCodeForm.Barcode = _barCode
If (barCodeForm.ShowDialog(Me) = DialogResult.OK) Then
Dim screenBarCode As Point = barCodeForm.Location
Dim clientBarCode As Point = Point.op_Subtraction(PointToClient(screenBarCode), New Point(0, 50)) '_pdfControl.Location '_imgView.Location
clientBarCode = New Point(10, 50)
Dim barcodeImg As New Bitmap(200, 50)
Using gc As Graphics = Graphics.FromImage(barcodeImg)
gc.DrawLine(Pens.Red, New Point(10, 10), New Point(20, 20))
'barCodeForm._barCode.DrawBarCode(gc, clientBarCode)
End Using
Dim convert As ImageConverter = New ImageConverter()
Dim bmpBytes As Byte() = DirectCast(convert.ConvertTo(barcodeImg, GetType(Byte())), Byte())
Dim thisImage As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(bmpBytes)
thisImage.SetAbsolutePosition(clientBarCode.X, clientBarCode.Y)
thisImage.SetDpi(72, 72)
pdfPage.AddImage(thisImage)
rdrAdobePdf.LoadFile(_path) 'Blank pdf
'rdrAdobePdf.src = _path '"Does not begin with '%PDF-' (even though it does)
'Me.Close()
'_myParent.ResetPdfViewer()
'ReloadPdfViewer(Me.Barcode)
End If
End Using
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "An error occurred.")
Return
Finally
If Not pdfReader Is Nothing Then pdfReader.Close()
End Try
End Sub
Any ideas what could be the problem here?
Problem was solved by getting the reloading code out of that click method. Putting it in another click method solved the problem - not sure why. The code I used just ran .LoadFile, then Form.Show() and Form.Activate().
I ma new Learner. I am creating an application in Visual Basic and I need help to load dynamically data from database into my tabpages.
I want TabPages names to be "Category Names" (From Tbl_Category) and in each Tabpages i want buttons to be created and these buttons are each record from "Tbl_ItemDetails.
button name will be from "ItemSKU" column. and button image will be from "Item_Image" column.
i have searched a lot but couldn't do it. Please help me on this.
if you guys know any other way of doing it (without tabpages) please share. Thanks!
here are some codes which i tried.
1. image code is not working.
2. if i have more items on tabpages it does not show any scroll bar. so i can see only few button not all.
![enter image description here][1]
Private Sub AddProductsToTabbedPanel()
Dim i As Integer = 1
For Each tp As TabPage In TabControl1.TabPages
Dim filteredProduct As ObjectQuery(Of Tbl_ItemDetails) = New ObjectQuery(Of Tbl_ItemDetails)(("SELECT VALUE P FROM Tbl_ItemDetails AS P WHERE P.CatID = " + i.ToString), cse)
Dim flp As FlowLayoutPanel = New FlowLayoutPanel
flp.Dock = DockStyle.Fill
For Each tprod As Tbl_ItemDetails In filteredProduct
Dim b As Button = New Button
b.Size = New Size(100, 100)
b.Text = tprod.ItemSKU
' ''how can i get image on button. bellow code is not working
'b.BackgroundImage = tprod.Item_Image
'b.Image = tprod.Item_Image
b.Tag = tprod
AddHandler b.Click, AddressOf Me.UpdateProductList
flp.Controls.Add(b)
Next
tp.Controls.Add(flp)
i = (i + 1)
Next
End Sub
1: How the Image will work
a) If you only provide a pathname to an existing file
button.Image = New Bitmap("C:\temp\Info.bmp")
b) If you get a bytearray from your DB containing the bitmap
Dim byteArrayFromDB As Byte()
Dim memStream As System.IO.MemoryStream
Dim img As Image
memStream = New System.IO.MemoryStream(byteArrayFromDB)
img = Image.FromStream(memStream)
2: Scrollable FlowLayoutPanel
flp.AutoScroll = True