github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/src/wingui/winapi.go (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build windows 6 7 package wingui 8 9 import ( 10 "syscall" 11 "unsafe" 12 ) 13 14 type Wndclassex struct { 15 Size uint32 16 Style uint32 17 WndProc uintptr 18 ClsExtra int32 19 WndExtra int32 20 Instance syscall.Handle 21 Icon syscall.Handle 22 Cursor syscall.Handle 23 Background syscall.Handle 24 MenuName *uint16 25 ClassName *uint16 26 IconSm syscall.Handle 27 } 28 29 type Point struct { 30 X uintptr 31 Y uintptr 32 } 33 34 type Msg struct { 35 Hwnd syscall.Handle 36 Message uint32 37 Wparam uintptr 38 Lparam uintptr 39 Time uint32 40 Pt Point 41 } 42 43 const ( 44 // Window styles 45 WS_OVERLAPPED = 0 46 WS_POPUP = 0x80000000 47 WS_CHILD = 0x40000000 48 WS_MINIMIZE = 0x20000000 49 WS_VISIBLE = 0x10000000 50 WS_DISABLED = 0x8000000 51 WS_CLIPSIBLINGS = 0x4000000 52 WS_CLIPCHILDREN = 0x2000000 53 WS_MAXIMIZE = 0x1000000 54 WS_CAPTION = WS_BORDER | WS_DLGFRAME 55 WS_BORDER = 0x800000 56 WS_DLGFRAME = 0x400000 57 WS_VSCROLL = 0x200000 58 WS_HSCROLL = 0x100000 59 WS_SYSMENU = 0x80000 60 WS_THICKFRAME = 0x40000 61 WS_GROUP = 0x20000 62 WS_TABSTOP = 0x10000 63 WS_MINIMIZEBOX = 0x20000 64 WS_MAXIMIZEBOX = 0x10000 65 WS_TILED = WS_OVERLAPPED 66 WS_ICONIC = WS_MINIMIZE 67 WS_SIZEBOX = WS_THICKFRAME 68 // Common Window Styles 69 WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX 70 WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW 71 WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU 72 WS_CHILDWINDOW = WS_CHILD 73 74 WS_EX_CLIENTEDGE = 0x200 75 76 // Some windows messages 77 WM_CREATE = 1 78 WM_DESTROY = 2 79 WM_SIZE = 5 80 WM_CLOSE = 16 81 WM_COMMAND = 273 82 83 // Some button control styles 84 BS_DEFPUSHBUTTON = 1 85 86 // Some color constants 87 COLOR_WINDOW = 5 88 COLOR_BTNFACE = 15 89 90 // Default window position 91 CW_USEDEFAULT = 0x80000000 - 0x100000000 92 93 // Show window default style 94 SW_SHOWDEFAULT = 10 95 ) 96 97 var ( 98 // Some globally known cursors 99 IDC_ARROW = MakeIntResource(32512) 100 IDC_IBEAM = MakeIntResource(32513) 101 IDC_WAIT = MakeIntResource(32514) 102 IDC_CROSS = MakeIntResource(32515) 103 104 // Some globally known icons 105 IDI_APPLICATION = MakeIntResource(32512) 106 IDI_HAND = MakeIntResource(32513) 107 IDI_QUESTION = MakeIntResource(32514) 108 IDI_EXCLAMATION = MakeIntResource(32515) 109 IDI_ASTERISK = MakeIntResource(32516) 110 IDI_WINLOGO = MakeIntResource(32517) 111 IDI_WARNING = IDI_EXCLAMATION 112 IDI_ERROR = IDI_HAND 113 IDI_INFORMATION = IDI_ASTERISK 114 ) 115 116 //sys GetModuleHandle(modname *uint16) (handle syscall.Handle, err error) = GetModuleHandleW 117 //sys RegisterClassEx(wndclass *Wndclassex) (atom uint16, err error) = user32.RegisterClassExW 118 //sys CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent syscall.Handle, menu syscall.Handle, instance syscall.Handle, param uintptr) (hwnd syscall.Handle, err error) = user32.CreateWindowExW 119 //sys DefWindowProc(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) = user32.DefWindowProcW 120 //sys DestroyWindow(hwnd syscall.Handle) (err error) = user32.DestroyWindow 121 //sys PostQuitMessage(exitcode int32) = user32.PostQuitMessage 122 //sys ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) = user32.ShowWindow 123 //sys UpdateWindow(hwnd syscall.Handle) (err error) = user32.UpdateWindow 124 //sys GetMessage(msg *Msg, hwnd syscall.Handle, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error) [failretval==-1] = user32.GetMessageW 125 //sys TranslateMessage(msg *Msg) (done bool) = user32.TranslateMessage 126 //sys DispatchMessage(msg *Msg) (ret int32) = user32.DispatchMessageW 127 //sys LoadIcon(instance syscall.Handle, iconname *uint16) (icon syscall.Handle, err error) = user32.LoadIconW 128 //sys LoadCursor(instance syscall.Handle, cursorname *uint16) (cursor syscall.Handle, err error) = user32.LoadCursorW 129 //sys SetCursor(cursor syscall.Handle) (precursor syscall.Handle, err error) = user32.SetCursor 130 //sys SendMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) = user32.SendMessageW 131 //sys PostMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (err error) = user32.PostMessageW 132 133 func MakeIntResource(id uint16) *uint16 { 134 return (*uint16)(unsafe.Pointer(uintptr(id))) 135 }