mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-11 14:39:30 +08:00
[windows] Support Startup hook
This commit is contained in:
parent
df32393215
commit
4acb3f83bf
@ -69,6 +69,9 @@ struct Application *NewApplication(const char *title, int width, int height, int
|
|||||||
// Capture Main Thread
|
// Capture Main Thread
|
||||||
mainThread = GetCurrentThreadId();
|
mainThread = GetCurrentThreadId();
|
||||||
|
|
||||||
|
// Startup url
|
||||||
|
result->startupURL = nullptr;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +91,12 @@ void SetBindings(struct Application *app, const char *bindings) {
|
|||||||
memcpy(app->bindings, temp.c_str(), temp.length()+1);
|
memcpy(app->bindings, temp.c_str(), temp.length()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void performShutdown(struct Application *app) {
|
||||||
|
if( app->startupURL != nullptr ) {
|
||||||
|
delete[] app->startupURL;
|
||||||
|
}
|
||||||
|
messageFromWindowCallback("WC");
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
|
|
||||||
@ -207,6 +216,13 @@ void loadAssets(struct Application* app) {
|
|||||||
void completed(struct Application* app) {
|
void completed(struct Application* app) {
|
||||||
delete[] app->initialCode;
|
delete[] app->initialCode;
|
||||||
app->initialCode = nullptr;
|
app->initialCode = nullptr;
|
||||||
|
|
||||||
|
if( app->startupURL == nullptr ) {
|
||||||
|
messageFromWindowCallback("SS");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string readyMessage = std::string("SS") + std::string(app->startupURL);
|
||||||
|
messageFromWindowCallback(readyMessage.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -341,7 +357,7 @@ void Run(struct Application* app, int argc, char **argv) {
|
|||||||
(*f)();
|
(*f)();
|
||||||
delete(f);
|
delete(f);
|
||||||
} else if (msg.message == WM_QUIT) {
|
} else if (msg.message == WM_QUIT) {
|
||||||
messageFromWindowCallback("Q");
|
performShutdown(app);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ struct Application{
|
|||||||
LONG maxWidth;
|
LONG maxWidth;
|
||||||
LONG maxHeight;
|
LONG maxHeight;
|
||||||
int frame;
|
int frame;
|
||||||
|
char *startupURL;
|
||||||
|
|
||||||
// placeholders
|
// placeholders
|
||||||
char* bindings;
|
char* bindings;
|
||||||
|
Loading…
Reference in New Issue
Block a user