(parent walk.Container)
| 450 | } |
| 451 | |
| 452 | func NewSyntaxEdit(parent walk.Container) (*SyntaxEdit, error) { |
| 453 | const LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800 |
| 454 | _, err := windows.LoadLibraryEx("msftedit.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32) |
| 455 | if err != nil { |
| 456 | return nil, fmt.Errorf("Failed to load msftedit.dll: %w", err) |
| 457 | } |
| 458 | |
| 459 | se := &SyntaxEdit{} |
| 460 | if err := walk.InitWidget( |
| 461 | se, |
| 462 | parent, |
| 463 | win.MSFTEDIT_CLASS, |
| 464 | win.WS_CHILD|win.ES_MULTILINE|win.WS_VISIBLE|win.WS_VSCROLL|win.WS_BORDER|win.WS_HSCROLL|win.WS_TABSTOP|win.ES_WANTRETURN|win.ES_NOOLEDRAGDROP, |
| 465 | 0); err != nil { |
| 466 | return nil, err |
| 467 | } |
| 468 | hWnd := se.Handle() |
| 469 | win.SetWindowLong(hWnd, win.GWL_EXSTYLE, win.GetWindowLong(hWnd, win.GWL_EXSTYLE)&^win.WS_EX_CLIENTEDGE) |
| 470 | win.SendMessage(hWnd, win.EM_GETOLEINTERFACE, 0, uintptr(unsafe.Pointer(&se.irich))) |
| 471 | var idoc unsafe.Pointer |
| 472 | se.irich.QueryInterface(&win.IID_ITextDocument, &idoc) |
| 473 | se.idoc = (*win.ITextDocument)(idoc) |
| 474 | win.SendMessage(hWnd, win.EM_SETEVENTMASK, 0, win.ENM_CHANGE) |
| 475 | win.SendMessage(hWnd, win.EM_SETTEXTMODE, win.TM_SINGLECODEPAGE, 0) |
| 476 | se.ApplyDPI(parent.DPI()) |
| 477 | se.GraphicsEffects().Add(walk.InteractionEffect) |
| 478 | se.GraphicsEffects().Add(walk.FocusEffect) |
| 479 | se.MustRegisterProperty("Text", walk.NewProperty( |
| 480 | func() any { |
| 481 | return se.Text() |
| 482 | }, |
| 483 | func(v any) error { |
| 484 | if s, ok := v.(string); ok { |
| 485 | return se.SetText(s) |
| 486 | } |
| 487 | return se.SetText("") |
| 488 | }, |
| 489 | se.textChangedPublisher.Event())) |
| 490 | return se, nil |
| 491 | } |
| 492 | |
| 493 | func (se *SyntaxEdit) ApplyDPI(dpi int) { |
| 494 | hWnd := se.Handle() |
no test coverage detected