Hopefully 2 easy questions:
1) what is the best way to pass a URL to Windows and have it open a webpage in the default browser?
2) Can I change the "Default" button at runtime? (as opposed to design time)
Thank you in advance!
2 quickies (I hope)
Hi,
for the web browser the standard way is :
for the web browser the standard way is :
newbie.ShellExecute_(#NULL, "open", "http://YOURURLHERE" , #NULL, #NULL, #SW_SHOWNORMAL)
- Registered PB user -
Using PB 4.00
Using PB 4.00
Re: 2 quickies (I hope)
> Can I change the "Default" button at runtime? (as opposed to design time)
Use the #PB_Button_Default flag for the desired ButtonGadget.
Use the #PB_Button_Default flag for the desired ButtonGadget.
Re: 2 quickies (I hope)
You could try thisNonproductive wrote:Hopefully 2 easy questions:
2) Can I change the "Default" button at runtime? (as opposed to design time)
Thank you in advance!
Code: Select all
SetFocus_(GadgetID(gadgetnumber))
-
Nonproductive
- User

- Posts: 17
- Joined: Fri Apr 25, 2003 10:43 pm
Thank you All!
ShellExecute does exactly what I wanted
PB -
I know that works at gadget creation time, can you also use that flag at runtime?
--------
For what it's worth I was looking at Realbasic 5.2
Running through the demo "quickstart" tutorial they have you create a "URL Manager" application. So I decided to recreate the little App in Purebasic for comparison.
Here's the result (lines typed does not include auto generated code):
Realbasic 5.2.1 Demo
31 lines of code typed
1511 KB EXE
Purebasic 3.7.2 Licensed
37 lines of code typed
13 KB EXE
Realbasic claims "no runtime" needed - which is true - but it *is* bound with the app. The one upside though is that you can recompile most code directly for Mac's with little modification. Of course, this comes at a cost of $400. ($100 if you only want to compile for the platform you are running on)
And here is the PB Code (I make no claims to be a programmer BTW)
ShellExecute does exactly what I wanted
PB -
I know that works at gadget creation time, can you also use that flag at runtime?
--------
For what it's worth I was looking at Realbasic 5.2
Running through the demo "quickstart" tutorial they have you create a "URL Manager" application. So I decided to recreate the little App in Purebasic for comparison.
Here's the result (lines typed does not include auto generated code):
Realbasic 5.2.1 Demo
31 lines of code typed
1511 KB EXE
Purebasic 3.7.2 Licensed
37 lines of code typed
13 KB EXE
Realbasic claims "no runtime" needed - which is true - but it *is* bound with the app. The one upside though is that you can recompile most code directly for Mac's with little modification. Of course, this comes at a cost of $400. ($100 if you only want to compile for the platform you are running on)
And here is the PB Code (I make no claims to be a programmer BTW)
Code: Select all
; PureBasic Visual Designer v3.72
;- Window Constants
;
#Window_0 = 0
;- Gadget Constants
;
#AddURL = 0
#ConnectURL = 1
#DeleteURL = 2
#SelectedURL = 3
#ListURL = 4
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 363, 434, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "URL Manager")
If CreateGadgetList(WindowID())
ButtonGadget(#AddURL, 10, 400, 90, 30, "Add")
ButtonGadget(#ConnectURL, 260, 400, 90, 30, "Connect")
ButtonGadget(#DeleteURL, 260, 320, 90, 30, "Delete")
StringGadget(#SelectedURL, 10, 360, 340, 30, "")
ListViewGadget(#ListURL, 10, 10, 340, 300)
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
GadgetID = EventGadgetID()
EvntT = EventType()
If EvntT = #PB_EventType_Change And GadgetID = #SelectedURL
SelURL.s = GetGadgetText(#SelectedURL)
If SelURL.s <> ""
DisableGadget(#ConnectURL,0)
DisableGadget(#AddURL,0)
;ConnectURL.Default=True
Else
DisableGadget(#ConnectURL,1)
DisableGadget(#AddURL,1)
;ConnectURL.Default=False
EndIf
ElseIf GadgetID = #ListURL
Result = GetGadgetState(#ListURL)
If Result <> -1
LstURL.s = GetGadgetText(#ListURL)
SetGadgetText(#SelectedURL,LstURL.s)
DisableGadget(#ConnectURL,0)
DisableGadget(#DeleteURL,0)
Else
DisableGadget(#DeleteURL,1)
EndIf
ElseIf GadgetID = #AddURL
SelURL.s = GetGadgetText(#SelectedURL)
LstURL.s = GetGadgetText(#ListURL)
If SelURL.s <> LstURL.s
AddGadgetItem(#ListURL,-1,SelURL.s)
Else
MBResult = MessageRequester("Oops!","Please Enter a different URL Or email address.",#PB_MessageRequester_Ok)
EndIf
ElseIf GadgetID = #ConnectURL
SelURL.s = GetGadgetText(#SelectedURL)
If SelURL.s <> ""
ShellExecute_(#NULL,"open",SelURL,"","",#SW_SHOWNORMAL)
Else
MBResult = MessageRequester("Oops!","Please Enter a URL or email address.",#PB_MessageRequester_Ok)
EndIf
ElseIf GadgetID = #DeleteURL
Result = GetGadgetState(#ListURL)
If Result <> -1
RemoveGadgetItem(#ListURL,Result)
Else
MBResult = MessageRequester("Oops!","Please select an item in the list.",#PB_MessageRequester_Ok)
EndIf
EndIf
EndIf
Until Event = #PB_EventCloseWindow
End
;

