I was using the following code to enter an image url at TextBox1 and display it in PictureBox1.Everything worked.
But suddenly the displayed image quality is lower than the original link. I've tried PictureBox1.Load(TextBox1.Text) and changing SizeMode still the same result.
Local images are displayed normally.
Imports System.Net
Public Class Form1
Dim client As WebClient
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
client = New WebClient()
Dim ImageInBytes() As Byte = client.DownloadData(TextBox1.Text)
Dim ImageStream As New IO.MemoryStream(ImageInBytes)
PictureBox1.Image = New System.Drawing.Bitmap(ImageStream)
End Sub
End Class
I'm using
Microsoft Visual Studio 2010 Version 10.0.30319.1 RTMRel,
Microsoft .NET Framework Version 4.0.30319 RTMRel
How can I get the image to display without the quality loss?
My guess is that the website you are linking to provides a low quality image when hotlinking to it. This is common practice so that users visit the actual site. And it doesn't use so much bandwidth.
If this is the case then there is nothing you can do about it.
Actually it was problem with my internet connection,there is too much packetloss which affects the image quality.
I tested the code with another connection and it worked.
Related
I've went to publish my first vb.net windows form and was surprised the format I meticulously combed over became all skewed after publishing.
Why did the controls change to older style '3d' and the overall ratio of the form stretched in the horizontal? My calendar date pickers also changed format.
Is there a way to make the published form look exactly like the release version, down to the pixel?
For anyone experiencing appearance issues, I can share that in my case, this seems to be related to my project starting first in visual studio 2019 and then I changed over VS 2022. I am happy to report that as soon as I copied my code over to a clean project in 2022, everything works great! The published copy looks completely identical to the release/debug version and I didn’t need to play with any settings in the Main Sub!
Thank you djv for working with me!
You can control visual styles before you create your UI thread, but VB.Net will enable visual styles for you in Sub Main, which is inaccessible to you! You can get around this by creating your own Sub Main, but you also need to choose this new method as the entry point to your application.
' in a new class file, I called Program.vb
Public Module Program
<STAThread>
Public Sub Main()
Application.VisualStyleState = VisualStyles.VisualStyleState.NonClientAreaEnabled
Application.Run(New Form1())
End Sub
End Module
In the project properties, click Startup object, choose Program
My Form1 has two TextBoxes. Here's the code
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TextBox1.BorderStyle = BorderStyle.FixedSingle
Me.TextBox2.BorderStyle = BorderStyle.Fixed3D
Me.FormBorderStyle = FormBorderStyle.FixedSingle
End Sub
End Class
and here is the result
Note with Application.EnableVisualStyles() instead, I'm getting all single borders.
Hope some setting of visual styles does the trick
I've just set up VS 2019 and I'm trying to use the WebBrowser in VB.net. I followed a YouTube video, created the form, browser, etc, but when I 'start' the code the Browser screen flashes on for half a second then drops.
There are no errors shown but I get 'The program '[7804] WebBrowser_2.exe' has exited with code 0 (0x0).'
and ideas please?
I've cut it down to the minumum, to go to one web site...
form1.vb
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("www.bbc.co.uk")
End Sub
End Class
I've also tried a few different web sites, and setting txtURL.Text then using:
WebBrowser1.Navigate(txtURL.Text)
WebBrowser1.Navigate(New Uri(txtURL.Text))
Nothing's working yet.
The problem is happening on 2 of the company's computers and on a client computer, but we can not identify a pattern.
I was able to reproduce the error using a simple program that only opens an OpenFileDialog. The program must be run by the generated executable itself (NOT by Debug) and it is still running in the background even after closing. Below is the code of the program, along with a link to download the project and a video demonstrating the error.
Code:
Public Class Form1
Private ofdAbrir As Windows.Forms.OpenFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ofdAbrir = New Windows.Forms.OpenFileDialog
ofdAbrir.ShowDialog()
ofdAbrir.Dispose()
ofdAbrir = Nothing
End Sub
End Class
As you can see in the code above, I only have one form, so it is not the case that some form remains open and it is also not related to threads running since none is created.
To reproduce the problem, click on Button1, cancel the OpenFileDialog and try to close the form (clicking on X). The form apparently will close, but you will see at task manager that it still running. The big mystery is that this problem does not happens in all computers.
Video: https://drive.google.com/open?id=1sfdVUGQlwYNCQkl1Ht-cJSOb4433sqnT
Project: https://drive.google.com/open?id=1d4oJYUjaaZ9xnRj4CX3HXOQPqwMZmE0V
I couldn't reproduce the problem, but how about using this method:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Using ofdAbrir As New Windows.Forms.OpenFileDialog
ofdAbrir.ShowDialog()
MsgBox(ofdAbrir.FileName)
End Using
End Sub
I've seen the video u posted...It is not your application that is running rather it is the vsHost.exe that is running :)...The problem shouldn't occur if u run the app outside visual studio.
If the problem is still there,just disable Enable Diagnostic Tools while debugging from Tools > Options > Debugging > Uncheck Enable Diagnostic Tools while debugging
Also u can disable Visual Studio hosting service from Project > Project Properties > Uncheck Enable the Visual Studio hosting service
In my application I have only a webbrowser and a few timers, but if the webbrowser is loading, it uses 50% of the CPU and afer 5 minutes around of 120k RAM. What can I do?
My code:
Public Sub work()
WebBrowser1.Navigate("Site")
tim.Start()
End Sub
Public Sub work2()
WebBrowser1.Document.GetElementFromPoint(point).InvokeMember("click")
tim2.Start()
tim.Stop()
End Sub
Dim point As New Point(800, 30)
Dim WithEvents tim As New Timer
Dim WithEvents tim2 As New Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tim.Interval = 6000
tim2.Interval = 6000
work()
End Sub
Private Sub tim_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tim.Tick
work2()
End Sub
Private Sub tim2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tim2.Tick
work()
End Sub
Long, Time ago since this was asked, but as i write this i have been working on my own project to create a YouTube app from Vb.net and, for a few weeks i have been stuck on trying to figure out why the IE Wrapper Web Control was taking so much of my CPU when Processing and Playing Videos, and from a lack of finding any good help with my problem that solved anything, i eventually researched enough and found a solution to my problem which were the use of Feature Registry Entries that i added for my program to check and add as needed on startup of the program, and the two i found which were a lot of help were both FEATURE_BROWSER_EMULATION and FEATURE_GPU_RENDERING, By Default i believe and could be wrong, the vb.net wrapper uses IE7 but if you change it to the latest version for your program in there it will make it more secure and improve performance, than you can turn on the gpu rendering with a DWORD subkey of 1 with the name of your program and it will make the gpu handle some of the workload also greatly improving the speed. using these made the webcontrol go from utilizing around 70-80% CPU during videos down to low of 3% and high of 20% CPU utilization, good for future reference, also learn more about the registry features here https://msdn.microsoft.com/en-us/library/ee330733(v=vs.85).aspx
120k sounds very reasonable if there is some heavy web page loaded in the control. E.g. if you save the main page of microsoft.com from within IE in a mht format (complete archive), it is almost 1MB large. The processor usage will most probably depend on what the click handler does - is there any heavy script attached to the element?
I have been searching all over for an answer to this, and I'm figuring there is no way to do it, but I thought I'd ask.
I'm looking to make a VB.net app that gets and displays the artist and title of a song playing in Windows Media Player. I'm not looking to embed the player in my app, just pull data from the already existing window.
Most of the stuff I find on how to do this is old or related to embedding WMP. I'm looking to do it in with MWP12. I've also seen references to using AxWindowsMediaPlayer.currentMedia Property, but that doesn't seem to work anymore. I used to be able to pull the data from the Registry, but it seems Microsoft took that away.
I've tried sooooo much other code, but this is currently what I have. I'm at my wits end.
Imports WMPLib
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wmp As WindowsMediaPlayer = New WindowsMediaPlayer
Dim playlist As IWMPPlaylist = wmp.currentMedia.???????(????).Item(?)
Label1.Text = playlist.getItemInfo("Title")
End Sub
End Class
No idea where to go here, but thanks for any help.