|
the formName is coming from a Database which is creating a menu dynamically. Depending on which menu item that is selected depends on which form is opened up.
I could do a select case for each of the forms but I wanted to keep it as dynamic as possible. (I know that if another menu item is added to the database then a new form will need to be manually created that corrosponds to it anyway. But when there are many people working around the same area, then doing it this way saves going back to the same code to popup a new form)
Thanks
Shawn
|
|
|
|
|
Well, sounds a bit shakey to me, but... I think you could get away with using Activator.CreateInstance(assemblyName, typeName) to get what you want.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi folks
I'm having a bit of trouble with printing. I have an application which creates and prints plastic cards (id cards etc).
I'm trying to encode a magstripe (with a datacard sp55 card printer) but not much sucess.
Now to encode a magstripe you send the printer the tilda char ~ followed by a track and then the data i.e ~1Helloworld
If I print the following from notepad or word:-
~1Track1
~2123456
~37890
All is well and the printer spits out a shiny encoded card. However my vb.net code just prints out the text on the card front!
Code is:-
Private Sub EncodeMagStripe(ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim magFont As New Font("Lucida Console", 10)
Dim magBrush As New SolidBrush(Drawing.Color.Black)
Dim lineHeight As Single = magFont.GetHeight(e.Graphics)
Dim yPos As Single = e.MarginBounds.Top
Dim xPos As Single = e.MarginBounds.Left
Dim magTrack1 As String
Dim magTrack2 As String
Dim magTrack3 As String
'If we have Magstripe data send it with the correct escape sequences
'i.e
'~1Testing
'~21234567890
'~31234567890
magTrack1 = "~1" & m_Card.MagTrack1
magTrack2 = "~2" & m_Card.MagTrack2
magTrack3 = "~3" & m_Card.MagTrack3
If IsNothing(m_Card.MagTrack1) = False Then e.Graphics.DrawString(magTrack1, magFont, magBrush, xPos, yPos)
yPos += lineHeight
If IsNothing(m_Card.MagTrack2) = False Then e.Graphics.DrawString(magTrack2, magFont, magBrush, xPos, yPos)
yPos += lineHeight
If IsNothing(m_Card.MagTrack3) = False Then e.Graphics.DrawString(magTrack3, magFont, magBrush, xPos, yPos)
End Sub
Any ideas?
Thanks
Steve.
|
|
|
|
|
Unfortunately, your not printing the string, but printing the image of a string of characters. You have to send the strings to the printer in a Raw format. Something Graphics.DrawString will not do.
This has been covered on the board many, many times. HOW TO: Send Raw Data to a Printer by Using Visual Basic .NET[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes I thought that may be the case
I'd seen the RAW article before on MSDN.
Unfortunately just sending the text via RAW isn't practical (as far as I can see) as I also have to print full colour bitmaps and fancy fonts.
I have the datacard SDK which I'll have to play with, it's not .NET complient tho, examples are in VB6 and use the VB6 printer object interpersed with DLL calls. Which the .NET docs say you can't do with the .NET print classes.
The only other way I can see is to automate Word or try the Crystal Reports.
Cheers
Steve.
|
|
|
|
|
Go with the SDK. You'll have much better luck, greater control, and no reliance on other applications. I've got a couple of DataCard printers here at work. Pretty cool little machines!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
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.
|
|
|
|
|
Steve,
I know you have done this long back. I need a small help from you on this. The below line is confusing me a lot.
premiercomputers wrote: Now do any other fancy graphics for your card layout and call the print event when finished.
We get the printpageeventargs graphics handler only after calling the 'Print' method. So first we have to call Print event and in it we get the handler to send the magnetic strip text, then next we send card design etc. Isn't it?
Can you give us the code that above the 'hDC = e.Graphics.GetHdc' and Print event method implementation if possible.
Thanks
Ram
|
|
|
|
|
hello everyone,
im using thread timer (System.Threading.Timer) , and its working perfectly.
When i try to stop it using
MyThreadTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite)
its stops , just after it finish the current task, isnt there anyway to stop it immediatly without waiting to finish its task.
Thanks in Advance
Mahmoud Manasrah
|
|
|
|
|
Once the timer Interval is set and the timer is running, you can't change the interval until the Timer fires its event and resets itself. The only way to change the interval, if the timer is already running, is to destroy the Timer, using Dispose, and recreate it with the new interval.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi again,
Dave Kreskowiak wrote:
is to destroy the Timer, using Dispose, and recreate it with the new interval.
i done this, just it didnt work
i disposed the thread and make a new instance with intial state aborted and stopped just it didnt stop until it finished.
Thanks in Advance
Mahmoud Manasrah
|
|
|
|
|
Whoops! Might have helped if a read the entire question again. I've never tried it before, but you might want to try setting the AutoResetEvent you used to create the Timer.
Dim autoEvent As New AutoResetEvent(False)
Dim timerDelegate As TimerCallback = AddressOf ...
Dim delayTime As New TimeSpan(0, 0, 1)
Dim intervalTime As New TimeSpan(0, 0, 0, 0, 250)
Dim stateTimer As Timer = New Timer( timerDelegate, autoEvent, delayTime, intervalTime)
.
.
.
autoEvent.Set()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
r u sure that this is the solution!
well the problem is not in running the timer, or in calling it back...
The problem is when i stop the timer..it dont stop until it ends the current process it is doing..
like if it was sending emails for 25 persons, and i click stop, it dont stop until it send to the 25 person...just it dont callback the timer...
i want to stop the thread which the timer is executing immediatly , and not wait until its done...
Thanks in Advance
Mahmoud Manasrah
|
|
|
|
|
Like I said, I've never done it before. So how can I be sure that it's going to work?
You never said anything about stopping the callback method that the Timer is executing...
You'll have to rewrite your code so that this callback method checks for a flag every once in a while to tell it to stop. This has nothing to do with the Timer functionality at all!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
You've asked the most generic question we've seen in a long time. What kind of control? Web Forms based or Windows Forms? What do you want this control to do?
If all you want is a tutorial on creating controls, the forums is not the place to look. There are entire books and websites dedicated to the subject. Try searching, Yahoo or Google, for "tutorial windows forms control", if that's what your looking for.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello all,
I need the control for .net arabic DateTimePicker Control(Ocx or Dll ,dll is prefered) which is display the hijri calender.If anybody have send to my mail(rugfy@yahoo.com)
otherwise suggest me the website
Thanks..........
Ishak
|
|
|
|
|
if u explorer this site and web u will find few article on creating ur own date/time control so why don't u try to make one urself and then ask the problem about ur codes
Computer... Programming... What That
|
|
|
|
|
I need it very urgent
Ishak
|
|
|
|
|
how can I get serial processor number in VB6??
|
|
|
|
|
Most systems have it turned off by default, and not all systems support a CPUID. Don't try and use it for licensing.
But, if you must, you can get the ProcessorID using WMI and the Win32_Processor class.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi, I wrote a windows service that starts fine when it is started manually, but when rebooting it times out(SCM 30 sec time-out). I've written some log code(to a textfile) in the Onstart() method to determine what section of this method is taking up too much time. Once again everything works fine when the service is started manually and it takes about 5 secs to start, with all the log information visible in the file. But when rebooting, it times out, before it even makes the very first entry into the logfile, which is the first thing it's suppose to do in the OnStart() method.
Can this be because the windows filesystem is not up and running yet on a reboot? Or possibly something else that my service is dependant on that didn't start yet?
Any ideas for possible("neat" or not so neat) solutions are welcome.
Thanks a lot.
Fanie
|
|
|
|
|
is there any log files generated with scheduled task? and how can i access it remotely with vb.net? thanks
|
|
|
|
|
The log is kept in a simple text file at C:\WINDOWS\SchedLgU.Txt
You can get to it via normal file methods using a UNC path: \\machinename\C$\WINDOWS\SchedLgU.Txt
That is, of course, if the target machine is in the same domain as your machine. Authentication to the target machine may become an issue if your not running in a domain environment.
You'll have to come up with your own code to parse up the log file into a suitable data structure.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks.. what if the scheduled task didn't run at all? would it still be on the log file?
|
|
|
|
|