|
How is this different from your last post[^]? If someone wants to copy something bad enough they'll just take a screen capture.
|
|
|
|
|
I am sure you can disable copy for PDF, but not sure how. Search on google and you will find something on it.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Hello!
I have a little problem....
When i get a print preview of any document how can i hide a small message box saying "Page 1 of 1 Document" befeore displaying print preview?
I dont want it....!
Could any body help me?
Thanks
colgateas900197
|
|
|
|
|
|
I have opened an image as a bitmap using GDI+. Before I save it I want to know if the image has transparency in it. That is; is there any pixels in the bitmap that has the transparent color. I have made a solution that looks like this:
Dim objImage As Drawing.Bitmap = Drawing.Image.FromFile("png_with_transparent_bg.png")
Dim booTransparentColorFound As Boolean = False
If Bitmap.IsAlphaPixelFormat(objImage.PixelFormat) Then
For y As Integer = 0 To objImage.Height - 1
If booTransparentColorFound Then Exit For
For x As Integer = 0 To objImage.Width - 1
Dim objColor As Drawing.Color = objImage.GetPixel(x, y)
If objColor.A = Color.Transparent.A And _
objColor.R = Color.Transparent.R And _
objColor.G = Color.Transparent.G And _
objColor.B = Color.Transparent.B _
Then
booTransparentColorFound = True
Exit For
End If
Next
Next
End If
The problem is that if the image is very big, and there is no transparent pixel in it (or a transparent pixel is located in the lower right corner), the routine is very slow. Is there some quicker way to determine if there is transparency in the image?
Thanks in advance.
...Allan, Denmark
|
|
|
|
|
You only need to check the alpha channel (objColor.A) to find out if the color is transparent.
You can use the LockBits and UnlockBits methods to get access to the pixel data, to circumvent the GetPixel method. In VB you need to use marshalling to copy the data into an array, though. If you would have used C#, you could use pointers to access the data directly.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
The Alpha channel is used by GDI+ ? The extra byte in a 32 bit image was ignored by GDI.
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 )
|
|
|
|
|
Christian Graus wrote: The Alpha channel is used by GDI+ ?
Yes.
The third line of the posted code checks that the pixel format actually is one that has an alpha channel.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
Two more comments:
1.
you could check the most likely transparent pixels first, say the four corners.
that would lower the average time, but not help for non-transparant images.
2.
in debug mode, you should avoid calling objImage.Height and objImage.Width in the
for loops; call them once instead, and store the values locally.
in release mode, this will not make a performance difference.
|
|
|
|
|
Hi,
I am writing program VB.Net (using Visual studio 2005). In this program, I am using browser control to send request on the internet. In responce to the request, one PDF file gets opened in the browser automatically. I want to save this PDF file on the hard disk. To do this, I think my program should be able to read the downloaded file in response to my request. Is there any way by which I can do this.
Thanks in advance.
Regards,
Sunil
|
|
|
|
|
If you just want to download the PDF file use HttpWebRequest. Google it and you'll find some example code.
|
|
|
|
|
I am afraid I can not use it. Becuase I don't have to use only the URL. Following is the flow of my program.
1) My application open a web page in WebBrowser control after sending some URL , say www.xx.com (using Navigate method)
2) The opened web page(www.xx.com) has fields like Name, Address, SSN. My application fills this information in the browser window programatically and clicks on one link in the same web page (this is also programatically)
3) on clicking the link, the filled infomration gets submitted and at the server end(of www.xx.com) it processes entered name, address and SSN and generates one PDF file. This PDF file gets opened in my browser(webbrowser) window.
4) This opened PDF, I want to save on the hard disk programatically without having to click manually on the save icon of the embedded acrobat reader.
I am unable to achieve step 4.
|
|
|
|
|
I really need help with this. I have tried multiple solutions but have not found an answer. Also, time will soon be a factor because this project is due at the end of June. The problem is I need my program to display files in an organized fashion and open them. I've done this but I need to just display the file name while maintaining functionality. My attempts have always left the full path to the file intact. Please, I don't even need the code, just a description of the solution.
|
|
|
|
|
If you use the FileInfo object
<br />
FileInfo fiYourFile = new FileInfo("Path\To\File.txt");<br />
There's a list of properties. FullName and Name both contain the name of the file, FullName is the full name including the path to the file. Name is just the name of the fil including it's extension. Is this the answer you're looking for? Else I don't understand your question..
|
|
|
|
|
I have this part down so far. If I use the .name property then I get the output I am looking for but I don't get path to the file necessary to open it. I need a way to give a list item one value and display another. I'd rather not use XML or databases.
|
|
|
|
|
Can you provide more description of what you are looking to achieve?
Do you want entire path intact or not?
Best Regards,
Sam Xavier
www.componentone.com
|
|
|
|
|
The program I am creating is a jump drive organizer. It is supposed to be able to organize various file types into separate lists. from these lists the file needs to be able to be selected and opened. My problem is that I don't want to display the fullpath to the file but only the name while still being able to open the file. (So far i've been manipulating strings for such things as choosing a directory.) I need the value of an item to be different than what is displayed the the end user.
|
|
|
|
|
Could you not create your own class with your overloaded "ToString" function... e.g.:
Public Class MyFileName
Public FileName As String
Public Overrides Function ToString() As String
Return System.IO.Path.GetFileName(FileName)
End Function
End Class
Then, when you add one of these items to a listbox, it will only display the filename, however, when you access the object, you can use the Filename string:
MessageBox.Show(DirectCast(ListBox1.Items(0), MyFileName).FileName)
|
|
|
|
|
I've just began learning about the concepts of object oriented programming this year. (second year of taking the comp. sci. course). I can use built in classes but still get a little confused making my own. Thanks for the help.
|
|
|
|
|
Hi,
No problem. It is really a simple class, but very useful in this instance (assuming you are displaying the list of files in a listbox, and using vb.net!!!).
If you are still struggling, here is a bit of messy code that may show you a bit more. All you need to do is create a new form with one listbox called listbox1, and paste this code into your app.
Public Class MyFileNameClass
Public FileName As String
Public Overrides Function ToString() As String
Return System.IO.Path.GetFileName(FileName)
End Function
End Class
Private Sub AddItemsToListBox(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Me.ListBox1.Items.Clear()
For Each FileNameStr As String In IO.Directory.GetFiles("c:\")
Dim o As New MyFileNameClass
o.FileName = FileNameStr
Me.ListBox1.Items.Add(o)
Next
End Sub
Public Sub DisplayInfo(ByVal sender As Object, ByVal e As EventArgs) Handles ListBox1.Click
If ListBox1.SelectedIndices.Count > 0 Then
For Each i As Integer In ListBox1.SelectedIndices
Dim o As Object = ListBox1.Items(i)
If TypeOf o Is MyFileNameClass Then
MessageBox.Show(DirectCast(o, MyFileNameClass).FileName)
End If
Next
End If
End Sub
This code should populate the listbox with all the files in your c:\ folder, but only display the name. When you click on a file, a messagebox will pop up with the full path & filename. Nothing exciting, but I think it may get you closer to what you want to do.
|
|
|
|
|
thanks, you saved me hours of work.
|
|
|
|
|
I appreciate the help but I need to ask one more favor. Your code works but I can't integrate it "as is" into my code because my program requires a file search within a given directory. I cannot put a type fileinfo value through this class. (sorry if my working knowledge of classes seems limited.). I tried converting the data to string but that didn't work. heres the code I attempted to use:
Dim dir As String = ComboBox1.Text
Dim files As String
Dim search As DirectoryInfo = New DirectoryInfo("m:\") '(dir & ":\")
For Each file As FileInfo In search.GetFiles("*.doc", SearchOption.AllDirectories)
Dim cls As New MyFileNameClass
cls.FileName = (file.ToString)
ListBox1.Items.Add(cls)
Next
I would repeat the for each/ next statement for every subsequent search I wanted to make. (I commented out the user directory selection because it was causing problems.)
|
|
|
|
|
Looking at it in a bit more detail, you can actually put an object of type "FileInfo" into a listbox, and it will have the same functionality:
Dim dir As String = "C:\"
Dim search As DirectoryInfo = New DirectoryInfo("c:\Windows\") '(dir & ":\")
For Each file As FileInfo In search.GetFiles("*.*", SearchOption.AllDirectories)
ListBox1.Items.Add(file)
Next
and in the click handler:
Public Sub DisplayInfo(ByVal sender As Object, ByVal e As EventArgs) Handles ListBox1.Click
If ListBox1.SelectedIndices.Count > 0 Then
For Each i As Integer In ListBox1.SelectedIndices
Dim o As Object = ListBox1.Items(i)
If TypeOf o Is FileInfo Then
MessageBox.Show(DirectCast(o, FileInfo).FullName)
End If
Next
End If
End Sub
Maybe that is more suitable? It will keep the whole FileInfo block in the listbox.
|
|
|
|
|
You could create a DataTable with columns of Path and FileName, then bind the DataTable to your control, setting the Path as the ValueMember and FileName as the DisplayMember .
This obviously is dependent on the control you are using.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Hello all,I am wondering anyone can guide me how to read tiny text column for MySQL using VB.NET Datareader.
The following are the code I used to read the column:
Public Function StartupData(ByVal strKeySet as String)
Dim test as string
Dim MyTinyText as string
Try
ObjComm = New OdbcCommand("SELECT SettingValue FROM pos_setting WHERE LocationCode='KK' AND SettingKey='ADD_BINLOG'", ObjConn)
ObjConn.Open()
ObjRead = ObjComm.ExecuteReader()
If ObjRead.Read Then
test = ObjRead.Item(0)
MessageBox.Show("This is " & test & "")
Else
MessageBox.Show("No value")
End If
ObjConn.Close()
Catch ex As Exception
Finally
Objconn.Close
End Try
And my database table as follow:
---------------------------------------------
Field Type Collation Null Key Default Extra Privileges Comment
------------ ----------- ----------------- ------ ------ ------- ------ ------------------------------- -------
LocationCode varchar(10) latin1_swedish_ci NO PRI select,insert,update,references
SettingKey varchar(10) latin1_swedish_ci NO PRI select,insert,update,references
SettingValue tinytext latin1_swedish_ci YES (NULL) select,insert,update,references
I'm wondering why its keep showing there is no data read inside the datareader? Actually there is a '0' inside the SettingValue for that row of data but I'm wondering why it doesn't read it? Anyone can give me a solution for this?
Thanks for reading~!
|
|
|
|