示例#1
1
func newHtmLayout(parent walk.Container) (*HtmLayout, error) {
	de := new(HtmLayout)

	if err := walk.InitWidget(
		de,
		parent,
		// htmlayoutClassName,
		gohl.GetClassName(),
		win.WS_CHILDWINDOW|win.WS_OVERLAPPEDWINDOW|win.WS_CLIPSIBLINGS,
		0); err != nil {
		return nil, err
	}
	hwnd2Widget[de.Handle()] = de
	// println("post", win.PostMessage(de.Handle(), win.WM_CREATE, 0, 0))
	// go func() {
	// 	win.ShowWindow(de.Handle(), win.SW_SHOW)
	// 	win.UpdateWindow(de.Handle())
	// 	var msg win.MSG

	// for win.GetMessage(&msg, 0, 0, 0) > 0 {
	// 	win.TranslateMessage(&msg)
	// 	win.DispatchMessage(&msg)
	// }
	// }()

	de.MustRegisterProperty("PageUrl", walk.NewProperty(
		func() interface{} {
			return de.pageUrl
		},
		func(v interface{}) error {
			de.pageUrl = v.(string)
			return nil
		},
		de.pageUrlChangedPublisher.Event()))

	de.MustRegisterProperty("PageContent", walk.NewProperty(
		func() interface{} {
			return de.pageContent
		},
		func(v interface{}) error {
			de.pageContent = v.(string)
			return nil
		},
		de.pageContentChangedPublisher.Event()))

	return de, nil
}
func NewMultilineLabel(parent walk.Container) (*multilineLabel, error) {
	l := new(multilineLabel)

	if err := walk.InitWidget(
		l,
		parent,
		"STATIC",
		win.WS_VISIBLE|win.SS_CENTER,
		0); err != nil {
		return nil, err
	}

	l.MustRegisterProperty("Text", walk.NewProperty(
		func() interface{} {
			return l.Text()
		},
		func(v interface{}) error {
			return l.SetText(v.(string))
		},
		l.textChangedPublisher.Event()))

	return l, nil
}