Jump to content
Xtreme .Net Talk

Goggy

Members
  • Posts

    8
  • Joined

  • Last visited

Goggy's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. what book would that be? only book i have read about vb.net was a simple book never handeld any api's... so i would be interrested in the book title....
  2. iam a vb.6 programmer just starting to explore vb.net.... and i was wondering what u guys thought of my tinkering...btw...each and all comment, improvements, add ons are welcome... excuse my pore grasp of the language but english isnt my first language... Test1001.zip
  3. :-) glad to help u my friend.... and if it works....it works....so feel free to use the double ;) best regards Goggy
  4. just some tinkering..... Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Name = "Form1" Me.Text = "Form1" End Sub #End Region Dim Coll As New Collection Public Structure Person Public Name As String Public Cash As Int32 End Structure Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim OrgArray(100, 1) As String Dim RetArray(0, 0) As String Dim InstanceOfPerson As Person 'Notice i have replaced "." with "," for the conversion from string to number to work properly. OrgArray(0, 0) = "Jay" OrgArray(0, 1) = "10,00" OrgArray(1, 0) = "Jay" OrgArray(1, 1) = "1,00" OrgArray(2, 0) = "David" OrgArray(2, 1) = "10,00" OrgArray(3, 0) = "Erin" OrgArray(3, 1) = "10,00" OrgArray(4, 0) = "David" OrgArray(4, 1) = "1,00" 'Make a collection to hold all the people and add the totals. For i As Int16 = 0 To UBound(OrgArray, 1) If OrgArray(i, 0) <> "" Then With InstanceOfPerson .Name = OrgArray(i, 0) .Cash = CInt(OrgArray(i, 1)) End With If Not ItemExistInCollection(InstanceOfPerson.Name) Then Coll.Add(InstanceOfPerson, InstanceOfPerson.Name) Else InstanceOfPerson = Coll(OrgArray(i, 0)) InstanceOfPerson.Cash = InstanceOfPerson.Cash + CInt(OrgArray(i, 1)) Coll.Remove(InstanceOfPerson.Name) Coll.Add(InstanceOfPerson, InstanceOfPerson.Name) End If End If Next 'if where keep going to work with the collection all we have to do to loop tru then is For Each InstanceOfPerson In Coll Debug.WriteLine(InstanceOfPerson.Name & InstanceOfPerson.Cash) Next End Sub Private Function ItemExistInCollection(ByVal Item As String) As Boolean On Error Resume Next Dim Ret As Object Ret = Coll(Item) If Ret <> "" Then Return True End If Return False End Function End Class
  5. iam used to vb 6 ...but going now to .net.... i was wondering whats faster in .net.... old Dir,FSO(scripting) or the System.IO.Directory class.
  6. Solved it Dim objRegistry As RegistryKey = Registry.ClassesRoot Dim objDefaultIcon As RegistryKey = Registry.ClassesRoot Dim Names() As String = objRegistry.GetSubKeyNames For i As Int32 = 1 To Names.Length - 1 If Mid(Names(i), 1, 1) <> "." Then Exit For objRegistry = objRegistry.OpenSubKey(Names(i)) On Error Resume Next objDefaultIcon = objDefaultIcon.OpenSubKey(objRegistry.GetValue("") & "\DefaultIcon") Console.WriteLine(Names(i) & objDefaultIcon.GetValue("").ToString) ExtentionCollection.Add(i, Names(i)) objRegistry = Registry.ClassesRoot objDefaultIcon = Registry.ClassesRoot Next
  7. Dim objRegistry As RegistryKey = Registry.ClassesRoot Dim objDefaultIcon As RegistryKey = Registry.ClassesRoot Dim Names() As String = objRegistry.GetSubKeyNames For i As Int32 = 1 To Names.Length - 1 If Mid(Names(i), 1, 1) <> "." Then Exit For objRegistry = objRegistry.OpenSubKey(Names(i)) objDefaultIcon = objDefaultIcon.OpenSubKey(objRegistry.GetValue("") & "\DefaultIcon") Console.WriteLine(Names(i) & objDefaultIcon.GetValue("").ToString) ExtentionCollection.Add(i, Names(i)) Next the loops runs once...and then i get the error...maybe iam missing something simple...but i dont get it
  8. According to msdn...(if i read it rite..)... the MOUSEHOOKSTRUCT should return the handle of the window thats recieving the message.... well it doesnt seem to return anything.... could someone shine some light on this for me? Thank u all 4 your help. Imports System.Runtime.InteropServices Imports System.Reflection Imports System.Drawing Imports System.Threading Imports System.String Public Class LLMouse #Region "Api Declarations" '--------------------------------------------------------------------------- 'A VB.6 long converts to a VB.net integer '--------------------------------------------------------------------------- Private Declare Function UnhookWindowsHookEx Lib "user32" _ (ByVal hHook As Integer) As Integer Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" ( _ ByVal idHook As Integer, _ ByVal lpfn As MouseHookDelegate, _ ByVal hmod As Integer, _ ByVal dwThreadId As Integer) As Integer Private Declare Function CallNextHookEx Lib "user32" _ (ByVal hHook As Integer, _ ByVal nCode As Integer, _ ByVal wParam As Integer, _ ByVal lParam As MOUSEHOOKSTRUCTEX) As Integer Private Declare Function GetFocus Lib "user32" Alias "GetFocus" () As Integer Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" ( _ ByVal hwnd As Integer, _ ByVal lpString As String, _ ByVal cch As Long) As Integer Private Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" ( _ ByVal xPoint As Integer, _ ByVal yPoint As Integer) As Integer Private Declare Function FlashWindow Lib "user32" Alias "FlashWindow" ( _ ByVal hwnd As Integer, _ ByVal bInvert As Integer) _ As Integer #End Region #Region "Mouse Structure" Public Structure MOUSEHOOKSTRUCT Public POINT As POINT Public hwnd As Integer Public wHitTestCode As Integer Public dwExtraInfo As Integer End Structure Public Structure MOUSEHOOKSTRUCTEX Public MOUSEHOOKSTRUCT As MOUSEHOOKSTRUCT Public mouseData As Integer End Structure #End Region #Region "Mouse Constants" Private Const HC_ACTION = 0 Private Const WM_MOUSEACTIVATE = &H21 private Const WM_MOUSEFIRST = &H200 Private Const WM_LBUTTONDOWN = &H201 Private Const WM_LBUTTONUP = &H202 Private Const WM_LBUTTONDBLCLK = &H203 Private Const WH_MOUSE_LL = 14& #End Region Private MouseHandle As Integer Public Delegate Function MouseHookDelegate( _ ByVal Code As Integer, _ ByVal wParam As Integer, _ ByRef lParam As MOUSEHOOKSTRUCTEX) _ As Integer <MarshalAs(UnmanagedType.FunctionPtr)> _ Private callback As MouseHookDelegate Public Sub HookMouse() callback = New MouseHookDelegate(AddressOf MouseCallback) MouseHandle = SetWindowsHookEx( _ WH_MOUSE_LL, _ callback, _ Marshal.GetHINSTANCE([Assembly].GetExecutingAssembly.GetModules()(0)).ToInt32, _ 0) End Sub Public Function MouseCallback( _ ByVal Code As Integer, _ ByVal wParam As Integer, _ ByRef lParam As MOUSEHOOKSTRUCTEX) As Integer If (Code = HC_ACTION) Then Select Case wParam Case Else Dim Window_Name As String Window_Name = Space(32) GetWindowText( _ WindowFromPoint( _ lParam.MOUSEHOOKSTRUCT.POINT.X, _ lParam.MOUSEHOOKSTRUCT.POINT.Y), _ Window_Name, _ Window_Name.Length) Window_Name = Left(Window_Name, InStr(Window_Name, Chr(0), CompareMethod.Binary) - 1) If Window_Name.Length <> 0 Then Debug.Write(Hex(wParam) & vbCrLf) Debug.Write(Window_Name.Length & vbCrLf) Debug.Write(Window_Name & vbCrLf) Debug.Write(lParam.MOUSEHOOKSTRUCT.hwnd & vbCrLf) Debug.Write(lParam.mouseData.ToString & vbCrLf) End If If lParam.MOUSEHOOKSTRUCT.hwnd <> 0 Then FlashWindow(lParam.MOUSEHOOKSTRUCT.hwnd, True) End Select End If Return CallNextHookEx( _ MouseHandle, _ Code, _ wParam, _ lParam) End Function Public Sub UnhookMouse() Call UnhookWindowsHookEx(MouseHandle) End Sub End Class
×
×
  • Create New...