Home | Index | Dotnet4all Snippets | Submit resources
About | Mail us 





How to send Control characters to a POS printer (Monday, January 10, 2005)

Found the following interesting discussion in the Newsgroups:

Sending Control characters to a POS printer
by:Frederik Wehlin via .NET 247

Hi,

I?m currently developing a POS application in VB.NET.
I want the user to be able to connect any kind of POS printer (available on the market).

I have tried printing the ordinary .NET way e.Graphics.DrawString(...) but it seems it cannot parse the special control characters that I want to use.

I have used Epsons OPOS Ocx (which works fine) but it?s not generic like I want it (too much hustle for the user to set up the device) I want it to be plug and print.

Has anyone accomplished this? If so could you please point me in the direction where I can find information about it?

Regards

--------------------------------
From: Frederik Wehlin

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>e1Zl6hs+Uk2ci0Bvz4LnVA==</Id>


 Reply:
by:Anonymous

 Hi Frederic

I think you are out of luck. The problem lies in the use of Graphics.DrawString(…), this will be turning the characters into their equivalent graphical representation and not sending them as raw data as I think you are expecting it to.

To use control characters I think you would have to talk to the printer directly. Does Graphics.DrawString produce something on the printer? If it does then can’t you write your code so that it handles formatting such as bold, underline etc and allow Windows to just do the printing of what you send?

What control characters are you trying to use?
Are they are serial POS printers? If they are then you could probably talk to them directly rather then via Windows.

I hope I have been of some help, I know its not the answer you where looking for.
Chris.


----- Frederik Wehlin via .NET 247 wrote: -----

Hi,

I?m currently developing a POS application in VB.NET.
I want the user to be able to connect any kind of POS printer (available on the market).

I have tried printing the ordinary .NET way e.Graphics.DrawString(...) but it seems it cannot parse the special control characters that I want to use.

I have used Epsons OPOS Ocx (which works fine) but it?s not generic like I want it (too much hustle for the user to set up the device) I want it to be plug and print.

Has anyone accomplished this? If so could you please point me in the direction where I can find information about it?

Regards

--------------------------------
From: Frederik Wehlin

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>e1Zl6hs+Uk2ci0Bvz4LnVA==</Id>


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
I don't know what a POS printer is, but maybe this sample works for you:

HOW TO: Send Raw Data to a Printer by Using Visual Basic .NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;322090>

--
Herfried K. Wagner [MVP]


 Reply:
by:Anonymous

 Herfrield,

POS Printer = Point of Sale Printer, well here in the UK anyway. Something like a Cash register receipt printer.

The link you have provided should point Frederik in the right direction, without actually trying it, it looks like it will do what he wants. Thanks for the link, I have saved it for my own information as the company I work for may do something with POS printers in the future.

Chris.

----- Herfried K. Wagner [MVP] wrote: -----

* Frederik Wehlin via .NET 247 <anonymous@dotnet247.com> scripsit:
> I?m currently developing a POS application in VB.NET.
> I want the user to be able to connect any kind of POS printer (available on the market).

I don't know what a POS printer is, but maybe this sample works for you:

HOW TO: Send Raw Data to a Printer by Using Visual Basic .NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;322090>

--
Herfried K. Wagner [MVP]


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 * "=?Utf-8?B?Q2hyaXMgUG9kbW9yZQ==?=" <anonymous@discussions.microsoft.com> scripsit:
> POS Printer = Point of Sale Printer, well here in the UK anyway. Something like a Cash register receipt printer.

Thank you for the explanation.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



Windows Service

Found the following interesting discussion in the Newsgroups:

Windows Service
by:Jonesgj

Hi,

I have an Windows application, an 'exe', which I believe I need to convert
to a windows 'service'? I need to do this as the application is basically an
ETL for data, and lives on our server and unfortunately our company run
scripts to close down applications left running when the remote access
software disconnects. The security processes in my company do not allow me
to work round this.

We have moved to Microsoft SQL 2000 DTS, which is itself an ETL, but for
the things it can't do I thought about converting our ETL to a windows
service (A DLL running in background ??)

I have put together quite a few VB applications in the past - all 'exe'
(including two small .net apps) but have no idea, at all, as to how to
create a windows service, or a windows console program. Any clues, or
suggested reading/advice etc etc greatly appreciated.

Many thanks in advance.

Jones G

((Ooops - I am also exploring a contingency plan where I would be putting
some of the functionality lacking in DTS but in my ETL into small discrete
applications which can be called from a DTS task - basically shelled and
programmed to receive command line parameters ))


 Reply:
by:Anonymous

 Have a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtbstroubleshootingdebuggingwindowsservices.asp

Hope this helps.
Chris.



Posted by Xander Zelders
0 Comments



Inline or Precedure

Found the following interesting discussion in the Newsgroups:

Inline or Precedure
by:Anonymous

I have Code that can either be run inline or called as multiple procedures. What would be the best practice, I like the component model with procedures but heard that inline executes faster... Thanks in advance...

Also, why does calling dispose such as with any var.dispose execute faster then simply setting to nothing..

Which is faster:

dim me as var
some code
me = nothing

or

dim me as var
some code
me.dispose
me = nothing

Thanks...


 Reply:
by:steve

 in-line code always executes faster that external calls to methods. however,
you should *always* design applications for maintainability...very few
occasions exist where that model of development will cost your application
time. w/o maintainability, you will *always* cost time...your customer's,
yours, and will eventually kill your app when it cost more to maintain than
the savings it originally afforded.

..net uses non-deterministic garbage collection in order to "know" when it
can release resources. setting an object to nothing in .net just helps the
gc better tell/determine that the object can no longer be reached/used...and
thereby can be killed off. disposing an object makes the gc look at that
object in a little different light...it has less to do in order to "know"
that no other referencing object can/has access to it.

hth,

steve
"Anthony Nystrom" <anthonynystrom@genetibase.com> wrote in message
news:0C7F24FC-E3E8-4E09-B5E2-4EFB23073711@microsoft.com...
| I have Code that can either be run inline or called as multiple
procedures. What would be the best practice, I like the component model with
procedures but heard that inline executes faster... Thanks in advance...
|
| Also, why does calling dispose such as with any var.dispose execute faster
then simply setting to nothing..
|
| Which is faster:
|
| dim me as var
| some code
| me = nothing
|
| or
|
| dim me as var
| some code
| me.dispose
| me = nothing
|
| Thanks...


 Reply:
by:Cor Ligthert

 Hi Anthony,

Search this newsgroup than you will see that both that you use is called bad
code.

See above.

I hope this helps something

Cor


 Reply:
by:Cor Ligthert

 Little addition in the sentence
> This can only when there is a dispose method in a class and should than
only
> be used for unmanaged resources, however that is never for a value.

(I placed later that unmanaged resource text in the middle)

now the end has to be.

A value has never a method, and therefore never a dispose.

Cor


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

IMO you should not need to care about that, the JITter is/will
be/should be able to do inlining automatically when it makes sense.

To your 2nd question: Setting an instance variable to 'Nothing' is
different from calling its 'Dispose' method. Calling 'Dispose' will
clean up unmanaged resources used by the instance at the time of calling
the procedure.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



GDI Drawing Text with outline and shadow

Found the following interesting discussion in the Newsgroups:

GDI Drawing Text with outline and shadow
by:Lou

I need to have a Face,Outline and drop shadow. I am close but can't get my
code to work.
The face and outline work fine but the shadow is not sized correctly???

Dim rec As New Rectangle(PictureBox1.Left, PictureBox1.Top,
PictureBox1.Height, PictureBox1.Height)

Try

'Set the Font

Dim myFont As New Font("Arial", Me.nudFontSize.Value, FontStyle.Regular)

'Set the Graphics Buffer

Dim bm As New Bitmap(Me.ClientSize.Width \ 4, Me.ClientSize.Height \ 4)

'==== DROP SHADOW ====================

Dim g As Graphics = g.FromImage(bm)

g.TextRenderingHint = TextRenderingHint.AntiAlias

Dim mx As New Matrix(0.25F, 0, 0, 0.25F, 1, 1)

g.Transform = mx

g.DrawString(txtShortText.Text, myFont, New SolidBrush(Color.FromArgb(128,
Color.Black)), 10, 10, StringFormat.GenericTypographic)

'Clean up

g.Dispose()

e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic

e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias

e.Graphics.DrawImage(bm, Me.ClientRectangle, 0, 0, bm.Width, bm.Height,
GraphicsUnit.Pixel)

''==== EDGE/FACE ==========================

Dim pth As New GraphicsPath

e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias

e.Graphics.SmoothingMode = SmoothingMode.AntiAlias

pth.AddString(txtShortText.Text, myFont.FontFamily, 0, (myFont.Size), New
Point(10, 10), StringFormat.GenericTypographic)

'pen size is the size of the edge

Dim P As New Pen(Color.Black, 1)

'Draw the face

e.Graphics.FillPath(Brushes.White, pth)

'Draw the edge

e.Graphics.DrawPath(P, pth)

pth.Dispose()

'Clean(up)

bm.Dispose()

Catch MyError As Exception

MessageBox.Show(MyError.Message)

Finally

End Try


 Reply:
by:Ken Tucker [MVP]

 

Hi,

This code makes the shadow draw 1/4 size. Adjust the size here.

> Dim mx As New Matrix(0.25F, 0, 0, 0.25F, 1, 1)
>
> g.Transform = mx

Ken
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004


 Reply:
by:Supra

 u need to drawstring again but change ur location and some colour too



Posted by Xander Zelders
0 Comments



How to create controls at runtime

Found the following interesting discussion in the Newsgroups:

creating controls at runtime
by:Anonymous

Well thanks to all of you my layout designer is moving along (slowly as I learn). I want to be able to give the user the ability to add label controls at runtime. I have this working for one label control, Label1. When the user adds the next label I would like my code to check (maybe a loop?) what the next available label number is and then create it. So if Label1 exists then the next one would be label2. I read a pretty good MSDN article but it lost me near the end. I also want the labels to be movable and resizable. I am using a context menu to set the size of label1 and mouse_down, mouse_move and mouse_up events to control the movement. This works also for Label1. I would like this code to be automatically created when the user adds a label.

Thank you,
John


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 
I would store the label count in a variable.

Have a look at 'AddHandler' and 'RemoveHandler' and the event handler's
'sender' parameter.

--
Herfried K. Wagner [MVP]


 Reply:
by:Anonymous

 This Idea has been scrapped due to lack of programmer ability. A new direction has been taken.

Thanks,
John


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 * "=?Utf-8?B?amNyb3VzZQ==?=" <anonymous@discussions.microsoft.com> scripsit:
> This Idea has been scrapped due to lack of programmer ability. A new direction has been taken.

What direction?

If you have any further questions, feel free to post them to this group.

--
Herfried K. Wagner [MVP]



Posted by Xander Zelders
0 Comments



 
Previous Posts
    - Rich Text Box SelectionColor
    - ListBox non-Dataset load Value and discription
    - Knew how to do it the old way, but ...
    - InvalidActiveXStateException error when editing si...
    - when to use DoEvents in vb.net?
    - Playing Audio from a Filestream using MCI
    - XML in a combobox
    - Setup Project
    - WMI Com Interop exception handling
    - Problem With Mailto Start Process

Archives
    - 08/01/2004 - 08/08/2004
    - 08/08/2004 - 08/15/2004
    - 08/15/2004 - 08/22/2004
    - 08/22/2004 - 08/29/2004
    - 08/29/2004 - 09/05/2004
    - 09/05/2004 - 09/12/2004
    - 09/12/2004 - 09/19/2004
    - 09/19/2004 - 09/26/2004
    - 09/26/2004 - 10/03/2004
    - 10/03/2004 - 10/10/2004
    - 01/02/2005 - 01/09/2005
    - 01/09/2005 - 01/16/2005
    - 01/30/2005 - 02/06/2005
    - 01/01/2006 - 01/08/2006


Disclaimer & Terms of Use | DotNet4All.Com concept & © 2004 - 2007 by Zelders² - Holland