|
Read my image processing articles, the first one has a greyscale filter. You can do it easier with a color matrix, you can find that code easily on the web. The Microsoft Fotovision sample certainly contains it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi All,
Can anybody point me in the right direction. I need to display text and numbers in extra large, Is it possible to make a character aprox. 300 Pixels x 300 Pixels. Any help would be appreciated.
Thanks
Tony Glover
|
|
|
|
|
What have you tried ? I'd expect DrawString to work just fine.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
we use webbrowser in a very simple protocol that just gets a string to a server and should receive a string back. the webbrowser does it all right, but we need to get to the received string in the code - and it just does not appear.
we tried webbrowser1.DocumentText aand although the browser shows the right message, the DocumentText is ""
????
Noki Lavie
Bar-Ore Ltd.
|
|
|
|
|
Hi,
I have written an activeX control that sends an event 200 times a second, so fairly quickly, the data needs to be sent this fast. The activeX control works fine, I can add it into VB .NET and it works fine, when I try to add into the event handler a counter that refreshes a label it freezes the program. Is this happening because I am trying to refresh the label too quickly.
The code I inserted into it is as follows:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim test As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AxTest.Initialize()
test = 0
End Sub
Private Sub AxTestCtrl1_DataReady(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxTestCtrl1.DataReady
test = test + 1
Label1.Text() = test
Label1.Refresh()
End Sub
End Class
This causes the whole application to freeze, and if I comment the two Label1 instructions out of the code it works fine without freezing.
Any help would be greatly appreciated.
|
|
|
|
|
Yes, calling a paint method 200 times a second will do that. Instead, set a timer that goes off every second, or something, and do the screen update then. You're not going to run a 200 times a second counter on a form and have it doing anything else.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i am developing clent server Application, where at client i have several datetimepicker controls for which i am setting a 'max value' Property as today. and for some datetime pickers i have not set any max value. So, if i run the appicaion and keep it for more than 24 hrs...
for controls which i set max value, maxvalue is not chnaging to todays date. they are showing yesterdays date. and for controls which i did not set any max value they are just fine. today's date is reflected there.
can any body suggest me how to fix this ASAP.
Thanks in advance.
Happiness keeps u Sweet, Trials keep u Strong, Sorrow keeps u Human,
Failure Keeps u Humble and Success keeps u glowing, but only Faith
Keeps u
Going.....
|
|
|
|
|
The only suggestion I have is use a timer to refresh the maxvalue. You could set the timer to go off at a reasonable interval and when it does it would set the maxvalue to the current date. The other thing you might need to consider is someone changing the computers system clock. A persons PC isn't a reliable source for the date because in it could be anything. Also just as an insurance policy you could validate the date selected. If it's beyond the current date you would set the date back to whatever it was before the user changed it. This is just a quick example.
Public Class Form1
Dim LastDate As Date = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Initialize the LastDate to the current date selected
'in the DateTimePicker1
LastDate = DateTimePicker1.Value
End Sub
Private Sub DateTimePicker1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
'Validate the date selected. If it's past the current date
'then reset it to the last date selected
If Date.Compare(DateTimePicker1.Value, Now) > 0 Then
DateTimePicker1.Value = LastDate
Else
LastDate = DateTimePicker1.Value
End If
End Sub
End Class
|
|
|
|
|
I made a quick change to how I think you should validate the date selected. This will allow you to easily handle multiple datetimepickers (of which you said you had) without really changing the code.
Public Class Form1
Dim LastDate As Date
Private Sub DateTimePicker_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePicker1.GotFocus, DateTimePicker2.GotFocus
LastDate = CType(sender, DateTimePicker).Value
End Sub
Private Sub DateTimePicker_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged, DateTimePicker2.ValueChanged
Dim dtp As DateTimePicker = DirectCast(sender, DateTimePicker)
If Date.Compare(dtp.Value, Now) > 0 Then
dtp.Value = LastDate
End If
End Sub
End Class Notice that after 'Handles' in each delaration I have added the appropriate events for Two DateTimePickers. You can add more in the same manner which is all you need to do to validate them all.
|
|
|
|
|
hi,
i am confused with Handle Keyword. what is this "Handle" key word?? why we need this?
i saw this sample code in microsoft core references VB.Net Book.
it is referenced to Accessing the user control from the client Page:
Proteced WithEvents pbar As PagingBar
Private Sub Page_load(ByVal sender As object, ByVal e As EventArgs)_
Handles MyBase.Load
pbar=Directcast(findcontrol("PagingBar1").PageingBar)
End Sub
please can anyone tell me what is "Handle" keyword??
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
You can add events after the handles keyword, which allows that procedure to handle a particular event . For instance if I had a procedure that I wanted to handle the click event for a number of buttons I could add each buttons click event after the handles keyword.
|
|
|
|
|
hi,
thanks for answering my question! i have one samll doubt....is it compulsory to use with withevent keyword to handle the event handler??
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
I'm not sure I understand the question. I don't think 'Withevents' is required in any circumstances. You can use it when you declare a variable. Like 'Withevents txt as new textbox'. This really just makes it easier to add an event handler for your object because you can select the event just like you would for any textbox you put on your form in the designer. However, you can always write an event handler even if you didn't use 'Withevents'. I hope that made some sense to you.
|
|
|
|
|
Hi - I have a small development app that (used to) talk to a servo on a com port, and get a status reply. I have somehow really fixed it (I tried to simplify the code) - but the symptoms are maddening, and I do not see what I did other than move a readline from a subroutine to be inline with the code.
Here is what I have
Public ServoCommName As String = "COM4"
Public ServoCommSpeed As Integer = 9600
Public ServoCommdataOut As String
Public ServoCommDataIn As String
Public ServoCommParity As System.IO.Ports.Parity
Public ServoCommDataBits As Integer
Public ServoCommStopBits As System.IO.Ports.StopBits
Public Com2 As SerialPort = My.Computer.Ports.OpenSerialPort(ServoCommName, ServoCommSpeed, IO.Ports.Parity.None, 8, IO.Ports.StopBits.One)
Then the subroutine . . .
Public Sub GetServoStatus()
' Sends a status request and then gets Status from the Servo serial port.
ServoCommdataOut = cstCameraServoAddress & "&R"
Call SendSerialData() 'This will return the Firmware Version
'just in case wait 500 ms ' I have tried all sorts of delays . . . it worked before with 500
Call DelayTimer(DelayTime)
ServoCommDataIn = Com2.ReadLine()
MsgBox("End Read" & DelayTime & ServoCommDataIn)
outLabel = "Read Servo"
outMessage = ServoCommDataIn
Call WriteToLog(outLabel, outMessage)
ServoStatusBoxOut = "Ready"
ServoStatusBox = ServoStatusBoxOut
End Sub
Here is the portmonitor recording for this part of the code . . . The response comes in on line 52 and portmon says it is fine !
32 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_BAUD_RATE slabser1 SUCCESS Rate: 9600
33 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_RTS slabser1 SUCCESS
34 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_DTR slabser1 SUCCESS
35 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_LINE_CONTROL slabser1 SUCCESS StopBits: 1 Parity: NONE WordLength: 8
36 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_CHAR slabser1 SUCCESS EOF:1a ERR BRK EVT:1a XON:11 XOFF:13
37 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_HANDFLOW slabser1 SUCCESS Shake Replace XonLimit:128 XoffLimit:128
38 7:18:29 AM CameraControlV1 IOCTL_SERIAL_CLR_RTS slabser1 SUCCESS
39 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_TIMEOUTS slabser1 SUCCESS RI:-1 RM:-1 RC:-2 WM WC
40 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_WAIT_MASK slabser1 SUCCESS Mask: RXCHAR RXFLAG CTS DSR RLSD BRK ERR RING
41 7:18:29 AM CameraControlV1 IOCTL_SERIAL_SET_QUEUE_SIZE slabser1 SUCCESS InSize: 4096 OutSize: 2048
42 7:18:29 AM CameraControlV1 IOCTL_SERIAL_WAIT_ON_MASK slabser1 SUCCESS
43 7:18:49 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 4: /1TR
44 7:18:49 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
45 7:18:49 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
46 7:18:50 AM CameraControlV1 IOCTL_SERIAL_WAIT_ON_MASK slabser1 SUCCESS
47 7:18:50 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 4: /1&R
48 7:18:50 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
49 7:18:50 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
50 7:18:51 AM CameraControlV1 IOCTL_SERIAL_WAIT_ON_MASK slabser1 SUCCESS
51 7:18:51 AM CameraControlV1 IOCTL_SERIAL_GET_COMMSTATUS slabser1 SUCCESS
52 7:18:51 AM CameraControlV1 IRP_MJ_READ slabser1 SUCCESS Length 48: ./0b...../0`EZServo All Motion V5.45 6-20-06....
53 7:18:51 AM CameraControlV1 IOCTL_SERIAL_GET_COMMSTATUS slabser1 SUCCESS
54 7:18:51 AM CameraControlV1 IOCTL_SERIAL_GET_COMMSTATUS slabser1 SUCCESS
55 7:18:51 AM CameraControlV1 IOCTL_SERIAL_GET_COMMSTATUS slabser1 SUCCESS
56 7:18:51 AM CameraControlV1 IOCTL_SERIAL_GET_COMMSTATUS slabser1 SUCCESS
57 7:18:51 AM CameraControlV1 IOCTL_SERIAL_GET_COMMSTATUS slabser1 SUCCESS
58 7:18:51 AM CameraControlV1 IOCTL_SERIAL_GET_COMMSTATUS slabser1 SUCCESS
59 7:18:51 AM CameraControlV1 IOCTL_SERIAL_GET_COMMSTATUS slabser1 SUCCESS
60 7:18:56 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 12: /1f0Z500000R
61 7:18:56 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
62 7:18:56 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
63 7:18:56 AM CameraControlV1 IOCTL_SERIAL_WAIT_ON_MASK slabser1 SUCCESS
64 7:19:01 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 6: /1Tz0R
65 7:19:01 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
66 7:19:01 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
67 7:19:01 AM CameraControlV1 IOCTL_SERIAL_WAIT_ON_MASK slabser1 SUCCESS
68 7:19:02 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 6: /1Tz0R
69 7:19:02 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
70 7:19:02 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
71 7:19:02 AM CameraControlV1 IOCTL_SERIAL_WAIT_ON_MASK slabser1 SUCCESS
72 7:19:02 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 8: /1A4576R
73 7:19:02 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
74 7:19:02 AM CameraControlV1 IRP_MJ_WRITE slabser1 SUCCESS Length 1: .
75 7:19:02 AM CameraControlV1 IOCTL_SERIAL_WAIT_ON_MASK slabser1 SUCCESS
But ....................... My log file has the following . . . .
Initialize, 2007020571849, File Created
Initialize, 2007020571849, AS2007020571849
Read GPS INIT, 2007020571849, GPRMC,151830,A,3743.1693,N,12203.7291,W,0.0,242.5,050207,15.0,E,A*33
servoInit, 2007020571850, AerialServices - EZComm Servo Control
servoWrite, 2007020571850, /1&R
Read Servo, 2007020571856, ?/0b <===================== This is what VB is seeing ! Help !!
servoWrite, 2007020571856, /1f0Z500000R
servoWrite, 2007020571901, /1Tz0R
servoZero, 2007020571902, /1Tz0R
servoWrite, 2007020571902, /1Tz0R
servoZero, 2007020571902, /1Tz0R
servoWrite, 2007020571902, /1A4576R
servoReadyPosition, 2007020571903, /1A4576R
Another oddity - (not necessarily related but strange that it would occur at the same time as this . . ) is that the vbCRLF constant seems to go missing in the midst of writing some of the log file entries -here is the sub I am using . . .
Public Sub WriteToLog(ByVal outLabel As String, _
ByVal outMessage As String)
'NAME: WriteToLog
'PURPOSE: Write Status message
'PARAMETERS: outMessage - message to be written to error file
' outLabel - type of the log file entry
'RETURNS: Nothing
'*************************************************************
Dim fs1 As FileStream = New FileStream("c:" & "\Logfiles\" & LogFileName & ".txt", FileMode.Append, FileAccess.Write)
Dim s1 As StreamWriter = New StreamWriter(fs1)
Dim DateStringOut As String = String.Format("{0:yyyyMMddHmmss}", DateTime.Now)
s1.Write(outLabel & ", " & DateStringOut & ", " & outMessage & vbCrLf)
s1.Close()
fs1.Close()
End Sub
The vbCRLF goes missing when I am reading another serial port and reading a series of NMEA messages - I thought that it might have something to do with a Public defining of variables such as outMessage but I changed these to a Dim (before the first sub) with no program output change.
|
|
|
|
|
I'm no expert but you moved a line of code maybe with a cut and paste maybe you got an extra line return in there somewhere.
Might be completely silly but the simple things first
Bird with no beak was born to succeed.
|
|
|
|
|
Thanks for the response - I have looked pretty carefully but nothing is obvious - the problem seems to be that PortMon sees the string comming in - but the readline(ServoDataIn) statement in the vb code either gets an incomplete transfer or garbage - I am not certain which . . . this is all very slow stuff and not much data is moving . . .
|
|
|
|
|
An article was printed about one week ago, week of Jan. 29, 2007, regarding purchase of Window s Vista. The article stated that a user can purchase the Ultimate package for around $200. I am wondering how one goes about this. Please let me know at EMAIL given. Thanks, Sid Kraft
Sid
|
|
|
|
|
how does this relate to VB.NET ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Well VB .Net will not be supported under Vista
Bird with no beak was born to succeed.
|
|
|
|
|
Christian: I am using Visual C++ 6.0, not VB. Sid Kraft
Sid
|
|
|
|
|
Then why are you asking a non-programming question, in a forum for a language you don't even use ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian: Sorry, thought I was sending a question to the Windows Group, Sid Kraft;)
Sid
|
|
|
|
|
I am reading a word document in a byte stream and trying to insert it in sql server table (field is varbinary type). The byte array contains 1000s elemets but in table it writes only '0xD0'.
Any idea what's wrong with it?
Thanks
Nas
|
|
|
|
|
manisghouri wrote: Any idea what's wrong with it?
Nope. Perhaps if you showed us what your code it we might be able to see what it wrong with it.
|
|
|
|
|
'To add document
'---------------
Private Function AddRequest(ByVal DocId As String, ByVal DocUSer As String _
, ByVal DocTitle As String, ByVal DocSubject As String, ByVal fileName As String) as Boolean
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
' Read the Data into the Byte Array
Dim fStream As New FileStream(fileName, FileMode.Open, FileAccess.Read)
Dim DocData(fStream.Length) As Byte
fStream.Read(DocData, 0, CInt(fStream.Length))
fStream.Close()
With cmd
.CommandType = CommandType.StoredProcedure
.CommandText = "sp_AddDocument"
.Connection = Conn
Dim para1 As SqlParameter = .Parameters.Add("@DocId", SqlDbType.Varchar)
Dim para2 As SqlParameter = .Parameters.Add("@DocUser", SqlDbType.Int)
Dim para3 As SqlParameter = .Parameters.Add("@DocTitle", SqlDbType.VarChar)
Dim para4 As SqlParameter = .Parameters.Add("@DocData", SqlDbType.VarBinary)
para1.Value = DocId
para2.Value = DocUser
para3.Value = DocTitle
para4.Value = DocData
End With
Try
dr = cmdBrochureRequest.ExecuteReader
With dr
If .HasRows Then
While .Read
DocStatus = .Item(0)
isDone = True
End While
Else
MsgBox("No Document status retrieved", MsgBoxStyle.Critical, appTitle)
isDone = False
End If
End With
cmd.Parameters.Clear()
cmd = Nothing
dr.Close()
Catch ex As Exception
MsgBox("Error while inserting document into database:" & vbCrLf & ex.Message.ToString, MsgBoxStyle.Critical, appTitle)
isDone = False
End Try
If isDone = True Then
isDone = AddRequestDetail(RequestId)
End If
Return isDone
End Function
'To read document
'---------------
Private Function OpenDocument(ByVal DocId as string)
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
With cmd
.CommandText = "sp_GetDocument "
.CommandType = CommandType.StoredProcedure
.Connection = ConnPIMPS
.Parameters.AddWithValue("@DocId", DocId)
End With
Try
dr = cmd.ExecuteReader
dr.Read()
Dim FileData(dr.GetBytes(0, 0, Nothing, 0, Integer.MaxValue) - 1) As Byte
dr.GetBytes(0, 0, FileData, 0, FileData.Length)
DisplayDocument(FileData)
dr.close
Catch ex As Exception
MsgBox("Error while opening document :" & vbCrLf & ex.Message.ToString, MsgBoxStyle.Critical, AppTitle)
Exit function
End Try
Private Sub DisplayDocument(ByVal arrInput() As Byte)
Dim i As Integer
Dim sOutput As New StringBuilder(arrInput.Length)
For i = 0 To arrInput.Length - 1
If Not CType(arrInput(i), Byte).ToString = 0 Then
sOutput.Append(Chr(arrInput(i)))
End If
Next
RichTextBox1.text = sOutput.ToString()
End Sub
Do you think it is what i required to save word document in sql server table,
regards
Nas
|
|
|
|
|