Skip to content

Instantly share code, notes, and snippets.

@ttytm
Created August 21, 2023 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttytm/b84832619c320772605fda0fac5b62c8 to your computer and use it in GitHub Desktop.
Save ttytm/b84832619c320772605fda0fac5b62c8 to your computer and use it in GitHub Desktop.
WebUI C example
#include "webui.h"
void my_c_fn(webui_event_t* e) {
printf("Hello from C!\n");
}
int main() {
const char* my_html = "<!DOCTYPE html>"
"<html>"
" <head>"
" <style>"
" body {"
" background-color: SlateGray;"
" color: GhostWhite;"
" text-align: center;"
" margin: 30px auto;"
" }"
" </style>"
" </head>"
" <body>"
" <h1>Thanks for using WebUI!</h1>"
" <button onclick=\"webui.call('my_c_fn', null)\">Call C!</button>"
" </body>"
"</html>";
size_t my_window = webui_new_window();
webui_show(my_window, my_html);
webui_bind(my_window, "my_c_fn", my_c_fn);
webui_wait();
return 0;
}
#if defined(_MSC_VER)
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) {
return main();
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment