Click here to Skip to main content
15,916,318 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: opening a form from a string name Pin
Dave Kreskowiak22-Feb-05 3:58
mveDave Kreskowiak22-Feb-05 3:58 
GeneralRe: opening a form from a string name Pin
Shawn200022-Feb-05 4:36
Shawn200022-Feb-05 4:36 
GeneralRe: opening a form from a string name Pin
Dave Kreskowiak22-Feb-05 6:09
mveDave Kreskowiak22-Feb-05 6:09 
GeneralPrinting + Encoding Magstripe Pin
YorkTech22-Feb-05 0:02
YorkTech22-Feb-05 0:02 
GeneralRe: Printing + Encoding Magstripe Pin
Dave Kreskowiak22-Feb-05 0:48
mveDave Kreskowiak22-Feb-05 0:48 
GeneralRe: Printing + Encoding Magstripe Pin
YorkTech22-Feb-05 7:11
YorkTech22-Feb-05 7:11 
GeneralRe: Printing + Encoding Magstripe Pin
Dave Kreskowiak22-Feb-05 7:32
mveDave Kreskowiak22-Feb-05 7:32 
GeneralRe: Printing + Encoding Magstripe Pin
YorkTech23-Feb-05 5:22
YorkTech23-Feb-05 5:22 
Ok folks I've managed to sort this out so here's how you do it. Just in case someone else has the same trouble.

This method should work for the following manufacturers printers that allow magnetic stripe encoding via Escape codes. The snytax is slight different for each manufacture. Usually ~1 ~2 ~3 for tracks 1,2,3 respectively.

Card Printers
-------------
Eltron
Alantek
Fargo
DataCard
Victor Data Systems

*Note* This does not mean sending sending RAW data straight to the printer. The Datacard documentation explains that the print data has to be sent to the driver.

This uses the standard .net printing objects

To Encode your magstripe

'Grab the handle of the graphics object provided by the printpageeventargs
hDC = e.Graphics.GetHdc
'Set up your data
magTrack1 = "~1" & m_Card.MagTrack1
magTrack2 = "~2" & m_Card.MagTrack2
magTrack3 = "~3" & m_Card.MagTrack3
'Call the GDI ExtTextOut Routine
ExtTextOut(hDC, 10, 10, 2, Nothing, magTrack1, magTrack1.Length, Nothing)
e.Graphics.ReleaseHdc(hDC)
'Release the hdc
e.graphics.release(hDC)

Now do any other fancy graphics for your card layout and call the print event when finished. If you use a print preview you'll seen the magstripe text drawn on the screen. But it isn't printed, the printer recognises the escape codes and encodes the mag stripe.

The code for calling ExtTextOut is :-

Private Structure RECT
Public Left As Int32
Public Top As Int32
Public Right As Int32
Public Botton As Int32
End Structure
Private Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As IntPtr, _
ByVal x As Integer, ByVal y As Integer, ByVal wOptions As Integer, ByRef lpRect As RECT, _
ByVal lpString As String, ByVal nCount As Integer, ByVal lpDx As Integer) As Integer

Hope this helps someone else
Cheers
Steve.Smile | :)

QuestionRe: Printing + Encoding Magstripe Pin
coderam1-Jun-09 1:30
coderam1-Jun-09 1:30 
Generalthread timer abort Pin
manasrahfantom21-Feb-05 23:49
manasrahfantom21-Feb-05 23:49 
GeneralRe: thread timer abort Pin
Dave Kreskowiak22-Feb-05 0:39
mveDave Kreskowiak22-Feb-05 0:39 
GeneralRe: thread timer abort Pin
manasrahfantom22-Feb-05 0:57
manasrahfantom22-Feb-05 0:57 
GeneralRe: thread timer abort Pin
Dave Kreskowiak22-Feb-05 1:41
mveDave Kreskowiak22-Feb-05 1:41 
GeneralRe: thread timer abort Pin
manasrahfantom22-Feb-05 2:07
manasrahfantom22-Feb-05 2:07 
GeneralRe: thread timer abort Pin
Dave Kreskowiak22-Feb-05 3:09
mveDave Kreskowiak22-Feb-05 3:09 
Questionhow is creating control? Pin
MGunes21-Feb-05 23:49
MGunes21-Feb-05 23:49 
AnswerRe: how is creating control? Pin
Dave Kreskowiak22-Feb-05 0:33
mveDave Kreskowiak22-Feb-05 0:33 
GeneralNeed Control Help Any One Pin
Virus Detecter21-Feb-05 20:51
Virus Detecter21-Feb-05 20:51 
GeneralRe: Need Control Help Any One Pin
Bad Sector21-Feb-05 22:26
Bad Sector21-Feb-05 22:26 
GeneralRe: Need Control Help Any One Pin
Virus Detecter22-Feb-05 3:15
Virus Detecter22-Feb-05 3:15 
QuestionProcessor number in VB6 ? Pin
a_yosef21-Feb-05 20:43
a_yosef21-Feb-05 20:43 
AnswerRe: Processor number in VB6 ? Pin
Dave Kreskowiak22-Feb-05 0:30
mveDave Kreskowiak22-Feb-05 0:30 
GeneralWindows Service not starting on reboot Pin
Maroela21-Feb-05 20:07
Maroela21-Feb-05 20:07 
Questionhow to check if the scheduled task ran successfully on a remote computer with vb.net Pin
MagicGirL8321-Feb-05 18:39
MagicGirL8321-Feb-05 18:39 
AnswerRe: how to check if the scheduled task ran successfully on a remote computer with vb.net Pin
Dave Kreskowiak22-Feb-05 4:10
mveDave Kreskowiak22-Feb-05 4:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.