MCPcopy Create free account
hub / github.com/lxn/walk / MustRegisterWindowClassWithWndProcPtrAndStyle

Function MustRegisterWindowClassWithWndProcPtrAndStyle

window.go:478–516  ·  view source on GitHub ↗
(className string, wndProcPtr uintptr, style uint32)

Source from the content-addressed store, hash-verified

476}
477
478func MustRegisterWindowClassWithWndProcPtrAndStyle(className string, wndProcPtr uintptr, style uint32) {
479 if registeredWindowClasses[className] {
480 panic("window class already registered")
481 }
482
483 hInst := win.GetModuleHandle(nil)
484 if hInst == 0 {
485 panic("GetModuleHandle")
486 }
487
488 hIcon := win.LoadIcon(hInst, win.MAKEINTRESOURCE(7)) // rsrc uses 7 for app icon
489 if hIcon == 0 {
490 hIcon = win.LoadIcon(0, win.MAKEINTRESOURCE(win.IDI_APPLICATION))
491 }
492 if hIcon == 0 {
493 panic("LoadIcon")
494 }
495
496 hCursor := win.LoadCursor(0, win.MAKEINTRESOURCE(win.IDC_ARROW))
497 if hCursor == 0 {
498 panic("LoadCursor")
499 }
500
501 var wc win.WNDCLASSEX
502 wc.CbSize = uint32(unsafe.Sizeof(wc))
503 wc.LpfnWndProc = wndProcPtr
504 wc.HInstance = hInst
505 wc.HIcon = hIcon
506 wc.HCursor = hCursor
507 wc.HbrBackground = win.COLOR_BTNFACE + 1
508 wc.LpszClassName = syscall.StringToUTF16Ptr(className)
509 wc.Style = style
510
511 if atom := win.RegisterClassEx(&wc); atom == 0 {
512 panic("RegisterClassEx")
513 }
514
515 registeredWindowClasses[className] = true
516}
517
518var initedWalk uint32
519var walkInit []func()

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…