MCPcopy
hub / github.com/lxn/walk / initWindowWithCfg

Function initWindowWithCfg

window.go:547–709  ·  view source on GitHub ↗
(cfg *windowCfg)

Source from the content-addressed store, hash-verified

545}
546
547func initWindowWithCfg(cfg *windowCfg) error {
548 // We can't use sync.Once, because tooltip.go's init also calls InitWindow, so we deadlock.
549 if atomic.CompareAndSwapUint32(&initedWalk, 0, 1) {
550 runtime.LockOSThread()
551
552 var initCtrls win.INITCOMMONCONTROLSEX
553 initCtrls.DwSize = uint32(unsafe.Sizeof(initCtrls))
554 initCtrls.DwICC = win.ICC_LINK_CLASS | win.ICC_LISTVIEW_CLASSES | win.ICC_PROGRESS_CLASS | win.ICC_TAB_CLASSES | win.ICC_TREEVIEW_CLASSES
555 win.InitCommonControlsEx(&initCtrls)
556
557 defaultWndProcPtr = syscall.NewCallback(defaultWndProc)
558 for _, fn := range walkInit {
559 fn()
560 }
561 }
562
563 wb := cfg.Window.AsWindowBase()
564 wb.window = cfg.Window
565 wb.enabled = true
566 wb.visible = cfg.Style&win.WS_VISIBLE != 0
567 wb.calcTextSizeInfo2TextSize = make(map[calcTextSizeInfo]Size)
568 wb.name2Property = make(map[string]Property)
569
570 var hwndParent win.HWND
571 var hMenu win.HMENU
572 if cfg.Parent != nil {
573 hwndParent = cfg.Parent.Handle()
574
575 if widget, ok := cfg.Window.(Widget); ok {
576 if container, ok := cfg.Parent.(Container); ok {
577 if cb := container.AsContainerBase(); cb != nil {
578 hMenu = win.HMENU(cb.NextChildID())
579 }
580 widget.AsWidgetBase().parent = container
581 }
582 }
583 }
584
585 var windowName *uint16
586 if len(wb.name) != 0 {
587 windowName = syscall.StringToUTF16Ptr(wb.name)
588 }
589
590 if hwnd := cfg.Window.Handle(); hwnd == 0 {
591 var x, y, w, h int32
592 if cfg.Bounds.IsZero() {
593 x = win.CW_USEDEFAULT
594 y = win.CW_USEDEFAULT
595 w = win.CW_USEDEFAULT
596 h = win.CW_USEDEFAULT
597 } else {
598 x = int32(cfg.Bounds.X)
599 y = int32(cfg.Bounds.Y)
600 w = int32(cfg.Bounds.Width)
601 h = int32(cfg.Bounds.Height)
602 }
603
604 wb.hWnd = win.CreateWindowEx(

Callers 2

InitWindowFunction · 0.85
NewMainWindowWithCfgFunction · 0.85

Calls 15

lastErrorFunction · 0.85
SetWindowFontFunction · 0.85
NewBoolPropertyFunction · 0.85
NewReadOnlyBoolPropertyFunction · 0.85
NextChildIDMethod · 0.80
CreateGroupMethod · 0.80
MustRegisterPropertyMethod · 0.80
AsWindowBaseMethod · 0.65
HandleMethod · 0.65
AsContainerBaseMethod · 0.65
AsWidgetBaseMethod · 0.65
DisposeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…