-
Notifications
You must be signed in to change notification settings - Fork 958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set default window position #642
Labels
type: feature request
Issue is a feature request
Comments
Upvote, please consider implementing this feature. https://stackoverflow.com/questions/17908584/how-to-set-the-gtk-window-to-the-center-of-screen/35144125#35144125 might be helpful. |
@zserge, with the following code, and in Ubuntu 20.04.3 LTS, libwebkit2gtk-4.0-37 version package main
import (
"fmt"
"github.com/webview/webview"
)
func main() {
w := webview.New(true)
defer w.Destroy()
w.SetTitle("Choices")
w.SetSize(300, 60, webview.HintNone)
var count uint
if err := w.Bind("btnClicked", func() {
fmt.Printf("Button click count: %v\n", count)
count++
}); err != nil {
panic(err)
}
w.Navigate(`data:text/html,
<!doctype html>
<html>
<body>
<button onclick="btnClicked()">AA</button>
<button onclick="btnClicked()">BB</button>
<button onclick="btnClicked()">CC</button>
</body>
</html>`)
w.Run()
} |
justjosias
added
the
type: improvement
Pull request is an improvement of an existing feature
label
Feb 9, 2022
Here is an example on how to center the window under Windows and C++: // Create the webview
webview::webview w(false, nullptr);
w.set_title("Test");
w.set_size(980, 650, WEBVIEW_HINT_NONE);
w.set_size(585, 550, WEBVIEW_HINT_MIN);
// Center
HWND hwndApp = static_cast<HWND>(w.window());
HWND hwndScreen = GetDesktopWindow();
RECT rectScreen;
GetWindowRect(hwndScreen, &rectScreen);
int ConsolePosX = ((rectScreen.right - rectScreen.left) / 2 - 1000 /2 );
int ConsolePosY = ((rectScreen.bottom - rectScreen.top)/ 2 - 500 /2 );
SetWindowPos(hwndApp, NULL, ConsolePosX, ConsolePosY,0,0, SWP_SHOWWINDOW || SWP_NOSIZE); |
SteffenL
added
type: feature request
Issue is a feature request
and removed
type: improvement
Pull request is an improvement of an existing feature
labels
Sep 24, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be great to be able to specify the window's coordinates when it first is created.
The text was updated successfully, but these errors were encountered: