Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 24th, 2006, 3:48 PM   #1
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 35
Rep Power: 0 irish is an unknown quantity at this point
Button links to applications

I'm having a go at VB and i'm trying to make a small program that will have buttons that link to applications (fast, easy access). But i can't actually get the buttons to link to anything. How would i go about making the buttons link to a program on my computer?
irish is offline   Reply With Quote
Old Mar 24th, 2006, 3:55 PM   #2
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Dunno which version you're using, but assuming you're using < VB6, you can use the AppActivate function.
Polyphemus_ is offline   Reply With Quote
Old Mar 24th, 2006, 3:58 PM   #3
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 35
Rep Power: 0 irish is an unknown quantity at this point
How do i do that? lol sorry.
irish is offline   Reply With Quote
Old Mar 24th, 2006, 4:06 PM   #4
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
I suggest reading a number of tutorials on Visual Basic, as you don't even know how to use a function.
Polyphemus_ is offline   Reply With Quote
Old Mar 24th, 2006, 6:28 PM   #5
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 35
Rep Power: 0 irish is an unknown quantity at this point
Ok, i had a look up for functions etc on google. But the AppActivate function only activates a program that is already running(as i discovered when building), i am trying to start a process. I'll have a look for another function or i'll try to find a way to work around it. Thanks for the help
irish is offline   Reply With Quote
Old Mar 24th, 2006, 6:48 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Check out the Shell function.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 24th, 2006, 9:00 PM   #7
irish
Programmer
 
Join Date: Nov 2005
Location: Belfast
Posts: 35
Rep Power: 0 irish is an unknown quantity at this point
After a bit more searching, i found this:

System.Diagnostics.Process.Start("Path")

It works fine, i just need to link it to the buttons now.
irish is offline   Reply With Quote
Old Mar 25th, 2006, 8:39 AM   #8
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Ah... you're using Visual Basic .NET or Visual Basic 2005 (which uses the .NET framework, but they dropped the ".NET" name for the language), not Visual Basic. Please post in the correct forum next time.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 25th, 2006, 1:38 PM   #9
brownhead
Programmer
 
Join Date: Mar 2006
Location: California
Posts: 37
Rep Power: 0 brownhead is on a distinguished road
Send a message via AIM to brownhead Send a message via MSN to brownhead
AppActivate wouldn't work for what your doing. Shell could work but would be tricky. I reccomend the ShellExecute API. Place this in a module.
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Sub Execute(ByVal FormHWND As Long, ByVal Path As String)
ShellExecute FormHWND, "Open", Path, 0&, 0&, 1
End Sub
NOw anything that you pass through the execute function will be executed just as if you typed it in to the "Run" tool accessible throught the windows start-bar. Heres an example of using this:
Private Sub Command1_Click()
Execute Me.hWND, "Notepad"
End Sub
That would open up notepad. YOu can also use paths:
Private Sub Command1_Click()
Execute Me.hWND, "C:\Documents and Settings\Computer\Test.txt"
End Sub
And it'll open the text document with your default plain-text editor. This is a very dynamic function, you can even search websites and it'll use your default web-browser.
Private Sub Command1_Click()
Execute Me.hWND, "www.google.com"
End Sub
Anyways. If ya need help using htis, my AIM sn is brownhead622 and my msn is brownhead622@hotmail.com. Gday all
brownhead is offline   Reply With Quote
Old Mar 26th, 2006, 4:34 PM   #10
ReubenK
Programmer
 
ReubenK's Avatar
 
Join Date: Mar 2006
Posts: 36
Rep Power: 0 ReubenK is on a distinguished road
Ah,I remember doing one of them when I started..
This is what I used


Private Sub Command1_Click()
Shell "notepad.exe"
End Sub


Private Sub Command1_Click()
Shell "C:\WINNT\System32\calc.exe"
End Sub

Two examples of the way you can do it.
Hope this helps,
Reuben Keeney
ReubenK is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC