Link to home
Start Free TrialLog in
Avatar of luthar
luthar

asked on

Loading a file and capturing keys...

Ok i want to make an application that opens a certin program called "Program A" and whenever the user presses f1 it loads another help file instead of the Program's A help file..

My first problem is that i only want the file path to be given at the first time they open the program then the program will renember it...

I think we do that with a *.ini file right?
My second thing is that i want the f1 key to be intercept before Program A help file loads and basicly Program A hlp file will never appear.

Any tip help is welcomed :)

Starting at 50pts and will see if it's enought (should be..)
Avatar of luthar
luthar

ASKER

Edited text of question.
You can put it in any file you like ..your app opens it, writes to it, and then when needed it opens the file and reads it.
How to intercept the key events

Option Explicit

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1: MsgBox "F1 pressed."
Case vbKeyF2: MsgBox "F2 pressed."
Case vbKeyEscape: MsgBox "ESC"
End Select
End Sub

Private Sub Form_Load()
Form1.KeyPreview = True
End Sub


Avatar of luthar

ASKER

Ok i can use a common dialog to get the path then transfer it to the file....what was the function to read a file again (can't access vb help on this comp :( )

Has for the keydown it's good when you have a form but i need to make this program invisible (form1.visible = false or have it put the code in a module).
Avatar of luthar

ASKER

Ok i can use a common dialog to get the path then transfer it to the file....what was the function to read a file again (can't access vb help on this comp :( )

Has for the keydown it's good when you have a form but i need to make this program invisible (form1.visible = false or have it put the code in a module).
'put this in a click event or a load
'reads a complete txt file and sends it
'to a multiline text box

CommonDialog1.Flags = cdlOFNNoChangeDir
CommonDialog1.InitDir = "C:\"
CommonDialog1.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*"
CommonDialog1.ShowOpen
Open CommonDialog1.filename For Input As #1
Text1.Text = Input(LOF(1), 1)
Close #1
Avatar of luthar

ASKER

Good suggestion :)

I did write a code that checks a *.ini file and takes the path if no *.ini file found or nothing in it, it ask to get the path with a commonDialog, copies it in the ini file, loads the program...etc



THanks for your comments :)
ASKER CERTIFIED SOLUTION
Avatar of Juilette
Juilette

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of luthar

ASKER

Since I feel generous today, i'll give you the points. I ust have to renember to stop asking questions here before i look at the help in VB/VB books...

Thanx again :)
Avatar of luthar

ASKER

Oh darn forgot to give the points :)
There you go :)
May as well, once you post, the points are gone from your side of the woods.

Wayne

Ps..Since I'm in a generous mood as well!

you are very correct...most answers are easily found....best thing I ever did was to build myself a database with all the tips and clues and things I might need somewhere down the line. I access the database with "Like" so I can find the answers very quickly....I have learned more from this site by answering and following leads that I did in 2 years of night school.
 The address below is a good Q & A as well and no points...takes the shark attitude out of it...Serge and Aaron are very good at anything you need answered. Check it out.
http://www.vb-world.net/cgi-bin/forumdisplay.cgi?action=topics&forum=General+Visual+Basic+Questions&number=1&DaysPrune=


Good luck in your endevours.