|
Hello! Everybody
I want to drag file from FileList Box from VB.NET forms to AUTOCAD (or any other application). Previously I did this useing OLEdrag but in .net OLE is obsolute. I need help. I will be greateful if anyone provide.
Thanks
|
|
|
|
|
See the DoDragDrop method for more information, as well as an example. .NET encapsulates the OLE drag and drop into (overly-)simple calls, also making use of the DragOver , DragDrop , and other related events.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I tried everything, I can drag and drop Text But I can not drag and drop files. U can try and test sample with windows explorer. If u can with explorer just send me sample code.
thanx
|
|
|
|
|
I've done it easily in the past. The only stipulation - without having to P/Invoke OLE's DoDragDrop function and the related OLE interfaces - is that you must have a file related to the item in your ListView . For example, lets say you store the actual path of the file in the ListViewItem.Tag property, so in the event handler for ListView.ItemDrag , you could do something like this:
Private Sub listView1_ItemDrag(ByVal sender As Object, ByVal e As ItemDragEventArgs)
Dim path As String = CStr(e.Tag)
Dim do As New DataObject(DataFormats.FileDrop, path)
listView1.DoDragDrop(do, DragDropEffects.Copy)
End Sub If your ListView contains "virtual" files that you need to stream to the drop target, you have to revert to OLE drag and drop, which can be done using P/Invoke and COM interop for declaring the related interfaces and structs.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi!
Thx for reply, I am sending my code herewith, I can drag file upto explorer but It could copy in explorer, send ur comments
Dim path1 As String = "C:\DWG\6420.dwg"
Dim dx As New DataObject(DataFormats.FileDrop, path1)
ListView1.DoDragDrop(dx, DragDropEffects.Copy Or dragDropEffects.Move)
I use same code in "ItemDrag" also.
Please do reply
Hemant
|
|
|
|
|
While a single string should work, also try a String() array with one element - the path. This does work. I've used it many times. Just make sure the file actually exists, since the .NET FCL doesn't expose other STGMEDIUM types (streams, storage, etc.).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying from last 1-2 days. But Explorer does not recognise and can not perform actions like copy/move. As soon as I started dragging a file from windows (VB.NET) application to Explorer ICON gets changed but it does ot perform any action for file copy OR file Move.
If anyone can provide me a sample code i will be very gr8ful.
Thanks
Hemant
|
|
|
|
|
I have a page where I am uploading an image. When the page is first called, the current image is displayed, after they upload a new one image, the new image is displayed. Here is my logic, When I use the code in red, the image displays and refreshes after hitting upload when working on my local computer. But when I move it over to the server. I get the broken image icon for the images. So I used the code in green and the images would show up fine. But I have to hit refresh after I upload to get the new picture to display. The code in blue is where i view the uploaded picture. Also the ConfigurationSettings.AppSettings("PhotoPath") 's value is
"../Images\ReatorPics\"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
PopulateCurrentImageInfo()
End If
End Sub
Sub PopulateCurrentImageInfo()
Dim vUserID As String
vUserID = HttpContext.Current.User.Identity.Name.ToString
CurrentPhotoInfo.Text = mlsgateway.DatabaseCalls.Searches.ReturnRealtorImage()
CurrentPhotoInfo.Style("Color") = "red"
NewImage.ImageUrl = Server.MapPath(ConfigurationSettings.AppSettings("PhotoPath")) & vUserID & ".jpg")
'NewImage.ImageUrl = ConfigurationSettings.AppSettings("PhotoPath") & vUserID & ".jpg")
NewImage.Visible = True
End Sub
'upload image
Sub Button_Click(ByVal s As Object, ByVal e As System.EventArgs)
'''''''''''grab property number and set path to images folder
Dim vUserID As String
vUserID = HttpContext.Current.User.Identity.Name.ToString
Dim vPath As String = ConfigurationSettings.AppSettings("PhotoPath")
''''''''''obtain info about posted file
Dim ImageFileUp = uploadedFile.PostedFile
Dim ImageFileName As String = Path.GetFileName(ImageFileUp.FileName)
Dim ImageFileType As String = ImageFileUp.ContentType.ToString
'''''''''''save the orignal image to make it easier to manipulate
uploadedFile.PostedFile.SaveAs(Server.MapPath(vPath) & "/TempImages/" & ImageFileName)
''''''''''create a new bitmap from the saved file
Dim temp As String
Dim G As Bitmap
G = New Bitmap(Server.MapPath(vPath) & "/TempImages/" & ImageFileName)
Dim GFormat = G.RawFormat
Dim vWidth As Integer = CType(G.Width, Integer)
Dim vHeight As Integer = CType(G.Height, Integer)
'''''''''run function to obtain new image sizes
Dim NewImageSize As New Size
vWidth = vWidth * 5000
vHeight = vHeight * 5000
NewImageSize = ResizeImage(vWidth, vHeight)
''''''''create new bitmap with old bitmap but new width and height
Dim B As New Bitmap(G, NewImageSize.Width, NewImageSize.Height)
Try
'''''''try and save resized image and convert it to jpeg
'''''''then display old info and new info plus new image
'''''''dispose of image objects
B.Save(Server.MapPath(vPath) & vUserID & ".jpg", ImageFormat.Jpeg)
Dim vUserType As String = Request.Cookies("UserInfo")("UserType")
If vUserType <> "M" Then
SaveImageNameToDBNonMLSUser(vUserID)
Else
SaveImageNameToDBMLSUser(vUserID)
End If
Message.Text = "Image upload complete! "
ImageInfoPrevious.Text = "Old File Name: " & ImageFileName & " Old File Type: " & ImageFileType & " "
ImageInfoNow.Text = "New File Name: " & vUserID & ".jpg New File Type: " & "JPEG"
PopulateCurrentImageInfo()
NewImage.Visible = True
G.Dispose()
B.Dispose()
Catch ObjException As SqlException
Dim ObjError As SqlError
Message.Text = " Image Upload did not complete. Please try again. The error was : " & ObjException.Number & " " & ObjException.Message
Message.Style("color") = "red"
End Try
Page_Load(s, e)
''''''''''call sub to clean up the temp image
'RemoveTempImage(ImageFileName, vPath)
End Sub
Function ResizeImage(ByVal currentwidth, ByVal currentheight)
''''''''''''change 256 value to what ever you want the thumbnail to be returned as
''''''''''''checks to see if it is portait or landscape
Dim TempMultiplier As Double
If currentheight > currentwidth Then
TempMultiplier = 100 / currentheight
Else
TempMultiplier = 100 / currentwidth
End If
Dim NewSize As New Size(CInt(currentwidth * TempMultiplier), CInt(currentheight * TempMultiplier))
Return NewSize
End Function
Sub SaveImageNameToDBMLSUser(ByVal vUserID As String)
''''''''''''saves the new image info into the database.
Dim MyConnection As SqlConnection
MyConnection = New SqlConnection(ConfigurationSettings.AppSettings("Conn_MLSGateway"))
Dim SQL As String
SQL = "Update Assoc_Image_Name Set Image = '" & vUserID & ".jpg' Where LoginID = '" & vUserID & "'"
Dim MyCommand As New SqlCommand(SQL, MyConnection)
MyCommand.Connection.Open()
MyCommand.ExecuteNonQuery()
MyCommand.Connection.Close()
'Response.Write(SQL)
End Sub
Sub SaveImageNameToDBNonMLSUser(ByVal vUserID As String)
''''''''''''saves the new image info into the database.
Dim MyConnection As SqlConnection
MyConnection = New SqlConnection(ConfigurationSettings.AppSettings("Conn_International"))
Dim SQL As String
SQL = "Update Users Set Image = '" & vUserID & ".jpg' Where EmailAddress = '" & vUserID & "'"
Dim MyCommand As New SqlCommand(SQL, MyConnection)
MyCommand.Connection.Open()
MyCommand.ExecuteNonQuery()
MyCommand.Connection.Close()
End Sub
Sub RemoveTempImage(ByVal vImageName As String, ByVal vPath As String)
'this will clean up disk for the old photos that are placed pre resize and conversion.
Dim objFSO
objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(vPath & vImageName, False)
objFSO = Nothing
End Sub
|
|
|
|
|
I am using VB.NET Standard edition and it doesn't have Crystal reports. My question is how can i create report in vb.net with out crystal reports? If any one has any examples, I would really appriciate it.
Thank you,
Santana
|
|
|
|
|
YES, possible. You can use the datagrid, and other normal controls to print your own reports with custom alignments etc
He who controls others may be powerful, But he who has mastered himself is mightier still.
|
|
|
|
|
Hi,
Alrite, I found a way to kill the process (hidden). But now I see that the application which kills this process hangs because the process which I just killed (cmd.exe) basically was executing compile commands using gcc, g++, etc. So in the task manager, I see that cmd.exe disappears because I killed it, but I also see g++.exe, cc1plus.exe for a second or so, and then they disappear too.
Also the whole CPU time is taken up by this application, when it hangs.
So I think that the application hangs because the other processes started by cmd.exe stay for sometime before exiting.
Is there a way to kill the main window (cmd.exe) and all the related threads/exe attached to it?
Thanks.
|
|
|
|
|
We can use some API function to get *** textbox password from another Application with win98 or older. Windows NT can not be done with API functions
Who can help me write application to do this work
Email me: hoanghiep@hoanghiep.com
Thanks a lot
|
|
|
|
|
I think this security flaw was closed after Windows 98.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Yes it was, and is documented. No external process can query text when the EM_PASSWORD style is set. In order to do so, you must "inject" your code into the application's process space using system hooks or valid plug connections whereby the application loads plugins into its own process space. There is an article about this in CodeProject if you search.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am finishing myfirst application and have assigned a new file extension. I want the allow the user to double click on the file to open the application and then the file that was selected. I have set up the Fiile Types Editor in the setup project, but am unsure how to add code to my application to actually open the file. Can anyone help me?
Thanks!
|
|
|
|
|
ok so you have associated your file type with your application in folder options > file types? that is step 1.
<br />
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Dim fileName As String = System.Environment.CommandLine.Substring( _<br />
System.Environment.CommandLine.IndexOf(Chr(34) & " " & Chr(34)) + 3)<br />
<br />
'this is now a string containing the exact path & filename which was opened with the program.<br />
fileName = fileName.Substring(0, fileName.Length - 1)<br />
<br />
'then in this sub or another, do something with the file:<br />
'(in this case, open the file, and copy the text in it into a textbox)<br />
Dim inFile As IO.StreamReader = IO.File.OpenText(fileName)<br />
textBox1.text = inFile.ReadToEnd<br />
inFile.Close()<br />
<br />
End Sub<br />
all you need here really is the 'fileName' string which i setup for you, and you can do what you want with it, or you can use the exact example above and test it out.
let me know if this helps.
[many thanks to the Rage man himself.]
------------------------
Jordan.
III
|
|
|
|
|
Thanks!
I tried this and got a path without the drive letter. What am I doing wrong?
Thanks!
|
|
|
|
|
i tried this exact example when i made it for you, on my computer and it worked properly. if for whatever reason it isnt working properly, take the line where the string delcaration for fileName is. edit that line to something like Dim fileName As String = System.Environment.CommandLine instead. then test this string (with, ex, a msgbox) to see what it is actually returning when u try and open a file with the program. keep motifying it (like how i did, taking a substring from it) untill it works. i just built a new computer last nite and have yet to reinstall VS.net so i cant help with examples for now.
------------------------
Jordan.
III
|
|
|
|
|
I got the path string right using your suggestion (by building the application from within Studio.NET and looking at the path for the .exe file). However when I tried opening the installed application by double clicking a file, I got an " illegal character in path" error. How can I debug this? Is there a way to set a breakpoint in the installed executable?
Thanks!
|
|
|
|
|
im not sure how to do that.
post the source here or send me a zip of your project and ill chk it out.
------------------------
Jordan.
III
|
|
|
|
|
Did you get something like this:
Settings\userid\Desktop\filename.txt
If so, go back to your file association and put quotation marks around the %1 marker.
myapp.exe "%1"
RageInTheMachine9532
|
|
|
|
|
I've got the quotes around the "%1". I can't figure our how to break the execution of the code on the installed program, when I double click on the file, so that I can see what the path string actually is. I therefore don't know the path string that is being generated. The files are in a folder on my desktop, so your path is conceptually correct with the addition of the folder name before the filename.
I did find a stupid mistake and am working to fix it. I'll post the relevant code as soon as I'm not (too) ashamed of it.
Can you tell me how to debug an installed program?
Thanks!
|
|
|
|
|
All you have to do to test your app with command line arguments is go to the Project menu, select <projectname> Properties, click on the Configuration Properties folder on the left, then select the Debugging item. On the right, you'll find a blank for command line parameters. Just fill it in with the full path of the file your trying to use (without the quotes around it.)
RageInTheMachine9532
|
|
|
|
|
OK, now we are getting somewhere! I can see the path string, but it includes BOTH the path to the application executable and the file whose path I put into the command line as you described. The error is probably the result of 2 drive letters and 2 colons.
What am I doing wrong?
Thanks again!
|
|
|
|
|
nvmoss wrote:
The error is probably the result of 2 drive letters and 2 colons.
Nope...The problem is that your using Environment.CommandLine. It will return the ENTIRE command line, including the command that started your app.
The solution is use Environment.GetCommandLineArgs(). This will return an array of Strings, the first of which, index 0, will be the command that started the app. Index 1 will be the first argument:
|----------- Index 0 --------------| |------------------- Index 1 ------------------------|
C:\Program Files\myCompany\myApp.exe C:\Documents and Settings\userID\Desktop\fileToUse.txt
Dim cmdArgs As String()
cmdArgs = Environment.GetCommandLineArgs()
cmdArgs(0) will be "C:\Program Files\myCompany\myApp.exe" and
cmdArgs(1) will be "C:\Documents and Settings\userID\Desktop\fileToUse.txt",
of course, without the quotes.
RageInTheMachine9532
|
|
|
|