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 3166
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 Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Handles PrintDocument.PrintPage
Dim i As Integer
Dim intPrintAreaHeight, intPrintAreaWidth, marginLeft, marginTop
As Int32
With PrintDocument.DefaultPageSettings
|
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 STRUCT_RECT
|
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 picturebox.
I have spent hours Googling to try and fathom out how to do it in VB.Net
(2005). Surely it doesn't take all the code I've seen?
|
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 application?
Max
|
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 want to take a print of all those contents or we can say controls placed in the picturebox....sa can anybody help me or tell me what should i do??any code sample plz??
waiting 4 ur reply
chal
| |
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 problem is output on page is vertical line with
length 4cm.
|
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 matter of assigning the value of the Textbox to a Label in the Picturebox. But VB.NET doesn't seem to support a Print method for the Picturebox.
How do I output the Picturebox (complete with its contents) to screen or the printer?
|
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)
&(Oval,Line,Rectangle ). with .BorderStyle =
BorderStyle.FixedSingle . All these things are generating at runtime
|
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# for its
generic autofit to page nature dont let me doing this. Every time it is
decreasing whole page's size and also altering my value position into some
specific ratio. Can anyone tell me how can I come over that problem.
This is my code
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |