|
does any one have a free twain software i could use in my project.. the one that i am using is vintasofttwain... and it is only the trial version.. so i can't save picture in jpeg or colored format.can anyone help, if it means suggesting a different twain i could use..
|
|
|
|
|
You can search the site, but I think the only free TWAIN library on here is C++. Atalasoft have a library for around $400 which looks good.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
VB.NET 2003
Say i have two forms frmA and frmB
Currently I am in form A and I want to open form B, However I do not know the name of form B. I am pulling the name of the form from a database.
The code to open the form normally would be: ( I know the name of the form here and declare it as so)
Dim frmtolaunch as new frmB ''Declare the form
frmtolaunch.show() ''Show the form
However I don't know the name and the code resembles the following (I do not know the name and wnat to declare it based on a variable name)
dim frmBName as string ''Variable to hold form B name
...Code here to get the form name from the database
...Store the name into frmBname
dim frmtolaunch as frmBName ''ERRORS occur here
frmtolaunch.show() ''Show the form
QUESTION: how can I declare the form based on the name I pull form the database. ----dim frmtolaunch as frmBName------
|
|
|
|
|
You could create a routine that will return you the object via a select case statement.
public function oGetForm(sName as string) as form
select case sName
case "frmBName"
return new frmBName
case .
.
.
end select
end function
--------------
dim oFrm as form = oGetForm(dsRow("FormName"))
|
|
|
|
|
I believe you could also use the reflection library where class name would be the form's name
Public Shared Function CreateInstance(ByVal sAssembly As String, ByVal sClass As String) As Object
Dim ao As [Assembly], aoName As New AssemblyName
Dim o As Object
Try
aoName.Name = sAssembly
ao = [Assembly].Load(aoName)
o = ao.CreateInstance(sAssembly & "." & sClass, True)
Catch ex As Exception
'ExceptionManager.PublishException(ex)
Throw ex
End Try
ao = Nothing
Return o
End Function
---------------------
dim oFrm as form = CreateInstance("myproject",dsRow("FormName"))
|
|
|
|
|
When you publish a project in VS2005 and then install the application to a PC that you need the application from the install opens the application and runs the program after the install is complete. Is there a setup option I can set to not have the application run after install?
Thanks for any insight anyone has...
Lost in the vast sea of .NET
|
|
|
|
|
Hi ..
Im having a slight margin problem when the print out copy is done.
for example.
note! - (| = left margin , 'a' = text)
"|a" in printpreview , the printout is "| a".
can anyone offer some advice on how to deal with this offset . i can tell you the e.margins.left is indented(to the right) on printout but GOOD IN PRINT PREVIEW and ALSO the e.margin.right margin is ok in print preview but not showing in print out.
I've got the e.margins drawing to see them in print preview and in printout
thanks in advance.
Robbo
-- modified at 19:43 Thursday 11th January, 2007
|
|
|
|
|
something to do with PrintDocument.OriginAtMargins ?
|
|
|
|
|
Hi duncan.
Thanks for your tip. I actually tried using printdoc.originatmargins= true
but didnt notice any improvement. are you able to tell me if there's another
way of using this if there is one.
Kind Regards
Robbo
|
|
|
|
|
I think he as eluding to the fact that every printer as unprintable margins and that this is where the margins that you are talking about start at. For example:
Edge of paper
------------------------------------------------------+
(unprintable margin) |
----------------------------------------------------+ |
Top Margin 0.0" | |
| |
---document begins here with a margin of 0.5" | |
but is actually 0.75" from the top of the page | |
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave
So i take it from you that its ok to see one thing in print preview and get something close on paper right ?... please clear this up for me.
also if this is the case is it ok for me to consider creating an xml file used to manipulate margins for different printers if need be.
i guess what i need to know is what is the proper standard for this type of thing.
many thanks Dave
Robbo
Robbo
|
|
|
|
|
It looks like your print preview code is making certain assumption about the page and not taking into account the margins. The one thing you haven't done is posted any code to show us how your seting up your printing.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave
Here is my code as you requested . Just to remind you print preview margins are great but printouts are not but only slightly off. i look forward to your comments to hopefully include some things to do.
CODE
====
RE: Imports System.Drawing.Printing
Public Class supreport
Private m_PagesPrinted As Integer
Private totalpages As Integer
' Display a print preview.
Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintPreview.Click
' Make a PrintDocument and attach it to
' the PrintPreview dialog.
dlgPrintPreview.Document = PreparePrintDocument()
dlgPrintPreview.WindowState = FormWindowState.Maximized
dlgPrintPreview.PrintPreviewControl.Zoom = 1.0 'set zoom preview to %100
' Preview.
dlgPrintPreview.WindowState = FormWindowState.Maximized
dlgPrintPreview.ShowDialog()
End Sub
Private Function PreparePrintDocument() As PrintDocument
' Make the PrintDocument object.
Dim print_document As New PrintDocument
With PageSetupDialog1
.PageSettings = print_document.DefaultPageSettings
End With
If PageSetupDialog1.ShowDialog = Windows.Forms.DialogResult.Yes Then
print_document.DefaultPageSettings = PageSetupDialog1.PageSettings
End If
AddHandler print_document.BeginPrint, AddressOf Print_BeginPrint
AddHandler print_document.QueryPageSettings, AddressOf Print_QueryPageSettings
AddHandler print_document.PrintPage, AddressOf Print_PrintPage
AddHandler print_document.EndPrint, AddressOf Print_EndPrint
' Return the object.
Return print_document
End Function
' Get ready to print pages.
Private Sub Print_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
m_PagesPrinted = 0
getdata() 'load data to print/preview
End Sub
' Print the next page.
Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
' Increment the page number.
m_PagesPrinted += 1
'**********RECTANGLES
Dim headingrect As New Rectangle(130, 100, 600, 800)
Dim DateRect As New Rectangle(e.MarginBounds.Left, 170, 100, 800)
Dim InvRect As New Rectangle(e.MarginBounds.Left + 130, 170, 130, 800)
Dim NameRect As New Rectangle(e.MarginBounds.Left + 281, 170, 100, 800)
Dim PDRect As New Rectangle(390, 170, 100, 800)
'*****************
'********FONTS
Dim headingfont As Font
headingfont = New Font("Times New Roman", 12, FontStyle.Underline, GraphicsUnit.Point)
Dim datafont As Font
datafont = New Font("Times New Roman", 10, FontStyle.Regular, GraphicsUnit.Point)
Dim subheadingsfont As Font
subheadingsfont = New Font("Time New Roman", 10, FontStyle.Regular, GraphicsUnit.Point)
'**************
'********STRING FORMATS
Dim headingstringformat As New StringFormat
headingstringformat.Alignment = StringAlignment.Center
Dim datastringformat As New StringFormat
datastringformat.Alignment = StringAlignment.Near
'********************
Dim reportheading As String = "Supplier Report As Of " & Today
Dim companyheading As String = "Company"
Dim addressheading As String = "Address"
Dim suburbheading As String = "Suburb"
Dim pcodeheading As String = "Postcode"
Dim ph1heading As String = "Phone 1"
Dim ph2heading As String = "Phone 2"
Dim contactheading As String = "Contact"
e.Graphics.DrawString(reportheading, headingfont, _
Brushes.Black, headingrect, headingstringformat) ' draw company heading details
e.Graphics.DrawString(ComData, datafont, Brushes.Black, DateRect, datastringformat)
e.Graphics.DrawString(AddressData, datafont, Brushes.Black, InvRect, datastringformat)
e.Graphics.DrawString(SubData, datafont, Brushes.Black, NameRect, datastringformat)
e.Graphics.DrawString(PcodeData, datafont, Brushes.Black, PDRect, datastringformat)
e.Graphics.DrawString(companyheading, subheadingsfont, Brushes.Black, e.MarginBounds.Left, 150)
e.Graphics.DrawString(addressheading, subheadingsfont, Brushes.Black, e.MarginBounds.Left + 130, 150)
e.Graphics.DrawString(suburbheading, subheadingsfont, Brushes.Black, 320, 150)
e.Graphics.DrawString(pcodeheading, subheadingsfont, Brushes.Black, 390, 150)
e.Graphics.DrawString(ph1heading, subheadingsfont, Brushes.Black, 480, 150)
e.Graphics.DrawString(ph2heading, subheadingsfont, Brushes.Black, 560, 150)
e.Graphics.DrawString(contactheading, subheadingsfont, Brushes.Black, 660, 150)
' Draw the margins (for debugging).
e.Graphics.DrawRectangle(Pens.SkyBlue, e.MarginBounds)
Dim the_font As Font
Dim string_format As New StringFormat
the_font = New Font("Times New Roman", _
8, FontStyle.Regular, GraphicsUnit.Point)
Dim getwidth As Int32 = e.PageBounds.Width
Dim getbottom As Int32 = e.MarginBounds.Bottom
getwidth = getwidth / 2
' MsgBox("getwidth " & getwidth)
e.Graphics.DrawString("( Page " & m_PagesPrinted.ToString & ")", _
the_font, Brushes.Black, getwidth, _
(120), _
string_format)
End Sub
End Class
|
|
|
|
|
Your code is based on the MarginBounds of the page, not the page bounds. It treating the top-left corner of the MarginBounds as the top-left corner of the page. Try using PageBounds instead of MarginBounds and see what happens.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thankyou Dave. I'll try your suggestion and get back to you.
Many thanks as always.
Robbo
|
|
|
|
|
Have been programming not just .net but as a whole for 2 years now and am self taught so I still am a begginner and far from intermediate. I cannot find any good resources or tutorials for working with the right click event. The only thing I wish to learn really is how to implement right click functionality to a row/record in a listview. If any of you guys know of any websites or text that could help me out with this, please let me know. Also, if you could help me to just get started because I really dont even know where to start!!! Thank you in advance for your help.
|
|
|
|
|
|
Hi all, my other question about Graphics.DrawString is that:
When I'm writing shoot date on the horizontal photo everything is great but the same things are not applied to vertical taken photos. On 2560x1920 string is great but on 1920x2560 so small. I'm taking position with
<br />
Dim f As New Font(FontFamily.GenericSerif, 35.0F, FontStyle.Regular, GraphicsUnit.Point)<br />
graph.DrawString(enc.GetString(bytes), f, Brushes.Yellow, CSng(img.Width) - 400.0F, CSng(img.Height) - 50.0F)<br />
Something wrong? Thanks..
Savas Cilve
|
|
|
|
|
There's nothing wrong with the code you've posted. An image is an image is an image. It doesn't matter what orientation the camera was in when the shot was taken. It's entirely possible that there's something wrong with the code that is passing in the image to this code that you posted.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
That's my entire code for the writing string.
<br />
For Each img As Image In _images<br />
Dim changed As Boolean = False<br />
Dim f As New Font(FontFamily.GenericSerif, 35.0F, FontStyle.Regular, GraphicsUnit.Point)<br />
Dim graph As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(img)<br />
Dim pi() As Drawing.Imaging.PropertyItem = img.PropertyItems<br />
Dim bytes() As Byte<br />
Dim enc As New System.Text.UTF8Encoding<br />
<br />
For Each pItem As Drawing.Imaging.PropertyItem In pi<br />
If pItem.Id = 36867 Then<br />
bytes = pItem.Value<br />
graph.DrawString(enc.GetString(bytes), f, Brushes.Yellow, CSng(img.Width) - 400.0F, CSng(img.Height) - 50.0F)<br />
changed = True<br />
Exit For<br />
End If<br />
Next<br />
<br />
If changed Then<br />
img.Save(_imagesHash.Item(img).ToString() & ".jpg")<br />
End If<br />
Next<br />
and I'm storing images and their paths in the hashtable.
oh last thing: When the image saved its size decreasing from 2mb to 250kb
Savas Cilve
|
|
|
|
|
Again, nowhere in your code do you call Dispose() on the Graphics object you're creating. You MUST ALWAYS call .Dispose() on a Graphics object when you're done using it, otherwise you get odd behavior, kind of like changes not being saved, when manipulating images and your app is suddenly leaking GDI Handles and will eventually crash the system! BTW, you also have to .Dispose() Font objects when you're done with them too.
Since you're only using the Graphics object when a property item contains a certain value, I suggest not creating any Graphics or Font objects unless you need them:
Imports System.Drawing.Imaging
.
.
.
For Each img As Image In _images
Dim changed As Boolean = False
Dim pi() As Drawing.Imaging.PropertyItem = img.PropertyItems
For Each pItem As Drawing.Imaging.PropertyItem In pi
If pItem.Id = 36867 Then
Dim bytes() As Byte = pItem.Value
Dim f As New Font(FontFamily.GenericSerif, 35.0F, FontStyle.Regular, GraphicsUnit.Point)
Dim graph As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(img)
Dim enc As New System.Text.UTF8Encoding
graph.DrawString(enc.GetString(bytes), f, Brushes.Yellow, CSng(img.Width) - 400.0F, CSng(img.Height) - 50.0F)
graph.Dispose()
f.Dipose()
' Create a JPEG Encoder and set it's Compression quality
Dim jpegCodec As ImageCodecInfo = GetEncoderInfo("image/jpeg")
Dim encoderParams As New EncoderParameters(1)
encoderParams.Param[0] = New EncoderParameter(Encoder.Quality, 100)
' Save the image using the new encoder
img.Save(_imagesHash.Item(img).ToString() & ".jpg", jpegCodec, encoderParams)
Exit For
End If
Next
Next
.
.
.
Public Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders()
For i As Integer = 0 To codecs.Length
If codecs[i].MimeType = mimeType Then
Return codecs[i]
End If
Next
Return Nothing
End Sub
The reason why it's size changes is because you didn't specify the format to use when the image is saved. In your case, the image is saved as PNG format, not JPG. The filename you give doesn't determine the format of the image written. If you want to save an image in JPG format, you have to tell it to do so. If you want to control the compression used on the JPG image, you have to add EncoderParameters to spell out how the JPG should be handled. Those above has been modified to do this.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks a lot for making my code much more better
|
|
|
|
|
I am inserting text files into MySQL using vb.net. However, when I insert the files into the database it only insert every other file. For example, it will insert one file then the next row will be zeros. Does any one know why it might be doing this. Here is some code:
Dim myConnString AsString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=192.168.1.27;" & _
"DATABASE=testship;" & _
"USER=?;" & _
"PASSWORD=?;" & _
"OPTION=3;"
Dim MyConnection AsNew Odbc.OdbcConnection(myConnString)
MyConnection.Open()
Dim MyCommand AsNew Odbc.OdbcCommand("INSERT INTO ls_orderitems (OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES ('" & OrderDate & "','" & OrderCustomer & "','" & OrderAcctNum & "','" & OrderType & "','" & OrderSoNum & "','" & OrderItemPartNum & "','" & OrderItemPartDesc & "','" & OrderItemQty & "','" & OrderItemQtyRec & "','" & OrderItemQtyDtRec & "','" & OrderItemBO & "','" & OrderItemBODt & "','" & OrderItemCanceled & "','" & OrderItemCanceledDt & "','" & OrderItemNotes & "','" & OrderItemPONum & "','" & OrderItemRetailPrice & "','" & OrderItemSalePrice & "','" & Status & "','" & InsertDate & "')")
MyCommand.Connection = MyConnection
MyCommand.ExecuteNonQuery()
MyConnection.Close()
jds1207
|
|
|
|
|
jds1207 wrote: I am inserting text files into MySQL using vb.net. However, when I insert the files into the database it only insert every other file. For example, it will insert one file then the next row will be zeros
???
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Well, from the description of the problem, there's something wrong with either the code that reads the files, or the code that validates the data, or the code that inserts the file into the database. And what have we told you about using parameterized queries?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|