|
(via Instant VB)
'----------------------------------------------------------------------------
' File: Devices.cs
'
' Copyright (c) Microsoft Corp. All rights reserved.
'-----------------------------------------------------------------------------
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports Microsoft.DirectX.DirectSound
Public Class DevicesForm
Inherits Form
Private WithEvents buttonOk As Button
Private WithEvents buttonCancel As Button
Private WithEvents labelStatic As Label
Private WithEvents comboboxCaptureDeviceCombo As ComboBox
Private mf As MainForm = Nothing
Private devices As CaptureDevicesCollection = New CaptureDevicesCollection()
Public Sub New(ByVal mf As MainForm)
'
' Required for Windows Form Designer support
'
InitializeComponent()
Me.mf = mf
For Each info As DeviceInformation In devices
comboboxCaptureDeviceCombo.Items.Add(info.Description)
Next info
comboboxCaptureDeviceCombo.SelectedIndex = 0
End Sub
#Region "InitializeComponent code"
Private Sub InitializeComponent()
Me.buttonOk = New System.Windows.Forms.Button()
Me.buttonCancel = New System.Windows.Forms.Button()
Me.labelStatic = New System.Windows.Forms.Label()
Me.comboboxCaptureDeviceCombo = New System.Windows.Forms.ComboBox()
Me.SuspendLayout()
'
' buttonOk
'
Me.buttonOk.Location = New System.Drawing.Point(10, 41)
Me.buttonOk.Name = "buttonOk"
Me.buttonOk.Size = New System.Drawing.Size(75, 23)
Me.buttonOk.TabIndex = 0
Me.buttonOk.Text = "OK"
'Me.buttonOk.Click += New System.EventHandler(Me.buttonOk_Click);
'
' buttonCancel
'
Me.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.buttonCancel.Location = New System.Drawing.Point(231, 41)
Me.buttonCancel.Name = "buttonCancel"
Me.buttonCancel.Size = New System.Drawing.Size(75, 23)
Me.buttonCancel.TabIndex = 1
Me.buttonCancel.Text = "Cancel"
'Me.buttonCancel.Click += New System.EventHandler(Me.buttonCancel_Click);
'
' labelStatic
'
Me.labelStatic.Location = New System.Drawing.Point(0, 14)
Me.labelStatic.Name = "labelStatic"
Me.labelStatic.Size = New System.Drawing.Size(88, 13)
Me.labelStatic.TabIndex = 2
Me.labelStatic.Text = "Capture Device:"
'Me.labelStatic.Click += New System.EventHandler(Me.labelStatic_Click);
'
' comboboxCaptureDeviceCombo
'
Me.comboboxCaptureDeviceCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.comboboxCaptureDeviceCombo.Location = New System.Drawing.Point(93, 11)
Me.comboboxCaptureDeviceCombo.Name = "comboboxCaptureDeviceCombo"
Me.comboboxCaptureDeviceCombo.Size = New System.Drawing.Size(213, 21)
Me.comboboxCaptureDeviceCombo.Sorted = True
Me.comboboxCaptureDeviceCombo.TabIndex = 3
'Me.comboboxCaptureDeviceCombo.SelectedIndexChanged += New System.EventHandler(Me.comboboxCaptureDeviceCombo_SelectedIndexChanged);
'
' DevicesForm
'
Me.AcceptButton = Me.buttonOk
Me.CancelButton = Me.buttonCancel
Me.ClientSize = New System.Drawing.Size(316, 79)
Me.Controls.Add(Me.buttonOk)
Me.Controls.Add(Me.buttonCancel)
Me.Controls.Add(Me.labelStatic)
Me.Controls.Add(Me.comboboxCaptureDeviceCombo)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Name = "DevicesForm"
Me.Text = "Select Capture Device"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub buttonOk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles buttonOk.Click
If 0 < comboboxCaptureDeviceCombo.Items.Count Then
mf.CaptureDeviceGuid = devices(0).DriverGuid
End If
Close()
End Sub
Private Sub buttonCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonCancel.Click
End Sub
Private Sub labelStatic_Click(ByVal sender As Object, ByVal e As EventArgs) Handles labelStatic.Click
End Sub
Private Sub comboboxCaptureDeviceCombo_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles comboboxCaptureDeviceCombo.SelectedIndexChanged
End Sub
End Class
David Anton
http://www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
C++ to VB Converter: converts C++ to VB
C++ to Java Converter: converts C++ to Java
Instant C++: converts C# to C++/CLI and VB to C++/CLI
|
|
|
|
|
Thank you, your code has cleared up the errors I was getting. However, there still seems to be 1 problem. On the c# program the devices form comes up first but the main form comes up in vb. The reason seems to be that in the c# project the program starts in this function:
[STAThread]<br />
public static void Main()<br />
{<br />
try<br />
{<br />
using(MainForm form = new MainForm())<br />
{<br />
form.ShowDialog();<br />
}<br />
}<br />
catch{}<br />
}
But when I placed a bunch of breakpoints in my vb program it doesn't seem to enter the equivelent sub or any other procedure. This is true even when I click on a button in the main form.
ps I agree I don't like the original formatting and structuring of the program. This is actually an example program from the directx sdk which is only in c++ or c#. If I completely understood it I would probably just rewrite it before incorporating it into my program but unfortunately there's not much documention on it.
thank you again for your help.
|
|
|
|
|
Check the project properties ('Application' tab) for the VB project. You probably just need to select the right form as the startup form.
David Anton
http://www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
C++ to VB Converter: converts C++ to VB
C++ to Java Converter: converts C++ to Java
Instant C++: converts C# to C++/CLI and VB to C++/CLI
|
|
|
|
|
sCmd = Chr(&H8s) & Chr(&H2s)
|
|
|
|
|
try:
Console.WriteLine(sCmd)
and check the output.
|
|
|
|
|
Hi,
&H8s is an integer value; the &H prefix indicates hexadecimal, the s suffix indicates
a short type; so it really is the number 8 (and there was no need to use hex in the first place).
Chr() is a function that turns a number into the character with that ASCII value.
And the & operator is used here to concatenate.
Therefore sCmd will be assigned a string consisting of two characters whose ASCII values
are 8 and 2.
If you were not able to discover this yourself, either by experimenting, or by googling,
I would suggest you work your way through a book on VB.NET to become familiar with it.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
|
|
The same as:
sCmd = (Convert.ToChar(8)).ToString() + (Convert.ToChar(2)).ToString()
---
single minded; short sighted; long gone;
|
|
|
|
|
It means someone came from VB.NET via VB6 and hasn't learned to write clean code, yet.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Please help me to filter my data on Crystal Report...if it is possible pls give me instructions...tnx
sunshine
|
|
|
|
|
Hii ,
i want to know the name of the control that is selected at runtime for runtime generated controls like label,rb,cb,tb ,etc . If i select a particular control at run time i want to know the name and it has to display in combobox without repetition of name ,and show properties of that control in propertygrid
s = Me.ActiveControl.Name if i am using this it is giving only panel1 as active control . i want the control i selected recently
Waiting For Ur Help...
DVSRIRAM
|
|
|
|
|
I don't know if it can count as a solution.
What you can do for textbox, richtextbox, checkbox is handle an event like Keydown, checkchanged, selectedindexchanged
In this example (sorry, in c#) i enable the savebutton when i modify a control. For you, see below the example.
private void CreateEventHandlers()
{
tbxC1.KeyDown += new KeyEventHandler(EnableSave);
tbxC2.KeyDown += new KeyEventHandler(EnableSave);
cmbxT1.SelectedIndexChanged += delegate { EnableSave(); };
tbxC3.KeyDown += new KeyEventHandler(EnableSave);
tbxC4.KeyDown += new KeyEventHandler(EnableSave);
}
private void EnableSave()
{
if (!m_bUpdating)
cobject.saveObject.Enabled = true;
}
private void EnableSave(object sender, KeyEventArgs e)
{
if (m_bUpdating)
return;
if (e.KeyCode == Keys.F1)
return;
else if (e.Control && e.KeyCode == Keys.C)
return;
else if (e.Control && e.KeyCode == Keys.V)
computerObjectFilter1.saveObject.Enabled = true;
else if (e.Control)
return;
else if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.End || e.KeyCode == Keys.Home || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.PageDown || e.KeyCode == Keys.Next || e.KeyCode == Keys.Insert)
return;
else
cobject.saveObject.Enabled = true;
}
For you, change the content of enable save to:
Console.WriteLine(sender.ToString)
Console.WriteLine(CType(sender, Button).Name.ToString())
The result will be something like:
System.Windows.Forms.Button, Text: &OK
btnOK
So you can make for every type of control a sort of enable save so you can cast them into the control so you can access all that you want, or you do the following:
1. Test Console.WriteLine(sender.ToString) with Instr() if it contains a Button, TextBox, ...
2. Than Cast correct resulting the test
You also asked Label, well, at the moment i don't have a solution for it. But if the one above is satisfying, you are a step ahead...
lmk
|
|
|
|
|
Thanks For the response ,
But i got it another way .
DVSRIRAM
|
|
|
|
|
Nice,
Can you share your solution? That is what this site is all about.
|
|
|
|
|
Firstly, an apology. My question isn't directly related to VB .NET but actually VBA in Office 2003. However, i have read these forums many times regarding VB .NET and C# questions and always have found responces friendly and informative. Hopefully the same can come from this question.
Simply, i have stored within an Access database OLE objects which are google maps of areas of the country. What i need to do is import this data into a word template. I know there are methods of using the Win32 API to store the data in memory and read directly to that from word, but i have no idea as to how this would be accomplished. What i was hoping for was a method similar to passing the data as a bookmark to word, but as bookmarks only accept Strings, i'm stuck for a way for this to work.
I have also been looking into another method of storing in the database the file path to the images, passing this path to word, then getting this path into the LoadPicture() method for the image. But after passing the path through as an bookmark, focus is lost on the bookmark which stores the path and i cannot reference it anymore.
Any advice you could offer to solve this problem would be very much appreciated. Although i do ask you that no messages contain the sentence "Stop using VBA!!!".... because i've been telling myself that enough already!
Many Thanks,
Plation
|
|
|
|
|
If no one can answer this question, would anyone be tempted in starting a project with me to figure out how to do this? When we find the answer we can post an article on codeproject about it.
Tempted? I'm sure im not the only person in the world who has wanted to do this.
|
|
|
|
|
Hi guys,
I am struggling to change the font style of a selected node in a treeview and a selected item in a listview control, your help is very much appreciated.
Regards
|
|
|
|
|
Got it and a bit embarrassed, its amazingly simple.
here are my lines, I used the AfterSelect event of the TreeView to set the font of the node, its parent and all its ancestors to bold, when another node is selected, i set the new node and its ancestors to bold, while returning the previously selected node to the normal font of the TreeView . By removing the while... statement in both methods, only the selected node is set to bold and back to normal. I know there are most likely better solutions but this one works fine.
<code>Dim previousSelectedNode as TreeNode
...
...
Private Sub Treeview1_AfterSelect(ByVal sender As System.Object, ByVal e As _ System.Windows.Forms.TreeViewEventArgs) Handles Treeview1.AfterSelect
Dim xnode As TreeNode
If previousSelectedNode IsNot Nothing Then DeSelectNode()
e.Node.NodeFont = New Font(Treeview1.Font, FontStyle.Bold)
xnode = e.Node
While xnode.Parent IsNot Nothing
xnode = xnode.Parent
xnode.NodeFont = New Font(Treeview1.Font, FontStyle.Bold)
End While
previousSelectedNode = e.Node
End Sub
'Deselecting a node
Private Sub DeSelectNode()
previousSelectedNode.NodeFont = Treeview1.Font
While previousSelectedNode.Parent IsNot Nothing
previousSelectedNode = previousSelectedNode.Parent
previousSelectedNode.NodeFont = Treeview1.Font
End While
End Sub
|
|
|
|
|
Hi i have a form with a datagridview and a listbox. The datagridview is bound to a table with 2 columns. the first column is a column that needs to store the name of a genre(specified in the listbox). the second column(which I have made invisible) is merely the name of the 24 hour template. what I mean by this is that the point of the datagrid is to allow a user to drag and drop genres to each hour of a day(so they need to drag 24 genres) onto the datagrid) and then save this as a 24 hour template. the datagrid is thus bound to the child table of a table called "24HourTemplate". when the user click save it will prompt for a name for the template and record the chnages to the 2 tables. how do I perform a drag and drop. I have enabled it for the tables but nothing happens?
Mr Oizo
|
|
|
|
|
Hi I am writing music and advert scheduling placement program for a radio station.I am nearing the final stages but need something that will allow the user to view the schedule and drag and drop songs/adverts into slots on the shedule. the problem is that everything is scheduled around time and constraints around that time(eg: a certain genre of music plays at a certain time of day). Basically I need something that displays the time in hours, minutes and seconds and can allow the user to drag and drop information into slots coinciding with specific times? Is there anything like this out there for free? Any advice on how I could make something like that? I was thinking of using a datgridview and then creating a schedule table which would just hold all the information the schedule needs and binding the 2 together?
Mr Oizo
|
|
|
|
|
Please don't double post. People here are volunteers and will answer your question when they are able, if they can provide an answer. Posting it a second time an hour later is a sure way to not get a response to either.
|
|
|
|
|
Hi my project im doing does music and advertisement placement on a schedule for playing on a radio station. It uses various selection criteria to schedule the playlist. I am nearing the final stages but am wondering if anyone could give me any advice how I should store the final playlist and what to use to display the completed schedule to the scheduler? at the moment I am thinking of using a datagridview. the problem is that everything is scheduled around the hours in the day and what types of music(specified by genre) and adverts need to play at certain times. I basically just need some type of tool or something that shows the hours, minutes and seconds in a 24 hour clock and allows me to drag and drop information coinciding with a specific time. Any ideas will be really appreciated. thanks
Mr Oizo
|
|
|
|
|
I have a strange problem
set up:
I have a mdi parent with server mdichildren (shown as tabs)
an mdichild has a control on it (datawindow) wich contains serveral fields
now when I create a new record for the first time the focus is set correctly on the correct field en the user can imidattly start entering data. But if we create another new record the focus is not set correctly. The code behinde the first and second new record is identicly (since it's the same code)
when I ask my form wich control has the focus it tells me that the correct control has the focus (datawindow) but still I can not enter any data without clicking in the control first. Even tab doesn't work, neighter do my schortcuts (who are at form level).
If I use alt-tab (to swith between open windows) and return to the programme (with alt-tab) the foces all of the sudden is set correctly.
I'v stept thru my code and nothing happens after I set the focus (it's the last thing I do)
On a side note:
the mdi child inherits from another form (but nothing happens there, at least not after I set the focus)
the same thing works on other forms just not on the last 5(or so) I created
Anyone have an idea what can cause this problem? Or how I can make sure the last thing the programme does is setting the focus?
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
i propose u change the tab-index for the form which doesnt focus correctly. Set the index to the desired order for data entry, then combine with the set focus code and should solve ur problem.
---------------------------
Baniani mbaya, kiatu chake dawa.
Regards,
Hesbon Ongira
Nairobi, Kenya.
|
|
|
|