Hi,
I am writing a program in VB6 where an image is loaded into a picture box if I print this image it is exactly where I expect it to be.
The problem is I need to be able to draw lines on the image in the picture box.
This works fine on the screen but when I then print the image has moved diagonally towards the top left corner of the picturebox.
I am sure the problem is with the line drawing code but can not work out why it is moving the image when printing.
the drawing code is below :- - Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
-
'Releases last line if right mouse button is pushed
-
If Button = 2 Then
-
'Erases current Line
-
Picture1.Line (X1, Y1)-(X2, Y2)
-
'Reset line vaiables
-
X2 = 0
-
Y2 = 0
-
LineOn = False
-
Exit Sub
-
End If
-
'If the LineOn Flag is true
-
If LineOn Then
-
'Erase the Stretch Line
-
Picture1.Line (X1, Y1)-(X2, Y2)
-
'Turn inverted draw off
-
Picture1.DrawMode = 13
-
-
X2 = X
-
Y2 = Y
-
-
'Draw the final line
-
Picture1.Line (X1, Y1)-(X2, Y2), RGB(0, 255, 0)
-
'Set new start line points
-
-
X1 = X2
-
Y1 = Y2
-
-
X1 = X
-
Y1 = Y
-
-
-
If LineOn <> 1 Then
-
X2 = 0
-
Y2 = 0
-
LineOn = False
-
Exit Sub
-
End If
-
Else
-
'The line has not been drawn yet
-
-
X1 = X: Y1 = Y
-
-
'Set end values
-
X2 = X
-
Y2 = Y
-
LineOn = True
-
End If
-
Picture1.DrawMode = 6
-
Picture1.DrawStyle = 6
-
X3 = X: Y3 = Y: X4 = X: Y = Y4
-
End Sub
-
-
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
'Draw the stretch or rubberband line
-
If LineOn Then
-
Picture1.AutoRedraw = True
-
Picture1.Line (X1, Y1)-(X2, Y2)
-
X2 = X
-
Y2 = Y
-
Picture1.Line (X1, Y1)-(X, Y)
-
-
-
End If
-
End Sub
I hope someone can help with this as it is driving me mad
Dave
2 3144
I have thoroughly analysed your code, and have fixed it up for you; however, I am not sure if it will fix your printing problem. Try checking the print settings before printing (i.e. alignment, orientation, margins, etc.) Declarations - Private LineOn As Boolean
-
Private X1 As Long, Y1 As Long, X2 As Long, Y2 As Long
General Code - Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
-
Select Case Button
-
Case 1 'Left mouse button (draw)
-
If LineOn Then
-
'Complete the current line
-
Picture1.DrawMode = 13
-
Picture1.Line (X1, Y1)-(X, Y), RGB(0, 255, 0)
-
LineOn = False
-
Else
-
'Prepare to draw line
-
X1 = X
-
Y1 = Y
-
X2 = X
-
Y2 = Y
-
LineOn = True
-
End If
-
Case 2 'Right mouse button (cancel)
-
If LineOn Then
-
'Erase line if one is being constructed
-
Picture1.Line (X1, Y1)-(X, Y)
-
LineOn = False
-
End If
-
End Select
-
Picture1.DrawMode = 6
-
Picture1.DrawStyle = 6
-
-
End Sub
-
-
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
-
If LineOn Then
-
Picture1.AutoRedraw = True
-
'Erase the previous line created by last mouse move
-
Picture1.Line (X1, Y1)-(X2, Y2)
-
X2 = X
-
Y2 = Y
-
'Draw the stretch or rubberband line
-
Picture1.Line (X1, Y1)-(X, Y)
-
End If
-
-
End Sub
-
Thanks for that it solved the right clicking to clear the line if you choose not to continue drawing, but still have the printing problem. I am new to this and it does not make sence to me that I can load different images from a drop down combo box and they load exactly in the picture box and just using the print form command will print it exactly where it should be, the form fits exactly the width of an A4 sheet of paper.
Draw even the shortest line and it prints the form ok with the picture box where it should be but the picture and lines have moved up and to the left obscuring the picture as though it has slipped behind the form.
I think I am going to have to try writing a full print command but are not sure that it will solve it.
Dave
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jos Roijakkers |
last post by:
I am writing a program in Visual Studio 2005 (VB) that can print scanned
images (saved as jpg-files). The printing is done by the following code:
Private Sub pdoc_PrintPage(ByVal sender As...
|
by: Vincent |
last post by:
Dear all,
I have implemented a class to export the content of RichTextBox to
image in WYSISYG mode so that line breaks on the screen are the same as
exported.
C# Code:
public struct...
|
by: Jerry Spence1 |
last post by:
The following seemed so simple in VB6 (CD1 is CommonDialogue1)
CD1.CancelError = True
CD1.ShowPrinter
Printer.PaintPicture ActiveForm.Picture1.Picture, 720, 720
to print the image in a...
|
by: Max |
last post by:
Hello,
How would you print a picture box? I found sites online on printing a form and its basic controls but nothing on picture boxes.
Is it possible to print a logo for example from a C# .NET...
|
by: chal |
last post by:
Hi all Experts ...Hope u dong fine..
well i have a problem in my application ..here runtime i hve given facility to the user to place controls on the picture box which already have image...Now i...
|
by: deore |
last post by:
Respected Sir,
OS : Windows XP Professional Edition sp2
Language :visual basic 6.0
I am trying to print Picturebox which contains vertical line of length 5cm
using "Printform" method.The...
|
by: VICTOR DIACONO |
last post by:
I have the following problem.
I am trying to print the contents of a number of Textboxes into Labels on a Picturebox. Then I wish to output the Picturebox to the screen.
Ok, it is a simple...
|
by: dotnet2005 |
last post by:
Hi Toall ,
I want to explain you clearly ,
I am having some panels having some controls
CheckBox,ComboBox,Datagridview,Hyperlink,label,Listbox,Picturebox,RadioButt
on ,Textbox)...
|
by: babaidebnath |
last post by:
Hello all,
I am presently having a problem with printing in C#.
The problem is my customer provided me a pre printed paper and I
need to print value into some specific positions. But problem is C#...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |