Created
August 21, 2023 22:20
-
-
Save ttytm/b84832619c320772605fda0fac5b62c8 to your computer and use it in GitHub Desktop.
WebUI C example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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