Skip to content

Commit

Permalink
examples/window: replace deprecated functions (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi authored Aug 22, 2024
1 parent a969731 commit ebc2d33
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions examples/window/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ func init() {
}

func main() {
className := windows.StringToUTF16Ptr("Sample Window Class")
className, err := windows.UTF16PtrFromString("Sample Window Class")
if err != nil {
panic(err)
}
inst := GetModuleHandle(className)

wc := WNDCLASSEX{
Expand All @@ -114,10 +117,14 @@ func main() {
Right: 320,
Bottom: 240,
}
title, err := windows.UTF16PtrFromString("My Title")
if err != nil {
panic(err)
}
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, false)
hwnd := CreateWindowEx(
0, className,
windows.StringToUTF16Ptr("My Title"),
title,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, int(wr.Right-wr.Left), int(wr.Bottom-wr.Top),
0, 0, inst, nil,
Expand Down

0 comments on commit ebc2d33

Please sign in to comment.