|
Hello,
I am creating a program in VB.Net that reads data from a specific file type (one that I didn't create). Part of my program reads the file to determine some of the data in it, references an embedded resource image (choosing which image based on said data), and displays that image in a picturebox.
I would like for these files to display a thumbnail of that same image in Explorer. I'd be all right with an explorer-like interface in my program that does this, but I'd much prefer if it could be applied to Explorer, so I can see these thumbnails even without the program running.
I've looked for information on how to do this everywhere, and I can't find any.
In a similar vein, I would like to associate these files with my program, so that when I double click them, my program launches and knows what to do with that file (basically it would run the functions it runs now, only without the need for an openfiledialog).
Any help (or points in the right direction at least) would be really appreciated. Thanks everyone!
As I sit here, I contemplate the last words of Socrates: "I drank what?".
Pokémon Pearl Friend Code: 4554-2418-6836
|
|
|
|
|
Associating the file extension is easy. You just have to go into Explorer >> Tools >> Options >> File Types tab >> New button. THen type in your file extension and click OK. When you get back to the list, click on your file extension, then click on Change. Click on the Browse button and file your application. That's a start anyway. You might have to tweak the final result for your requirements.
Writing a Shell Extension, on the other hand, isn't so easy. It is highly recommended that you do NOT do this in any managed language (C#, VB.NET, ...) but instead, write it in plain Visual C++. But, you can read up a bit on it at http://msdn.microsoft.com/en-us/magazine/cc188741.aspx[^]
If you're not familiar with Shell internals, I suggest postponing this project until you do a ton of research on the topic. You can start here[^]. This was the first in a series of three articles on the subject.
|
|
|
|
|
The file association has to be done programmatically, for deployment purposes... although that method would be fine for my personal use (if I could then figure out how to set my program to know what to do once the file is opened in this fashion).
I'll look into those links you provided. I may be in over my head, but something tells me someone else has tried something like this. Thanks!
As I sit here, I contemplate the last words of Socrates: "I drank what?".
Pokémon Pearl Friend Code: 4554-2418-6836
|
|
|
|
|
CodeMonkey85 wrote: The file association has to be done programmatically, for deployment purposes... although that method would be fine for my personal use (if I could then figure out how to set my program to know what to do once the file is opened in this fashion).
Get the association to work in your dev environment first. Then you can look in the Registry, under HKEY_CLASSES_ROOT to show you what you have to reproduce in your installation code to do it.
As for the image preview in Explorer, yes, other people have done it, and that's what they had to go through to accomplish it. There is no "template" project where you just modify a little bit of code, compile it call it Done!
|
|
|
|
|
Hello friends,
I am Usind MSAccess for loading some txtfiles from a folder to the SQL server. These txtfiles are gnerated from a testing tool. My Access will autoload the files to the server i.e my application is scheduled to call from scheduled task, twice a day. It will check the folder for txtfiles , if the folder is empty, the applicaton exits. Else it will load the files to server and move all loaded files to another folder.
My problem is if both tool(my MSAccess and the testing tool which creating txt files) are running simultanously these is a chance of half generated txt file(generating by testing tool) to be loaded in the server. I dont want that. That file has to be loaded next time.
How to prevent the half generated txtfiles from loading to server.
Hope u got my problem
Regards
Jishith
|
|
|
|
|
One way is to check the file size, wait say 10 seconds and check it again. Repeat until there is no change.
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
In the old days (VAX/VMS) I used to be able to open a file either as "Shared" or "Exclusive". What you want here is to open the file, "Exclusive", so that you are guaranteed that that no other process is touching it.
You will need to test this out with OpenTextFile in MS-Access.
Just and idea.
|
|
|
|
|
We use a first pass flag. We know the write does not take more than x seconds so the loop sets a time flag the first pass. Second pass if the time flag is > wait setting then the file is loaded.
I almost like the exclusive idea (and will test it Monday) except you are programming by error (one of my favourite rants) ie try and open the file, if it fails then deal with it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
the txt file may take minute for complete write.. And its with the customer side..i dont want to fail my application while opening..Want to load other file skipping the file which is still in writing process..
|
|
|
|
|
jishbalan wrote: Want to load other file skipping the file which is still in writing process.
That is precisely what we do. If the file has not been resident in the folder for #n seconds then the loop progresses to the next file in the folder and ignores the potentially locked file. Next pass it will get the file it ignored.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks a lot..
These is exactly what i want...
But
"If the file has not been resident in the folder for #n seconds" What it means? and how to check?
"potentially locked file" How can i check for these?
|
|
|
|
|
You need a table/list of filenames with a datetime field.
Start loop (foreach file in directory)
check if the file is in the list
add the file to the list with the time (first pass)
if the file is there has enough time passed (check time flag in list for this file)
if time passed > Setting then process
end loop
A potentially locked file has been in the folder less than #n seconds/minutes. You really don't care if it is actually locked, just make sure the time to wait is > than any possible locking period.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello all!
How can I delete listbox contents populated through a database? Here's my code for the delete button...
If Adodc1.Recordset.RecordCount <> 0 Then
res = MsgBox("Are You Sure You Want To Delete This Record?", vbYesNo, "System Message")
If res = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.Requery
Adodc1.Refresh
MsgBox "Recored has been Deleted"
lstpromo.RemoveItem lstpromo.ListIndex
End If
Else
MsgBox "No Record to delete"
End If
However I get the error "Either BOF or EOF is true, etc...". Is there a method in vb6 that I can use like the in odbccommand in .Net?
Aim small, miss small
|
|
|
|
|
Your code isn't deleting specific records in the database. You're going through the listbox, but not matching those items to records in the recordset. You're not even looking at the first record in the recordset.
Judging by your verbage, you're not binding the listbox (if that's even possible in VB6) to the recordset. This means that you have to look at each item in the listbox, find the corresponding record in the recordset, then delete that record, and continue with the search.
|
|
|
|
|
Hey thanks! Kind of a noobish question there but thanks for the aid. Incidentally I wasn't matching the items to the recordset as you said. Got used to vb.net DB manipulation I forgot it was different here in VB6. Agin thanks for the help
Aim small, miss small
|
|
|
|
|
Try to this query.
str="delete from tablename where field name=" & "'" & List1.Items.Text & "';"
Execute this query then refresh the database and remove the all item from list and add up once again.
|
|
|
|
|
Hi All
In my project i want to load a English Dictionary(similar in MS Word Dictionary)and find spell check?Is there any Reference in vb.net?
Give me an idea....
Thanks in Advance
|
|
|
|
|
The only way you can get this for free is if your users have Word installed and you can interop with it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi all...
I am creating a program in VS2005 which accepts a username and password to execute the program.
I have done all things but I want to give a checkbox below password textbox so that users can see their passwords.
What should I write in checkbox.checked event so that the password character (*****) would appear in its original text format (12345).
Thanks.
Gagan
|
|
|
|
|
Hi
Change the password char property in check box click or change event.
If checkbox1.checked then
textbox1.Passwordchar="*"
else
textbox1.Passwordchar=""
end if
Hope this helpfull.
Thanx
~Khatri Mitesh
khatrimitesh@hotmail.com
Bikaner (Rajasthan)
INDIA
|
|
|
|
|
Thanks Mitesh for your help.
It works.
|
|
|
|
|
I have a simple problem and find it hard to believe there isn't an article or documentation around on how to solve it. Probably just looking in the wrong place. Anyway I have a form with a grid bound to a table in the dataset. There are several other tables in the dataset which provide detail info for the parent record. My main form has a grid and a tab control. When the user selects a tab a control bound to the original form is added with the detail info from the appropriate table. No problem so far. I just pass the dataset and filter in the new routine of the control.
Now when I change recors in the master grid I would like the detail in the loaded control to be synchronized. Anyone have a simple example of this or know an easy to understand article on maintaining concurrency between a form and a loaded control?
Such a Larry
|
|
|
|
|
larry118 wrote: Now when I change recors in the master grid I would like the detail in the loaded control to be synchronized.
Based on what you've said about your detail grid, I would think all you had to do was update the filter with the new parameters.
|
|
|
|
|
Hi Friends I have tried many times to convert this code into Vb.net but every time I got some exceptions ans errors and finally I am unable to Write this code into Vb.net please can some one please help me...
actually this is a Steganography project...
where two textboxes are used named txtmessage for the message to be hidden into image and txtpassword that acts as a key and a picture box named Picimage and two buttons named cmdEncode to Encode and cmddecode to Decode...
Option Explicit
Private Sub ArrangeControls()
Dim wid As Single
Width = picImage.Left + picImage.Width + Width - ScaleWidth + 120
Height = picImage.Top + picImage.Height + Height - ScaleHeight + 120
wid = ScaleWidth - txtMessage.Left - 120
If wid < 120 Then wid = 120
txtMessage.Width = wid
txtPassword.Width = wid
End Sub
' Encode this byte's data.
Private Sub EncodeByte(ByVal Value As Byte, ByVal used_positions As Collection, ByVal wid As Integer, ByVal hgt As Integer, ByVal show_pixels As Boolean)
Dim i As Integer
Dim byte_mask As Integer
Dim r As Integer
Dim c As Integer
Dim pixel As Integer
Dim clrr As Byte
Dim clrg As Byte
Dim clrb As Byte
Dim color_mask As Integer
byte_mask = 1
For i = 1 To 8
' Pick a random pixel and RGB component.
PickPosition used_positions, wid, hgt, r, c, pixel
' Get the pixel's color components.
UnRGB picImage.Point(r, c), clrr, clrg, clrb
If show_pixels Then
clrr = 255
clrg = clrg And &H1
clrb = clrb And &H1
End If
' Get the value we must store.
If Value And byte_mask Then
color_mask = 1
Else
color_mask = 0
End If
' Update the color.
Select Case pixel
Case 0
clrr = (clrr And &HFE) Or color_mask
Case 1
clrg = (clrg And &HFE) Or color_mask
Case 2
clrb = (clrb And &HFE) Or color_mask
End Select
' Set the pixel's color.
picImage.PSet (r, c), RGB(clrr, clrg, clrb)
byte_mask = byte_mask * 2
Next i
End Sub
' Decode this byte's data.
Private Function DecodeByte(ByVal used_positions As Collection, ByVal wid As Integer, ByVal hgt As Integer, ByVal show_pixels As Boolean) As Byte
Dim Value As Integer
Dim i As Integer
Dim byte_mask As Integer
Dim r As Integer
Dim c As Integer
Dim pixel As Integer
Dim clrr As Byte
Dim clrg As Byte
Dim clrb As Byte
Dim color_mask As Integer
byte_mask = 1
For i = 1 To 8
' Pick a random pixel and RGB component.
PickPosition used_positions, wid, hgt, r, c, pixel
' Get the pixel's color components.
UnRGB picImage.Point(r, c), clrr, clrg, clrb
' Get the stored value.
Select Case pixel
Case 0
color_mask = (clrr And &H1)
Case 1
color_mask = (clrg And &H1)
Case 2
color_mask = (clrb And &H1)
End Select
If color_mask Then
Value = Value Or byte_mask
End If
If show_pixels Then
picImage.PSet (r, c), RGB( _
clrr And &H1, _
clrg And &H1, _
clrb And &H1)
End If
byte_mask = byte_mask * 2
Next i
DecodeByte = CByte(Value)
End Function
' Translate a password into an offset value.
Private Function NumericPassword(ByVal password As String) As Long
Dim Value As Long
Dim ch As Long
Dim shift1 As Long
Dim shift2 As Long
Dim i As Integer
Dim str_len As Integer
' Initialize the shift values to different
' non-zero values.
shift1 = 3
shift2 = 17
' Process the message.
str_len = Len(password)
For i = 1 To str_len
' Add the next letter.
ch = Asc(Mid$(password, i, 1))
Value = Value Xor (ch * 2 ^ shift1)
Value = Value Xor (ch * 2 ^ shift2)
' Change the shift offsets.
shift1 = (shift1 + 7) Mod 19
shift2 = (shift2 + 13) Mod 23
Next i
NumericPassword = Value
End Function
' Pick an unused (r, c, pixel) combination.
Private Sub PickPosition(ByVal used_positions As Collection, ByVal wid As Integer, ByVal hgt As Integer, ByRef r As Integer, ByRef c As Integer, ByRef pixel As Integer)
Dim position_code As String
On Error Resume Next
Do
' Pick a position.
r = Int(Rnd * wid)
c = Int(Rnd * hgt)
pixel = Int(Rnd * 3)
' See if the position is unused.
position_code = "(" & r & "," & c & "," & pixel & ")"
used_positions.Add position_code, position_code
If Err.Number = 0 Then Exit Do
Err.Clear
Loop
End Sub
' Return the color's components.
Private Sub UnRGB(ByVal color As OLE_COLOR, ByRef r As Byte, ByRef g As Byte, ByRef b As Byte)
r = color And &HFF&
g = (color And &HFF00&) \ &H100&
b = (color And &HFF0000) \ &H10000
End Sub
Private Sub cmdDecode_Click()
Dim msg_length As Byte
Dim msg As String
Dim ch As Byte
Dim i As Integer
Dim used_positions As Collection
Dim wid As Integer
Dim hgt As Integer
Dim show_pixels As Boolean
If txtPassword.Text = "" Then
MsgBox ("Please Enter The Password to Continue...")
Exit Sub
End If
Screen.MousePointer = vbHourglass
DoEvents
' Initialize the random number generator.
Rnd -1
Randomize NumericPassword(txtPassword.Text)
wid = picImage.ScaleWidth
hgt = picImage.ScaleHeight
show_pixels = chkShowPixels.Value
Set used_positions = New Collection
' Decode the message length.
msg_length = DecodeByte(used_positions, wid, hgt, show_pixels)
' Decode the message.
For i = 1 To msg_length
ch = DecodeByte(used_positions, wid, hgt, show_pixels)
msg = msg & Chr$(ch)
Next i
picImage.Picture = picImage.Image
txtMessage.Text = msg
Screen.MousePointer = vbDefault
MsgBox ("Decryption Completed....")
End Sub
Private Sub cmdEncode_Click()
Dim msg As String
Dim i As Integer
Dim used_positions As Collection
Dim wid As Integer
Dim hgt As Integer
Dim show_pixels As Boolean
If txtMessage.Text = "" Then
MsgBox ("Please Enter Text to Encrypt...")
Exit Sub
ElseIf txtPassword.Text = "" Then
MsgBox ("Please Enter Password To Protect Data...")
Exit Sub
End If
Screen.MousePointer = vbHourglass
DoEvents
' Initialize the random number generator.
Rnd -1
Randomize NumericPassword(txtPassword.Text)
wid = picImage.ScaleWidth
hgt = picImage.ScaleHeight
msg = Left$(txtMessage.Text, 255)
show_pixels = chkShowPixels.Value
Set used_positions = New Collection
' Encode the message length.
EncodeByte CByte(Len(msg)), _
used_positions, wid, hgt, show_pixels
' Encode the message.
For i = 1 To Len(msg)
EncodeByte Asc(Mid$(msg, i, 1)), _
used_positions, wid, hgt, show_pixels
Next i
picImage.Picture = picImage.Image
Screen.MousePointer = vbDefault
MsgBox ("Encryption Complete..." & vbNewLine & vbNewLine & "You Can Save Picture Using Menu...")
End Sub
Private Sub Form_Load()
picImage.ScaleMode = vbPixels
picImage.AutoRedraw = True
dlgImage.InitDir = App.Path
ArrangeControls
End Sub
|
|
|
|
|
The auto convert doesn't really work, the languages are too different. I'd say you need to just rewrite it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|