Changing Form Size Via Screen Resolution - vb.net

I've got a checkbox which resizes my form to reveal other settings, but it looks completely different on my display to my friends display. He is able to see way more than on my screen. He has a dual monitor desktop whereas I run on a laptop. I use this code -
Code:
Private Sub HuraCheckBox1_CheckedChanged_1(sender As Object) Handles HuraCheckBox1.CheckedChanged
If HuraCheckBox1.Checked = True Then Me.Size = New Size(1145, 642) Else Me.Size = New Size(409, 642)
End Sub
If you need a photo of what I mean, I can provide one :)
Any help would be appreciated, thanks!

Related

access make list field visible when clicking Button

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

emgu cv save image to file in vb

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.

Preserve swf transparency on forms vb

Is there any way to include a .swf on my form and also preserve its original transparency? That is, so you can see any controls 'behind it' (obviously in the transparent areas). It's looking unlikely as I understand vb can't control the flash activex control (and hence the control's rendered background?) but wondering whether there's any workarounds?
relevant code thusfar:
Dim flash1 As New AxShockwaveFlash
.....
flash1.Location = New System.Drawing.Point(300, 23)
Me.Controls.Add(flash1)
flash1.Movie = "C:\Users\Steve\Scripts\Projects\CPWizBiz\Assets\Test SWFs\Artwork4.swf"
flash1.Size = New System.Drawing.Size(192, 400)
flash1.Play()
In the absence of any other solutions, here's what I did:
Basically, I just created a new form with a transparetn background. You then overlay this onto your main form (you can link any forms to move and resize with each other etc). Then you set the flash background to match the form transparency key and you're done. Brief, illustrative code:
Public Sub MarqueeFlash_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.TransparencyKey = Color.FromArgb(1, 4, 3)
Me.BackColor = Color.FromArgb(1, 4, 3)
dim FlashCtrl as As New AxShockwaveFlash
Controls.Add(FlashCtrl)
With FlashCtrl
.BGColor = Me.BackColor.R.ToString("X2") & Me.BackColor.G.ToString("X2") & Me.BackColor.B.ToString("X2")
.Movie = IndexedDR(0).Item("File")
.Location = New Point(10,10)
End With
FlashCtrl.Play()
FlashCtrl.Size = New Size(400,300)
end sub

DataGridView bound to DataTable is not showing

I am trying to show a DataGridView in a form that is bound to a DataTable, but it's not showing up. I was doing this using a C1TrueDBGrid and that was working...I decided to switch to using a DataGridView due to some complications with the TrueDBGrid. Can anyone help me figure out why nothing is showing?
In the form I declare these:
Public binData As DataSet
Friend WithEvents dgvData As System.Windows.Forms.DataGridView
The binData is filled with tables created via a separate calculation routine. Then this is the form load event:
'create a tab page and add data grid view for every table in the set
For i = 0 To binData.Tables.Count - 1
Dim tabPage As C1.Win.C1Command.C1DockingTabPage = New C1.Win.C1Command.C1DockingTabPage
tabPage.Text = binData.Tables(i).TableName
tabContent.TabPages.Add(tabPage)
Dim dgvData = New System.Windows.Forms.DataGridView
Dim binding As New BindingSource
binding.DataSource = binData.Tables(i)
With dgvData
.Dock = DockStyle.Fill
.AllowUserToOrderColumns = False
.AllowUserToAddRows = False
.AllowUserToDeleteRows = False
.DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft
.DataSource = binding
.AutoGenerateColumns = True
End With
tabPage.Controls.Add(dgvData)
Next 'DataTable In binData.Tables
When the form loads, the tab pages are there and labeled as expected, but they look empty (no table).
I did try instead setting the DataSource to the DataSet called binData (as opposed to a specific table), and then setting dgvData's DataMember property to the name of the specific table I want to display in it...that made no difference.
Note: I need to be able to do this programmatically at runtime as opposed to using the visual designer because I do not know the exact number of grids I need until the form loads with a particular dataset - the dataset it gets can have a different number of tables depending on what the user wants.
Here's some rough code to add dgvs to a flow panel:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Static dgvCount As Integer
dgvCount += 1
Dim dgvNew As New DataGridView
dgvNew.Width = DataGridView1.Width
dgvNew.Height = DataGridView1.Height
dgvNew.Name = "dgv" & dgvCount
' clone other properties as need
FlowLayoutPanel1.Controls.Add(dgvNew)
Debug.Print(FlowLayoutPanel1.Controls(FlowLayoutPanel1.Controls.Count - 1).Name)
End Sub
Starts with one dgv - DataGridView1 as the model for properties. Anchoring is not working in the flow panel so some custom code may be need to change width.
Flow panel doesn't scroll so may not be the best choice - look into TableLayout as a possibility. TabControl is another option.
OK, well it turns out there was nothing wrong with what I was doing. The issue turned out to be in one line of code that has nothing to do with binding the DGV's datasource or anything.
ComponentOne has a control called a ThemeController in which you can set themes for your forms and the controls within. I had a line of code to set the theme for dgvData to my default application theme (which sets visual style and details regarding colors, fonts, etc.). For whatever reason, THAT was rendering my grid non-visible. I will be logging a ticket with them.

VB.Net WebBrowser Navigate Only Working Once

Hoping someone can help me with this. I have two separate but related Forms, one of which contains a WebBrowser control. The user fills out some information on Form 1 and clicks a button with the following code:
If Form2Shown = False Then
Dim memoscreen As New Form2
Form2Ref = memoscreen
memoscreen.show()
Form2Shown = True
memoscreen.TopMost = OptionOnTop
Else
Dim memoscreen As Form2
memoscreen = Form2Ref
memoscreen.TopMost = OptionOnTop
memoscreen.QuickRefresh()
End If
The QuickRefresh sub in Form2 is the method that navigates. It is called both when the form is loaded as well as manually in the code above:
Public Sub QuickRefresh()
Dim HM As Form1
HM = Form1Ref
Me.Text = "retrieving information..."
Me.AxWebBrowser1.Navigate("SomeValidURL")
HM.Focus()
HM.SetHugoFocus()
End Sub
The problem I'm having is that the first time QuickRefresh is called (i.e. when Form2 is loaded) the navigation is successful and the page displays fine. If I then click the button on Form1 again, the page does not change. The Text attribute and window focus does change however, so I know the method is firing.
Some things I've tried/checked:
AllowNavigation is set to True on the WebBrowser control
Have tried looping while the browser is busy while calling Application.DoEvents()
Any suggestions would be appreciated. Thanks.
From your "Internet Options dialog > General Tab > Settings Button > Check for newer version of stored page" change that option to *Every Time I visit the webpage". That setting impacts how the webbrowser control deals with the refreshing.
Use the method refresh.
browser.Navigate("http://www.google.com") : browser.Refresh()