|
Hi Thomas,
Point 1 is ensured, im only drawing in the DrawItem Event.
Point 3, i had enabled:
ControlStyles.DoubleBuffer
ControlStyles.Opaque
ControlStyles.AllPaintingInWmPaint
ControlStyles.UserPaint
ControlStyles.OptimizedDoubleBuffer
but all of that dont seem to work.
My English was not good enough to understand point 2, it would be
really great if you would explain it in other words!
regards,
Julian
|
|
|
|
|
DAMN IT WORKS !!! 32 h of endless hate
I made a User Control inherit from the listview control,
and in the constructor i added (like you said):
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.UserPaint, True)
Me.SetStyle(ControlStyles.Opaque, True)
This Combination is working!!
Seems like the last time i made something wrong, thanks of you i tried it again,
i also want to recommend This Article[^] + falling Blocks )
My best regards
|
|
|
|
|
I want to find the creation date of an exe. I am using the following code.
Public Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer
Dim fHandle As Integer
fHandle = CreateFile(FileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0)
Using this handle, with some more code we can find the creation date.
This is working fine in VB. But not working in VB.net. CreateFile is returning -1 in VB.net.
Could anyone of you please tell me why it is not working in VB.net and is there any other way(methods) to find the creation date of an vb.exe file.
Thanks in advance,
AR Reddy
|
|
|
|
|
Dim file As New System.IO.FileInfo("path to file")
Dim creationdate As DateTime = file.CreationTime
That should do it
|
|
|
|
|
System.IO.File.GetCreation???(string filename)
Look for a method similar to the above in .NET and run it on the specified file.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Dim objFileInfo As New FileInfo("D:\64.jpg")
'To get the creation, lastaccess, lastwrite time of this file
Dim dtCreationDate As DateTime = objFileInfo.CreationTime
Dim dtLastAccessTime As DateTime = objFileInfo.LastAccessTime
Dim dtLastWriteTime As DateTime = objFileInfo.LastWriteTime
Found at:
http://www.devasp.net/net/articles/display/215.html[^]
Or
Dim fileName As String = "C:\MyPath\MyFile.txt"
If File.Exists(fileName) Then
Label_CreationTime.Text =
File.GetCreationTime(fileName).ToString
Label_LastAccess.Text =
File.GetLastAccessTime(fileName).ToString
Label_LastWrite.Text =
File.GetLastWriteTime(fileName).ToString
End If
Found at:
http://www.codeproject.com/KB/dotnet/FileTime.aspx[^]
If you need anymore help. Let me know.
modified 18-Dec-21 21:01pm.
|
|
|
|
|
I am Copying directory from one drive to another using the code below.The Function is working fine but my problem is that Is there any other way that I can reduce time taken to copy the directory.
thanks in advance...
my code is:
Sub CopyDirectory(ByVal SourcePath As String, ByVal DestPath As String, Optional ByVal Overwrite As Boolean = False)
Dim SourceDir As DirectoryInfo = New DirectoryInfo(SourcePath)
Dim DestDir As DirectoryInfo = New DirectoryInfo(DestPath)
' the source directory must exist, otherwise throw an exception
If SourceDir.Exists Then
' if destination SubDir's parent SubDir does not exist throw an exception
If Not DestDir.Parent.Exists Then
Throw New DirectoryNotFoundException _
("Destination directory does not exist: " + DestDir.Parent.FullName)
End If
If Not DestDir.Exists Then
DestDir.Create()
End If
' copy all the files of the current directory
Dim ChildFile As FileInfo
For Each ChildFile In SourceDir.GetFiles()
If Overwrite Then
ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), True)
Else
' if Overwrite = false, copy the file only if it does not exist
' this is done to avoid an IOException if a file already exists
' this way the other files can be copied anyway...
If Not File.Exists(Path.Combine(DestDir.FullName, ChildFile.Name)) Then
ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), False)
End If
End If
Next
' copy all the sub-directories by recursively calling this same routine
Dim SubDir As DirectoryInfo
For Each SubDir In SourceDir.GetDirectories()
CopyDirectory(SubDir.FullName, Path.Combine(DestDir.FullName, _
SubDir.Name), Overwrite)
Next
Else
Throw New DirectoryNotFoundException("Source directory does not exist: " + SourceDir.FullName)
End If
End Sub
|
|
|
|
|
I guess you could create the directory structure first and then use multiple threads to copy the files.
|
|
|
|
|
Can u provide any example for that.
I guess that the use of thread will Slow the copy of files as it will take some time to switch over b/w the Threads.
Thanks
|
|
|
|
|
i have here a source code for MSFlexgrid to highlight a specifi cell
or object with a value of greater than 0. i want to know how i'll gonna
increment the selection in MSFlexgrid. i hope you all understand my probelm... ^^
Private Sub Form_Activate()
Dim x As Integer
`x = 2 to skip the fixrow of MSFlexgrid
x = 2
Do Until x = Data1.Recordset.RecordCount
While Data1.Recordset.EOF = False
If Data1.Recordset.Fields("Balance") = MSFlexGrid1.TextArray(x) Then
If Data1.Recordset.Fields("C_Balance").Value > 0 Then
MSFlexGrid1.CellBackColor = vbYellow
Else
MSFlexGrid1.CellBackColor = vbBlue
End If
Data1.Recordset.MoveNext
Else
Data1.Recordset.MoveNext
End If
Wend
x = x + 1
Loop
End Sub
|
|
|
|
|
Hello all,
I was trying to print the text file in vb.net (winform)
After googling i got this code...
Let me explain in detail...
I Create a file at runtime based on user request. user can print that file after viewing it.
I want to show that file in PrintPreviewDialog and if user chooses to print then it can be.
The PrintPage event i m using is as
Dim pd As New PrintDocument
AddHandler pd.PrintPage, AddressOf pd_PrintPage
'Event for printpage
Private Sub pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = 0
Dim topMargin As Single = 0
Dim line As String = Nothing
linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)
' Iterate over the file, printing each line.
While count < linesPerPage + 9 ' manipulate the pagelength according to your interest
line = streamToPrint.ReadLine()
If line Is Nothing Then
Exit While
End If
yPos = topMargin + count * printFont.GetHeight(e.Graphics)
e.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, _
yPos, New StringFormat)
count += 1
End While
Pgnum = Pgnum + 1
If Not (line Is Nothing) Then
e.HasMorePages = True
count = count + 1
yPos = topMargin + count * printFont.GetHeight(e.Graphics)
e.Graphics.DrawString("Page:" + CStr(Pgnum), printFont, Brushes.Black, leftMargin + 700, _
yPos, New StringFormat)
Else
e.HasMorePages = False
count = count + 1
yPos = topMargin + count * printFont.GetHeight(e.Graphics)
e.Graphics.DrawString("Page:" + CStr(Pgnum), printFont, Brushes.Black, leftMargin + 700, _
yPos, New StringFormat)
End If
End Sub
But i m not sure where i should add this code to show document in oreview
PrintPreviewDialog1.Document = pd
PrintPreviewDialog1.ShowDialog()
am i missing something. or completely wrong?
Thanks.........!
___________________________________________
.Net Developer
|
|
|
|
|
Hi,
I am developing Anti spyware product. I got idea on what is spyware. I have seen different softwares. In that they are searching for memory items, registry items and file items. But how to find those spyware in our system.Based on which exes and dlls we can tell spyware, malware and trojans etc. are present in our system.Please give me some idea on which dlls, exes etc will cause spyware, adware.
Thank you in advance
|
|
|
|
|
pavanip wrote: Please give me some idea on which dlls, exes etc will cause spyware, adware
That surely is what your application is trying to find out? Any file COULD contain malware, the whole point of Anti spyware software is that it looks for these.
I suspect you are biting off rather more than you can chew here.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I guess Dave Kreskowiak answer didn't make it clear enough?
Anti spyware/virus/adware/... programme's are probably one of the most difficult things to write. Since the things you are searching for are always changing and are so many.
I would suggest you start with something more simple or at the very least do alot of research before you start writing this thing
|
|
|
|
|
I have a tabcontrol with 3 pages.
I have combo with the data coming from a datatable or dataview on each tab page.
I then bind the ValueMember to a property in of a class.
Dim dvMatrix As DataView = New DataView(gMT.PLMatrix, "", "Description", DataViewRowState.CurrentRows)<br />
cboMatrixID.DisplayMember = "Description"<br />
cboMatrixID.ValueMember = "MatrixID"<br />
cboMatrixID.DataBindings.Add("ValueMember", oSettings, "MatrixID")<br />
cboMatrixID.DataSource = dvMatrix
This works fine if it is on tabpage0
If I do exactly the same objec and binding on tabpage2 I get the following error
Cannot bind to the new value member.<br />
Parameter name: value
Has anyone else run up against this issues and is there a work around.
[edit] I only get the error when I change pages to page2, not when binding. There is no onchangevent and it does not hit any of the other break points (I have one in EVERY catch block on the form)
[/edit]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am trying to complete my project with third party dll using vb.net ,
i cant call the function RDA_ReadAlarmList as below ,
this function call return a integer value and receive the RDA_ReadAlarmList Structure and RDA_AlarmSearchParam as a parameter.
Hope the bro here can help me on this , already headache for few week on this .. what --> RDS_AlarmList **outAlarmList means ?
Structure array ? How should i call this in vb.net ?
Function
10.8.1 It acquires an alarm list ( The asynchronousness ).
int WINAPI RDA_ReadAlarmList(RDS_AlarmList **outAlarmList, RDS_AlarmSearchParam *inAlarmSearchParam);
Structure
11.8.4 The alarm list search parameter
typedef struct {
RDE_SearchDir dir; The direction of the search
RDE_SearchMode mode; The browse mode
int num; The number of the searches (1-1000)
bool senser[16]; The sensor true...The sensor is valid.
int year; The year ( The 4 digit Christian era )
int month; The month (1-12)
int day; The day (1-31)
int hour; The hour (0-23)
int minute; The minute (0-59)
int second; The second (0-59)
} RDS_AlarmSearchParam;
11.8.4 The alarm list item
typedef struct {
int listNumber; The list supervision number (0-9999)
int alarmNumber; The alarm list number (1-10000)
bool isEnable; The alarm validity / the invalidity ( true: Valid, false: Invalid )
int year; The year ( 4 digits )
int month; The month (1-12)
int day; The day (1-31)
int hour; The hour (0-23)
int minute; The minute (0-59)
int second; The second (0-59)
int block; The device index
int field; The field number
int drive; The playback point drive number
int vol; The playback point VOLUME number
int camera; The camera number ( 0: The emergency, 1-: The camera number )
RDE_Alarm alarmType; The alarm type
} RDS_AlarmList;
**Superbom**
|
|
|
|
|
Let me tell you this step by step.
RDS_AlarmList is a structure, therefore
RDS_AlarmList obj1 is one object of this structure.
RDS_AlarmList *obj2 defines a pointer of this structure type.
RDS_AlarmList **obj3 defines a pointer of pointer.
A pointer of pointer is a pointer variable which can hold memory address of a pointer.
If you want to know more about pointers of pointer, I would recommend you to search on Google, it will give you links of tutorials.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
In general, I would assume that the **outAlarmList indicates an array instead of just a pointer to a pointer to a single structure. The documentation of the function or some other piece of context tell you. However, you will need to declare things a little differently on the .NET side than if it was outAlarmList[]. Since the "array" seems to be an array of pointers, you will have to declare the RDS_AlarmList as a class (making sure to still mark it with the StructLayout attribute).
This single pointer to the second parameter means that you want to either declare RDS_AlarmSearchParam as a Structure and pass ByRef (the normal approach) or declare it as a Class and pass ByVal
So you should end up with this:
<StructLayout(LayoutKind.Sequential)> _
Public Structure RDS_AlarmSearchParam
<StructLayout(LayoutKind.Sequential)> _
Public Class RDS_AlarmList
<DllImport(fill in information)> _
Public Shared Function RDA_ReadAlarmList(ByVal outAlarmList() As RDS_AlarmList, _
ByRef inAlarmSearchParam as RDS_AlarmSearchParam)
|
|
|
|
|
Hi All!
I'm struggling to figure out how to add event handlers to a control at runtime, I'm looking for some code like this:
Panel1.MouseEnter = MyFunction()
That assigns MyFunction() to be called whenever Panel1 has the Cursor placed over it.
I've tried this and it doesn't work, and I can't seem to figure it out. Does anybody know how to solve this?
Thanks!
MrWolfy
|
|
|
|
|
Lookup AddHandler and RemoveHandler .
AddHandler someObject.Event, AddressOf myEventHandler
Of course, the eventhandler is going to need to have the method signature expected by the event.
|
|
|
|
|
Hi And Thanks!
Works perfectly!
Thanks Again!
MrWolfy
|
|
|
|
|
I want a grid control for a Windows Forms Project that will take a DataTable and display it vertically. For example it would take a DataTable like this:
Name Amount Due
Bob 55.65
Sue 20.33
Fred 15.18
And then display it like this:
Name Bob Sue Fred
Amount Due 55.65 20.33 15.18
I know I can get basically the same result by just flipping rows/columns in the DataTable, but I'm guessing that with very large DataTables this would not be very efficient. And I may need to use very large DataTables.
So, does anyone know of a good article of how to get started creating a control that would do this or something similar, or of a control out there that already does this? I've found some info on web versions of a grid that does this, but I've had a hard time finding anything that is specifically for a Windows Forms project. Any help would be appreciated.
|
|
|
|
|
I created a stored procedure which worked fine on Query Analyzer, except I had to load my text file locally on my "server", using this command [EXEC OrderImport 'C:\Import.txt']. Here are the problems:
1. How can I tell my stored procedure to look for my "text file" in the client, not the server?
2. On my VB codes, I have a "text box" (Txt_Path.Text) to enter the "File Path" and when I execute the stored-procedure, this file path should be included. How can I code it correctly in VB? Please look at this statement if I did it wrong "Cmd.Parameters.Append Cmd.CreateParameter("File_Path", adVarChar, adParamInput, 6, FilePath)"
Thank you again for your help.
*******This is my Stored Procedure********
CREATE PROCEDURE OrderImport
@PathFileName varchar(100) --this is my parameter for the file path
AS
DECLARE @SQL varchar(2000)
BEGIN
SET @SQL = "BULK INSERT TmpDeck_Ord FROM '"+@PathFileName+"' WITH (FIELDTERMINATOR = ',') "
END
EXEC (@SQL)
INSERT Deck_Ord (Depot_Num,Wty_Status,Ros_Num )
select Depot_Num, Wty_Status, Ros_Num
FROM tmpDeck_Ord
TRUNCATE TABLE TmpDeck_Ord
GO
******and this is my VB codes********************
Option Explicit
Dim Con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Cmd As ADODB.Command
Dim FilePath, StrConnect As String
Private Sub Cmd_get_Click()
FilePath = Txt_Path.Text
Set Cmd = New ADODB.Command
Cmd.ActiveConnection = Con
Cmd.CommandType = adCmdStoredProc
Cmd.CommandText = "OrderImport"
Cmd.Parameters.Append Cmd.CreateParameter("File_Path", adVarChar, adParamInput, 6, FilePath)
Set rs = Cmd.Execute
Set Cmd.ActiveConnection = Nothing
End Sub
Private Sub Form_Load()
StrConnect = "Database=myDB;SERVER=myServer;DRIVER={SQL SERVER};"
Con.Open StrConnect, "sa", "password"
End Sub
PNH
|
|
|
|
|
phn110 wrote: 1. How can I tell my stored procedure to look for my "text file" in the client, not the server?
You can't. The server's SQL accounts are not going to have any permissions to the filesystem of the local workstation.
|
|
|
|
|
Dave, thank you for your reply.
How can I work around that with VB app.? I used a "FilePath" as a parameter in the stored procedure. Thanks in advance for your help.
PNH
PNH
|
|
|
|
|