We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-09-25 09:26 AM - last edited on 2024-09-16 02:56 PM by Doreena Deng
Hehey evryone
i hope my question is not to obvious, but im having trouble to start the webbrowser with a given url from a add-on.
how do i do that?
i know so far:
we can save url documentation data in a element with the calls
APIDb_SetElementURLRefID
APIDb_GetElementURLRefID
and the notification example show how to add and retrieve this url data
but it does not show how to open that given url...
we can edit the Add-Ons help URL with the DGRegisterAdditionalHelpLocation, but it also does not show how to open that url... or am i missing something?
Solved! Go to Solution.
2023-09-25 01:57 PM
Not sure if I understand the question correctly, but you can open any url with the default web browser by using the OSUtils::OpenWithDefaultBrowser call from the DefaultProgramRunner.hpp header.
2023-09-25 01:57 PM
Not sure if I understand the question correctly, but you can open any url with the default web browser by using the OSUtils::OpenWithDefaultBrowser call from the DefaultProgramRunner.hpp header.
2023-09-25 02:23 PM - edited 2023-09-25 02:31 PM
works like a charm! thank you very much!
i recommend to add this to one of the examples.
2023-09-26 10:15 AM
I did something similar few months ago. In general, you can execute any app from within your plugin using ShellExecute() in Windows and std::system() for Mac, something like this
#if defined (WINDOWS)
LPCWSTR command = L"https://graphisoft.com";
ShellExecute(NULL, L"open", command, NULL, NULL, SW_SHOWNORMAL);
#elif defined (macintosh)
GS::UniString command = "open https://graphisoft.com";
std::system(command.ToCStr().Get());
#endif
2023-10-05 09:16 AM
And you can also show a webpage inside your dialog by adding a DG::Browser dialog item and loading the URL by calling the LoadURL (const GS::UniString& url) member function.
2023-10-05 10:59 AM
thanks 😄
im a big fan of the DG::Browser Dialog and i made the whole gui as a browser dialog since i like html a lot better then the DG Framework 😄
i thought to open a new dialog to show help documents would be unusual behavior since archicad also opens a webbroser for help resources.
2023-11-02 06:06 PM
Hi Joel, in your pluggin do you open a local HTML file or an outside webpage on the browser?
2023-11-05 09:04 AM
im hosting the html on a subdomain.
with the html.LoadHTML(htmlstring) method you can load local html, waht is very cool. but i was never able to have a html file and feed this to the ressources compiler tool. =(
i developed the following hacks:
1. you can have your html in the "AddOnFix.grc". like this:
this html can you then call with somethink like this:
2. you can have your html directly in your code and consume it with the LoadHTML function. something like this:
2023-11-07 06:31 PM
You can add a html file as a resource by adding it as a DATA resource. For example:
'DATA' 2024 "HTML Resource" {
"BrowserContent.html"
}
The resource can be loaded like this (I did not compile it):
GS::UniString htmlStr;
GSHandle resHandle = RSLoadResource ('DATA', resModule, 2024);
if (resHandle != nullptr) {
USize hdlSize = BMGetHandleSize (resHandle);
const char* p = (const char*) *resHandle;
htmlStr = GS::UniString (p, hdlSize);
BMKillHandle (&resHandle);
}
The loaded resource data does not contain a terminating zero, so a length is needed to the UniString constructor.
The string can then be loaded to a browser control.
2023-11-07 08:00 PM
Also, you can check the Browser_Control example Add-On in the Development Kit. It's a full example of using a browser control, and storing a html file as a resource.