|
|
thanks i will see it
|
|
|
|
|
Try this :-
Public Class PrintForm<br />
<br />
Private _frmForm As Windows.Forms.Form<br />
Private _imgScreenShot As System.Drawing.Bitmap<br />
<br />
'API Calls to help generate final screenshot<br />
Private Declare Auto Function BitBlt Lib "gdi32.dll" _<br />
(ByVal hdcDest As IntPtr, ByVal nXDest As Integer, _<br />
ByVal nYDest As Integer, ByVal nWidth As Integer, _<br />
ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, _<br />
ByVal nXSrc As Integer, ByVal nYSrc As Integer, _<br />
ByVal dwRow As System.Int32) As Boolean<br />
<br />
Public Sub New(ByRef Form As Windows.Forms.Form)<br />
_frmForm = Form<br />
End Sub<br />
<br />
Public Sub Print()<br />
GetScreen()<br />
Dim printDialog As New Windows.Forms.PrintDialog<br />
Dim printDocument As New System.Drawing.Printing.PrintDocument<br />
AddHandler printDocument.PrintPage, AddressOf printDocument_PrintPage<br />
printDialog.Document = printDocument<br />
If printDialog.ShowDialog = Windows.Forms.DialogResult.OK Then<br />
printDocument.Print()<br />
End If<br />
End Sub<br />
<br />
Public Sub Dispose()<br />
_imgScreenShot.Dispose()<br />
End Sub<br />
<br />
Private Sub GetScreen()<br />
Const SRCCOPY As Integer = &HCC0020<br />
<br />
Dim oGraphics As System.Drawing.Graphics = _frmForm.CreateGraphics<br />
Dim oSize As System.Drawing.Size = _frmForm.Size<br />
<br />
_imgScreenShot = New System.Drawing.Bitmap(oSize.Width, oSize.Height, oGraphics)<br />
Dim oGraphics2 As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(_imgScreenShot)<br />
Dim deviceContext1 As IntPtr = oGraphics.GetHdc<br />
Dim deviceContext2 As IntPtr = oGraphics2.GetHdc<br />
<br />
BitBlt(deviceContext2, 0, 0, _frmForm.ClientRectangle.Width, _frmForm.ClientRectangle.Height, deviceContext1, 0, 0, SRCCOPY)<br />
oGraphics.ReleaseHdc(deviceContext1)<br />
oGraphics2.ReleaseHdc(deviceContext2)<br />
End Sub<br />
<br />
Private Sub printDocument_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)<br />
Dim oImageToPrint As System.Drawing.Graphics = e.Graphics<br />
oImageToPrint.DrawImage(_imgScreenShot, 0, 0)<br />
oImageToPrint.Dispose()<br />
e.HasMorePages = False<br />
End Sub<br />
<br />
End Class
Then to print from your form :-
Dim oScreen as New PrintForm(me)<br />
oScreen.Print
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
thanks it work
but it do not print the part at the right what is the argument you think i have to change
thank so much
|
|
|
|
|
asha_s wrote: but it do not print the part at the right what
Not really sure what you mean, but I assume that your form is wider than your paper. If this is the case you will need to resize the bitmap that is generated, so that it fits the paper.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
thanks Steve Jowett
sorry about latency
yes that what i mean but i do not know how to resize the bitmap con you tell me please
|
|
|
|
|
I think you will find that the Bitmap object has Height and Width properties. You will need to change these to resize the screen shot.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
|
Hey,
I have the following code:
e.Graphics.DrawImage(Logo, 50, 50)<br />
<br />
Dim PrintFont As New Font(Me.Font, FontStyle.Regular)<br />
Dim PrintFontBold As New Font(Me.Font, FontStyle.Bold)<br />
<br />
Dim strFormat As New StringFormat<br />
<br />
Dim rectDraw As New RectangleF( _<br />
e.MarginBounds.Left, e.MarginBounds.Top, _<br />
e.MarginBounds.Width, e.MarginBounds.Height)<br />
<br />
Dim sizeMeasure As New SizeF(e.MarginBounds.Width, _<br />
e.MarginBounds.Height - PrintFont.GetHeight(e.Graphics))<br />
<br />
Dim FontHgt As Single = PrintFont.GetHeight(e.Graphics)<br />
Dim g As System.Drawing.Graphics = Me.CreateGraphics<br />
<br />
strFormat.Trimming = StringTrimming.None<br />
<br />
Dim strAdress As String = "Adres: " & CompAdress & ", " & CompPostCode & ", " & CompCity<br />
Dim strPhoneFax As String = "Tel: " & CompPhoneNo & ", Fax: " & CompFaxNo<br />
Dim strWebEmail As String = "Internet: " & CompWebsite & ", E-mail: " & CompEmail<br />
Dim strBankAcc As String = "Bank: " & CompBankName & ", Bankrekeningnummer: " & CompAccNo<br />
Dim strGiro As String = "Gironummer: " & CompGiroNo<br />
Dim strBTWNo As String = "BTW Nummer: " & CompBTWNo<br />
<br />
<br />
Dim StrAdrSize As SizeF = e.Graphics.MeasureString(strAdress, PrintFont)<br />
Dim StrPhoneFaxSize As SizeF = e.Graphics.MeasureString(strPhoneFax, PrintFont)<br />
Dim StrWebEmailSize As SizeF = e.Graphics.MeasureString(strWebEmail, PrintFont)<br />
Dim StrBankAccSize As SizeF = e.Graphics.MeasureString(strBankAcc, PrintFont)<br />
Dim StrGiroSize As SizeF = e.Graphics.MeasureString(strGiro, PrintFont)<br />
Dim StrBTWNoSize As SizeF = e.Graphics.MeasureString(strBTWNo, PrintFont)<br />
<br />
e.Graphics.DrawString(strAdress, PrintFont, Brushes.Black, rectDraw.Width - StrAdrSize.Width, 50)<br />
e.Graphics.DrawString(strPhoneFax, PrintFont, Brushes.Black, rectDraw.Width - StrPhoneFaxSize.Width, 50 + FontHgt)<br />
e.Graphics.DrawString(strWebEmail, PrintFont, Brushes.Black, rectDraw.Width - StrWebEmailSize.Width, 50 + FontHgt * 2)<br />
e.Graphics.DrawString(strBankAcc, PrintFont, Brushes.Black, rectDraw.Width - StrBankAccSize.Width, 50 + FontHgt * 3)<br />
e.Graphics.DrawString(strGiro, PrintFont, Brushes.Black, rectDraw.Width - StrGiroSize.Width, 50 + FontHgt * 4)<br />
e.Graphics.DrawString(strGiro, PrintFont, Brushes.Black, rectDraw.Width - StrBTWNoSize.Width, 50 + FontHgt * 5)<br />
e.HasMorePages = False
When I print this i get the following result:
Link>
As you can see the sentences are not lined up properly. What am I doing wrong?
I would like to have all the sentences at a straight line.
Thanks in advance,
Zaegra
modified on Wednesday, April 16, 2008 6:24 AM
|
|
|
|
|
I had a similar problem with measurestring not returning the correct length of the string. My solution was to create a stringformat object:
Dim sf As StringFormat = StringFormat.GenericTypographic
sf.FormatFlags = sf.FormatFlags Or StringFormatFlags.MeasureTrailingSpaces
And, when calling measurestring:
e.Graphics.MeasureString(StringToDraw, _Font, New Point(0, 0), sf).Width
This solved the issues I was having - mayby this will help you?
Good luck!
|
|
|
|
|
That worked! I could'nt have solved this problem without you, so thanks!!
|
|
|
|
|
Hi,
I need to capture my screen as movie, all the articles i found are in c++, i need them vb.net code or c# if any one can help thanks alot.
Mohammad Al Hoss
|
|
|
|
|
I don't know of any articles that describe what you want in any other language than C++.
You might want to do some research into "VNC". It's normally used for capturing screens for remote control software, but it may be of some use to you.
|
|
|
|
|
Hi all, I have a user control (listview) and i want to see position of scrool. How can i manage scroll position on listview without using API.
My code below please help me..
'--------------- user control side
Public Class List
Inherits ListView
Private Const WM_HSCROLL As Integer = 276
Private Const WM_VSCROLL As Integer = 277
Private Const WM_KEYDOWN As Integer = 256
Private Const WM_MOUSEWHEEL As Integer = 522
Public Event ScrollEvent As System.EventHandler
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_VSCROLL OrElse m.Msg = WM_HSCROLL OrElse m.Msg = WM_KEYDOWN OrElse m.Msg = WM_MOUSEWHEEL Then
RaiseEvent ScrollEvent(Me, Nothing)
End If
MyBase.WndProc(m)
End Sub
End Class
'------------- And other code side ------------
Private Sub List_ScrollEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles L.ScrollEvent
lblScrollDown.Text = lblScrollDown.Text + System.Threading.Interlocked.Increment(scrollCount)
End Sub
'here i just see move to scrool, not any other.
S.A.A
|
|
|
|
|
cmpe orko wrote: How can i manage scroll position on listview without using API.
Without using the Win32 API?? Simple. You can't.
|
|
|
|
|
Can u explain how i can do this what i am changing my code
S.A.A
|
|
|
|
|
Your code doesn't define an event, nor does it transfer any information in event arguments to the subscriber. I'm short on time right now so I can't come up with an example yet.
|
|
|
|
|
Thanks my friend. Can u help me how i can define event and transfer information ?? thanks again..
S.A.A
|
|
|
|
|
The easiest way to declare an event with parameters in your control is:
Public Event MyEvent(ByVal sender As Object, ByVal arguments As MyEventArgs)
Of course, you're going to need a class called MyEventArgs that'll hold the parameters you pass to the event subscriber:
Public Class MyEventArgs
' This is not the proper way to do this, but it works for demo purposes...
Public SomeValue As Integer
Public OtherValue As Integer
Public Sub New(ByVal someValue As Integer, ByVal otherValue As Integer)
Me.SomeValue = someValue
Me.OtherValue = otherValue
End Sub
End Class
and, lastly, to raise the event from your control:
RaiseEvent MyEvent(Me, New MyEventArgs(123,321))
Seriously, pick up a book on VB.NET and work through it. Decalring events is covered in just about every book I've seen.
|
|
|
|
|
Thanks Dave Kreskowiak
S.A.A
|
|
|
|
|
hi
I made a win-application in vb.net but i want to have a exe file that work undependent on .netframework
if you know any program please tell me
tanks in advanse .
en.mahdi
|
|
|
|
|
Ifyou google, you'll find something. But, it's very expensive.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Adding to CG's post, AFAIK, those programs embed the framework runtime assemblies into a single assembly and loads it when the application runs. What is the problem to install framework which is free ?
|
|
|
|
|
I want to make my programs faster in load and work speed .
by having the machine code not IL codes
thanks .
|
|
|
|
|
You really can't get around that.
There is a tool that generates native code from the IL code in the assemblies, but, you can't just NGEN your assemblies and then distribute those to your customers. NGEN generates code speicifically for the processor that it's running on. So, if you NGEN an assmebly on an Intel Core 2 Duo, the resulting native code isn't guaranteed to work on an AMD Athlon 2600+. NGEN has to be run on the assemblies at installation time on the customer workstations.
Also, don't expect to get large performance boosts in load times. When an assembly is loaded, the native compiler does a very good job at compiling the code down to native and does it very fast. The .NET CLR will also not compile an entire assembly, but only what it needs to compile to run the current code. If you create an instance of a class in, say, a .DLL, that class won't get compiled into native code until your code first tries to create an instance of the class. The compiler works on a on-demand basis.
Now, if you go the other route and use an expesive third party product to build the .NET Framework into your .EXE, you still have an IL .EXE which will be compiled on-demand, but now you have a MUCH larger .EXE file, which will take longer to load anyway.
|
|
|
|
|