help with internet connection ...

Just starting out? Need help? Post your questions and find answers here.
marc_256
Addict
Addict
Posts: 858
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

help with internet connection ...

Post by marc_256 »

Hi,

For my CAD program, I want to integrate some [info buttons] (see arrow on image)
when the user needs info about some tools, he needs only to push that button.
I like to connect the program with a centralized updated help file on my website.

But this is not at all my experienced zone of programming.

So, is there a simple way to connect my program to a web page ?

for example:
where Hostname = my website
ProgramPart = CAD or CAM or CNC or PLC
InfoPart = The tool name


thanks
Marc


PS: the pink color is only for testing ...


Image
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4996
Joined: Sun Apr 12, 2009 6:27 am

Re: help with internet connection ...

Post by RASHAD »

Hi

Code: Select all

Procedure open_url(url$)
 
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Linux
      RunProgram("xdg-open",url$,"")
    CompilerCase #PB_OS_Windows
      RunProgram(url$)
    CompilerCase #PB_OS_MacOS
      RunProgram("open", url$, "")
  CompilerEndSelect             
 
EndProcedure
 
 
open_url("https://www.purebasic.fr")
End
Egypt my love
infratec
Always Here
Always Here
Posts: 7665
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: help with internet connection ...

Post by infratec »

Maybe something like this:

Code: Select all

CompilerIf #PB_Compiler_IsMainFile
  EnableExplicit
CompilerEndIf



Structure HelpWindowStructure
  ParentWindow.i
  HelpGadgdet.i
EndStructure


Procedure SizeHelpWindow()
  
  Protected HelpWindow.i, *HelpWindow.HelpWindowStructure
  
  
  HelpWindow = EventWindow()
  *HelpWindow = GetWindowData(HelpWindow)
  
  If *HelpWindow
    ResizeGadget(*HelpWindow\HelpGadgdet, 0, 0, WindowWidth(HelpWindow), WindowHeight(HelpWindow))
  EndIf
  
EndProcedure


Procedure CloseHelpWindow()
  
  Protected EventWindow.i, *HelpWindow.HelpWindowStructure
  
  EventWindow = EventWindow()
  *HelpWindow = GetWindowData(EventWindow)
  CloseWindow(EventWindow)
  If *HelpWindow
    SetActiveWindow(*HelpWindow\ParentWindow)
    FreeStructure(*HelpWindow)
  EndIf
EndProcedure


Procedure ShowHelpWindow(Url$, ParentWindow.i=0)
  
  Protected.i HelpWindow, *HelpWindow.HelpWindowStructure
  
  
  If ParentWindow = 0
    ParentWindow = GetActiveWindow()
  EndIf
  HelpWindow = OpenWindow(#PB_Any, 0, 0, 800, 600, GetFilePart(ProgramFilename(), #PB_FileSystem_NoExtension) + " Help", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_WindowCentered, WindowID(ParentWindow))
  If HelpWindow
    *HelpWindow = AllocateStructure(HelpWindowStructure)
    If *HelpWindow
      *HelpWindow\ParentWindow = ParentWindow
      *HelpWindow\HelpGadgdet = WebGadget(#PB_Any, 0, 0, 800, 600, Url$)
      SetWindowData(HelpWindow, *HelpWindow)
      BindEvent(#PB_Event_SizeWindow, @SizeHelpWindow(), HelpWindow)
      BindEvent(#PB_Event_CloseWindow, @CloseHelpWindow(), HelpWindow)
    Else
      CloseWindow(HelpWindow)
      SetActiveWindow(ParentWindow)
    EndIf
  EndIf
  
EndProcedure


CompilerIf #PB_Compiler_IsMainFile
  
  Define.i Event
  
  
  OpenWindow(0, 0, 0, 900, 500, "Test", #PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
  ButtonGadget(0, 10, 10, 100, 30, "Help")
  
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget
      If EventGadget() = 0
        ShowHelpWindow("https://www.purebasic.com/documentation")
      EndIf
    EndIf
    
  Until Event = #PB_Event_CloseWindow
  
CompilerEndIf
Last edited by infratec on Sun Dec 03, 2023 10:46 am, edited 3 times in total.
infratec
Always Here
Always Here
Posts: 7665
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: help with internet connection ...

Post by infratec »

Extend the listing above to use ParentWindow.
marc_256
Addict
Addict
Posts: 858
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: help with internet connection ...

Post by marc_256 »

Hi RASHAD and infratec,

Thanks for your quick answers ...
I will use it asap in my program.

thanks,
marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
Post Reply