I found a WebCam class here's a link "http://dotnetjunkies.com/WebLog/principal/articles/32662.aspx" it's in C# but you can either convert it to vb or compile it as a .dll and use it that way. This is the structure I pulled out of the class example in the link above. _ Public Structure VIDEOHDR _ Public lpData As Integer _ Public dwBufferLength As Integer _ Public dwBytesUsed As Integer _ Public dwTimeCaptured As Integer _ Public dwUser As Integer _ Public dwFlags As Integer _ Public dwReserved() As Integer End Structure 'VIDEOHDR
OICU812
Posts
-
Callback function not working?? Video capture. -
mdi child problemI'm sorry Gary, I tested my previous example on VisualBasic 2005 Beta and it works there. You're right it does produce an error on my VS 2003. I tested this on VS 2003 and it works.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm3 As New Form3
frm3.MdiParent = Me.MdiParent
frm3.Show()
End Sub -
mdi child problemTry this:
Public Class Form1
Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim frm2 As New Form2 frm2.MdiParent = Me frm2.Show() End Sub
End Class
Public Class Form2
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm3 As New Form3 frm3.MdiParent = Me.ParentForm frm3.Show() End Sub
End Class
-
Callback function not working?? Video capture.Marshal.PtrToStructure(ptr,structure) is a Shared Sub and doesn't return a value. Try this revised code. I can't test it live but this is what i suspect is wrong with your code.
Public Function myCallBack(ByVal lwnd As Long, ByVal lpVHdr As Long) As Boolean
Dim VideoData() As Byte
Dim gh As Runtime.InteropServices.GCHandle _
= Runtime.InteropServices.GCHandle.Alloc _
(lpVHdr, Runtime.InteropServices.GCHandleType.Pinned)Dim AddrOflpVHdr As IntPtr = gh.AddrOfPinnedObject() Dim VideoHeader As New VIDEOHDR Marshal.PtrToStructure(AddrOflpVHdr, VideoHeader) gh.Free() End Function
-
Callback functionIm so far removed from VB6 that I didn't even consider that you maybe using it.
-
Callback functionThe problem is that you need to declare a "delegate" callback function. Here is some example code for enumerating thru windows using callbacks just like you need to implement in your code. You shouldn't have any problems figuring out what you need to do from here.
Module EnumWindows
Delegate Function EnumWindows_Callback(ByVal hWnd As Integer, ByVal lParam As Integer) As IntegerPublic Declare Function EnumWindows Lib "user32" \_ (ByVal lpEnumFunc As EnumWindows\_Callback, \_ ByVal lParam As Integer) As Integer Public Declare Function EnumChildWindows Lib "user32" \_ (ByVal hWndParent As Integer, ByVal lpEnumFunc As EnumWindows\_Callback, \_ ByVal lParam As Integer) As Integer Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" \_ (ByVal hWnd As Integer, ByVal lpClassName As System.Text.StringBuilder, \_ ByVal nMaxCount As Integer) As Integer Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" \_ (ByVal hWnd As Integer, ByVal lpString As System.Text.StringBuilder, \_ ByVal cch As Integer) As Integer ' The callback routine, common to both EnumWindows and EnumChildWindows. ' the argument passed in lParam is the indent level. Function EnumWindows\_CBK(ByVal hWnd As Integer, ByVal lParam As Integer) As Integer ' display information on this window, with correct indentation Console.WriteLine(New String(" "c, lParam \* 3) & WindowDescription(hWnd)) ' then display all child windows, but indent them to the right EnumChildWindows(hWnd, AddressOf EnumWindows\_CBK, lParam + 1) ' Return 1 to continue enumeration. Return 1 End Function ' return a windows description given its hWnd Function WindowDescription(ByVal hWnd As Integer) As String Dim text As String text = WindowText(hWnd) WindowDescription = "\[" & Right$("0000000" & Hex$(hWnd), 8) & "\] " \_ & WindowClassName(hWnd) If Len(text) > 0 Then WindowDescription &= " - """ & text & """" End If End Function ' Return the caption/text of a window. Function WindowText(ByVal hWnd As Integer) As String Dim buffer As New System.Text.StringBuilder(256) Dim length As Integer length = GetWindowText(hWnd, buffer, buffer.Capacity) WindowText = buffer.ToString.Substring(0, length) End Function Function
-
Pretty Code in Forum:doh: Thanks! Makes a big difference.
-
Pretty Code in ForumThis isn't related to VB but to this forum. How do I post code in the forums where it retains the format. The <code></code> tags don't seem to do what I expect them to do.
-
Can I do an event handler in a collection class to capture an event raised by one of its objectsI've been working on a similar problem and I handled it with Delegates. I made an example using your class descriptions to test my knowledge of delegates. I'm no expert here but this will do what I think you are looking for.
'The delegate that handles the communications between classes.
Public Delegate Sub AreaChangedHandler(ByVal sender As PartObject)Public Class PartsCollection
'simplified collection
'not intended to demonstrate a true collection class
Dim m_collection As New ArrayList
Dim m_Area As Double
Shared Event AreaChanged As AreaChangedHandler
Public Event PartAdded(ByVal part As PartObject)
ReadOnly Property Area() As Double
Get
Dim obj As PartObject
Dim totalArea As Single
For Each obj In m_collection
totalArea += obj.Area
Next
Return totalArea
End GetEnd Property Friend Sub Add(ByVal part As PartObject) m\_collection.Add(part) RaiseEvent PartAdded(part) End Sub Shared Sub OnAreaChanged(ByVal sender As PartObject) RaiseEvent AreaChanged(sender) End Sub
End Class
Public Class PartObject
Dim m_Width As Single
Dim m_Height As Single
'Shared delegate that invokes OnAreaChanged method in PartsCollection
'without having to create an instance of PartsCollection
Private Shared delegateAreaChanged As New AreaChangedHandler(AddressOf PartsCollection.OnAreaChanged)Property Height() As Single Get Return m\_Height End Get Set(ByVal Value As Single) m\_Height = Value Call AreaChanged() End Set End Property Property Width() As Single Get Return m\_Width End Get Set(ByVal Value As Single) m\_Width = Value Call AreaChanged() End Set End Property ReadOnly Property Area() As Single Get Return m\_Height \* m\_Width End Get End Property Protected Overridable Sub AreaChanged() delegateAreaChanged.Invoke(Me) End Sub
End Class
-
Rubber-Band Focus RectangleI'm searching for a VB.net example of a rubber-band rectangle or select rectangle using pinvoke ROP2 codes. I know about ControlPaint.DrawReversableFrame but im working in the .Net Compact Framework and that isn't in the compact framework. Also drawing to a bitmap and erasing it is inefficient for what im doing. I know an example is around here somewhere I just can't seem to find it. I had this all figured out a year ago in a project I shelved only now I can't find that project or all the code samples I produced. :mad:
-
Converting text to dateDave Kreskowiak wrote: Oh! And using Me to death pisses me off to! It's completely unnecessary... LMAO...But Intellisense makes it so useful to help remember all those names that I forget!
-
custom sorting datatablesmfriedenthal wrote: The watch has these colums delimited by "#"s so I have reason to believe that .net is indeed seeing the fields as dates and not strings. Are you sure the data isn't being handled as a string? I made a quick table in ms access and it sorted it fine with the "TimeNeeded" column as a DATE/TIME but when i changed it to a string it basically returned results like you show. Double check the column data type:
Debug.WriteLine(MyDataSet.Tables("MyTable").Columns("TimeNeeded").DataType.ToString)
Do the same for your PurchaseOrderID column. Other than being the wrong datatype I can't understand why it doesn't work for you. -
Making Monitor BlackRamesh Yadavalli wrote: i want to do some background process which should not display There are all kind of thing you can do with a background process without anyone seeing it. But making the whole screen black sound like you're trying to make a prank or get fired from your job! But it's really easy
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.BackColor = Color.Black Me.FormBorderStyle = FormBorderStyle.None Me.WindowState = FormWindowState.Maximized End Sub
-
Database access through VB.Netnyjcr wrote: VB is supposed to be this easy to learn, "foolproof" language...Its not! .Net has made so many thing with VB much easier than previous versions, with the exception of connecting to a plain ol Access database. I miss using vb6 only for data, but im really starting to get the hang of ADO.Net and am starting to like it.
-
Database -- What am i not understanding.Thanks for replying. Thats what I thought I would have to do. I just wanted to be sure there wasn't something more efficent that did that automatically.
-
Database -- What am i not understanding.I have an ms access db with many 'views' (queries) within the database that I want to use with ADO.NET but it seems I'm having to reinvent the wheel to use them the way i want. Simplified example: Lets say i have a query within Access "Select FirstName, LastName, FirstName + ' ' + LastName as FullName FROM Customers" Now I use that in a DataTable bound to a DataGrid -- When i enter (or edit) the FirstName and LastName and move to the next row it doesn't update the 'calculated field' FullName. I know I can make a 'Calculated Column' and make it work but im trying not to have to write so much dang code and use what already works. Am I just missing somthing obvious? Is there a way to tell ADO that the field should calculate 'LIVE' using the sql, or do I have to insert into code every calculation done with the data as a calculated column?
-
custom sorting datatablesTry this MyDataView.Sort = "PurchaseOrderID, TimeNeeded ASC" -or- MyDataView.Sort = "PurchaseOrderID ASC, TimeNeeded ASC" Use DESC for Descending *EDIT* I just tried it with a dataview containing null values and it sorts the null values to the top of list in my datagrid. I really don't see a problem with your code. I thought maybe the parentheses in your .sort code was the problem but it works either way.
-
Help !! Event not Raise in VB.netI'd check first to see if the EVENT on the form has a handler. Sometimes if you delete or cut/paste a control you'll loose the handler for the event but the event stays and you're left scratching your head. Sub MyEvent(byval sender as object, byval e as system.event) handles MyClass.MyEvent -or- addHandler MyClass.MyEvent, addressOf MyEvent '<--Handler won't get deleted if you cut/paste Other thing that happens to me is some other event raises an exception and causes the RaiseEvent to fail. Especially if i have a Try Catch with an empty catch that i havent coded in a response yet(not a good practice)
-
Columns in a string in VB.NETI just had that same problem. Here is an example:
' Draw all font names on form Dim gr As Graphics = Me.CreateGraphics gr.Clear(Color.White) ' Prepare a message with tabs and carriage returns. Dim msg As String = String.Format("{0}Column 1{0}Column 2{0}Column 3{1}" _ & "Row 1{0}Cell (1,1){0}Cell (1,2){0}Cell (1,3){1}" _ & "Row 2{0}Cell (2,1){0}Cell (2,2){0}Cell (2,3){1}", _ ControlChars.Tab, ControlChars.CrLf) Dim fnt As New Font("Arial", 12) Dim strFormat As New StringFormat() ' Set the tab stops. Dim tabStops() As Single = {80, 140, 200} strFormat.SetTabStops(0, tabStops) ' Draw the text with specified tab stops. gr.DrawString(msg, fnt, Brushes.Black, 20, 20, strFormat) fnt.Dispose() gr.Dispose()
Hope that hels you! -
Database access through VB.NetDrop an OleDbDataAdapter on a form and use the wizard to connect to the access DB and select a table that you want to view and it will auto-generate all the select, insert, delete and updates for the table. Right click the OleDbDataAdapter and choose Generate DataSet. Add a DataGrid to your form and set the DataSource and DataMember for the DataGrid in the properties Grid. ON the form load event add: Me.OleDbDataAdapter1.Fill(DataSet1) '<-- Assuming you used the default autogenerated names. I suggest reading thru MSDN and just search using DataSet, DataView, BindingManager, BindingManagerBase, CurrencyManager, Calculated Column, Strongly Typed DataSet. You'll need to know what all these things are if you are ever to make anything work. MSDN & Google is your best source really for learning just lookup those words. Don't buy the Book "Programing MicroSoft VisualBasic.Net For MicroSoft Access Databases", it's absolute garbage. Use the "DataForm Wizard" by selecting File|Add new item and look at how it builds a form with navigation buttons. I've been learning all this over the last few weeks, and I must say it's quite FUSTRATING to say the least. It shouldnt be this hard to connect to data and work with it without using third party solutions. I've been playing with the 2005 vb.net Beta and It looks like it's going to be much much easier to work with.