|
The scanner should give you some capability to prepend a character string to what it scans. For example if the code it see is 1234567890 , it should give you the ability to tell it to prefix the code with a character or two, like @123456789 is sent to your application.
Don't worry about the focus. The focus will change with every button that's pressed. On the Form, turn KeyPreview on. Handle the form's KeyDown event. In that event handler, check to see if the key being pressed is a "@", or whatever you want. If it is, then you can force the focus to the TextBox and let the rest of the keypresses through.
Oh, the scanner should also let to append a character to the string too, like ASCII 13 (ENTER).
|
|
|
|
|
This information is helpful and points me in the right direction, but I seem to be running into an error. Below is the test code I am using.
[CODE]
Private Sub Form1_KeyDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If (Me.KeyPreview = "q") Then
MsgBox("q")
TextBox5.Visible = True
End If
End Sub
[/CODE]
However, I am when I press the [q] key I get "System.InvalidCastException was unhandled. Conversion from string "q" to type 'Boolean' is not valid." Truth be told I have no idea what that means. Could you send a little code sample back my way. Thanks.
|
|
|
|
|
Absenm wrote: If (Me.KeyPreview = "q") Then
Ummm... You might want to lookup the docs on KeyPreview. It's not a property that get's the key, it's a True/False property you set to turn it on.
The KeyEventArgs has the key that is beind pressed, in its KeyCode property.
Private Sub Form1_KeyDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Q Then
MsgBox("q")
' This line stops the key from beings seen by the control with the focus.
e.Handled = True
End If
End Sub
|
|
|
|
|
Yes, after doing further research and read a bit more at tbe .NET Framework Developer Center I figured out how to get my application to see keystrokes. I used something simular to what Dave suggested.
<br />
Private Sub Form1_KeyDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown<br />
If e.KeyCode = Keys.G Then<br />
TextBox5.BringToFront()<br />
TextBox5.Focus()<br />
End If<br />
If e.KeyCode = Keys.Enter Then<br />
MsgBox("Complete")<br />
' Go to sub routine to process gift cards.<br />
End If<br />
End Sub<br />
It works pretty good but I wish I could figure out what the keycodes are for percent sign and question mark as these are the anchor characters on our gift cards magnetic strips.
|
|
|
|
|
There is no "%" key on the keyboard, is there?? It's the "5" key with the Shift key held down, isn't it?? So...
If e.Modifiers = Keys.Shift AndAlso e.KeyCode = Keys.D5 Then
Debug.WriteLine("Shift 5 detected!")
e.Handled = True
End If
If you want to find out what key was pressed, just put
Debug.WriteLine(e.KeyCode.ToString())
just before the If statement.
|
|
|
|
|
Dear all
fine
I want to write code to generate serial hard disk , but I cannot do my own self so that if you can do . Please detail step to do it. Thanks you.
The best regard
From Sovy.
email: sovy_sim@yahoo.com
|
|
|
|
|
|
What do you mean by "generate serial hard disk"??
|
|
|
|
|
Hi everyone
I got a small problem I have devloped hotel software and I am trying to draw achart that shows %age occupancy. I would like to draw a pie chart on a form. I have managed to do this so far,the chart is being drawn when the form loads.
I would like the form to be able to redraw when a user specifies a different date such that you can view the past occupancy. The code I am using is shown below. I hope you will be able to help me.
twisted F8
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim TotalCount As Single
Dim rect As Rectangle = New Rectangle(100, 105, 150, 150)
For Each gd As GraphData In occupancy
TotalCount += gd.percentageocc
Next
Dim g As Graphics = e.Graphics
' Create variables to hold the changing values of Angles
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
Dim StartAngle As Single = 0
Dim SweepAngle As Single = 0
For Each gd As GraphData In occupancy
SweepAngle = 360 * gd.percentageocc / TotalCount
g.FillPie(New SolidBrush(gd.Clr), rect, StartAngle, SweepAngle)
StartAngle += SweepAngle
Next
' g.DrawPie(New Pen(Color.Brown), rect, StartAngle, SweepAngle)
' Create a Brush to draw the text
Dim TextBrsh As Brush = New SolidBrush(Color.Black)
' Create a Font object instance for text display
Dim TextFont As New Font("Arial", 12, FontStyle.Bold)
g.DrawString("Chart Key", TextFont, TextBrsh, 310, 100)
Dim pxFromTop As Integer = 135
For Each gd As GraphData In occupancy
' Draw bullet
g.FillEllipse(New SolidBrush(gd.Clr), 310, pxFromTop, 15, 15)
' Draw line round bullet.
g.DrawEllipse(New Pen(Color.Black), 310, pxFromTop, 15, 15)
' Draw the text - color coded
g.DrawString(gd.Description & " (" & gd.percentageocc & "%)", TextFont, TextBrsh, 360, pxFromTop)
' Increase gap from Top for next line
pxFromTop += 30
Next
End Sub
|
|
|
|
|
I think Form.Refresh() method will do the job for you.
AliAmjad(MCP)
|
|
|
|
|
Hi,
some remarks:
1. You can force a redraw by calling Invalidate() on the Control that does the drawing,
in your case a Form.
2. Please, please publish code snippets inside PRE tags; it reads much better.
3. You must call Dispose() on those objects that you create and havre such a class,
as in SolidBrush and Pen.
4. For predefined colors there also exist predefined objects (Pen, Brush), see
Pens class and Brushes class. You should not try to dispose these, since you did not
create them!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hey,, i just want to ask on how to program a digital persona fingerprint scanner.
I've installed the SDK and the platinum integrator I've also followed the sample codes that are written in the manual but it still doesn't work...
can you help me with this problem??
|
|
|
|
|
get the sdk that come with your finger print device. Some device and sdks come with sample code. I have used CrossMatch fingerprint reader with grFinger sdks and is working fine
you may visit www.griaule.com
good luck
t.aransiola
|
|
|
|
|
thanks for the advice. But I've already got the SDK of the device and I've already installed it in my PC. But the samples that are written in the manual are missing. Can the device work even if the SDK are not similar?
Thanks a lot.
|
|
|
|
|
|
if your device is among teh device list supported by grfinger, teh code will work. Check the griaule site to check the fingerprint devices supported. I am using CrossMatch300 finger print reader and has been working with the sample code from grfinger
good luck
t.aransiola
|
|
|
|
|
|
This is a very specific application. One where there isn't going to be a whole lot of experience floating around. Your single best source of information would be the support forums on the company that made the device.
|
|
|
|
|
hey all, i have a list box displaying data, with all the formatting anf all of that
Dim fmtStr As String = "{0, -15} {1, -7}"
lstDisplay.Items.Add(String.Format(fmtStr, inputNum, inputNum * inputNum2))
so far everything works fine
Now, I need to search in the listbox ....
im, making use of the indexOF function
this function listBox.items.indexof("fgfgfg") works fine when the listbox is not formatted, when it is formatted ... i do not get any error messages ... it shows that the thing im searching for isnt there when it really is there .. any ideas?
gHoSt
|
|
|
|
|
Hi,
AFAIK ListBox.Items.IndexOf() will only match exact strings, i.e. it will not find partial
matches. You should look at ListBox.FindString() instead, which does partial matching.
Check the documentation on these methods!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
When Opening the other windows form old windows form should be closed otherwise i want a code to display eror massage that please close the old form .
i want latest and professional code .
please send me yar.
Pavan
|
|
|
|
|
Noone is going to write the code for you. There is no "latest" code to do this. YOU have to write the code.
It's not that difficult. All you do is maintain a variable that holds the currently opened Form object. If, when creating a new form, you check that variable and see that it's not Nothing, you can put up your warning. If it's Nothing, then it's safe to create your new form and put it in that variable. When that form closes, you set the variable to Nothing.
|
|
|
|
|
Hi to all!
I am new of The Code Project....
I'm trying to develop an application for my PDA Device ( Windows Mobile 2003 SE), using Visual Studio 2005 and .NET Compact Framework in Basic language.
It consist in drawing a diagram, reading data from a Text file.
I already reached a decent result, but now I am a little in difficulties, because in this text file there is a field containing a Date/Time value in TDateTime format (Delphi/Pascal or C++ language?), that I must read and convert in Basic format (or in string).
I not found any simple resolution (for me) to solve this problem, also because I don't know other programming languages.
Someone can help me, please?
Thanks in advance.
Marco
|
|
|
|
|
Since I've never used Delphi, I don't know what the Date/Time looks like in a text file.
From what I can Google, it look like a Delphi DateTime is stored as a Double type in VB.NET. After getting that, it should be a matter of some simple math to convert it to a DateTime type.
|
|
|
|
|
Thanks for help Dave.
Following is a sample of the text file that I need to get data:
Example
-27.350436, 153.055540,1,-777,36169.6307194, 09-Jan-99, 3:08:14
-27.348610, 153.055867,0,-777,36169.6307194, 09-Jan-99, 3:08:14
Field 1 : Latitude - decimal degrees.
Field 2 : Longitude - decimal degrees.
Field 3 : Code - 0 if normal, 1 if break in track line
Field 4 : Altitude in feet (-777 if not valid)
Field 5 : Date - see Date Format below, if blank a preset date will be used
Field 6 : Date as a string
Field 7 : Time as a string
Date Format
Delphi stores date and time values in the TDateTime type. The integral part of a TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a TDateTime value is the time of day.
Following are some examples of TDateTime values and their corresponding dates and times:
0 --------> 12/30/1899 12:00 am
2.75 -----> 1/1/1900 6:00 pm
-1.25 ----> 12/29/1899 6:00 am
35065 ----> 1/1/1996 12:00 am
The problem for me is that not ever Date and Time (in string format) are present in the text file, but only the TDateTime format.
I hope that with above sample is more easy to understand my problem.
Marco
|
|
|
|
|