本文整理汇总了Golang中github.com/lxn/win.CreateWindowEx函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateWindowEx函数的具体用法?Golang CreateWindowEx怎么用?Golang CreateWindowEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateWindowEx函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
MustRegisterWindowClass(clipboardWindowClass)
hwnd := win.CreateWindowEx(
0,
syscall.StringToUTF16Ptr(clipboardWindowClass),
nil,
0,
0,
0,
0,
0,
win.HWND_MESSAGE,
0,
0,
nil)
if hwnd == 0 {
panic("failed to create clipboard window")
}
if !win.AddClipboardFormatListener(hwnd) {
panic(lastError("AddClipboardFormatListener"))
}
clipboard.hwnd = hwnd
}
开发者ID:JSchwehn,项目名称:walk,代码行数:27,代码来源:clipboard.go
示例2: NewNotifyIcon
// NewNotifyIcon creates and returns a new NotifyIcon.
//
// The NotifyIcon is initially not visible.
func NewNotifyIcon() (*NotifyIcon, error) {
// Create the message-only window for the NotifyIcon.
hWnd := win.CreateWindowEx(
0,
syscall.StringToUTF16Ptr(notifyIconWindowClass),
nil,
0,
0,
0,
0,
0,
win.HWND_MESSAGE,
0,
0,
nil)
if hWnd == 0 {
return nil, lastError("CreateWindowEx")
}
// Add our notify icon to the status area and make sure it is hidden.
nid := win.NOTIFYICONDATA{
HWnd: hWnd,
UFlags: win.NIF_MESSAGE | win.NIF_STATE,
DwState: win.NIS_HIDDEN,
DwStateMask: win.NIS_HIDDEN,
UCallbackMessage: notifyIconMessageId,
}
nid.CbSize = uint32(unsafe.Sizeof(nid))
if !win.Shell_NotifyIcon(win.NIM_ADD, &nid) {
return nil, newError("Shell_NotifyIcon")
}
// We want XP-compatible message behavior.
nid.UVersion = win.NOTIFYICON_VERSION
if !win.Shell_NotifyIcon(win.NIM_SETVERSION, &nid) {
return nil, newError("Shell_NotifyIcon")
}
// Create and initialize the NotifyIcon already.
menu, err := NewMenu()
if err != nil {
return nil, err
}
ni := &NotifyIcon{
id: nid.UID,
hWnd: hWnd,
contextMenu: menu,
}
// Set our *NotifyIcon as user data for the message window.
win.SetWindowLongPtr(hWnd, win.GWLP_USERDATA, uintptr(unsafe.Pointer(ni)))
return ni, nil
}
开发者ID:Ryanker,项目名称:walk,代码行数:60,代码来源:notifyicon.go
示例3: NewGroupBox
func NewGroupBox(parent Container) (*GroupBox, error) {
gb := new(GroupBox)
if err := InitWidget(
gb,
parent,
groupBoxWindowClass,
win.WS_VISIBLE,
win.WS_EX_CONTROLPARENT); err != nil {
return nil, err
}
succeeded := false
defer func() {
if !succeeded {
gb.Dispose()
}
}()
var err error
gb.composite, err = NewComposite(gb)
if err != nil {
return nil, err
}
gb.hWndGroupBox = win.CreateWindowEx(
0, syscall.StringToUTF16Ptr("BUTTON"), nil,
win.WS_CHILD|win.WS_VISIBLE|win.BS_GROUPBOX,
0, 0, 80, 24, gb.hWnd, 0, 0, nil)
if gb.hWndGroupBox == 0 {
return nil, lastError("CreateWindowEx(BUTTON)")
}
// Set font to nil first to outsmart SetFont.
// gb.font = nil
// gb.SetFont(defaultFont)
gb.MustRegisterProperty("Title", NewProperty(
func() interface{} {
return gb.Title()
},
func(v interface{}) error {
return gb.SetTitle(v.(string))
},
gb.titleChangedPublisher.Event()))
succeeded = true
return gb, nil
}
开发者ID:oltolm,项目名称:walk,代码行数:50,代码来源:groupbox.go
示例4: WinMain
func WinMain(Inst win.HINSTANCE) int32 {
// 1. 注册窗口类
atom := MyRegisterClass(Inst)
if atom == 0 {
fmt.Println("注册窗口类失败:", win.GetLastError())
return 0
}
fmt.Println("注册窗口类成功", atom)
// 2. 创建窗口
wnd := win.CreateWindowEx(win.WS_EX_APPWINDOW,
syscall.StringToUTF16Ptr("主窗口类"),
nil,
win.WS_OVERLAPPEDWINDOW|win.WS_CLIPSIBLINGS,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
0,
0,
Inst,
nil)
if wnd == 0 {
fmt.Println("创建窗口失败", win.GetLastError())
return 0
}
fmt.Println("创建窗口成功", wnd)
win.ShowWindow(wnd, win.SW_SHOW)
win.UpdateWindow(wnd)
// load file
gohl.EnableDebug()
if err := gohl.LoadFile(wnd, "a.html"); err != nil {
println("LoadFile failed", err.Error())
return 0
}
ui(wnd)
// 3. 主消息循环
var msg win.MSG
msg.Message = win.WM_QUIT + 1 // 让它不等于 win.WM_QUIT
for win.GetMessage(&msg, 0, 0, 0) > 0 {
win.TranslateMessage(&msg)
win.DispatchMessage(&msg)
}
return int32(msg.WParam)
}
开发者ID:Archs,项目名称:go-htmlayout,代码行数:48,代码来源:main.go
示例5: WinMain
func WinMain(Inst win.HINSTANCE) int32 {
// RegisterClass
atom := MyRegisterClass(Inst)
if atom == 0 {
fmt.Println("RegisterClass failed:", win.GetLastError())
return 0
}
fmt.Println("RegisterClass ok", atom)
// CreateWindowEx
wnd := win.CreateWindowEx(win.WS_EX_APPWINDOW,
syscall.StringToUTF16Ptr(wndClassName),
nil,
win.WS_OVERLAPPEDWINDOW|win.WS_CLIPSIBLINGS,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
0,
0,
Inst,
nil)
if wnd == 0 {
fmt.Println("CreateWindowEx failed:", win.GetLastError())
return 0
}
fmt.Println("CreateWindowEx done", wnd)
win.ShowWindow(wnd, win.SW_SHOW)
win.UpdateWindow(wnd)
// load file
gohl.EnableDebug()
if err := gohl.LoadFile(wnd, "a.html"); err != nil {
println("LoadFile failed", err.Error())
return 0
}
// main message loop
var msg win.MSG
for win.GetMessage(&msg, 0, 0, 0) > 0 {
win.TranslateMessage(&msg)
win.DispatchMessage(&msg)
}
return int32(msg.WParam)
}
开发者ID:Archs,项目名称:go-htmlayout,代码行数:46,代码来源:main4.go
示例6: NewTabWidget
func NewTabWidget(parent Container) (*TabWidget, error) {
tw := &TabWidget{currentIndex: -1}
tw.pages = newTabPageList(tw)
if err := InitWidget(
tw,
parent,
tabWidgetWindowClass,
win.WS_VISIBLE,
win.WS_EX_CONTROLPARENT); err != nil {
return nil, err
}
succeeded := false
defer func() {
if !succeeded {
tw.Dispose()
}
}()
tw.SetPersistent(true)
tw.hWndTab = win.CreateWindowEx(
0, syscall.StringToUTF16Ptr("SysTabControl32"), nil,
win.WS_CHILD|win.WS_CLIPSIBLINGS|win.WS_TABSTOP|win.WS_VISIBLE,
0, 0, 0, 0, tw.hWnd, 0, 0, nil)
if tw.hWndTab == 0 {
return nil, lastError("CreateWindowEx")
}
win.SendMessage(tw.hWndTab, win.WM_SETFONT, uintptr(defaultFont.handleForDPI(0)), 1)
setWindowFont(tw.hWndTab, tw.Font())
tw.MustRegisterProperty("HasCurrentPage", NewReadOnlyBoolProperty(
func() bool {
return tw.CurrentIndex() != -1
},
tw.CurrentIndexChanged()))
succeeded = true
return tw, nil
}
开发者ID:Ryanker,项目名称:walk,代码行数:43,代码来源:tabwidget.go
示例7: init
func init() {
MustRegisterWindowClass(clipboardWindowClass)
hwnd := win.CreateWindowEx(
0,
syscall.StringToUTF16Ptr(clipboardWindowClass),
nil,
0,
0,
0,
0,
0,
win.HWND_MESSAGE,
0,
0,
nil)
if hwnd == 0 {
panic("failed to create clipboard window")
}
clipboard.hwnd = hwnd
}
开发者ID:2105666566,项目名称:walk,代码行数:23,代码来源:clipboard.go
示例8: NewGroupBox
func NewGroupBox(parent Container) (*GroupBox, error) {
gb := new(GroupBox)
if err := InitWidget(
gb,
parent,
groupBoxWindowClass,
win.WS_VISIBLE,
win.WS_EX_CONTROLPARENT); err != nil {
return nil, err
}
succeeded := false
defer func() {
if !succeeded {
gb.Dispose()
}
}()
gb.hWndGroupBox = win.CreateWindowEx(
0, syscall.StringToUTF16Ptr("BUTTON"), nil,
win.WS_CHILD|win.WS_VISIBLE|win.BS_GROUPBOX,
0, 0, 80, 24, gb.hWnd, 0, 0, nil)
if gb.hWndGroupBox == 0 {
return nil, lastError("CreateWindowEx(BUTTON)")
}
setWindowFont(gb.hWndGroupBox, gb.Font())
var err error
gb.checkBox, err = NewCheckBox(gb)
if err != nil {
return nil, err
}
gb.checkBox.SetChecked(true)
gb.checkBox.CheckedChanged().Attach(func() {
gb.applyEnabledFromCheckBox(gb.checkBox.Checked())
})
setWindowVisible(gb.checkBox.hWnd, false)
gb.composite, err = NewComposite(gb)
if err != nil {
return nil, err
}
win.SetWindowPos(gb.checkBox.hWnd, win.HWND_TOP, 0, 0, 0, 0, win.SWP_NOMOVE|win.SWP_NOSIZE)
gb.MustRegisterProperty("Title", NewProperty(
func() interface{} {
return gb.Title()
},
func(v interface{}) error {
return gb.SetTitle(v.(string))
},
gb.titleChangedPublisher.Event()))
gb.MustRegisterProperty("Checked", NewBoolProperty(
func() bool {
return gb.Checked()
},
func(v bool) error {
gb.SetChecked(v)
return nil
},
gb.CheckedChanged()))
succeeded = true
return gb, nil
}
开发者ID:scarecroweib,项目名称:golang_study_zone,代码行数:74,代码来源:groupbox.go
示例9: InitWindow
// InitWindow initializes a window.
//
// Widgets should be initialized using InitWidget instead.
func InitWindow(window, parent Window, className string, style, exStyle uint32) error {
wb := window.AsWindowBase()
wb.window = window
wb.enabled = true
wb.visible = true
wb.name2Property = make(map[string]Property)
var hwndParent win.HWND
if parent != nil {
hwndParent = parent.Handle()
if widget, ok := window.(Widget); ok {
if container, ok := parent.(Container); ok {
widget.AsWidgetBase().parent = container
}
}
}
wb.hWnd = win.CreateWindowEx(
exStyle,
syscall.StringToUTF16Ptr(className),
nil,
style|win.WS_CLIPSIBLINGS,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
hwndParent,
0,
0,
nil)
if wb.hWnd == 0 {
return lastError("CreateWindowEx")
}
succeeded := false
defer func() {
if !succeeded {
wb.Dispose()
}
}()
hwnd2WindowBase[wb.hWnd] = wb
if !registeredWindowClasses[className] {
// We subclass all windows of system classes.
wb.origWndProcPtr = win.SetWindowLongPtr(wb.hWnd, win.GWLP_WNDPROC, defaultWndProcPtr)
if wb.origWndProcPtr == 0 {
return lastError("SetWindowLongPtr")
}
}
setWindowFont(wb.hWnd, defaultFont)
if form, ok := window.(Form); ok {
if fb := form.AsFormBase(); fb != nil {
if err := fb.init(form); err != nil {
return err
}
}
}
if widget, ok := window.(Widget); ok {
if wb := widget.AsWidgetBase(); wb != nil {
if err := wb.init(widget); err != nil {
return err
}
}
}
wb.enabledProperty = NewBoolProperty(
func() bool {
return wb.window.Enabled()
},
func(b bool) error {
wb.window.SetEnabled(b)
return nil
},
wb.enabledChangedPublisher.Event())
wb.visibleProperty = NewBoolProperty(
func() bool {
return window.Visible()
},
func(b bool) error {
wb.window.SetVisible(b)
return nil
},
wb.visibleChangedPublisher.Event())
wb.MustRegisterProperty("Enabled", wb.enabledProperty)
wb.MustRegisterProperty("Visible", wb.visibleProperty)
succeeded = true
return nil
//.........这里部分代码省略.........
开发者ID:henrylee2cn,项目名称:walk,代码行数:101,代码来源:window.go
注:本文中的github.com/lxn/win.CreateWindowEx函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论