[
  {
    "path": ".gitignore",
    "content": "# Binaries for programs and plugins\n*.exe\n*.exe~\n*.dll\n*.so\n*.dylib\n\n# Test binary, build with `go test -c`\n*.test\n\n# Output of the go coverage tool, specifically when used with LiteIDE\n*.out\n"
  },
  {
    "path": "AUTHORS",
    "content": "# This is the official list of 'Winc' authors for copyright purposes.\n\n# Names should be added to this file as\n#   Name or Organization <email address>\n# The email address is not required for organizations.\n\n# Please keep the list sorted.\n\n# Contributors\n# ============\n\nTad Vizbaras <tad@etasoft.com>\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019 winc Authors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# winc\n\nCommon library for Go GUI apps on Windows. It is for Windows OS only. This makes library smaller than some other UI libraries for Go.\n\nDesign goals: minimalism and simplicity.\n\n## Dependencies\n\nNo other dependencies except Go standard library.\n\n## Building\n\nIf you want to package icon files and other resources into binary **rsrc** tool is recommended:\n\n\trsrc -manifest app.manifest -ico=app.ico,application_edit.ico,application_error.ico -o rsrc.syso\n\nHere app.manifest is XML file in format:\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n    <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n    <dependency>\n        <dependentAssembly>\n            <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n        </dependentAssembly>\n    </dependency>\n</assembly>\n```\n\nMost Windows applications do not display command prompt. Build your Go project with flag to indicate that it is Windows GUI binary:\n\n\tgo build -ldflags=\"-H windowsgui\"\n\n## Samples\n\nBest way to learn how to use the library is to look at the included **examples** projects.\n\n## Setup\n\n1. Make sure you have a working Go installation and build environment, see more for details on page below.\n   http://golang.org/doc/install\n\n2. go get github.com/tadvi/winc\n\n## Icons\n\nWhen rsrc is used to pack icons into binary it displays IDs of the packed icons.\n```\nrsrc -manifest app.manifest -ico=app.ico,lightning.ico,edit.ico,application_error.ico -o rsrc.syso\nManifest ID:  1\nIcon  app.ico  ID:  10\nIcon  lightning.ico  ID:  13\nIcon  edit.ico  ID:  16\nIcon  application_error.ico  ID:  19\n```\n\nUse IDs to reference packed icons.\n\n```\nconst myIcon = 13\n\nbtn.SetResIcon(myIcon) // Set icon on the button.\n```\n\nIncluded source **examples** use basic building via `release.bat` files. Note that icon IDs are order dependent. So if you change they order in -ico flag then icon IDs will be different. If you want to keep order the same, just add new icons to the end of -ico comma separated list.\n\n## Layout Manager\n\nSimpleDock is default layout manager.\n\nCurrent design of docking and split views allows building simple apps but if you need to have multiple split views in few different directions you might need to create your own layout manager.\n\nImportant point is to have **one** control inside SimpleDock set to dock as **Fill**. Controls that are not set to any docking get placed using SetPos() function. So you can have Panel set to dock at the Top and then have another dock to arrange controls inside that Panel or have controls placed using SetPos() at fixed positions.\n\n![Example layout with two toolbars and status bar](dock_topbottom.png)\n\nThis is basic layout. Instead of toolbars and status bar you can have Panel or any other control that can resize. Panel can have its own internal Dock that will arrange other controls inside of it.\n\n![Example layout with two toolbars and navigation on the left](dock_topleft.png)\n\nThis is layout with extra control(s) on the left. Left side is usually treeview or listview.\n\nThe rule is simple: you either dock controls using SimpleDock OR use SetPos() to set them at fixed positions. That's it.\n\nAt some point **winc** may get more sophisticated layout manager.\n\n## Dialog Screens\n\nDialog screens are not based on Windows resource files (.rc). They are just windows with controls placed at fixed coordinates. This works fine for dialog screens up to 10-14 controls.\n\n# Minimal Demo\n\n```\npackage main\n\nimport (\n\t\"github.com/tadvi/winc\"\n)\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tmainWindow.SetSize(400, 300)  // (width, height)\n\tmainWindow.SetText(\"Hello World Demo\")\n\n\tedt := winc.NewEdit(mainWindow)\n\tedt.SetPos(10, 20)\n\t// Most Controls have default size unless SetSize is called.\n\tedt.SetText(\"edit text\")\n\n\tbtn := winc.NewPushButton(mainWindow)\n\tbtn.SetText(\"Show or Hide\")\n\tbtn.SetPos(40, 50)\t// (x, y)\n\tbtn.SetSize(100, 40) // (width, height)\n\tbtn.OnClick().Bind(func(e *winc.Event) {\n\t\tif edt.Visible() {\n\t\t\tedt.Hide()\n\t\t} else {\n\t\t\tedt.Show()\n\t\t}\n\t})\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop() // Must call to start event loop.\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n```\n\n![Hello World](examples/hello.png)\n\nResult of running sample_minimal.\n\n## Create Your Own\n\nIt is good practice to create your own controls based on existing structures and event model.\nLibrary contains some of the controls built that way: IconButton (button.go), ErrorPanel (panel.go), MultiEdit (edit.go), etc.\nPlease look at existing controls as examples before building your own.\n\nWhen designing your own controls keep in mind that types have to be converted from Go into Win32 API and back.\nThis is usually due to string UTF8 and UTF16 conversions. But there are other types of conversions too.\n\nWhen developing your own controls you might also need to:\n\n\timport \"github.com/tadvi/winc/w32\"\n\nw32 has Win32 API low level constants and functions.\n\nLook at **sample_control** for example of custom built window.\n\n## Companion Package\n\n[Go package for Windows Systray icon, menu and notifications](https://github.com/tadvi/systray)\n\n## Credits\n\nThis library is built on\n\n[AllenDang/gform Windows GUI framework for Go](https://github.com/AllenDang/gform)\n\n**winc** takes most design decisions from **gform** and adds many more controls and code samples to it.\n\n\n"
  },
  {
    "path": "app.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"runtime\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\nvar (\n\t// resource compilation tool assigns app.ico ID of 3\n\t// rsrc -manifest app.manifest -ico app.ico -o rsrc.syso\n\tAppIconID = 3\n)\n\nfunc init() {\n\truntime.LockOSThread()\n\n\tgAppInstance = w32.GetModuleHandle(\"\")\n\tif gAppInstance == 0 {\n\t\tpanic(\"Error occurred in App.Init\")\n\t}\n\n\t// Initialize the common controls\n\tvar initCtrls w32.INITCOMMONCONTROLSEX\n\tinitCtrls.DwSize = uint32(unsafe.Sizeof(initCtrls))\n\tinitCtrls.DwICC =\n\t\tw32.ICC_LISTVIEW_CLASSES | w32.ICC_PROGRESS_CLASS | w32.ICC_TAB_CLASSES |\n\t\t\tw32.ICC_TREEVIEW_CLASSES | w32.ICC_BAR_CLASSES\n\n\tw32.InitCommonControlsEx(&initCtrls)\n}\n\n// SetAppIconID sets recource icon ID for the apps windows.\nfunc SetAppIcon(appIconID int) {\n\tAppIconID = appIconID\n}\n\nfunc GetAppInstance() w32.HINSTANCE {\n\treturn gAppInstance\n}\n\nfunc PreTranslateMessage(msg *w32.MSG) bool {\n\t// This functions is called by the MessageLoop. It processes the\n\t// keyboard accelerator keys and calls Controller.PreTranslateMessage for\n\t// keyboard and mouse events.\n\n\tprocessed := false\n\n\tif (msg.Message >= w32.WM_KEYFIRST && msg.Message <= w32.WM_KEYLAST) ||\n\t\t(msg.Message >= w32.WM_MOUSEFIRST && msg.Message <= w32.WM_MOUSELAST) {\n\n\t\tif msg.Hwnd != 0 {\n\t\t\tif controller := GetMsgHandler(msg.Hwnd); controller != nil {\n\t\t\t\t// Search the chain of parents for pretranslated messages.\n\t\t\t\tfor p := controller; p != nil; p = p.Parent() {\n\n\t\t\t\t\tif processed = p.PreTranslateMessage(msg); processed {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn processed\n}\n\n// RunMainLoop processes messages in main application loop.\nfunc RunMainLoop() int {\n\tvar m w32.MSG\n\n\tfor w32.GetMessage(&m, 0, 0, 0) != 0 {\n\n\t\tif !PreTranslateMessage(&m) {\n\t\t\tw32.TranslateMessage(&m)\n\t\t\tw32.DispatchMessage(&m)\n\t\t}\n\t}\n\n\tw32.GdiplusShutdown()\n\treturn int(m.WParam)\n}\n\n// PostMessages processes recent messages. Sometimes helpful for instant window refresh.\nfunc PostMessages() {\n\tvar m w32.MSG\n\tfor i := 0; i < 10; i++ {\n\t\tif w32.GetMessage(&m, 0, 0, 0) != 0 {\n\t\t\tif !PreTranslateMessage(&m) {\n\t\t\t\tw32.TranslateMessage(&m)\n\t\t\t\tw32.DispatchMessage(&m)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc Exit() {\n\tw32.PostQuitMessage(0)\n}\n"
  },
  {
    "path": "bitmap.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"errors\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Bitmap struct {\n\thandle        w32.HBITMAP\n\twidth, height int\n}\n\nfunc assembleBitmapFromHBITMAP(hbitmap w32.HBITMAP) (*Bitmap, error) {\n\tvar dib w32.DIBSECTION\n\tif w32.GetObject(w32.HGDIOBJ(hbitmap), unsafe.Sizeof(dib), unsafe.Pointer(&dib)) == 0 {\n\t\treturn nil, errors.New(\"GetObject for HBITMAP failed\")\n\t}\n\n\treturn &Bitmap{\n\t\thandle: hbitmap,\n\t\twidth:  int(dib.DsBmih.BiWidth),\n\t\theight: int(dib.DsBmih.BiHeight),\n\t}, nil\n}\n\nfunc NewBitmapFromFile(filepath string, background Color) (*Bitmap, error) {\n\tvar gpBitmap *uintptr\n\tvar err error\n\n\tgpBitmap, err = w32.GdipCreateBitmapFromFile(filepath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer w32.GdipDisposeImage(gpBitmap)\n\n\tvar hbitmap w32.HBITMAP\n\t// Reverse RGB to BGR to satisfy gdiplus color schema.\n\thbitmap, err = w32.GdipCreateHBITMAPFromBitmap(gpBitmap, uint32(RGB(background.B(), background.G(), background.R())))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn assembleBitmapFromHBITMAP(hbitmap)\n}\n\nfunc NewBitmapFromResource(instance w32.HINSTANCE, resName *uint16, resType *uint16, background Color) (*Bitmap, error) {\n\tvar gpBitmap *uintptr\n\tvar err error\n\tvar hRes w32.HRSRC\n\n\thRes, err = w32.FindResource(w32.HMODULE(instance), resName, resType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresSize := w32.SizeofResource(w32.HMODULE(instance), hRes)\n\tpResData := w32.LockResource(w32.LoadResource(w32.HMODULE(instance), hRes))\n\tresBuffer := w32.GlobalAlloc(w32.GMEM_MOVEABLE, resSize)\n\tpResBuffer := w32.GlobalLock(resBuffer)\n\tw32.MoveMemory(pResBuffer, pResData, resSize)\n\n\tstream := w32.CreateStreamOnHGlobal(resBuffer, false)\n\n\tgpBitmap, err = w32.GdipCreateBitmapFromStream(stream)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer stream.Release()\n\tdefer w32.GlobalUnlock(resBuffer)\n\tdefer w32.GlobalFree(resBuffer)\n\tdefer w32.GdipDisposeImage(gpBitmap)\n\n\tvar hbitmap w32.HBITMAP\n\t// Reverse gform.RGB to BGR to satisfy gdiplus color schema.\n\thbitmap, err = w32.GdipCreateHBITMAPFromBitmap(gpBitmap, uint32(RGB(background.B(), background.G(), background.R())))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn assembleBitmapFromHBITMAP(hbitmap)\n}\n\nfunc (bm *Bitmap) Dispose() {\n\tif bm.handle != 0 {\n\t\tw32.DeleteObject(w32.HGDIOBJ(bm.handle))\n\t\tbm.handle = 0\n\t}\n}\n\nfunc (bm *Bitmap) GetHBITMAP() w32.HBITMAP {\n\treturn bm.handle\n}\n\nfunc (bm *Bitmap) Size() (int, int) {\n\treturn bm.width, bm.height\n}\n\nfunc (bm *Bitmap) Height() int {\n\treturn bm.height\n}\n\nfunc (bm *Bitmap) Width() int {\n\treturn bm.width\n}\n"
  },
  {
    "path": "brush.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\nvar DefaultBackgroundBrush = NewSystemColorBrush(w32.COLOR_BTNFACE)\n\ntype Brush struct {\n\thBrush   w32.HBRUSH\n\tlogBrush w32.LOGBRUSH\n}\n\nfunc NewSolidColorBrush(color Color) *Brush {\n\tlb := w32.LOGBRUSH{LbStyle: w32.BS_SOLID, LbColor: w32.COLORREF(color)}\n\thBrush := w32.CreateBrushIndirect(&lb)\n\tif hBrush == 0 {\n\t\tpanic(\"Faild to create solid color brush\")\n\t}\n\n\treturn &Brush{hBrush, lb}\n}\n\nfunc NewSystemColorBrush(colorIndex int) *Brush {\n\t//lb := w32.LOGBRUSH{LbStyle: w32.BS_SOLID, LbColor: w32.COLORREF(colorIndex)}\n\tlb := w32.LOGBRUSH{LbStyle: w32.BS_NULL}\n\thBrush := w32.GetSysColorBrush(colorIndex)\n\tif hBrush == 0 {\n\t\tpanic(\"GetSysColorBrush failed\")\n\t}\n\treturn &Brush{hBrush, lb}\n}\n\nfunc NewHatchedColorBrush(color Color) *Brush {\n\tlb := w32.LOGBRUSH{LbStyle: w32.BS_HATCHED, LbColor: w32.COLORREF(color)}\n\thBrush := w32.CreateBrushIndirect(&lb)\n\tif hBrush == 0 {\n\t\tpanic(\"Faild to create solid color brush\")\n\t}\n\n\treturn &Brush{hBrush, lb}\n}\n\nfunc NewNullBrush() *Brush {\n\tlb := w32.LOGBRUSH{LbStyle: w32.BS_NULL}\n\thBrush := w32.CreateBrushIndirect(&lb)\n\tif hBrush == 0 {\n\t\tpanic(\"Failed to create null brush\")\n\t}\n\n\treturn &Brush{hBrush, lb}\n}\n\nfunc (br *Brush) GetHBRUSH() w32.HBRUSH {\n\treturn br.hBrush\n}\n\nfunc (br *Brush) GetLOGBRUSH() *w32.LOGBRUSH {\n\treturn &br.logBrush\n}\n\nfunc (br *Brush) Dispose() {\n\tif br.hBrush != 0 {\n\t\tw32.DeleteObject(w32.HGDIOBJ(br.hBrush))\n\t\tbr.hBrush = 0\n\t}\n}\n"
  },
  {
    "path": "buttons.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Button struct {\n\tControlBase\n\tonClick EventManager\n}\n\nfunc (bt *Button) OnClick() *EventManager {\n\treturn &bt.onClick\n}\n\nfunc (bt *Button) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_COMMAND:\n\t\tbt.onClick.Fire(NewEvent(bt, nil))\n\t\t/*case w32.WM_LBUTTONDOWN:\n\t\t\tw32.SetCapture(bt.Handle())\n\t\tcase w32.WM_LBUTTONUP:\n\t\t\tw32.ReleaseCapture()*/\n\t\t/*case win.WM_GETDLGCODE:\n\t\tprintln(\"GETDLGCODE\")*/\n\t}\n\treturn w32.DefWindowProc(bt.hwnd, msg, wparam, lparam)\n\t//return bt.W32Control.WndProc(msg, wparam, lparam)\n}\n\nfunc (bt *Button) Checked() bool {\n\tresult := w32.SendMessage(bt.hwnd, w32.BM_GETCHECK, 0, 0)\n\treturn result == w32.BST_CHECKED\n}\n\nfunc (bt *Button) SetChecked(checked bool) {\n\twparam := w32.BST_CHECKED\n\tif !checked {\n\t\twparam = w32.BST_UNCHECKED\n\t}\n\tw32.SendMessage(bt.hwnd, w32.BM_SETCHECK, uintptr(wparam), 0)\n}\n\n// SetIcon sets icon on the button. Recommended icons are 32x32 with 32bit color depth.\nfunc (bt *Button) SetIcon(ico *Icon) {\n\tw32.SendMessage(bt.hwnd, w32.BM_SETIMAGE, w32.IMAGE_ICON, uintptr(ico.handle))\n}\n\nfunc (bt *Button) SetResIcon(iconID uint16) {\n\tif ico, err := NewIconFromResource(GetAppInstance(), iconID); err == nil {\n\t\tbt.SetIcon(ico)\n\t\treturn\n\t}\n\tpanic(fmt.Sprintf(\"missing icon with icon ID: %d\", iconID))\n}\n\ntype PushButton struct {\n\tButton\n}\n\nfunc NewPushButton(parent Controller) *PushButton {\n\tpb := new(PushButton)\n\n\tpb.InitControl(\"BUTTON\", parent, 0, w32.BS_PUSHBUTTON|w32.WS_TABSTOP|w32.WS_VISIBLE|w32.WS_CHILD)\n\tRegMsgHandler(pb)\n\n\tpb.SetFont(DefaultFont)\n\tpb.SetText(\"Button\")\n\tpb.SetSize(100, 22)\n\n\treturn pb\n}\n\n// SetDefault is used for dialogs to set default button.\nfunc (pb *PushButton) SetDefault() {\n\tpb.SetAndClearStyleBits(w32.BS_DEFPUSHBUTTON, w32.BS_PUSHBUTTON)\n}\n\n// IconButton does not display text, requires SetResIcon call.\ntype IconButton struct {\n\tButton\n}\n\nfunc NewIconButton(parent Controller) *IconButton {\n\tpb := new(IconButton)\n\n\tpb.InitControl(\"BUTTON\", parent, 0, w32.BS_ICON|w32.WS_TABSTOP|w32.WS_VISIBLE|w32.WS_CHILD)\n\tRegMsgHandler(pb)\n\n\tpb.SetFont(DefaultFont)\n\t// even if text would be set it would not be displayed\n\tpb.SetText(\"\")\n\tpb.SetSize(100, 22)\n\n\treturn pb\n}\n\ntype CheckBox struct {\n\tButton\n}\n\nfunc NewCheckBox(parent Controller) *CheckBox {\n\tcb := new(CheckBox)\n\n\tcb.InitControl(\"BUTTON\", parent, 0, w32.WS_TABSTOP|w32.WS_VISIBLE|w32.WS_CHILD|w32.BS_AUTOCHECKBOX)\n\tRegMsgHandler(cb)\n\n\tcb.SetFont(DefaultFont)\n\tcb.SetText(\"CheckBox\")\n\tcb.SetSize(100, 22)\n\n\treturn cb\n}\n\ntype RadioButton struct {\n\tButton\n}\n\nfunc NewRadioButton(parent Controller) *RadioButton {\n\trb := new(RadioButton)\n\n\trb.InitControl(\"BUTTON\", parent, 0, w32.WS_TABSTOP|w32.WS_VISIBLE|w32.WS_CHILD|w32.BS_AUTORADIOBUTTON)\n\tRegMsgHandler(rb)\n\n\trb.SetFont(DefaultFont)\n\trb.SetText(\"RadioButton\")\n\trb.SetSize(100, 22)\n\n\treturn rb\n}\n\ntype GroupBox struct {\n\tButton\n}\n\nfunc NewGroupBox(parent Controller) *GroupBox {\n\tgb := new(GroupBox)\n\n\tgb.InitControl(\"BUTTON\", parent, 0, w32.WS_CHILD|w32.WS_VISIBLE|w32.WS_GROUP|w32.BS_GROUPBOX)\n\tRegMsgHandler(gb)\n\n\tgb.SetFont(DefaultFont)\n\tgb.SetText(\"GroupBox\")\n\tgb.SetSize(100, 100)\n\n\treturn gb\n}\n"
  },
  {
    "path": "canvas.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Canvas struct {\n\thwnd         w32.HWND\n\thdc          w32.HDC\n\tdoNotDispose bool\n}\n\nvar nullBrush = NewNullBrush()\n\nfunc NewCanvasFromHwnd(hwnd w32.HWND) *Canvas {\n\thdc := w32.GetDC(hwnd)\n\tif hdc == 0 {\n\t\tpanic(fmt.Sprintf(\"Create canvas from %v failed.\", hwnd))\n\t}\n\n\treturn &Canvas{hwnd: hwnd, hdc: hdc, doNotDispose: false}\n}\n\nfunc NewCanvasFromHDC(hdc w32.HDC) *Canvas {\n\tif hdc == 0 {\n\t\tpanic(\"Cannot create canvas from invalid HDC.\")\n\t}\n\n\treturn &Canvas{hdc: hdc, doNotDispose: true}\n}\n\nfunc (ca *Canvas) Dispose() {\n\tif !ca.doNotDispose && ca.hdc != 0 {\n\t\tif ca.hwnd == 0 {\n\t\t\tw32.DeleteDC(ca.hdc)\n\t\t} else {\n\t\t\tw32.ReleaseDC(ca.hwnd, ca.hdc)\n\t\t}\n\n\t\tca.hdc = 0\n\t}\n}\n\nfunc (ca *Canvas) DrawBitmap(bmp *Bitmap, x, y int) {\n\tcdc := w32.CreateCompatibleDC(0)\n\tdefer w32.DeleteDC(cdc)\n\n\thbmpOld := w32.SelectObject(cdc, w32.HGDIOBJ(bmp.GetHBITMAP()))\n\tdefer w32.SelectObject(cdc, w32.HGDIOBJ(hbmpOld))\n\n\tw, h := bmp.Size()\n\n\tw32.BitBlt(ca.hdc, x, y, w, h, cdc, 0, 0, w32.SRCCOPY)\n}\n\nfunc (ca *Canvas) DrawStretchedBitmap(bmp *Bitmap, rect *Rect) {\n\tcdc := w32.CreateCompatibleDC(0)\n\tdefer w32.DeleteDC(cdc)\n\n\thbmpOld := w32.SelectObject(cdc, w32.HGDIOBJ(bmp.GetHBITMAP()))\n\tdefer w32.SelectObject(cdc, w32.HGDIOBJ(hbmpOld))\n\n\tw, h := bmp.Size()\n\n\trc := rect.GetW32Rect()\n\tw32.StretchBlt(ca.hdc, int(rc.Left), int(rc.Top), int(rc.Right), int(rc.Bottom), cdc, 0, 0, w, h, w32.SRCCOPY)\n}\n\nfunc (ca *Canvas) DrawIcon(ico *Icon, x, y int) bool {\n\treturn w32.DrawIcon(ca.hdc, x, y, ico.Handle())\n}\n\n// DrawFillRect draw and fill rectangle with color.\nfunc (ca *Canvas) DrawFillRect(rect *Rect, pen *Pen, brush *Brush) {\n\tw32Rect := rect.GetW32Rect()\n\n\tpreviousPen := w32.SelectObject(ca.hdc, w32.HGDIOBJ(pen.GetHPEN()))\n\tdefer w32.SelectObject(ca.hdc, previousPen)\n\n\tpreviousBrush := w32.SelectObject(ca.hdc, w32.HGDIOBJ(brush.GetHBRUSH()))\n\tdefer w32.SelectObject(ca.hdc, previousBrush)\n\n\tw32.Rectangle(ca.hdc, w32Rect.Left, w32Rect.Top, w32Rect.Right, w32Rect.Bottom)\n}\n\nfunc (ca *Canvas) DrawRect(rect *Rect, pen *Pen) {\n\tw32Rect := rect.GetW32Rect()\n\n\tpreviousPen := w32.SelectObject(ca.hdc, w32.HGDIOBJ(pen.GetHPEN()))\n\tdefer w32.SelectObject(ca.hdc, previousPen)\n\n\t// nullBrush is used to make interior of the rect transparent\n\tpreviousBrush := w32.SelectObject(ca.hdc, w32.HGDIOBJ(nullBrush.GetHBRUSH()))\n\tdefer w32.SelectObject(ca.hdc, previousBrush)\n\n\tw32.Rectangle(ca.hdc, w32Rect.Left, w32Rect.Top, w32Rect.Right, w32Rect.Bottom)\n}\n\nfunc (ca *Canvas) FillRect(rect *Rect, brush *Brush) {\n\tw32.FillRect(ca.hdc, rect.GetW32Rect(), brush.GetHBRUSH())\n}\n\nfunc (ca *Canvas) DrawEllipse(rect *Rect, pen *Pen) {\n\tw32Rect := rect.GetW32Rect()\n\n\tpreviousPen := w32.SelectObject(ca.hdc, w32.HGDIOBJ(pen.GetHPEN()))\n\tdefer w32.SelectObject(ca.hdc, previousPen)\n\n\t// nullBrush is used to make interior of the rect transparent\n\tpreviousBrush := w32.SelectObject(ca.hdc, w32.HGDIOBJ(nullBrush.GetHBRUSH()))\n\tdefer w32.SelectObject(ca.hdc, previousBrush)\n\n\tw32.Ellipse(ca.hdc, w32Rect.Left, w32Rect.Top, w32Rect.Right, w32Rect.Bottom)\n}\n\n// DrawFillEllipse draw and fill ellipse with color.\nfunc (ca *Canvas) DrawFillEllipse(rect *Rect, pen *Pen, brush *Brush) {\n\tw32Rect := rect.GetW32Rect()\n\n\tpreviousPen := w32.SelectObject(ca.hdc, w32.HGDIOBJ(pen.GetHPEN()))\n\tdefer w32.SelectObject(ca.hdc, previousPen)\n\n\tpreviousBrush := w32.SelectObject(ca.hdc, w32.HGDIOBJ(brush.GetHBRUSH()))\n\tdefer w32.SelectObject(ca.hdc, previousBrush)\n\n\tw32.Ellipse(ca.hdc, w32Rect.Left, w32Rect.Top, w32Rect.Right, w32Rect.Bottom)\n}\n\nfunc (ca *Canvas) DrawLine(x, y, x2, y2 int, pen *Pen) {\n\tw32.MoveToEx(ca.hdc, x, y, nil)\n\n\tpreviousPen := w32.SelectObject(ca.hdc, w32.HGDIOBJ(pen.GetHPEN()))\n\tdefer w32.SelectObject(ca.hdc, previousPen)\n\n\tw32.LineTo(ca.hdc, int32(x2), int32(y2))\n}\n\n// Refer win32 DrawText document for uFormat.\nfunc (ca *Canvas) DrawText(text string, rect *Rect, format uint, font *Font, textColor Color) {\n\tpreviousFont := w32.SelectObject(ca.hdc, w32.HGDIOBJ(font.GetHFONT()))\n\tdefer w32.SelectObject(ca.hdc, w32.HGDIOBJ(previousFont))\n\n\tpreviousBkMode := w32.SetBkMode(ca.hdc, w32.TRANSPARENT)\n\tdefer w32.SetBkMode(ca.hdc, previousBkMode)\n\n\tpreviousTextColor := w32.SetTextColor(ca.hdc, w32.COLORREF(textColor))\n\tdefer w32.SetTextColor(ca.hdc, previousTextColor)\n\n\tw32.DrawText(ca.hdc, text, len(text), rect.GetW32Rect(), format)\n}\n"
  },
  {
    "path": "color.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\ntype Color uint32\n\nfunc RGB(r, g, b byte) Color {\n\treturn Color(uint32(r) | uint32(g)<<8 | uint32(b)<<16)\n}\n\nfunc (c Color) R() byte {\n\treturn byte(c & 0xff)\n}\n\nfunc (c Color) G() byte {\n\treturn byte((c >> 8) & 0xff)\n}\n\nfunc (c Color) B() byte {\n\treturn byte((c >> 16) & 0xff)\n}\n"
  },
  {
    "path": "combobox.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype ComboBox struct {\n\tControlBase\n\tonSelectedChange EventManager\n}\n\nfunc NewComboBox(parent Controller) *ComboBox {\n\tcb := new(ComboBox)\n\n\tcb.InitControl(\"COMBOBOX\", parent, 0, w32.WS_CHILD|w32.WS_VISIBLE|w32.WS_TABSTOP|w32.WS_VSCROLL|w32.CBS_DROPDOWNLIST)\n\tRegMsgHandler(cb)\n\n\tcb.SetFont(DefaultFont)\n\tcb.SetSize(200, 400)\n\treturn cb\n}\n\nfunc (cb *ComboBox) DeleteAllItems() bool {\n\treturn w32.SendMessage(cb.hwnd, w32.CB_RESETCONTENT, 0, 0) == w32.TRUE\n}\n\nfunc (cb *ComboBox) InsertItem(index int, str string) bool {\n\tlp := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(str)))\n\treturn w32.SendMessage(cb.hwnd, w32.CB_INSERTSTRING, uintptr(index), lp) != w32.CB_ERR\n}\n\nfunc (cb *ComboBox) DeleteItem(index int) bool {\n\treturn w32.SendMessage(cb.hwnd, w32.CB_DELETESTRING, uintptr(index), 0) != w32.CB_ERR\n}\n\nfunc (cb *ComboBox) SelectedItem() int {\n\treturn int(int32(w32.SendMessage(cb.hwnd, w32.CB_GETCURSEL, 0, 0)))\n}\n\nfunc (cb *ComboBox) SetSelectedItem(value int) bool {\n\treturn int(int32(w32.SendMessage(cb.hwnd, w32.CB_SETCURSEL, uintptr(value), 0))) == value\n}\n\nfunc (cb *ComboBox) OnSelectedChange() *EventManager {\n\treturn &cb.onSelectedChange\n}\n\n// Message processer\nfunc (cb *ComboBox) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_COMMAND:\n\t\tcode := w32.HIWORD(uint32(wparam))\n\n\t\tswitch code {\n\t\tcase w32.CBN_SELCHANGE:\n\t\t\tcb.onSelectedChange.Fire(NewEvent(cb, nil))\n\t\t}\n\t}\n\treturn w32.DefWindowProc(cb.hwnd, msg, wparam, lparam)\n\t//return cb.W32Control.WndProc(msg, wparam, lparam)\n}\n"
  },
  {
    "path": "commondlgs.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\nfunc genOFN(parent Controller, title, filter string, filterIndex uint, initialDir string, buf []uint16) *w32.OPENFILENAME {\n\tvar ofn w32.OPENFILENAME\n\tofn.StructSize = uint32(unsafe.Sizeof(ofn))\n\tofn.Owner = parent.Handle()\n\n\tif filter != \"\" {\n\t\tfilterBuf := make([]uint16, len(filter)+1)\n\t\tcopy(filterBuf, syscall.StringToUTF16(filter))\n\t\t// Replace '|' with the expected '\\0'\n\t\tfor i, c := range filterBuf {\n\t\t\tif byte(c) == '|' {\n\t\t\t\tfilterBuf[i] = uint16(0)\n\t\t\t}\n\t\t}\n\t\tofn.Filter = &filterBuf[0]\n\t\tofn.FilterIndex = uint32(filterIndex)\n\t}\n\n\tofn.File = &buf[0]\n\tofn.MaxFile = uint32(len(buf))\n\n\tif initialDir != \"\" {\n\t\tofn.InitialDir = syscall.StringToUTF16Ptr(initialDir)\n\t}\n\tif title != \"\" {\n\t\tofn.Title = syscall.StringToUTF16Ptr(title)\n\t}\n\n\tofn.Flags = w32.OFN_FILEMUSTEXIST\n\treturn &ofn\n}\n\nfunc ShowOpenFileDlg(parent Controller, title, filter string, filterIndex uint, initialDir string) (filePath string, accepted bool) {\n\tbuf := make([]uint16, 1024)\n\tofn := genOFN(parent, title, filter, filterIndex, initialDir, buf)\n\n\tif accepted = w32.GetOpenFileName(ofn); accepted {\n\t\tfilePath = syscall.UTF16ToString(buf)\n\t}\n\treturn\n}\n\nfunc ShowSaveFileDlg(parent Controller, title, filter string, filterIndex uint, initialDir string) (filePath string, accepted bool) {\n\tbuf := make([]uint16, 1024)\n\tofn := genOFN(parent, title, filter, filterIndex, initialDir, buf)\n\n\tif accepted = w32.GetSaveFileName(ofn); accepted {\n\t\tfilePath = syscall.UTF16ToString(buf)\n\t}\n\treturn\n}\n\nfunc ShowBrowseFolderDlg(parent Controller, title string) (folder string, accepted bool) {\n\tvar bi w32.BROWSEINFO\n\tbi.Owner = parent.Handle()\n\tbi.Title = syscall.StringToUTF16Ptr(title)\n\tbi.Flags = w32.BIF_RETURNONLYFSDIRS | w32.BIF_NEWDIALOGSTYLE\n\n\tw32.CoInitialize()\n\tret := w32.SHBrowseForFolder(&bi)\n\tw32.CoUninitialize()\n\n\tfolder = w32.SHGetPathFromIDList(ret)\n\taccepted = folder != \"\"\n\treturn\n}\n\n// MsgBoxOkCancel basic pop up message. Returns 1 for OK and 2 for CANCEL.\nfunc MsgBoxOkCancel(parent Controller, title, caption string) int {\n\treturn MsgBox(parent, title, caption, w32.MB_ICONEXCLAMATION|w32.MB_OKCANCEL)\n}\n\nfunc MsgBoxYesNo(parent Controller, title, caption string) int {\n\treturn MsgBox(parent, title, caption, w32.MB_ICONEXCLAMATION|w32.MB_YESNO)\n}\n\nfunc MsgBoxOk(parent Controller, title, caption string) {\n\tMsgBox(parent, title, caption, w32.MB_ICONINFORMATION|w32.MB_OK)\n}\n\n// Warningf is generic warning message with OK and Cancel buttons. Returns 1 for OK.\nfunc Warningf(parent Controller, format string, data ...interface{}) int {\n\tcaption := fmt.Sprintf(format, data...)\n\treturn MsgBox(parent, \"Warning\", caption, w32.MB_ICONWARNING|w32.MB_OKCANCEL)\n}\n\n// Printf is generic info message with OK button.\nfunc Printf(parent Controller, format string, data ...interface{}) {\n\tcaption := fmt.Sprintf(format, data...)\n\tMsgBox(parent, \"Information\", caption, w32.MB_ICONINFORMATION|w32.MB_OK)\n}\n\n// Errorf is generic error message with OK button.\nfunc Errorf(parent Controller, format string, data ...interface{}) {\n\tcaption := fmt.Sprintf(format, data...)\n\tMsgBox(parent, \"Error\", caption, w32.MB_ICONERROR|w32.MB_OK)\n}\n\nfunc MsgBox(parent Controller, title, caption string, flags uint) int {\n\tvar result int\n\tif parent != nil {\n\t\tresult = w32.MessageBox(parent.Handle(), caption, title, flags)\n\t} else {\n\t\tresult = w32.MessageBox(0, caption, title, flags)\n\t}\n\n\treturn result\n}\n"
  },
  {
    "path": "controlbase.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype ControlBase struct {\n\thwnd        w32.HWND\n\tfont        *Font\n\tparent      Controller\n\tcontextMenu *MenuItem\n\n\tisForm bool\n\n\tminWidth, minHeight int\n\tmaxWidth, maxHeight int\n\n\t// General events\n\tonCreate EventManager\n\tonClose  EventManager\n\n\t// Focus events\n\tonKillFocus EventManager\n\tonSetFocus  EventManager\n\n\t// Drag and drop events\n\tonDropFiles EventManager\n\n\t// Mouse events\n\tonLBDown    EventManager\n\tonLBUp      EventManager\n\tonLBDbl     EventManager\n\tonMBDown    EventManager\n\tonMBUp      EventManager\n\tonRBDown    EventManager\n\tonRBUp      EventManager\n\tonRBDbl     EventManager\n\tonMouseMove EventManager\n\n\t// use MouseControl to capture onMouseHover and onMouseLeave events.\n\tonMouseHover EventManager\n\tonMouseLeave EventManager\n\n\t// Keyboard events\n\tonKeyUp EventManager\n\n\t// Paint events\n\tonPaint EventManager\n\tonSize  EventManager\n}\n\n// initControl is called by controls: edit, button, treeview, listview, and so on.\nfunc (cba *ControlBase) InitControl(className string, parent Controller, exstyle, style uint) {\n\tcba.hwnd = CreateWindow(className, parent, exstyle, style)\n\tif cba.hwnd == 0 {\n\t\tpanic(\"cannot create window for \" + className)\n\t}\n\tcba.parent = parent\n}\n\n// InitWindow is called by custom window based controls such as split, panel, etc.\nfunc (cba *ControlBase) InitWindow(className string, parent Controller, exstyle, style uint) {\n\tRegClassOnlyOnce(className)\n\tcba.hwnd = CreateWindow(className, parent, exstyle, style)\n\tif cba.hwnd == 0 {\n\t\tpanic(\"cannot create window for \" + className)\n\t}\n\tcba.parent = parent\n}\n\n// SetTheme for TreeView and ListView controls.\nfunc (cba *ControlBase) SetTheme(appName string) error {\n\tif hr := w32.SetWindowTheme(cba.hwnd, syscall.StringToUTF16Ptr(appName), nil); w32.FAILED(hr) {\n\t\treturn fmt.Errorf(\"SetWindowTheme %d\", hr)\n\t}\n\treturn nil\n}\n\nfunc (cba *ControlBase) Handle() w32.HWND {\n\treturn cba.hwnd\n}\n\nfunc (cba *ControlBase) SetHandle(hwnd w32.HWND) {\n\tcba.hwnd = hwnd\n}\n\nfunc (cba *ControlBase) GetWindowDPI() (w32.UINT, w32.UINT) {\n\tmonitor := w32.MonitorFromWindow(cba.hwnd, w32.MONITOR_DEFAULTTOPRIMARY)\n\tvar dpiX, dpiY w32.UINT\n\tw32.GetDPIForMonitor(monitor, w32.MDT_EFFECTIVE_DPI, &dpiX, &dpiY)\n\treturn dpiX, dpiY\n}\n\nfunc (cba *ControlBase) SetAndClearStyleBits(set, clear uint32) error {\n\tstyle := uint32(w32.GetWindowLong(cba.hwnd, w32.GWL_STYLE))\n\tif style == 0 {\n\t\treturn fmt.Errorf(\"GetWindowLong\")\n\t}\n\n\tif newStyle := style&^clear | set; newStyle != style {\n\t\tif w32.SetWindowLong(cba.hwnd, w32.GWL_STYLE, newStyle) == 0 {\n\t\t\treturn fmt.Errorf(\"SetWindowLong\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (cba *ControlBase) SetIsForm(isform bool) {\n\tcba.isForm = isform\n}\n\nfunc (cba *ControlBase) SetText(caption string) {\n\tw32.SetWindowText(cba.hwnd, caption)\n}\n\nfunc (cba *ControlBase) Text() string {\n\treturn w32.GetWindowText(cba.hwnd)\n}\n\nfunc (cba *ControlBase) Close() {\n\tUnRegMsgHandler(cba.hwnd)\n\tw32.DestroyWindow(cba.hwnd)\n}\n\nfunc (cba *ControlBase) SetTranslucentBackground() {\n\tvar accent = w32.ACCENT_POLICY{\n\t\tAccentState: w32.ACCENT_ENABLE_BLURBEHIND,\n\t}\n\tvar data w32.WINDOWCOMPOSITIONATTRIBDATA\n\tdata.Attrib = w32.WCA_ACCENT_POLICY\n\tdata.PvData = unsafe.Pointer(&accent)\n\tdata.CbData = unsafe.Sizeof(accent)\n\n\tw32.SetWindowCompositionAttribute(cba.hwnd, &data)\n}\n\nfunc min(a, b int) int {\n\tif a < b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc max(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}\n\nfunc (cba *ControlBase) clampSize(width, height int) (int, int) {\n\tif cba.minWidth != 0 {\n\t\twidth = max(width, cba.minWidth)\n\t}\n\tif cba.maxWidth != 0 {\n\t\twidth = min(width, cba.maxWidth)\n\t}\n\tif cba.minHeight != 0 {\n\t\theight = max(height, cba.minHeight)\n\t}\n\tif cba.maxHeight != 0 {\n\t\theight = min(height, cba.maxHeight)\n\t}\n\treturn width, height\n}\n\nfunc (cba *ControlBase) SetSize(width, height int) {\n\tx, y := cba.Pos()\n\twidth, height = cba.clampSize(width, height)\n\tw32.MoveWindow(cba.hwnd, x, y, width, height, true)\n}\n\nfunc (cba *ControlBase) SetMinSize(width, height int) {\n\tcba.minWidth = width\n\tcba.minHeight = height\n\n\t// Ensure we set max if min > max\n\tif cba.maxWidth > 0 {\n\t\tcba.maxWidth = max(cba.minWidth, cba.maxWidth)\n\t}\n\tif cba.maxHeight > 0 {\n\t\tcba.maxHeight = max(cba.minHeight, cba.maxHeight)\n\t}\n\n\tx, y := cba.Pos()\n\tcurrentWidth, currentHeight := cba.Size()\n\tclampedWidth, clampedHeight := cba.clampSize(currentWidth, currentHeight)\n\tif clampedWidth != currentWidth || clampedHeight != currentHeight {\n\t\tw32.MoveWindow(cba.hwnd, x, y, clampedWidth, clampedHeight, true)\n\t}\n}\nfunc (cba *ControlBase) SetMaxSize(width, height int) {\n\tcba.maxWidth = width\n\tcba.maxHeight = height\n\n\t// Ensure we set min if max > min\n\tif cba.minWidth > 0 {\n\t\tcba.minWidth = min(cba.maxWidth, cba.minWidth)\n\t}\n\tif cba.maxHeight > 0 {\n\t\tcba.minHeight = min(cba.maxHeight, cba.minHeight)\n\t}\n\n\tx, y := cba.Pos()\n\tcurrentWidth, currentHeight := cba.Size()\n\tclampedWidth, clampedHeight := cba.clampSize(currentWidth, currentHeight)\n\tif clampedWidth != currentWidth || clampedHeight != currentHeight {\n\t\tw32.MoveWindow(cba.hwnd, x, y, clampedWidth, clampedHeight, true)\n\t}\n}\n\nfunc (cba *ControlBase) Size() (width, height int) {\n\trect := w32.GetWindowRect(cba.hwnd)\n\twidth = int(rect.Right - rect.Left)\n\theight = int(rect.Bottom - rect.Top)\n\treturn\n}\n\nfunc (cba *ControlBase) Width() int {\n\trect := w32.GetWindowRect(cba.hwnd)\n\treturn int(rect.Right - rect.Left)\n}\n\nfunc (cba *ControlBase) Height() int {\n\trect := w32.GetWindowRect(cba.hwnd)\n\treturn int(rect.Bottom - rect.Top)\n}\n\nfunc (cba *ControlBase) SetPos(x, y int) {\n\tinfo := getMonitorInfo(cba.hwnd)\n\tworkRect := info.RcWork\n\n\tw32.SetWindowPos(cba.hwnd, w32.HWND_TOP, int(workRect.Left)+x, int(workRect.Top)+y, 0, 0, w32.SWP_NOSIZE)\n}\n\nfunc (cba *ControlBase) Pos() (x, y int) {\n\trect := w32.GetWindowRect(cba.hwnd)\n\tx = int(rect.Left)\n\ty = int(rect.Top)\n\tif !cba.isForm && cba.parent != nil {\n\t\tx, y, _ = w32.ScreenToClient(cba.parent.Handle(), x, y)\n\t}\n\treturn\n}\n\nfunc (cba *ControlBase) Visible() bool {\n\treturn w32.IsWindowVisible(cba.hwnd)\n}\n\nfunc (cba *ControlBase) ToggleVisible() bool {\n\tvisible := w32.IsWindowVisible(cba.hwnd)\n\tif visible {\n\t\tcba.Hide()\n\t} else {\n\t\tcba.Show()\n\t}\n\treturn !visible\n}\n\nfunc (cba *ControlBase) ContextMenu() *MenuItem {\n\treturn cba.contextMenu\n}\n\nfunc (cba *ControlBase) SetContextMenu(menu *MenuItem) {\n\tcba.contextMenu = menu\n}\n\nfunc (cba *ControlBase) Bounds() *Rect {\n\trect := w32.GetWindowRect(cba.hwnd)\n\tif cba.isForm {\n\t\treturn &Rect{*rect}\n\t}\n\n\treturn ScreenToClientRect(cba.hwnd, rect)\n}\n\nfunc (cba *ControlBase) ClientRect() *Rect {\n\trect := w32.GetClientRect(cba.hwnd)\n\treturn ScreenToClientRect(cba.hwnd, rect)\n}\nfunc (cba *ControlBase) ClientWidth() int {\n\trect := w32.GetClientRect(cba.hwnd)\n\treturn int(rect.Right - rect.Left)\n}\n\nfunc (cba *ControlBase) ClientHeight() int {\n\trect := w32.GetClientRect(cba.hwnd)\n\treturn int(rect.Bottom - rect.Top)\n}\n\nfunc (cba *ControlBase) Show() {\n\tw32.ShowWindow(cba.hwnd, w32.SW_SHOWDEFAULT)\n}\n\nfunc (cba *ControlBase) Hide() {\n\tw32.ShowWindow(cba.hwnd, w32.SW_HIDE)\n}\n\nfunc (cba *ControlBase) Enabled() bool {\n\treturn w32.IsWindowEnabled(cba.hwnd)\n}\n\nfunc (cba *ControlBase) SetEnabled(b bool) {\n\tw32.EnableWindow(cba.hwnd, b)\n}\n\nfunc (cba *ControlBase) SetFocus() {\n\tw32.SetFocus(cba.hwnd)\n}\n\nfunc (cba *ControlBase) Invalidate(erase bool) {\n\t// pRect := w32.GetClientRect(cba.hwnd)\n\t// if cba.isForm {\n\t// \tw32.InvalidateRect(cba.hwnd, pRect, erase)\n\t// } else {\n\t// \trc := ScreenToClientRect(cba.hwnd, pRect)\n\t// \tw32.InvalidateRect(cba.hwnd, rc.GetW32Rect(), erase)\n\t// }\n\tw32.InvalidateRect(cba.hwnd, nil, erase)\n}\n\nfunc (cba *ControlBase) Parent() Controller {\n\treturn cba.parent\n}\n\nfunc (cba *ControlBase) SetParent(parent Controller) {\n\tcba.parent = parent\n}\n\nfunc (cba *ControlBase) Font() *Font {\n\treturn cba.font\n}\n\nfunc (cba *ControlBase) SetFont(font *Font) {\n\tw32.SendMessage(cba.hwnd, w32.WM_SETFONT, uintptr(font.hfont), 1)\n\tcba.font = font\n}\n\nfunc (cba *ControlBase) EnableDragAcceptFiles(b bool) {\n\tw32.DragAcceptFiles(cba.hwnd, b)\n}\n\nfunc (cba *ControlBase) InvokeRequired() bool {\n\tif cba.hwnd == 0 {\n\t\treturn false\n\t}\n\n\twindowThreadId, _ := w32.GetWindowThreadProcessId(cba.hwnd)\n\tcurrentThreadId := w32.GetCurrentThread()\n\n\treturn windowThreadId != currentThreadId\n}\n\nfunc (cba *ControlBase) PreTranslateMessage(msg *w32.MSG) bool {\n\tif msg.Message == w32.WM_GETDLGCODE {\n\t\tprintln(\"pretranslate, WM_GETDLGCODE\")\n\t}\n\treturn false\n}\n\n//Events\nfunc (cba *ControlBase) OnCreate() *EventManager {\n\treturn &cba.onCreate\n}\n\nfunc (cba *ControlBase) OnClose() *EventManager {\n\treturn &cba.onClose\n}\n\nfunc (cba *ControlBase) OnKillFocus() *EventManager {\n\treturn &cba.onKillFocus\n}\n\nfunc (cba *ControlBase) OnSetFocus() *EventManager {\n\treturn &cba.onSetFocus\n}\n\nfunc (cba *ControlBase) OnDropFiles() *EventManager {\n\treturn &cba.onDropFiles\n}\n\nfunc (cba *ControlBase) OnLBDown() *EventManager {\n\treturn &cba.onLBDown\n}\n\nfunc (cba *ControlBase) OnLBUp() *EventManager {\n\treturn &cba.onLBUp\n}\n\nfunc (cba *ControlBase) OnLBDbl() *EventManager {\n\treturn &cba.onLBDbl\n}\n\nfunc (cba *ControlBase) OnMBDown() *EventManager {\n\treturn &cba.onMBDown\n}\n\nfunc (cba *ControlBase) OnMBUp() *EventManager {\n\treturn &cba.onMBUp\n}\n\nfunc (cba *ControlBase) OnRBDown() *EventManager {\n\treturn &cba.onRBDown\n}\n\nfunc (cba *ControlBase) OnRBUp() *EventManager {\n\treturn &cba.onRBUp\n}\n\nfunc (cba *ControlBase) OnRBDbl() *EventManager {\n\treturn &cba.onRBDbl\n}\n\nfunc (cba *ControlBase) OnMouseMove() *EventManager {\n\treturn &cba.onMouseMove\n}\n\nfunc (cba *ControlBase) OnMouseHover() *EventManager {\n\treturn &cba.onMouseHover\n}\n\nfunc (cba *ControlBase) OnMouseLeave() *EventManager {\n\treturn &cba.onMouseLeave\n}\n\nfunc (cba *ControlBase) OnPaint() *EventManager {\n\treturn &cba.onPaint\n}\n\nfunc (cba *ControlBase) OnSize() *EventManager {\n\treturn &cba.onSize\n}\n\nfunc (cba *ControlBase) OnKeyUp() *EventManager {\n\treturn &cba.onKeyUp\n}\n"
  },
  {
    "path": "controller.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Controller interface {\n\tText() string\n\n\tEnabled() bool\n\tSetFocus()\n\n\tHandle() w32.HWND\n\tInvalidate(erase bool)\n\tParent() Controller\n\n\tPos() (x, y int)\n\tSize() (w, h int)\n\tHeight() int\n\tWidth() int\n\tVisible() bool\n\tBounds() *Rect\n\tClientRect() *Rect\n\n\tSetText(s string)\n\tSetEnabled(b bool)\n\tSetPos(x, y int)\n\tSetSize(w, h int)\n\tEnableDragAcceptFiles(b bool)\n\tShow()\n\tHide()\n\n\tContextMenu() *MenuItem\n\tSetContextMenu(menu *MenuItem)\n\n\tFont() *Font\n\tSetFont(font *Font)\n\tInvokeRequired() bool\n\tPreTranslateMessage(msg *w32.MSG) bool\n\tWndProc(msg uint32, wparam, lparam uintptr) uintptr\n\n\t//General events\n\tOnCreate() *EventManager\n\tOnClose() *EventManager\n\n\t// Focus events\n\tOnKillFocus() *EventManager\n\tOnSetFocus() *EventManager\n\n\t//Drag and drop events\n\tOnDropFiles() *EventManager\n\n\t//Mouse events\n\tOnLBDown() *EventManager\n\tOnLBUp() *EventManager\n\tOnLBDbl() *EventManager\n\tOnMBDown() *EventManager\n\tOnMBUp() *EventManager\n\tOnRBDown() *EventManager\n\tOnRBUp() *EventManager\n\tOnRBDbl() *EventManager\n\tOnMouseMove() *EventManager\n\n\t// OnMouseLeave and OnMouseHover does not fire unless control called internalTrackMouseEvent.\n\t// Use MouseControl for a how to example.\n\tOnMouseHover() *EventManager\n\tOnMouseLeave() *EventManager\n\n\t//Keyboard events\n\tOnKeyUp() *EventManager\n\n\t//Paint events\n\tOnPaint() *EventManager\n\tOnSize() *EventManager\n}\n"
  },
  {
    "path": "dialog.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport \"github.com/tadvi/winc/w32\"\n\n// Dialog displayed as z-order top window until closed.\n// It also disables parent window so it can not be clicked.\ntype Dialog struct {\n\tForm\n\tisModal bool\n\n\tbtnOk     *PushButton\n\tbtnCancel *PushButton\n\n\tonLoad   EventManager\n\tonOk     EventManager\n\tonCancel EventManager\n}\n\nfunc NewDialog(parent Controller) *Dialog {\n\tdlg := new(Dialog)\n\n\tdlg.isForm = true\n\tdlg.isModal = true\n\tRegClassOnlyOnce(\"winc_Dialog\")\n\n\tdlg.hwnd = CreateWindow(\"winc_Dialog\", parent, w32.WS_EX_CONTROLPARENT, /* IMPORTANT */\n\t\tw32.WS_SYSMENU|w32.WS_CAPTION|w32.WS_THICKFRAME /*|w32.WS_BORDER|w32.WS_POPUP*/)\n\tdlg.parent = parent\n\n\t// dlg might fail if icon resource is not embedded in the binary\n\tif ico, err := NewIconFromResource(GetAppInstance(), uint16(AppIconID)); err == nil {\n\t\tdlg.SetIcon(0, ico)\n\t}\n\n\t// Dlg forces display of focus rectangles, as soon as the user starts to type.\n\tw32.SendMessage(dlg.hwnd, w32.WM_CHANGEUISTATE, w32.UIS_INITIALIZE, 0)\n\tRegMsgHandler(dlg)\n\n\tdlg.SetFont(DefaultFont)\n\tdlg.SetText(\"Form\")\n\tdlg.SetSize(200, 100)\n\treturn dlg\n}\n\nfunc (dlg *Dialog) SetModal(modal bool) {\n\tdlg.isModal = modal\n}\n\n// SetButtons wires up dialog events to buttons. btnCancel can be nil.\nfunc (dlg *Dialog) SetButtons(btnOk *PushButton, btnCancel *PushButton) {\n\tdlg.btnOk = btnOk\n\tdlg.btnOk.SetDefault()\n\tdlg.btnCancel = btnCancel\n}\n\n// Events\nfunc (dlg *Dialog) OnLoad() *EventManager {\n\treturn &dlg.onLoad\n}\n\nfunc (dlg *Dialog) OnOk() *EventManager {\n\treturn &dlg.onOk\n}\n\nfunc (dlg *Dialog) OnCancel() *EventManager {\n\treturn &dlg.onCancel\n}\n\n// PreTranslateMessage handles dialog specific messages. IMPORTANT.\nfunc (dlg *Dialog) PreTranslateMessage(msg *w32.MSG) bool {\n\tif msg.Message >= w32.WM_KEYFIRST && msg.Message <= w32.WM_KEYLAST {\n\t\tif w32.IsDialogMessage(dlg.hwnd, msg) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// Show dialog performs special setup for dialog windows.\nfunc (dlg *Dialog) Show() {\n\tif dlg.isModal {\n\t\tdlg.Parent().SetEnabled(false)\n\t}\n\tdlg.onLoad.Fire(NewEvent(dlg, nil))\n\tdlg.Form.Show()\n}\n\n// Close dialog when you done with it.\nfunc (dlg *Dialog) Close() {\n\tif dlg.isModal {\n\t\tdlg.Parent().SetEnabled(true)\n\t}\n\tdlg.ControlBase.Close()\n}\n\nfunc (dlg *Dialog) cancel() {\n\tif dlg.btnCancel != nil {\n\t\tdlg.btnCancel.onClick.Fire(NewEvent(dlg.btnCancel, nil))\n\t}\n\tdlg.onCancel.Fire(NewEvent(dlg, nil))\n}\n\nfunc (dlg *Dialog) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_COMMAND:\n\t\tswitch w32.LOWORD(uint32(wparam)) {\n\t\tcase w32.IDOK:\n\t\t\tif dlg.btnOk != nil {\n\t\t\t\tdlg.btnOk.onClick.Fire(NewEvent(dlg.btnOk, nil))\n\t\t\t}\n\t\t\tdlg.onOk.Fire(NewEvent(dlg, nil))\n\t\t\treturn w32.TRUE\n\n\t\tcase w32.IDCANCEL:\n\t\t\tdlg.cancel()\n\t\t\treturn w32.TRUE\n\t\t}\n\n\tcase w32.WM_CLOSE:\n\t\tdlg.cancel() // use onCancel or dlg.btnCancel.OnClick to close\n\t\treturn 0\n\n\tcase w32.WM_DESTROY:\n\t\tif dlg.isModal {\n\t\t\tdlg.Parent().SetEnabled(true)\n\t\t}\n\t}\n\treturn w32.DefWindowProc(dlg.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "edit.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport \"github.com/tadvi/winc/w32\"\n\ntype Edit struct {\n\tControlBase\n\tonChange EventManager\n}\n\nconst passwordChar = '*'\nconst nopasswordChar = ' '\n\nfunc NewEdit(parent Controller) *Edit {\n\tedt := new(Edit)\n\n\tedt.InitControl(\"EDIT\", parent, w32.WS_EX_CLIENTEDGE, w32.WS_CHILD|w32.WS_VISIBLE|w32.WS_TABSTOP|w32.ES_LEFT|\n\t\tw32.ES_AUTOHSCROLL)\n\tRegMsgHandler(edt)\n\n\tedt.SetFont(DefaultFont)\n\tedt.SetSize(200, 22)\n\treturn edt\n}\n\n// Events.\nfunc (ed *Edit) OnChange() *EventManager {\n\treturn &ed.onChange\n}\n\n// Public methods.\nfunc (ed *Edit) SetReadOnly(isReadOnly bool) {\n\tw32.SendMessage(ed.hwnd, w32.EM_SETREADONLY, uintptr(w32.BoolToBOOL(isReadOnly)), 0)\n}\n\n//Public methods\nfunc (ed *Edit) SetPassword(isPassword bool) {\n\tif isPassword {\n\t\tw32.SendMessage(ed.hwnd, w32.EM_SETPASSWORDCHAR, uintptr(passwordChar), 0)\n\t} else {\n\t\tw32.SendMessage(ed.hwnd, w32.EM_SETPASSWORDCHAR, 0, 0)\n\t}\n}\n\nfunc (ed *Edit) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_COMMAND:\n\t\tswitch w32.HIWORD(uint32(wparam)) {\n\t\tcase w32.EN_CHANGE:\n\t\t\ted.onChange.Fire(NewEvent(ed, nil))\n\t\t}\n\t\t/*case w32.WM_GETDLGCODE:\n\t\tprintln(\"Edit\")\n\t\tif wparam == w32.VK_RETURN {\n\t\t\treturn w32.DLGC_WANTALLKEYS\n\t\t}*/\n\t}\n\treturn w32.DefWindowProc(ed.hwnd, msg, wparam, lparam)\n}\n\n// MultiEdit is multiline text edit.\ntype MultiEdit struct {\n\tControlBase\n\tonChange EventManager\n}\n\nfunc NewMultiEdit(parent Controller) *MultiEdit {\n\tmed := new(MultiEdit)\n\n\tmed.InitControl(\"EDIT\", parent, w32.WS_EX_CLIENTEDGE, w32.WS_CHILD|w32.WS_VISIBLE|w32.WS_TABSTOP|w32.ES_LEFT|\n\t\tw32.WS_VSCROLL|w32.WS_HSCROLL|w32.ES_MULTILINE|w32.ES_WANTRETURN|w32.ES_AUTOHSCROLL|w32.ES_AUTOVSCROLL)\n\tRegMsgHandler(med)\n\n\tmed.SetFont(DefaultFont)\n\tmed.SetSize(200, 400)\n\treturn med\n}\n\n// Events\nfunc (med *MultiEdit) OnChange() *EventManager {\n\treturn &med.onChange\n}\n\n// Public methods\nfunc (med *MultiEdit) SetReadOnly(isReadOnly bool) {\n\tw32.SendMessage(med.hwnd, w32.EM_SETREADONLY, uintptr(w32.BoolToBOOL(isReadOnly)), 0)\n}\n\nfunc (med *MultiEdit) AddLine(text string) {\n\tif len(med.Text()) == 0 {\n\t\tmed.SetText(text)\n\t} else {\n\t\tmed.SetText(med.Text() + \"\\r\\n\" + text)\n\t}\n}\n\nfunc (med *MultiEdit) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\n\tcase w32.WM_COMMAND:\n\t\tswitch w32.HIWORD(uint32(wparam)) {\n\t\tcase w32.EN_CHANGE:\n\t\t\tmed.onChange.Fire(NewEvent(med, nil))\n\t\t}\n\t}\n\treturn w32.DefWindowProc(med.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "event.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\ntype Event struct {\n\tSender Controller\n\tData   interface{}\n}\n\nfunc NewEvent(sender Controller, data interface{}) *Event {\n\treturn &Event{Sender: sender, Data: data}\n}\n"
  },
  {
    "path": "eventdata.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype RawMsg struct {\n\tHwnd           w32.HWND\n\tMsg            uint32\n\tWParam, LParam uintptr\n}\n\ntype MouseEventData struct {\n\tX, Y   int\n\tButton int\n\tWheel  int\n}\n\ntype DropFilesEventData struct {\n\tX, Y  int\n\tFiles []string\n}\n\ntype PaintEventData struct {\n\tCanvas *Canvas\n}\n\ntype LabelEditEventData struct {\n\tItem ListItem\n\tText string\n\t//PszText *uint16\n}\n\n/*type LVDBLClickEventData struct {\n\tNmItem *w32.NMITEMACTIVATE\n}*/\n\ntype KeyUpEventData struct {\n\tVKey, Code int\n}\n\ntype SizeEventData struct {\n\tType uint\n\tX, Y int\n}\n"
  },
  {
    "path": "eventmanager.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\ntype EventHandler func(arg *Event)\n\ntype EventManager struct {\n\thandler EventHandler\n}\n\nfunc (evm *EventManager) Fire(arg *Event) {\n\tif evm.handler != nil {\n\t\tevm.handler(arg)\n\t}\n}\n\nfunc (evm *EventManager) Bind(handler EventHandler) {\n\tevm.handler = handler\n}\n"
  },
  {
    "path": "examples/sample_contextmenu/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_contextmenu/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\n// Item for the treeview.\ntype Item struct {\n\tT string\n}\n\nfunc (item Item) Text() string    { return item.T }\nfunc (item Item) ImageIndex() int { return 0 }\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\tmainWindow.SetLayout(dock)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\ttabs := winc.NewMultiPanel(mainWindow)\n\ttabs.SetPos(10, 10)\n\ttabs.SetSize(100, 92)\n\n\ttree := winc.NewTreeView(mainWindow)\n\ttree.SetPos(10, 80)\n\tp := &Item{\"First Item\"}\n\ttree.InsertItem(p, nil, nil)\n\tsec := &Item{\"Second\"}\n\tif err := tree.InsertItem(sec, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := tree.InsertItem(&Item{\"Third\"}, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := tree.InsertItem(&Item{\"Fourth\"}, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tfor i := 0; i < 50; i++ {\n\t\tif err := tree.InsertItem(&Item{\"after second\"}, sec, nil); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\ttree.Expand(p)\n\ttree.OnCollapse().Bind(func(e *winc.Event) {\n\t\tprintln(\"collapse\")\n\t})\n\n\t// Pop up menu.\n\tpopupMn := winc.NewContextMenu()\n\tcutAllMn := popupMn.AddItemCheckable(\"Cut All\", winc.NoShortcut)\n\tcutAllMn.SetChecked(true)\n\tcopyAllMn := popupMn.AddItem(\"Copy All\", winc.NoShortcut)\n\tcopyAllMn.SetEnabled(false)\n\t_ = popupMn.AddItem(\"Paste All\", winc.NoShortcut)\n\t// Attach pop up menu to the treeview.\n\ttree.SetContextMenu(popupMn)\n\n\tcutAllMn.OnClick().Bind(func(e *winc.Event) { fmt.Println(\"cutAllMn\") })\n\tcopyAllMn.OnClick().Bind(func(e *winc.Event) { fmt.Println(\"copyAllMn\") })\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"cut click\")\n\t\tok := tree.EnsureVisible(p)\n\t\tfmt.Println(\"result of EnsureVisible\", ok)\n\t})\n\n\tpanel := winc.NewPanel(tabs)\n\ttabs.AddPanel(panel)\n\n\tpanelDock := winc.NewSimpleDock(panel)\n\tpanel.SetLayout(panelDock)\n\tpanel.SetPos(0, 0)\n\n\tpanelErr := winc.NewErrorPanel(panel)\n\tpanelErr.SetPos(140, 10)\n\tpanelErr.SetSize(200, 32)\n\tpanelErr.ShowAsError(false)\n\n\tedt := winc.NewEdit(panel)\n\tedt.SetPos(10, 535)\n\tedt.SetText(\"some text\")\n\n\tbtn := winc.NewPushButton(panel)\n\tbtn.SetText(\"Button\")\n\tbtn.SetSize(100, 40)\n\tbtn.OnClick().Bind(func(e *winc.Event) {\n\t\tif edt.Visible() {\n\t\t\tedt.Hide()\n\t\t} else {\n\t\t\tedt.Show()\n\t\t}\n\t})\n\tbtn.SetResIcon(13)\n\n\tpanelDock.Dock(btn, winc.Top)\n\tpanelDock.Dock(edt, winc.Top)\n\tpanelDock.Dock(panelErr, winc.Top)\n\n\tdock.Dock(tree, winc.Left)\n\tdock.Dock(tabs, winc.Top)\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_contextmenu/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_control/main.go",
    "content": "package main\n\nimport (\n\t\"github.com/tadvi/winc\"\n)\n\nfunc main() {\n\tmainWindow := NewTopForm(nil) // Our TopForm control gets created here.\n\tmainWindow.SetSize(400, 300)\n\tmainWindow.SetText(\"Hello World Demo\")\n\n\tedt := winc.NewEdit(mainWindow)\n\tedt.SetPos(10, 20)\n\t// Most Controls have default size unless SetSize is called.\n\tedt.SetText(\"edit text\")\n\n\tbtn := winc.NewPushButton(mainWindow)\n\tbtn.SetText(\"Show or Hide\")\n\tbtn.SetPos(40, 50)\n\tbtn.SetSize(100, 40)\n\tbtn.OnClick().Bind(func(e *winc.Event) {\n\t\tif edt.Visible() {\n\t\t\tedt.Hide()\n\t\t} else {\n\t\t\tedt.Show()\n\t\t}\n\t})\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop() // Must call to start event loop.\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n"
  },
  {
    "path": "examples/sample_control/topform.go",
    "content": "package main\n\nimport (\n\t\"github.com/tadvi/winc\"\n\t\"github.com/tadvi/winc/w32\"\n)\n\n// TopForm displayed as topmost window until closed.\n// By itself this is not very useful since Form has function EnableTopMost() making form topmost.\n// This is just an example showing how custom window Form can be implemented inside your package.\ntype TopForm struct {\n\twinc.Form\n\n\tonLoad winc.EventManager\n}\n\nfunc NewTopForm(parent winc.Controller) *TopForm {\n\tdlg := new(TopForm)\n\tdlg.SetIsForm(true)\n\n\twinc.RegClassOnlyOnce(\"my_TopForm\")\n\tdlg.SetHandle(winc.CreateWindow(\"my_TopForm\", parent, w32.WS_EX_DLGMODALFRAME|w32.WS_EX_TOPMOST,\n\t\tw32.WS_VISIBLE|w32.WS_SYSMENU|w32.WS_CAPTION))\n\tdlg.SetParent(parent)\n\n\t// dlg might fail if icon resource is not embedded in the binary\n\tif ico, err := winc.NewIconFromResource(winc.GetAppInstance(), uint16(winc.AppIconID)); err == nil {\n\t\tdlg.SetIcon(0, ico)\n\t}\n\n\t// Dlg forces display of focus rectangles, as soon as the user starts to type.\n\tw32.SendMessage(dlg.Handle(), w32.WM_CHANGEUISTATE, w32.UIS_INITIALIZE, 0)\n\twinc.RegMsgHandler(dlg)\n\n\tdlg.SetFont(winc.DefaultFont)\n\tdlg.SetText(\"Form\")\n\treturn dlg\n}\n\n// Events\nfunc (dlg *TopForm) OnLoad() *winc.EventManager {\n\treturn &dlg.onLoad\n}\n\nfunc (dlg *TopForm) Show() {\n\tdlg.onLoad.Fire(winc.NewEvent(dlg, nil))\n\tdlg.Form.Show()\n}\n\nfunc (dlg *TopForm) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_CLOSE:\n\t\tdlg.Close()\n\tcase w32.WM_DESTROY:\n\t\tif dlg.Parent() == nil {\n\t\t\twinc.Exit()\n\t\t}\n\t}\n\treturn w32.DefWindowProc(dlg.Handle(), msg, wparam, lparam)\n}\n"
  },
  {
    "path": "examples/sample_docking/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n    <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n    <dependency>\n        <dependentAssembly>\n            <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n        </dependentAssembly>\n    </dependency>\n</assembly>\n"
  },
  {
    "path": "examples/sample_docking/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\ntype Item struct {\n\tT string\n}\n\nfunc (item Item) Text() string    { return item.T }\nfunc (item Item) ImageIndex() int { return 0 }\n\nfunc main() {\n\t//winc.Init()\n\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\tmainWindow.SetLayout(dock)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\ttabs := winc.NewMultiPanel(mainWindow)\n\ttabs.SetPos(10, 10)\n\ttabs.SetSize(100, 92)\n\n\ttree := winc.NewTreeView(mainWindow)\n\ttree.SetPos(10, 80)\n\tp := &Item{\"First Item\"}\n\ttree.InsertItem(p, nil, nil)\n\tsec := &Item{\"Second\"}\n\tif err := tree.InsertItem(sec, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := tree.InsertItem(&Item{\"Third\"}, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := tree.InsertItem(&Item{\"Fourth\"}, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tfor i := 0; i < 50; i++ {\n\t\tif err := tree.InsertItem(&Item{\"after second\"}, sec, nil); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\ttree.Expand(p)\n\ttree.OnCollapse().Bind(func(e *winc.Event) {\n\t\tprintln(\"collapse\")\n\t})\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"cut click\")\n\t\tok := tree.EnsureVisible(p)\n\t\tfmt.Println(\"result of EnsureVisible\", ok)\n\t})\n\n\tpanel := winc.NewPanel(tabs)\n\ttabs.AddPanel(panel)\n\n\tpanelDock := winc.NewSimpleDock(panel)\n\tpanel.SetLayout(panelDock)\n\tpanel.SetPos(0, 0)\n\n\tpanelErr := winc.NewErrorPanel(panel)\n\tpanelErr.SetPos(140, 10)\n\tpanelErr.SetSize(200, 32)\n\tpanelErr.ShowAsError(false)\n\n\tedt := winc.NewEdit(panel)\n\tedt.SetPos(10, 535)\n\tedt.SetText(\"some text\")\n\n\tbtn := winc.NewPushButton(panel)\n\tbtn.SetText(\"Button\")\n\tbtn.SetSize(100, 40)\n\tbtn.OnClick().Bind(func(e *winc.Event) {\n\t\tif edt.Visible() {\n\t\t\tedt.Hide()\n\t\t} else {\n\t\t\tedt.Show()\n\t\t}\n\t})\n\tbtn.SetResIcon(13)\n\n\tpanelDock.Dock(btn, winc.Top)\n\tpanelDock.Dock(edt, winc.Top)\n\tpanelDock.Dock(panelErr, winc.Top)\n\n\tdock.Dock(tree, winc.Left)\n\tdock.Dock(tabs, winc.Top)\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_docking/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_hello/main.go",
    "content": "package main\n\nimport (\n\t\"github.com/tadvi/winc\"\n)\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tmainWindow.SetSize(400, 300)\n\tmainWindow.SetText(\"Hello World Demo\")\n\n\t// Main window menu. Context menus on controls also available.\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.Shortcut{winc.ModControl, winc.KeyN})\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\t// Menu items can be disabled and checked.\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\twinc.MsgBoxOk(mainWindow, \"Cut\", \"Click event\")\n\t})\n\n\tedt := winc.NewEdit(mainWindow)\n\tedt.SetPos(10, 20)\n\t// Most Controls have default size unless SetSize is called.\n\tedt.SetText(\"edit text\")\n\n\tbtn := winc.NewPushButton(mainWindow)\n\tbtn.SetText(\"Show or Hide\")\n\tbtn.SetPos(40, 50)\n\tbtn.SetSize(100, 40)\n\tbtn.OnClick().Bind(func(e *winc.Event) {\n\t\tif edt.Visible() {\n\t\t\tedt.Hide()\n\t\t} else {\n\t\t\tedt.Show()\n\t\t}\n\t})\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop() // Must call to start event loop.\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n"
  },
  {
    "path": "examples/sample_image/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_image/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"cut click\")\n\t})\n\n\timlistTb := winc.NewImageList(16, 16)\n\timlistTb.AddResIcon(10)\n\timlistTb.AddResIcon(12)\n\timlistTb.AddResIcon(15)\n\n\ttoolbar := winc.NewToolbar(mainWindow)\n\ttoolbar.SetImageList(imlistTb)\n\taddBtn := toolbar.AddButton(\"Add\", 1)\n\ttoolbar.AddSeparator()\n\trunBtn := toolbar.AddButton(\"Run\", 2)\n\ttoolbar.Show()\n\n\trunBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"runBtn click\")\n\t})\n\n\tscroll := winc.NewScrollView(mainWindow)\n\timgv := winc.NewImageView(scroll)\n\tscroll.SetChild(imgv)\n\n\taddBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tif filePath, ok := winc.ShowOpenFileDlg(mainWindow,\n\t\t\t\"Select EDI X12 file\", \"All files (*.*)|*.*\", 0, \"\"); ok {\n\n\t\t\tif err := imgv.DrawImageFile(filePath); err != nil {\n\t\t\t\twinc.Errorf(mainWindow, \"Error: %s\", err)\n\t\t\t}\n\t\t\tscroll.Invalidate(true)\n\t\t}\n\t})\n\n\tdock.Dock(toolbar, winc.Top) // toolbars always dock to the top\n\tdock.Dock(scroll, winc.Fill)\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tdock.Update()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_image/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,add.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_imagebox/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_imagebox/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"cut click\")\n\t})\n\n\timlistTb := winc.NewImageList(16, 16)\n\timlistTb.AddResIcon(10)\n\timlistTb.AddResIcon(12)\n\timlistTb.AddResIcon(15)\n\n\ttoolbar := winc.NewToolbar(mainWindow)\n\ttoolbar.SetImageList(imlistTb)\n\taddBtn := toolbar.AddButton(\"Add\", 1)\n\n\ttoolbar.AddSeparator()\n\trunBtn := toolbar.AddButton(\"Run\", 2)\n\n\ttoolbar.Show()\n\n\trunBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"runBtn click\")\n\t})\n\n\tscroll := winc.NewScrollView(mainWindow)\n\timgv := winc.NewImageViewBox(scroll)\n\tscroll.SetChild(imgv)\n\n\taddBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tif filePath, ok := winc.ShowOpenFileDlg(mainWindow,\n\t\t\t\"Select EDI X12 file\", \"All files (*.*)|*.*\", 0, \"\"); ok {\n\n\t\t\tif err := imgv.DrawImageFile(filePath); err != nil {\n\t\t\t\twinc.Errorf(mainWindow, \"Error: %s\", err)\n\t\t\t}\n\t\t\tscroll.Invalidate(true)\n\t\t}\n\t})\n\n\tdock.Dock(toolbar, winc.Top) // toolbars always dock to the top\n\tdock.Dock(scroll, winc.Fill)\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tdock.Update()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_imagebox/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,add.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_listview/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_listview/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\ntype Item struct {\n\tT       []string\n\tchecked bool\n}\n\nfunc (item Item) Text() []string    { return item.T }\nfunc (item *Item) SetText(s string) { item.T[0] = s }\n\nfunc (item Item) Checked() bool            { return item.checked }\nfunc (item *Item) SetChecked(checked bool) { item.checked = checked }\nfunc (item Item) ImageIndex() int          { return 0 }\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tnone := winc.Shortcut{}\n\n\timlist := winc.NewImageList(16, 16)\n\timlist.AddResIcon(16)\n\timlist.AddResIcon(10)\n\timlist.AddResIcon(13)\n\n\tls := winc.NewListView(mainWindow)\n\tls.SetImageList(imlist)\n\tls.EnableEditLabels(false)\n\tls.SetCheckBoxes(true)\n\t//ls.EnableFullRowSelect(true)\n\t//ls.EnableHotTrack(true)\n\t//ls.EnableSortHeader(true)\n\t//ls.EnableSortAscending(true)\n\n\tls.AddColumn(\"One\", 120)\n\tls.AddColumn(\"Two\", 120)\n\tls.SetPos(10, 180)\n\tp1 := &Item{[]string{\"First Item\", \"A\"}, true}\n\tls.AddItem(p1)\n\tp2 := &Item{[]string{\"Second Item\", \"B\"}, true}\n\tls.AddItem(p2)\n\tp3 := &Item{[]string{\"Third Item\", \"C\"}, true}\n\tls.AddItem(p3)\n\tfor i := 0; i < 200; i++ {\n\t\tp4 := &Item{[]string{\"Fourth Item\", \"D\"}, false}\n\t\tls.AddItem(p4)\n\t}\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", none)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tdelMn := editMn.AddItem(\"Delete\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tdelAllMn := editMn.AddItem(\"Delete All\", none)\n\tmenu.Show()\n\n\tls.OnEndLabelEdit().Bind(func(e *winc.Event) {\n\t\tprintln(\"edited\", e)\n\t\t// acccept label edit event!\n\t\t//d := e.Data.(*winc.LabelEditEventData)\n\t\t//d.Item.SetText(d.Text)\n\t\t//fmt.Println(d.Item.Text())\n\t})\n\n\tdelMn.OnClick().Bind(func(e *winc.Event) {\n\t\titems := ls.SelectedItems()\n\t\tfor _, it := range items {\n\t\t\tfmt.Println(it)\n\t\t}\n\t})\n\n\tdelAllMn.OnClick().Bind(func(e *winc.Event) {\n\t\tls.DeleteAllItems()\n\t})\n\n\tls.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"onClick listview\")\n\t})\n\n\tdock.Dock(ls, winc.Fill)\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_listview/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_minimal/main.go",
    "content": "package main\n\nimport (\n\t\"github.com/tadvi/winc\"\n)\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tmainWindow.SetSize(400, 300)\n\tmainWindow.SetText(\"Hello World Demo\")\n\n\tedt := winc.NewEdit(mainWindow)\n\tedt.SetPos(10, 20)\n\t// Most Controls have default size unless SetSize is called.\n\tedt.SetText(\"edit text\")\n\n\tbtn := winc.NewPushButton(mainWindow)\n\tbtn.SetText(\"Show or Hide\")\n\tbtn.SetPos(40, 50)\n\tbtn.SetSize(100, 40)\n\tbtn.OnClick().Bind(func(e *winc.Event) {\n\t\tif edt.Visible() {\n\t\t\tedt.Hide()\n\t\t} else {\n\t\t\tedt.Show()\n\t\t}\n\t})\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop() // Must call to start event loop.\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n"
  },
  {
    "path": "examples/sample_scrollview/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_scrollview/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\t//edt.SetCaption(\"Got you !!!\")\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\ntype Item struct {\n\tT string\n}\n\nfunc (item Item) Text() string    { return item.T }\nfunc (item Item) ImageIndex() int { return 1 }\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\tmainWindow.SetLayout(dock)\n\n\tmainWindow.SetSize(540, 540)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"cut click\")\n\t})\n\n\timlist := winc.NewImageList(16, 16)\n\timlist.AddResIcon(10)\n\timlist.AddResIcon(12)\n\timlist.AddResIcon(15)\n\n\tscroll := winc.NewScrollView(mainWindow)\n\ttree := winc.NewTreeView(scroll)\n\tscroll.SetChild(&tree.ControlBase)\n\t//scroll.Show()\n\n\ttree.SetImageList(imlist)\n\ttree.SetPos(10, 80)\n\ttree.SetSize(800, 800)\n\tp := &Item{\"First Item\"}\n\ttree.InsertItem(p, nil, nil)\n\tsec := &Item{\"Second\"}\n\tif err := tree.InsertItem(sec, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := tree.InsertItem(&Item{\"Third\"}, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := tree.InsertItem(&Item{\"Fourth\"}, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tfor i := 0; i < 50; i++ {\n\t\tif err := tree.InsertItem(&Item{\"after second\"}, sec, nil); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\ttree.Expand(p)\n\ttree.OnCollapse().Bind(func(e *winc.Event) {\n\t\tprintln(\"collapse\")\n\t})\n\n\timlistTb := winc.NewImageList(16, 16)\n\timlistTb.AddResIcon(10)\n\timlistTb.AddResIcon(12)\n\timlistTb.AddResIcon(15)\n\n\ttoolbar := winc.NewToolbar(mainWindow)\n\ttoolbar.SetImageList(imlistTb)\n\taddBtn := toolbar.AddButton(\"Add\", 1)\n\ttoolbar.AddSeparator()\n\trunBtn := toolbar.AddButton(\"Run\", 2)\n\ttoolbar.Show()\n\n\trunBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"runBtn click\")\n\t})\n\n\taddBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"addBtn click\")\n\t})\n\n\tdock.Dock(toolbar, winc.Top) // toolbars always dock to the top\n\tdock.Dock(scroll, winc.Fill)\n\n\tmainWindow.Center()\n\tdock.Update()\n\tmainWindow.Show()\n\n\tmainWindow.OnClose().Bind(wndOnClose)\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_scrollview/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,add.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_slider/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_slider/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\t//mainWindow.SetLayout(dock)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"cut click\")\n\t})\n\n\timlistTb := winc.NewImageList(16, 16)\n\timlistTb.AddResIcon(10)\n\timlistTb.AddResIcon(12)\n\timlistTb.AddResIcon(15)\n\n\ttoolbar := winc.NewToolbar(mainWindow)\n\ttoolbar.SetImageList(imlistTb)\n\taddBtn := toolbar.AddButton(\"Add\", 1)\n\ttoolbar.AddSeparator()\n\trunBtn := toolbar.AddButton(\"Run Now Fast\", 2)\n\ttoolbar.Show()\n\n\trunBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"runBtn click\")\n\t})\n\n\tdock.Dock(toolbar, winc.Top) // toolbars always dock to the top\n\t//dock.Dock(tree, winc.Fill)\n\n\tslide := winc.NewSlider(mainWindow)\n\tslide.SetPos(10, 50)\n\tslide.OnScroll().Bind(func(e *winc.Event) {\n\t\tprintln(slide.Value())\n\t})\n\n\taddBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"addBtn click\")\n\t\tslide.SetValue(30)\n\t})\n\n\t//track.SetRange(0, 100)\n\t//track.SetValue(20)\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tdock.Update()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_slider/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,add.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_splitview/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_splitview/layout.json",
    "content": "{\"WindowState\":\"0 1 -1 -1 -1 -1 610 228 1310 828\",\"Controls\":[{\"X\":0,\"Y\":0,\"Width\":684,\"Height\":40},{\"X\":0,\"Y\":40,\"Width\":522,\"Height\":501},{\"X\":522,\"Y\":40,\"Width\":20,\"Height\":501},{\"X\":542,\"Y\":40,\"Width\":142,\"Height\":501}]}\n"
  },
  {
    "path": "examples/sample_splitview/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\t//edt.SetCaption(\"Got you !!!\")\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\t//none := winc.Shortcut{}\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tdelMn := editMn.AddItem(\"Delete\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tdelAllMn := editMn.AddItem(\"Delete All\", winc.NoShortcut)\n\tmenu.Show()\n\n\tdelMn.OnClick().Bind(func(e *winc.Event) {\n\t\tdlg := winc.NewDialog(mainWindow)\n\t\tdlg.Center()\n\t\tdlg.Show()\n\t})\n\n\tdelAllMn.OnClick().Bind(func(e *winc.Event) {\n\t\tdlg := winc.NewDialog(mainWindow)\n\t\tdlg.Center()\n\t\tdlg.Show()\n\t})\n\n\ttoolbar := winc.NewPanel(mainWindow)\n\ttoolbar.SetPos(0, 0)\n\ttoolbar.SetSize(100, 40)\n\n\tbtnRun := winc.NewIconButton(toolbar)\n\tbtnRun.SetText(\" Run\")\n\tbtnRun.SetPos(2, 2)\n\tbtnRun.SetSize(98, 38)\n\tbtnRun.SetResIcon(15)\n\n\tbtnRun.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"event OnClick\")\n\t})\n\n\t//tipRun := winc.NewToolTip(mainWindow)\n\t//tipRun.AddTool(btnRun, \"Run project\")\n\n\tbtnEdit := winc.NewPushButton(toolbar)\n\tbtnEdit.SetText(\" Edit\")\n\tbtnEdit.SetPos(102, 2)\n\tbtnEdit.SetSize(98, 38)\n\tbtnEdit.SetResIcon(18)\n\n\tleft := winc.NewMultiEdit(mainWindow)\n\tleft.SetPos(5, 5)\n\tright := winc.NewMultiEdit(mainWindow)\n\tright.SetPos(50, 100)\n\n\tsplit := winc.NewVResizer(mainWindow)\n\tsplit.SetControl(left, right, winc.Left, 150)\n\n\t// --- Add controls to Dock, LoadStateFile and Show window in this order\n\tmainWindow.Center()\n\tmainWindow.Show()\n\n\tdock := winc.NewSimpleDock(mainWindow)\n\t//mainWindow.SetLayout(dock)\n\tdock.Dock(toolbar, winc.Top)\n\tdock.Dock(left, winc.Left)\n\tdock.Dock(split, winc.Left)\n\tdock.Dock(right, winc.Fill)\n\t// if err := dock.LoadStateFile(\"layout.json\"); err != nil {\n\t// \tlog.Println(err)\n\t// }\n\n\tmainWindow.OnClose().Bind(func(e *winc.Event) {\n\t\tdock.SaveStateFile(\"layout.json\") // error gets ignored\n\t\twinc.Exit()\n\t})\n\n\tdock.Update()\n\n\twinc.RunMainLoop()\n\t// --- end of Dock and main window management\n\n}\n"
  },
  {
    "path": "examples/sample_splitview/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,add.ico,run.ico,edit.ico,error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_tab/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_tab/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\ntype Item struct {\n\tT       []string\n\tchecked bool\n}\n\nfunc (item Item) Text() []string    { return item.T }\nfunc (item *Item) SetText(s string) { item.T[0] = s }\n\nfunc (item Item) Checked() bool            { return item.checked }\nfunc (item *Item) SetChecked(checked bool) { item.checked = checked }\nfunc (item Item) ImageIndex() int          { return 0 }\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"cut click\")\n\t})\n\n\timlistTb := winc.NewImageList(16, 16)\n\timlistTb.AddResIcon(10)\n\timlistTb.AddResIcon(12)\n\timlistTb.AddResIcon(15)\n\n\t// --- Toolbar\n\ttoolbar := winc.NewToolbar(mainWindow)\n\ttoolbar.SetImageList(imlistTb)\n\taddBtn := toolbar.AddButton(\"Add\", 1)\n\ttoolbar.AddSeparator()\n\trunBtn := toolbar.AddButton(\"Run Now Fast\", 2)\n\ttoolbar.Show()\n\n\trunBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"runBtn click\")\n\t})\n\n\taddBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"addBtn click\")\n\t})\n\n\t// --- Tabs\n\ttabs := winc.NewTabView(mainWindow)\n\tpanel1 := tabs.AddPanel(\"First\")\n\tpanel2 := tabs.AddPanel(\"Second\")\n\tpanel3 := tabs.AddPanel(\"Third\")\n\tpanel4 := tabs.AddPanel(\"Fourth\")\n\n\tedt := winc.NewEdit(panel1)\n\tedt.SetPos(100, 10)\n\n\tedt2 := winc.NewEdit(panel2)\n\tedt2.SetPos(40, 10)\n\n\tbtn := winc.NewPushButton(panel3)\n\tbtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"click\")\n\t})\n\n\timlist := winc.NewImageList(16, 16)\n\timlist.AddResIcon(12)\n\n\tls := winc.NewListView(panel4)\n\tls.SetImageList(imlist)\n\tls.EnableEditLabels(false)\n\tls.SetCheckBoxes(true)\n\t//ls.EnableFullRowSelect(true)\n\t//ls.EnableHotTrack(true)\n\t//ls.EnableSortHeader(true)\n\t//ls.EnableSortAscending(true)\n\n\tls.AddColumn(\"One\", 120)\n\tls.AddColumn(\"Two\", 120)\n\tls.SetPos(10, 180)\n\tp1 := &Item{[]string{\"First Item\", \"A\"}, true}\n\tls.AddItem(p1)\n\tp2 := &Item{[]string{\"Second Item\", \"B\"}, true}\n\tls.AddItem(p2)\n\tp3 := &Item{[]string{\"Third Item\", \"C\"}, true}\n\tls.AddItem(p3)\n\tfor i := 0; i < 200; i++ {\n\t\tp4 := &Item{[]string{\"Fourth Item\", \"D\"}, false}\n\t\tls.AddItem(p4)\n\t}\n\n\t// --- Dock\n\tdock2 := winc.NewSimpleDock(panel4)\n\tdock2.Dock(ls, winc.Fill)\n\ttabs.SetCurrent(0)\n\n\tdock.Dock(toolbar, winc.Top)        // toolbars always dock to the top\n\tdock.Dock(tabs, winc.Top)           // tabs should prefer docking at the top\n\tdock.Dock(tabs.Panels(), winc.Fill) // tab panels dock just below tabs and fill area\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_tab/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,add.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "examples/sample_treeview/app.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n    <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n        <assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"*\" name=\"App\" type=\"win32\"/>\n        <dependency>\n            <dependentAssembly>\n                <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"*\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"/>\n            </dependentAssembly>\n        </dependency>\n    </assembly>\n"
  },
  {
    "path": "examples/sample_treeview/main.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc\"\n)\n\nfunc btnOnClick(arg *winc.Event) {\n\tfmt.Println(\"Button clicked\")\n}\n\nfunc wndOnClose(arg *winc.Event) {\n\twinc.Exit()\n}\n\ntype Item struct {\n\tT string\n}\n\nfunc (item Item) Text() string    { return item.T }\nfunc (item Item) ImageIndex() int { return 1 }\n\nfunc main() {\n\tmainWindow := winc.NewForm(nil)\n\tdock := winc.NewSimpleDock(mainWindow)\n\tmainWindow.SetLayout(dock)\n\n\tmainWindow.SetSize(700, 600)\n\tmainWindow.SetText(\"Controls Demo\")\n\n\tmenu := mainWindow.NewMenu()\n\tfileMn := menu.AddSubMenu(\"File\")\n\tfileMn.AddItem(\"New\", winc.NoShortcut)\n\teditMn := menu.AddSubMenu(\"Edit\")\n\tcutMn := editMn.AddItem(\"Cut\", winc.Shortcut{winc.ModControl, winc.KeyX})\n\tcopyMn := editMn.AddItem(\"Copy\", winc.NoShortcut)\n\tpasteMn := editMn.AddItem(\"Paste\", winc.NoShortcut)\n\tmenu.Show()\n\tcopyMn.SetCheckable(true)\n\tcopyMn.SetChecked(true)\n\tpasteMn.SetEnabled(false)\n\n\tcutMn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"cut click\")\n\t})\n\n\timlist := winc.NewImageList(16, 16)\n\timlist.AddResIcon(10)\n\timlist.AddResIcon(12)\n\timlist.AddResIcon(15)\n\n\ttree := winc.NewTreeView(mainWindow)\n\ttree.SetImageList(imlist)\n\ttree.SetPos(10, 80)\n\tp := &Item{\"First Item\"}\n\ttree.InsertItem(p, nil, nil)\n\tsec := &Item{\"Second\"}\n\tif err := tree.InsertItem(sec, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := tree.InsertItem(&Item{\"Third\"}, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := tree.InsertItem(&Item{\"Fourth\"}, p, nil); err != nil {\n\t\tpanic(err)\n\t}\n\tfor i := 0; i < 50; i++ {\n\t\tif err := tree.InsertItem(&Item{\"after second\"}, sec, nil); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\ttree.Expand(p)\n\ttree.OnCollapse().Bind(func(e *winc.Event) {\n\t\tprintln(\"collapse\")\n\t})\n\n\timlistTb := winc.NewImageList(16, 16)\n\timlistTb.AddResIcon(10)\n\timlistTb.AddResIcon(12)\n\timlistTb.AddResIcon(15)\n\n\ttoolbar := winc.NewToolbar(mainWindow)\n\ttoolbar.SetImageList(imlistTb)\n\taddBtn := toolbar.AddButton(\"Add\", 1)\n\ttoolbar.AddSeparator()\n\trunBtn := toolbar.AddButton(\"Run\", 2)\n\ttoolbar.Show()\n\n\trunBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"runBtn click\")\n\t})\n\n\taddBtn.OnClick().Bind(func(e *winc.Event) {\n\t\tprintln(\"addBtn click\")\n\t})\n\n\tdock.Dock(toolbar, winc.Top) // toolbars always dock to the top\n\tdock.Dock(tree, winc.Fill)\n\n\tmainWindow.Center()\n\tmainWindow.Show()\n\tdock.Update()\n\tmainWindow.OnClose().Bind(wndOnClose)\n\n\twinc.RunMainLoop()\n}\n"
  },
  {
    "path": "examples/sample_treeview/release.bat",
    "content": "rsrc -manifest app.manifest -ico=app.ico,add.ico,application_lightning.ico,application_edit.ico,application_error.ico -o rsrc.syso\ngo build -ldflags=\"-H windowsgui\"\n"
  },
  {
    "path": "font.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"syscall\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\nconst (\n\tFontBold      byte = 0x01\n\tFontItalic    byte = 0x02\n\tFontUnderline byte = 0x04\n\tFontStrikeOut byte = 0x08\n)\n\nfunc init() {\n\tDefaultFont = NewFont(\"MS Shell Dlg 2\", 8, 0)\n}\n\ntype Font struct {\n\thfont     w32.HFONT\n\tfamily    string\n\tpointSize int\n\tstyle     byte\n}\n\nfunc NewFont(family string, pointSize int, style byte) *Font {\n\tif style > FontBold|FontItalic|FontUnderline|FontStrikeOut {\n\t\tpanic(\"Invalid font style\")\n\t}\n\n\t//Retrive screen DPI\n\thDC := w32.GetDC(0)\n\tdefer w32.ReleaseDC(0, hDC)\n\tscreenDPIY := w32.GetDeviceCaps(hDC, w32.LOGPIXELSY)\n\n\tfont := Font{\n\t\tfamily:    family,\n\t\tpointSize: pointSize,\n\t\tstyle:     style,\n\t}\n\n\tfont.hfont = font.createForDPI(screenDPIY)\n\tif font.hfont == 0 {\n\t\tpanic(\"CreateFontIndirect failed\")\n\t}\n\n\treturn &font\n}\n\nfunc (fnt *Font) createForDPI(dpi int) w32.HFONT {\n\tvar lf w32.LOGFONT\n\n\tlf.Height = int32(-w32.MulDiv(fnt.pointSize, dpi, 72))\n\tif fnt.style&FontBold > 0 {\n\t\tlf.Weight = w32.FW_BOLD\n\t} else {\n\t\tlf.Weight = w32.FW_NORMAL\n\t}\n\tif fnt.style&FontItalic > 0 {\n\t\tlf.Italic = 1\n\t}\n\tif fnt.style&FontUnderline > 0 {\n\t\tlf.Underline = 1\n\t}\n\tif fnt.style&FontStrikeOut > 0 {\n\t\tlf.StrikeOut = 1\n\t}\n\tlf.CharSet = w32.DEFAULT_CHARSET\n\tlf.OutPrecision = w32.OUT_TT_PRECIS\n\tlf.ClipPrecision = w32.CLIP_DEFAULT_PRECIS\n\tlf.Quality = w32.CLEARTYPE_QUALITY\n\tlf.PitchAndFamily = w32.VARIABLE_PITCH | w32.FF_SWISS\n\n\tsrc := syscall.StringToUTF16(fnt.family)\n\tdest := lf.FaceName[:]\n\tcopy(dest, src)\n\n\treturn w32.CreateFontIndirect(&lf)\n}\n\nfunc (fnt *Font) GetHFONT() w32.HFONT {\n\treturn fnt.hfont\n}\n\nfunc (fnt *Font) Bold() bool {\n\treturn fnt.style&FontBold > 0\n}\n\nfunc (fnt *Font) Dispose() {\n\tif fnt.hfont != 0 {\n\t\tw32.DeleteObject(w32.HGDIOBJ(fnt.hfont))\n\t}\n}\n\nfunc (fnt *Font) Family() string {\n\treturn fnt.family\n}\n\nfunc (fnt *Font) Italic() bool {\n\treturn fnt.style&FontItalic > 0\n}\n\nfunc (fnt *Font) StrikeOut() bool {\n\treturn fnt.style&FontStrikeOut > 0\n}\n\nfunc (fnt *Font) Underline() bool {\n\treturn fnt.style&FontUnderline > 0\n}\n\nfunc (fnt *Font) Style() byte {\n\treturn fnt.style\n}\n"
  },
  {
    "path": "form.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n\t\"unsafe\"\n)\n\ntype LayoutManager interface {\n\tUpdate()\n}\n\n// A Form is main window of the application.\ntype Form struct {\n\tControlBase\n\n\tlayoutMng LayoutManager\n\n\t// Fullscreen / Unfullscreen\n\tisFullscreen            bool\n\tpreviousWindowStyle     uint32\n\tpreviousWindowPlacement w32.WINDOWPLACEMENT\n}\n\nfunc NewCustomForm(parent Controller, exStyle int, dwStyle uint) *Form {\n\tfm := new(Form)\n\n\tRegClassOnlyOnce(\"winc_Form\")\n\n\tfm.isForm = true\n\n\tif exStyle == 0 {\n\t\texStyle = w32.WS_EX_CONTROLPARENT | w32.WS_EX_APPWINDOW\n\t}\n\n\tif dwStyle == 0 {\n\t\tdwStyle = w32.WS_OVERLAPPEDWINDOW\n\t}\n\n\tfm.hwnd = CreateWindow(\"winc_Form\", parent, uint(exStyle), dwStyle)\n\tfm.parent = parent\n\n\t// this might fail if icon resource is not embedded in the binary\n\tif ico, err := NewIconFromResource(GetAppInstance(), uint16(AppIconID)); err == nil {\n\t\tfm.SetIcon(0, ico)\n\t}\n\n\t// This forces display of focus rectangles, as soon as the user starts to type.\n\tw32.SendMessage(fm.hwnd, w32.WM_CHANGEUISTATE, w32.UIS_INITIALIZE, 0)\n\n\tRegMsgHandler(fm)\n\n\tfm.SetFont(DefaultFont)\n\tfm.SetText(\"Form\")\n\treturn fm\n}\n\nfunc NewForm(parent Controller) *Form {\n\tfm := new(Form)\n\n\tRegClassOnlyOnce(\"winc_Form\")\n\n\tfm.isForm = true\n\tfm.hwnd = CreateWindow(\"winc_Form\", parent, w32.WS_EX_CONTROLPARENT|w32.WS_EX_APPWINDOW, w32.WS_OVERLAPPEDWINDOW)\n\tfm.parent = parent\n\n\t// this might fail if icon resource is not embedded in the binary\n\tif ico, err := NewIconFromResource(GetAppInstance(), uint16(AppIconID)); err == nil {\n\t\tfm.SetIcon(0, ico)\n\t}\n\n\t// This forces display of focus rectangles, as soon as the user starts to type.\n\tw32.SendMessage(fm.hwnd, w32.WM_CHANGEUISTATE, w32.UIS_INITIALIZE, 0)\n\n\tRegMsgHandler(fm)\n\n\tfm.SetFont(DefaultFont)\n\tfm.SetText(\"Form\")\n\treturn fm\n}\n\nfunc (fm *Form) SetLayout(mng LayoutManager) {\n\tfm.layoutMng = mng\n}\n\n// UpdateLayout refresh layout.\nfunc (fm *Form) UpdateLayout() {\n\tif fm.layoutMng != nil {\n\t\tfm.layoutMng.Update()\n\t}\n}\n\nfunc (fm *Form) NewMenu() *Menu {\n\thMenu := w32.CreateMenu()\n\tif hMenu == 0 {\n\t\tpanic(\"failed CreateMenu\")\n\t}\n\tm := &Menu{hMenu: hMenu, hwnd: fm.hwnd}\n\tif !w32.SetMenu(fm.hwnd, hMenu) {\n\t\tpanic(\"failed SetMenu\")\n\t}\n\treturn m\n}\n\nfunc (fm *Form) DisableIcon() {\n\twindowInfo := getWindowInfo(fm.hwnd)\n\tframeless := windowInfo.IsPopup()\n\tif frameless {\n\t\treturn\n\t}\n\texStyle := w32.GetWindowLong(fm.hwnd, w32.GWL_EXSTYLE)\n\tw32.SetWindowLong(fm.hwnd, w32.GWL_EXSTYLE, uint32(exStyle|w32.WS_EX_DLGMODALFRAME))\n\tw32.SetWindowPos(fm.hwnd, 0, 0, 0, 0, 0,\n\t\tuint(\n\t\t\tw32.SWP_FRAMECHANGED|\n\t\t\t\tw32.SWP_NOMOVE|\n\t\t\t\tw32.SWP_NOSIZE|\n\t\t\t\tw32.SWP_NOZORDER),\n\t)\n}\n\nfunc (fm *Form) Maximise() {\n\tw32.ShowWindow(fm.hwnd, w32.SW_MAXIMIZE)\n}\n\nfunc (fm *Form) Minimise() {\n\tw32.ShowWindow(fm.hwnd, w32.SW_MINIMIZE)\n}\n\nfunc (fm *Form) Restore() {\n\tw32.ShowWindow(fm.hwnd, w32.SW_RESTORE)\n}\n\n// Public methods\nfunc (fm *Form) Center() {\n\n\twindowInfo := getWindowInfo(fm.hwnd)\n\tframeless := windowInfo.IsPopup()\n\n\tinfo := getMonitorInfo(fm.hwnd)\n\tworkRect := info.RcWork\n\tscreenMiddleW := workRect.Left + (workRect.Right-workRect.Left)/2\n\tscreenMiddleH := workRect.Top + (workRect.Bottom-workRect.Top)/2\n\tvar winRect *w32.RECT\n\tif !frameless {\n\t\twinRect = w32.GetWindowRect(fm.hwnd)\n\t} else {\n\t\twinRect = w32.GetClientRect(fm.hwnd)\n\t}\n\twinWidth := winRect.Right - winRect.Left\n\twinHeight := winRect.Bottom - winRect.Top\n\twindowX := screenMiddleW - (winWidth / 2)\n\twindowY := screenMiddleH - (winHeight / 2)\n\tw32.SetWindowPos(fm.hwnd, w32.HWND_TOP, int(windowX), int(windowY), int(winWidth), int(winHeight), w32.SWP_NOSIZE)\n}\n\nfunc (fm *Form) Fullscreen() {\n\tif fm.isFullscreen {\n\t\treturn\n\t}\n\n\tfm.previousWindowStyle = uint32(w32.GetWindowLongPtr(fm.hwnd, w32.GWL_STYLE))\n\tmonitor := w32.MonitorFromWindow(fm.hwnd, w32.MONITOR_DEFAULTTOPRIMARY)\n\tvar monitorInfo w32.MONITORINFO\n\tmonitorInfo.CbSize = uint32(unsafe.Sizeof(monitorInfo))\n\tif !w32.GetMonitorInfo(monitor, &monitorInfo) {\n\t\treturn\n\t}\n\tif !w32.GetWindowPlacement(fm.hwnd, &fm.previousWindowPlacement) {\n\t\treturn\n\t}\n\tw32.SetWindowLong(fm.hwnd, w32.GWL_STYLE, fm.previousWindowStyle & ^uint32(w32.WS_OVERLAPPEDWINDOW))\n\tw32.SetWindowPos(fm.hwnd, w32.HWND_TOP,\n\t\tint(monitorInfo.RcMonitor.Left),\n\t\tint(monitorInfo.RcMonitor.Top),\n\t\tint(monitorInfo.RcMonitor.Right-monitorInfo.RcMonitor.Left),\n\t\tint(monitorInfo.RcMonitor.Bottom-monitorInfo.RcMonitor.Top),\n\t\tw32.SWP_NOOWNERZORDER|w32.SWP_FRAMECHANGED)\n\tfm.isFullscreen = true\n}\n\nfunc (fm *Form) UnFullscreen() {\n\tif !fm.isFullscreen {\n\t\treturn\n\t}\n\tw32.SetWindowLong(fm.hwnd, w32.GWL_STYLE, fm.previousWindowStyle)\n\tw32.SetWindowPlacement(fm.hwnd, &fm.previousWindowPlacement)\n\tw32.SetWindowPos(fm.hwnd, 0, 0, 0, 0, 0,\n\t\tw32.SWP_NOMOVE|w32.SWP_NOSIZE|w32.SWP_NOZORDER|w32.SWP_NOOWNERZORDER|w32.SWP_FRAMECHANGED)\n\tfm.isFullscreen = false\n}\n\n// IconType: 1 - ICON_BIG; 0 - ICON_SMALL\nfunc (fm *Form) SetIcon(iconType int, icon *Icon) {\n\tif iconType > 1 {\n\t\tpanic(\"IconType is invalid\")\n\t}\n\tw32.SendMessage(fm.hwnd, w32.WM_SETICON, uintptr(iconType), uintptr(icon.Handle()))\n}\n\nfunc (fm *Form) EnableMaxButton(b bool) {\n\tToggleStyle(fm.hwnd, b, w32.WS_MAXIMIZEBOX)\n}\n\nfunc (fm *Form) EnableMinButton(b bool) {\n\tToggleStyle(fm.hwnd, b, w32.WS_MINIMIZEBOX)\n}\n\nfunc (fm *Form) EnableSizable(b bool) {\n\tToggleStyle(fm.hwnd, b, w32.WS_THICKFRAME)\n}\n\nfunc (fm *Form) EnableDragMove(_ bool) {\n\t//fm.isDragMove = b\n}\n\nfunc (fm *Form) EnableTopMost(b bool) {\n\ttag := w32.HWND_NOTOPMOST\n\tif b {\n\t\ttag = w32.HWND_TOPMOST\n\t}\n\tw32.SetWindowPos(fm.hwnd, tag, 0, 0, 0, 0, w32.SWP_NOMOVE|w32.SWP_NOSIZE)\n}\n\nfunc (fm *Form) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\n\tswitch msg {\n\tcase w32.WM_COMMAND:\n\t\tif lparam == 0 && w32.HIWORD(uint32(wparam)) == 0 {\n\t\t\t// Menu support.\n\t\t\tactionID := uint16(w32.LOWORD(uint32(wparam)))\n\t\t\tif action, ok := actionsByID[actionID]; ok {\n\t\t\t\taction.onClick.Fire(NewEvent(fm, nil))\n\t\t\t}\n\t\t}\n\tcase w32.WM_KEYDOWN:\n\t\t// Accelerator support.\n\t\tkey := Key(wparam)\n\t\tif uint32(lparam)>>30 == 0 {\n\t\t\t// Using TranslateAccelerators refused to work, so we handle them\n\t\t\t// ourselves, at least for now.\n\t\t\tshortcut := Shortcut{ModifiersDown(), key}\n\t\t\tif action, ok := shortcut2Action[shortcut]; ok {\n\t\t\t\tif action.Enabled() {\n\t\t\t\t\taction.onClick.Fire(NewEvent(fm, nil))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\tcase w32.WM_CLOSE:\n\t\treturn 0\n\tcase w32.WM_DESTROY:\n\t\tw32.PostQuitMessage(0)\n\t\treturn 0\n\n\tcase w32.WM_SIZE, w32.WM_PAINT:\n\t\tif fm.layoutMng != nil {\n\t\t\tfm.layoutMng.Update()\n\t\t}\n\tcase w32.WM_GETMINMAXINFO:\n\t\tif fm.minWidth != 0 || fm.maxWidth != 0 || fm.minHeight != 0 || fm.maxHeight != 0 {\n\t\t\tdpix, dpiy := fm.GetWindowDPI()\n\n\t\t\tDPIScaleX := dpix / 96.0\n\t\t\tDPIScaleY := dpiy / 96.0\n\n\t\t\tmmi := (*w32.MINMAXINFO)(unsafe.Pointer(lparam))\n\t\t\tif fm.minWidth > 0 && fm.minHeight > 0 {\n\t\t\t\tmmi.PtMinTrackSize.X = int32(fm.minWidth * int(DPIScaleX))\n\t\t\t\tmmi.PtMinTrackSize.Y = int32(fm.minHeight * int(DPIScaleY))\n\t\t\t}\n\t\t\tif fm.maxWidth > 0 && fm.maxHeight > 0 {\n\t\t\t\tmmi.PtMaxSize.X = int32(fm.maxWidth * int(DPIScaleX))\n\t\t\t\tmmi.PtMaxSize.Y = int32(fm.maxHeight * int(DPIScaleY))\n\t\t\t\tmmi.PtMaxTrackSize.X = int32(fm.maxWidth * int(DPIScaleX))\n\t\t\t\tmmi.PtMaxTrackSize.Y = int32(fm.maxHeight * int(DPIScaleY))\n\t\t\t}\n\t\t\treturn 0\n\t\t}\n\t}\n\n\treturn w32.DefWindowProc(fm.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "globalvars.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"syscall\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\n//Private global variables.\nvar (\n\tgAppInstance        w32.HINSTANCE\n\tgControllerRegistry map[w32.HWND]Controller\n\tgRegisteredClasses  []string\n)\n\n//Public global variables.\nvar (\n\tGeneralWndprocCallBack = syscall.NewCallback(generalWndProc)\n\tDefaultFont            *Font\n)\n"
  },
  {
    "path": "go.mod",
    "content": "module github.com/tadvi/winc\n\ngo 1.12\n"
  },
  {
    "path": "icon.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"syscall\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Icon struct {\n\thandle w32.HICON\n}\n\nfunc NewIconFromFile(path string) (*Icon, error) {\n\tico := new(Icon)\n\tvar err error\n\tif ico.handle = w32.LoadIcon(0, syscall.StringToUTF16Ptr(path)); ico.handle == 0 {\n\t\terr = errors.New(fmt.Sprintf(\"Cannot load icon from %s\", path))\n\t}\n\treturn ico, err\n}\n\nfunc NewIconFromResource(instance w32.HINSTANCE, resId uint16) (*Icon, error) {\n\tico := new(Icon)\n\tvar err error\n\tif ico.handle = w32.LoadIcon(instance, w32.MakeIntResource(resId)); ico.handle == 0 {\n\t\terr = errors.New(fmt.Sprintf(\"Cannot load icon from resource with id %v\", resId))\n\t}\n\treturn ico, err\n}\n\nfunc ExtractIcon(fileName string, index int) (*Icon, error) {\n\tico := new(Icon)\n\tvar err error\n\tif ico.handle = w32.ExtractIcon(fileName, index); ico.handle == 0 || ico.handle == 1 {\n\t\terr = errors.New(fmt.Sprintf(\"Cannot extract icon from %s at index %v\", fileName, index))\n\t}\n\treturn ico, err\n}\n\nfunc (ic *Icon) Destroy() bool {\n\treturn w32.DestroyIcon(ic.handle)\n}\n\nfunc (ic *Icon) Handle() w32.HICON {\n\treturn ic.handle\n}\n"
  },
  {
    "path": "imagelist.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype ImageList struct {\n\thandle w32.HIMAGELIST\n}\n\nfunc NewImageList(cx, cy int) *ImageList {\n\treturn newImageList(cx, cy, w32.ILC_COLOR32, 0, 0)\n}\n\nfunc newImageList(cx, cy int, flags uint, cInitial, cGrow int) *ImageList {\n\timgl := new(ImageList)\n\timgl.handle = w32.ImageList_Create(cx, cy, flags, cInitial, cGrow)\n\treturn imgl\n}\n\nfunc (im *ImageList) Handle() w32.HIMAGELIST {\n\treturn im.handle\n}\n\nfunc (im *ImageList) Destroy() bool {\n\treturn w32.ImageList_Destroy(im.handle)\n}\n\nfunc (im *ImageList) SetImageCount(uNewCount uint) bool {\n\treturn w32.ImageList_SetImageCount(im.handle, uNewCount)\n}\n\nfunc (im *ImageList) ImageCount() int {\n\treturn w32.ImageList_GetImageCount(im.handle)\n}\n\nfunc (im *ImageList) AddIcon(icon *Icon) int {\n\treturn w32.ImageList_AddIcon(im.handle, icon.Handle())\n}\n\nfunc (im *ImageList) AddResIcon(iconID uint16) {\n\tif ico, err := NewIconFromResource(GetAppInstance(), iconID); err == nil {\n\t\tim.AddIcon(ico)\n\t\treturn\n\t}\n\tpanic(fmt.Sprintf(\"missing icon with icon ID: %d\", iconID))\n}\n\nfunc (im *ImageList) RemoveAll() bool {\n\treturn w32.ImageList_RemoveAll(im.handle)\n}\n\nfunc (im *ImageList) Remove(i int) bool {\n\treturn w32.ImageList_Remove(im.handle, i)\n}\n"
  },
  {
    "path": "imageview.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport \"github.com/tadvi/winc/w32\"\n\ntype ImageView struct {\n\tControlBase\n\n\tbmp *Bitmap\n}\n\nfunc NewImageView(parent Controller) *ImageView {\n\tiv := new(ImageView)\n\n\tiv.InitWindow(\"winc_ImageView\", parent, w32.WS_EX_CONTROLPARENT, w32.WS_CHILD|w32.WS_VISIBLE)\n\tRegMsgHandler(iv)\n\n\tiv.SetFont(DefaultFont)\n\tiv.SetText(\"\")\n\tiv.SetSize(200, 65)\n\treturn iv\n}\n\nfunc (iv *ImageView) DrawImageFile(filepath string) error {\n\tbmp, err := NewBitmapFromFile(filepath, RGB(255, 255, 0))\n\tif err != nil {\n\t\treturn err\n\t}\n\tiv.bmp = bmp\n\treturn nil\n}\n\nfunc (iv *ImageView) DrawImage(bmp *Bitmap) {\n\tiv.bmp = bmp\n}\n\nfunc (iv *ImageView) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_SIZE, w32.WM_SIZING:\n\t\tiv.Invalidate(true)\n\n\tcase w32.WM_ERASEBKGND:\n\t\treturn 1 // important\n\n\tcase w32.WM_PAINT:\n\t\tif iv.bmp != nil {\n\t\t\tcanvas := NewCanvasFromHwnd(iv.hwnd)\n\t\t\tdefer canvas.Dispose()\n\t\t\tiv.SetSize(iv.bmp.Size())\n\t\t\tcanvas.DrawBitmap(iv.bmp, 0, 0)\n\t\t}\n\t}\n\treturn w32.DefWindowProc(iv.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "imageviewbox.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype direction int\n\nconst (\n\tDirNone direction = iota\n\tDirX\n\tDirY\n\tDirX2\n\tDirY2\n)\n\nvar ImageBoxPen = NewPen(w32.PS_GEOMETRIC, 2, NewSolidColorBrush(RGB(140, 140, 220)))\nvar ImageBoxHiPen = NewPen(w32.PS_GEOMETRIC, 2, NewSolidColorBrush(RGB(220, 140, 140)))\nvar ImageBoxMarkBrush = NewSolidColorBrush(RGB(40, 40, 40))\nvar ImageBoxMarkPen = NewPen(w32.PS_GEOMETRIC, 2, ImageBoxMarkBrush)\n\ntype ImageBox struct {\n\tName         string\n\tType         int\n\tX, Y, X2, Y2 int\n\n\tunderMouse bool // dynamic value\n}\n\nfunc (b *ImageBox) Rect() *Rect {\n\treturn NewRect(b.X, b.Y, b.X2, b.Y2)\n}\n\n// ImageViewBox is image view with boxes.\ntype ImageViewBox struct {\n\tControlBase\n\n\tbmp       *Bitmap\n\tmouseLeft bool\n\tmodified  bool // used by GUI to see if any image box modified\n\n\tadd bool\n\n\tBoxes   []*ImageBox // might be persisted to file\n\tdragBox *ImageBox\n\tselBox  *ImageBox\n\n\tdragStartX, dragStartY int\n\tresize                 direction\n\n\tonSelectedChange EventManager\n\tonAdd            EventManager\n\tonModify         EventManager\n}\n\nfunc NewImageViewBox(parent Controller) *ImageViewBox {\n\tiv := new(ImageViewBox)\n\n\tiv.InitWindow(\"winc_ImageViewBox\", parent, w32.WS_EX_CONTROLPARENT, w32.WS_CHILD|w32.WS_VISIBLE)\n\tRegMsgHandler(iv)\n\n\tiv.SetFont(DefaultFont)\n\tiv.SetText(\"\")\n\tiv.SetSize(200, 65)\n\n\treturn iv\n}\n\nfunc (iv *ImageViewBox) OnSelectedChange() *EventManager {\n\treturn &iv.onSelectedChange\n}\n\nfunc (iv *ImageViewBox) OnAdd() *EventManager {\n\treturn &iv.onAdd\n}\n\nfunc (iv *ImageViewBox) OnModify() *EventManager {\n\treturn &iv.onModify\n}\n\nfunc (iv *ImageViewBox) IsModified() bool          { return iv.modified }\nfunc (iv *ImageViewBox) SetModified(modified bool) { iv.modified = modified }\nfunc (iv *ImageViewBox) IsLoaded() bool            { return iv.bmp != nil }\nfunc (iv *ImageViewBox) AddMode() bool             { return iv.add }\nfunc (iv *ImageViewBox) SetAddMode(add bool)       { iv.add = add }\nfunc (iv *ImageViewBox) HasSelected() bool         { return iv.selBox != nil && iv.bmp != nil }\n\nfunc (iv *ImageViewBox) wasModified() {\n\tiv.modified = true\n\tiv.onModify.Fire(NewEvent(iv, nil))\n}\n\nfunc (iv *ImageViewBox) DeleteSelected() {\n\tif iv.selBox != nil {\n\t\tfor i, b := range iv.Boxes {\n\t\t\tif b == iv.selBox {\n\t\t\t\tiv.Boxes = append(iv.Boxes[:i], iv.Boxes[i+1:]...)\n\t\t\t\tiv.selBox = nil\n\t\t\t\tiv.Invalidate(true)\n\t\t\t\tiv.wasModified()\n\t\t\t\tiv.onSelectedChange.Fire(NewEvent(iv, nil))\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc (iv *ImageViewBox) NameSelected() string {\n\tif iv.selBox != nil {\n\t\treturn iv.selBox.Name\n\t}\n\treturn \"\"\n}\n\nfunc (iv *ImageViewBox) SetNameSelected(name string) {\n\tif iv.selBox != nil {\n\t\tiv.selBox.Name = name\n\t\tiv.wasModified()\n\t}\n}\n\nfunc (iv *ImageViewBox) TypeSelected() int {\n\tif iv.selBox != nil {\n\t\treturn iv.selBox.Type\n\t}\n\treturn 0\n}\n\nfunc (iv *ImageViewBox) SetTypeSelected(typ int) {\n\tif iv.selBox != nil {\n\t\tiv.selBox.Type = typ\n\t\tiv.wasModified()\n\t}\n}\n\nfunc (ib *ImageViewBox) updateHighlight(x, y int) bool {\n\tvar changed bool\n\tfor _, b := range ib.Boxes {\n\t\tunder := x >= b.X && y >= b.Y && x <= b.X2 && y <= b.Y2\n\t\tif b.underMouse != under {\n\t\t\tchanged = true\n\t\t}\n\t\tb.underMouse = under\n\t\t/*if sel {\n\t\t\tbreak // allow only one to be underMouse\n\t\t}*/\n\t}\n\treturn changed\n}\n\nfunc (ib *ImageViewBox) isUnderMouse(x, y int) *ImageBox {\n\tfor _, b := range ib.Boxes {\n\t\tif x >= b.X && y >= b.Y && x <= b.X2 && y <= b.Y2 {\n\t\t\treturn b\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (ib *ImageViewBox) getCursor(x, y int) uint16 {\n\tfor _, b := range ib.Boxes {\n\t\tswitch d := ib.resizingDirection(b, x, y); d {\n\t\tcase DirY, DirY2:\n\t\t\treturn w32.IDC_SIZENS\n\t\tcase DirX, DirX2:\n\t\t\treturn w32.IDC_SIZEWE\n\t\t}\n\t\t// w32.IDC_SIZEALL or w32.IDC_SIZE for resize\n\t}\n\treturn w32.IDC_ARROW\n}\n\nfunc (ib *ImageViewBox) resizingDirection(b *ImageBox, x, y int) direction {\n\tif b == nil {\n\t\treturn DirNone\n\t}\n\tswitch {\n\tcase b.X == x || b.X == x-1 || b.X == x+1:\n\t\treturn DirX\n\tcase b.X2 == x || b.X2 == x-1 || b.X2 == x+1:\n\t\treturn DirX2\n\tcase b.Y == y || b.Y == y-1 || b.Y == y+1:\n\t\treturn DirY\n\tcase b.Y2 == y || b.Y2 == y-1 || b.Y2 == y+1:\n\t\treturn DirY2\n\t}\n\treturn DirNone\n}\n\nfunc (ib *ImageViewBox) resizeToDirection(b *ImageBox, x, y int) {\n\tswitch ib.resize {\n\tcase DirX:\n\t\tb.X = x\n\tcase DirY:\n\t\tb.Y = y\n\tcase DirX2:\n\t\tb.X2 = x\n\tcase DirY2:\n\t\tb.Y2 = y\n\t}\n}\n\nfunc (ib *ImageViewBox) drag(b *ImageBox, x, y int) {\n\tw, h := b.X2-b.X, b.Y2-b.Y\n\n\tnx := ib.dragStartX - b.X\n\tny := ib.dragStartY - b.Y\n\n\tb.X = x - nx\n\tb.Y = y - ny\n\tb.X2 = b.X + w\n\tb.Y2 = b.Y + h\n\n\tib.dragStartX, ib.dragStartY = x, y\n}\n\nfunc (iv *ImageViewBox) DrawImageFile(filepath string) (err error) {\n\tiv.bmp, err = NewBitmapFromFile(filepath, RGB(255, 255, 0))\n\tiv.selBox = nil\n\tiv.modified = false\n\tiv.onSelectedChange.Fire(NewEvent(iv, nil))\n\tiv.onModify.Fire(NewEvent(iv, nil))\n\treturn\n}\n\nfunc (iv *ImageViewBox) DrawImage(bmp *Bitmap) {\n\tiv.bmp = bmp\n\tiv.selBox = nil\n\tiv.modified = false\n\tiv.onSelectedChange.Fire(NewEvent(iv, nil))\n\tiv.onModify.Fire(NewEvent(iv, nil))\n}\n\nfunc (iv *ImageViewBox) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_SIZE, w32.WM_SIZING:\n\t\tiv.Invalidate(true)\n\n\tcase w32.WM_ERASEBKGND:\n\t\treturn 1 // important\n\n\tcase w32.WM_CREATE:\n\t\tinternalTrackMouseEvent(iv.hwnd)\n\n\tcase w32.WM_PAINT:\n\t\tif iv.bmp != nil {\n\t\t\tcanvas := NewCanvasFromHwnd(iv.hwnd)\n\t\t\tdefer canvas.Dispose()\n\t\t\tiv.SetSize(iv.bmp.Size())\n\t\t\tcanvas.DrawBitmap(iv.bmp, 0, 0)\n\n\t\t\tfor _, b := range iv.Boxes {\n\t\t\t\t// old code used NewSystemColorBrush(w32.COLOR_BTNFACE) w32.COLOR_WINDOW\n\t\t\t\tpen := ImageBoxPen\n\t\t\t\tif b.underMouse {\n\t\t\t\t\tpen = ImageBoxHiPen\n\t\t\t\t}\n\t\t\t\tcanvas.DrawRect(b.Rect(), pen)\n\n\t\t\t\tif b == iv.selBox {\n\t\t\t\t\tx1 := []int{b.X, b.X2, b.X2, b.X}\n\t\t\t\t\ty1 := []int{b.Y, b.Y, b.Y2, b.Y2}\n\n\t\t\t\t\tfor i := 0; i < len(x1); i++ {\n\t\t\t\t\t\tr := NewRect(x1[i]-2, y1[i]-2, x1[i]+2, y1[i]+2)\n\t\t\t\t\t\tcanvas.DrawFillRect(r, ImageBoxMarkPen, ImageBoxMarkBrush)\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\tcase w32.WM_MOUSEMOVE:\n\t\tx, y := genPoint(lparam)\n\n\t\tif iv.dragBox != nil {\n\t\t\tif iv.resize == DirNone {\n\t\t\t\tiv.drag(iv.dragBox, x, y)\n\t\t\t\tiv.wasModified()\n\t\t\t} else {\n\t\t\t\tiv.resizeToDirection(iv.dragBox, x, y)\n\t\t\t\tiv.wasModified()\n\t\t\t}\n\t\t\tiv.Invalidate(true)\n\n\t\t} else {\n\t\t\tif !iv.add {\n\t\t\t\tw32.SetCursor(w32.LoadCursor(0, w32.MakeIntResource(iv.getCursor(x, y))))\n\t\t\t}\n\t\t\t//  do not call repaint if underMouse item did not change.\n\t\t\tif iv.updateHighlight(x, y) {\n\t\t\t\tiv.Invalidate(true)\n\t\t\t}\n\t\t}\n\n\t\tif iv.mouseLeft {\n\t\t\tinternalTrackMouseEvent(iv.hwnd)\n\t\t\tiv.mouseLeft = false\n\t\t}\n\n\tcase w32.WM_MOUSELEAVE:\n\t\tiv.dragBox = nil\n\t\tiv.mouseLeft = true\n\t\tiv.updateHighlight(-1, -1)\n\t\tiv.Invalidate(true)\n\n\tcase w32.WM_LBUTTONUP:\n\t\tiv.dragBox = nil\n\n\tcase w32.WM_LBUTTONDOWN:\n\t\tx, y := genPoint(lparam)\n\t\tif iv.add {\n\t\t\tnow := time.Now()\n\t\t\ts := fmt.Sprintf(\"field%s\", now.Format(\"020405\"))\n\t\t\tb := &ImageBox{Name: s, underMouse: true, X: x, Y: y, X2: x + 150, Y2: y + 30}\n\t\t\tiv.Boxes = append(iv.Boxes, b)\n\t\t\tiv.selBox = b\n\t\t\tiv.wasModified()\n\t\t\tiv.onAdd.Fire(NewEvent(iv, nil))\n\t\t} else {\n\t\t\tiv.dragBox = iv.isUnderMouse(x, y)\n\t\t\tiv.selBox = iv.dragBox\n\t\t\tiv.dragStartX, iv.dragStartY = x, y\n\t\t\tiv.resize = iv.resizingDirection(iv.dragBox, x, y)\n\t\t}\n\t\tiv.Invalidate(true)\n\t\tiv.onSelectedChange.Fire(NewEvent(iv, nil))\n\n\tcase w32.WM_RBUTTONDOWN:\n\n\t}\n\treturn w32.DefWindowProc(iv.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "init.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\nfunc init() {\n\tgControllerRegistry = make(map[w32.HWND]Controller)\n\tgRegisteredClasses = make([]string, 0)\n\n\tvar si w32.GdiplusStartupInput\n\tsi.GdiplusVersion = 1\n\tw32.GdiplusStartup(&si, nil)\n}\n"
  },
  {
    "path": "keyboard.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"bytes\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Key uint16\n\nfunc (k Key) String() string {\n\treturn key2string[k]\n}\n\nconst (\n\tKeyLButton           Key = w32.VK_LBUTTON\n\tKeyRButton           Key = w32.VK_RBUTTON\n\tKeyCancel            Key = w32.VK_CANCEL\n\tKeyMButton           Key = w32.VK_MBUTTON\n\tKeyXButton1          Key = w32.VK_XBUTTON1\n\tKeyXButton2          Key = w32.VK_XBUTTON2\n\tKeyBack              Key = w32.VK_BACK\n\tKeyTab               Key = w32.VK_TAB\n\tKeyClear             Key = w32.VK_CLEAR\n\tKeyReturn            Key = w32.VK_RETURN\n\tKeyShift             Key = w32.VK_SHIFT\n\tKeyControl           Key = w32.VK_CONTROL\n\tKeyAlt               Key = w32.VK_MENU\n\tKeyMenu              Key = w32.VK_MENU\n\tKeyPause             Key = w32.VK_PAUSE\n\tKeyCapital           Key = w32.VK_CAPITAL\n\tKeyKana              Key = w32.VK_KANA\n\tKeyHangul            Key = w32.VK_HANGUL\n\tKeyJunja             Key = w32.VK_JUNJA\n\tKeyFinal             Key = w32.VK_FINAL\n\tKeyHanja             Key = w32.VK_HANJA\n\tKeyKanji             Key = w32.VK_KANJI\n\tKeyEscape            Key = w32.VK_ESCAPE\n\tKeyConvert           Key = w32.VK_CONVERT\n\tKeyNonconvert        Key = w32.VK_NONCONVERT\n\tKeyAccept            Key = w32.VK_ACCEPT\n\tKeyModeChange        Key = w32.VK_MODECHANGE\n\tKeySpace             Key = w32.VK_SPACE\n\tKeyPrior             Key = w32.VK_PRIOR\n\tKeyNext              Key = w32.VK_NEXT\n\tKeyEnd               Key = w32.VK_END\n\tKeyHome              Key = w32.VK_HOME\n\tKeyLeft              Key = w32.VK_LEFT\n\tKeyUp                Key = w32.VK_UP\n\tKeyRight             Key = w32.VK_RIGHT\n\tKeyDown              Key = w32.VK_DOWN\n\tKeySelect            Key = w32.VK_SELECT\n\tKeyPrint             Key = w32.VK_PRINT\n\tKeyExecute           Key = w32.VK_EXECUTE\n\tKeySnapshot          Key = w32.VK_SNAPSHOT\n\tKeyInsert            Key = w32.VK_INSERT\n\tKeyDelete            Key = w32.VK_DELETE\n\tKeyHelp              Key = w32.VK_HELP\n\tKey0                 Key = 0x30\n\tKey1                 Key = 0x31\n\tKey2                 Key = 0x32\n\tKey3                 Key = 0x33\n\tKey4                 Key = 0x34\n\tKey5                 Key = 0x35\n\tKey6                 Key = 0x36\n\tKey7                 Key = 0x37\n\tKey8                 Key = 0x38\n\tKey9                 Key = 0x39\n\tKeyA                 Key = 0x41\n\tKeyB                 Key = 0x42\n\tKeyC                 Key = 0x43\n\tKeyD                 Key = 0x44\n\tKeyE                 Key = 0x45\n\tKeyF                 Key = 0x46\n\tKeyG                 Key = 0x47\n\tKeyH                 Key = 0x48\n\tKeyI                 Key = 0x49\n\tKeyJ                 Key = 0x4A\n\tKeyK                 Key = 0x4B\n\tKeyL                 Key = 0x4C\n\tKeyM                 Key = 0x4D\n\tKeyN                 Key = 0x4E\n\tKeyO                 Key = 0x4F\n\tKeyP                 Key = 0x50\n\tKeyQ                 Key = 0x51\n\tKeyR                 Key = 0x52\n\tKeyS                 Key = 0x53\n\tKeyT                 Key = 0x54\n\tKeyU                 Key = 0x55\n\tKeyV                 Key = 0x56\n\tKeyW                 Key = 0x57\n\tKeyX                 Key = 0x58\n\tKeyY                 Key = 0x59\n\tKeyZ                 Key = 0x5A\n\tKeyLWIN              Key = w32.VK_LWIN\n\tKeyRWIN              Key = w32.VK_RWIN\n\tKeyApps              Key = w32.VK_APPS\n\tKeySleep             Key = w32.VK_SLEEP\n\tKeyNumpad0           Key = w32.VK_NUMPAD0\n\tKeyNumpad1           Key = w32.VK_NUMPAD1\n\tKeyNumpad2           Key = w32.VK_NUMPAD2\n\tKeyNumpad3           Key = w32.VK_NUMPAD3\n\tKeyNumpad4           Key = w32.VK_NUMPAD4\n\tKeyNumpad5           Key = w32.VK_NUMPAD5\n\tKeyNumpad6           Key = w32.VK_NUMPAD6\n\tKeyNumpad7           Key = w32.VK_NUMPAD7\n\tKeyNumpad8           Key = w32.VK_NUMPAD8\n\tKeyNumpad9           Key = w32.VK_NUMPAD9\n\tKeyMultiply          Key = w32.VK_MULTIPLY\n\tKeyAdd               Key = w32.VK_ADD\n\tKeySeparator         Key = w32.VK_SEPARATOR\n\tKeySubtract          Key = w32.VK_SUBTRACT\n\tKeyDecimal           Key = w32.VK_DECIMAL\n\tKeyDivide            Key = w32.VK_DIVIDE\n\tKeyF1                Key = w32.VK_F1\n\tKeyF2                Key = w32.VK_F2\n\tKeyF3                Key = w32.VK_F3\n\tKeyF4                Key = w32.VK_F4\n\tKeyF5                Key = w32.VK_F5\n\tKeyF6                Key = w32.VK_F6\n\tKeyF7                Key = w32.VK_F7\n\tKeyF8                Key = w32.VK_F8\n\tKeyF9                Key = w32.VK_F9\n\tKeyF10               Key = w32.VK_F10\n\tKeyF11               Key = w32.VK_F11\n\tKeyF12               Key = w32.VK_F12\n\tKeyF13               Key = w32.VK_F13\n\tKeyF14               Key = w32.VK_F14\n\tKeyF15               Key = w32.VK_F15\n\tKeyF16               Key = w32.VK_F16\n\tKeyF17               Key = w32.VK_F17\n\tKeyF18               Key = w32.VK_F18\n\tKeyF19               Key = w32.VK_F19\n\tKeyF20               Key = w32.VK_F20\n\tKeyF21               Key = w32.VK_F21\n\tKeyF22               Key = w32.VK_F22\n\tKeyF23               Key = w32.VK_F23\n\tKeyF24               Key = w32.VK_F24\n\tKeyNumlock           Key = w32.VK_NUMLOCK\n\tKeyScroll            Key = w32.VK_SCROLL\n\tKeyLShift            Key = w32.VK_LSHIFT\n\tKeyRShift            Key = w32.VK_RSHIFT\n\tKeyLControl          Key = w32.VK_LCONTROL\n\tKeyRControl          Key = w32.VK_RCONTROL\n\tKeyLAlt              Key = w32.VK_LMENU\n\tKeyLMenu             Key = w32.VK_LMENU\n\tKeyRAlt              Key = w32.VK_RMENU\n\tKeyRMenu             Key = w32.VK_RMENU\n\tKeyBrowserBack       Key = w32.VK_BROWSER_BACK\n\tKeyBrowserForward    Key = w32.VK_BROWSER_FORWARD\n\tKeyBrowserRefresh    Key = w32.VK_BROWSER_REFRESH\n\tKeyBrowserStop       Key = w32.VK_BROWSER_STOP\n\tKeyBrowserSearch     Key = w32.VK_BROWSER_SEARCH\n\tKeyBrowserFavorites  Key = w32.VK_BROWSER_FAVORITES\n\tKeyBrowserHome       Key = w32.VK_BROWSER_HOME\n\tKeyVolumeMute        Key = w32.VK_VOLUME_MUTE\n\tKeyVolumeDown        Key = w32.VK_VOLUME_DOWN\n\tKeyVolumeUp          Key = w32.VK_VOLUME_UP\n\tKeyMediaNextTrack    Key = w32.VK_MEDIA_NEXT_TRACK\n\tKeyMediaPrevTrack    Key = w32.VK_MEDIA_PREV_TRACK\n\tKeyMediaStop         Key = w32.VK_MEDIA_STOP\n\tKeyMediaPlayPause    Key = w32.VK_MEDIA_PLAY_PAUSE\n\tKeyLaunchMail        Key = w32.VK_LAUNCH_MAIL\n\tKeyLaunchMediaSelect Key = w32.VK_LAUNCH_MEDIA_SELECT\n\tKeyLaunchApp1        Key = w32.VK_LAUNCH_APP1\n\tKeyLaunchApp2        Key = w32.VK_LAUNCH_APP2\n\tKeyOEM1              Key = w32.VK_OEM_1\n\tKeyOEMPlus           Key = w32.VK_OEM_PLUS\n\tKeyOEMComma          Key = w32.VK_OEM_COMMA\n\tKeyOEMMinus          Key = w32.VK_OEM_MINUS\n\tKeyOEMPeriod         Key = w32.VK_OEM_PERIOD\n\tKeyOEM2              Key = w32.VK_OEM_2\n\tKeyOEM3              Key = w32.VK_OEM_3\n\tKeyOEM4              Key = w32.VK_OEM_4\n\tKeyOEM5              Key = w32.VK_OEM_5\n\tKeyOEM6              Key = w32.VK_OEM_6\n\tKeyOEM7              Key = w32.VK_OEM_7\n\tKeyOEM8              Key = w32.VK_OEM_8\n\tKeyOEM102            Key = w32.VK_OEM_102\n\tKeyProcessKey        Key = w32.VK_PROCESSKEY\n\tKeyPacket            Key = w32.VK_PACKET\n\tKeyAttn              Key = w32.VK_ATTN\n\tKeyCRSel             Key = w32.VK_CRSEL\n\tKeyEXSel             Key = w32.VK_EXSEL\n\tKeyErEOF             Key = w32.VK_EREOF\n\tKeyPlay              Key = w32.VK_PLAY\n\tKeyZoom              Key = w32.VK_ZOOM\n\tKeyNoName            Key = w32.VK_NONAME\n\tKeyPA1               Key = w32.VK_PA1\n\tKeyOEMClear          Key = w32.VK_OEM_CLEAR\n)\n\nvar key2string = map[Key]string{\n\tKeyLButton:           \"LButton\",\n\tKeyRButton:           \"RButton\",\n\tKeyCancel:            \"Cancel\",\n\tKeyMButton:           \"MButton\",\n\tKeyXButton1:          \"XButton1\",\n\tKeyXButton2:          \"XButton2\",\n\tKeyBack:              \"Back\",\n\tKeyTab:               \"Tab\",\n\tKeyClear:             \"Clear\",\n\tKeyReturn:            \"Return\",\n\tKeyShift:             \"Shift\",\n\tKeyControl:           \"Control\",\n\tKeyAlt:               \"Alt / Menu\",\n\tKeyPause:             \"Pause\",\n\tKeyCapital:           \"Capital\",\n\tKeyKana:              \"Kana / Hangul\",\n\tKeyJunja:             \"Junja\",\n\tKeyFinal:             \"Final\",\n\tKeyHanja:             \"Hanja / Kanji\",\n\tKeyEscape:            \"Escape\",\n\tKeyConvert:           \"Convert\",\n\tKeyNonconvert:        \"Nonconvert\",\n\tKeyAccept:            \"Accept\",\n\tKeyModeChange:        \"ModeChange\",\n\tKeySpace:             \"Space\",\n\tKeyPrior:             \"Prior\",\n\tKeyNext:              \"Next\",\n\tKeyEnd:               \"End\",\n\tKeyHome:              \"Home\",\n\tKeyLeft:              \"Left\",\n\tKeyUp:                \"Up\",\n\tKeyRight:             \"Right\",\n\tKeyDown:              \"Down\",\n\tKeySelect:            \"Select\",\n\tKeyPrint:             \"Print\",\n\tKeyExecute:           \"Execute\",\n\tKeySnapshot:          \"Snapshot\",\n\tKeyInsert:            \"Insert\",\n\tKeyDelete:            \"Delete\",\n\tKeyHelp:              \"Help\",\n\tKey0:                 \"0\",\n\tKey1:                 \"1\",\n\tKey2:                 \"2\",\n\tKey3:                 \"3\",\n\tKey4:                 \"4\",\n\tKey5:                 \"5\",\n\tKey6:                 \"6\",\n\tKey7:                 \"7\",\n\tKey8:                 \"8\",\n\tKey9:                 \"9\",\n\tKeyA:                 \"A\",\n\tKeyB:                 \"B\",\n\tKeyC:                 \"C\",\n\tKeyD:                 \"D\",\n\tKeyE:                 \"E\",\n\tKeyF:                 \"F\",\n\tKeyG:                 \"G\",\n\tKeyH:                 \"H\",\n\tKeyI:                 \"I\",\n\tKeyJ:                 \"J\",\n\tKeyK:                 \"K\",\n\tKeyL:                 \"L\",\n\tKeyM:                 \"M\",\n\tKeyN:                 \"N\",\n\tKeyO:                 \"O\",\n\tKeyP:                 \"P\",\n\tKeyQ:                 \"Q\",\n\tKeyR:                 \"R\",\n\tKeyS:                 \"S\",\n\tKeyT:                 \"T\",\n\tKeyU:                 \"U\",\n\tKeyV:                 \"V\",\n\tKeyW:                 \"W\",\n\tKeyX:                 \"X\",\n\tKeyY:                 \"Y\",\n\tKeyZ:                 \"Z\",\n\tKeyLWIN:              \"LWIN\",\n\tKeyRWIN:              \"RWIN\",\n\tKeyApps:              \"Apps\",\n\tKeySleep:             \"Sleep\",\n\tKeyNumpad0:           \"Numpad0\",\n\tKeyNumpad1:           \"Numpad1\",\n\tKeyNumpad2:           \"Numpad2\",\n\tKeyNumpad3:           \"Numpad3\",\n\tKeyNumpad4:           \"Numpad4\",\n\tKeyNumpad5:           \"Numpad5\",\n\tKeyNumpad6:           \"Numpad6\",\n\tKeyNumpad7:           \"Numpad7\",\n\tKeyNumpad8:           \"Numpad8\",\n\tKeyNumpad9:           \"Numpad9\",\n\tKeyMultiply:          \"Multiply\",\n\tKeyAdd:               \"Add\",\n\tKeySeparator:         \"Separator\",\n\tKeySubtract:          \"Subtract\",\n\tKeyDecimal:           \"Decimal\",\n\tKeyDivide:            \"Divide\",\n\tKeyF1:                \"F1\",\n\tKeyF2:                \"F2\",\n\tKeyF3:                \"F3\",\n\tKeyF4:                \"F4\",\n\tKeyF5:                \"F5\",\n\tKeyF6:                \"F6\",\n\tKeyF7:                \"F7\",\n\tKeyF8:                \"F8\",\n\tKeyF9:                \"F9\",\n\tKeyF10:               \"F10\",\n\tKeyF11:               \"F11\",\n\tKeyF12:               \"F12\",\n\tKeyF13:               \"F13\",\n\tKeyF14:               \"F14\",\n\tKeyF15:               \"F15\",\n\tKeyF16:               \"F16\",\n\tKeyF17:               \"F17\",\n\tKeyF18:               \"F18\",\n\tKeyF19:               \"F19\",\n\tKeyF20:               \"F20\",\n\tKeyF21:               \"F21\",\n\tKeyF22:               \"F22\",\n\tKeyF23:               \"F23\",\n\tKeyF24:               \"F24\",\n\tKeyNumlock:           \"Numlock\",\n\tKeyScroll:            \"Scroll\",\n\tKeyLShift:            \"LShift\",\n\tKeyRShift:            \"RShift\",\n\tKeyLControl:          \"LControl\",\n\tKeyRControl:          \"RControl\",\n\tKeyLMenu:             \"LMenu\",\n\tKeyRMenu:             \"RMenu\",\n\tKeyBrowserBack:       \"BrowserBack\",\n\tKeyBrowserForward:    \"BrowserForward\",\n\tKeyBrowserRefresh:    \"BrowserRefresh\",\n\tKeyBrowserStop:       \"BrowserStop\",\n\tKeyBrowserSearch:     \"BrowserSearch\",\n\tKeyBrowserFavorites:  \"BrowserFavorites\",\n\tKeyBrowserHome:       \"BrowserHome\",\n\tKeyVolumeMute:        \"VolumeMute\",\n\tKeyVolumeDown:        \"VolumeDown\",\n\tKeyVolumeUp:          \"VolumeUp\",\n\tKeyMediaNextTrack:    \"MediaNextTrack\",\n\tKeyMediaPrevTrack:    \"MediaPrevTrack\",\n\tKeyMediaStop:         \"MediaStop\",\n\tKeyMediaPlayPause:    \"MediaPlayPause\",\n\tKeyLaunchMail:        \"LaunchMail\",\n\tKeyLaunchMediaSelect: \"LaunchMediaSelect\",\n\tKeyLaunchApp1:        \"LaunchApp1\",\n\tKeyLaunchApp2:        \"LaunchApp2\",\n\tKeyOEM1:              \"OEM1\",\n\tKeyOEMPlus:           \"OEMPlus\",\n\tKeyOEMComma:          \"OEMComma\",\n\tKeyOEMMinus:          \"OEMMinus\",\n\tKeyOEMPeriod:         \"OEMPeriod\",\n\tKeyOEM2:              \"OEM2\",\n\tKeyOEM3:              \"OEM3\",\n\tKeyOEM4:              \"OEM4\",\n\tKeyOEM5:              \"OEM5\",\n\tKeyOEM6:              \"OEM6\",\n\tKeyOEM7:              \"OEM7\",\n\tKeyOEM8:              \"OEM8\",\n\tKeyOEM102:            \"OEM102\",\n\tKeyProcessKey:        \"ProcessKey\",\n\tKeyPacket:            \"Packet\",\n\tKeyAttn:              \"Attn\",\n\tKeyCRSel:             \"CRSel\",\n\tKeyEXSel:             \"EXSel\",\n\tKeyErEOF:             \"ErEOF\",\n\tKeyPlay:              \"Play\",\n\tKeyZoom:              \"Zoom\",\n\tKeyNoName:            \"NoName\",\n\tKeyPA1:               \"PA1\",\n\tKeyOEMClear:          \"OEMClear\",\n}\n\ntype Modifiers byte\n\nfunc (m Modifiers) String() string {\n\treturn modifiers2string[m]\n}\n\nvar modifiers2string = map[Modifiers]string{\n\tModShift:                       \"Shift\",\n\tModControl:                     \"Ctrl\",\n\tModControl | ModShift:          \"Ctrl+Shift\",\n\tModAlt:                         \"Alt\",\n\tModAlt | ModShift:              \"Alt+Shift\",\n\tModAlt | ModControl | ModShift: \"Alt+Ctrl+Shift\",\n}\n\nconst (\n\tModShift Modifiers = 1 << iota\n\tModControl\n\tModAlt\n)\n\nfunc ModifiersDown() Modifiers {\n\tvar m Modifiers\n\n\tif ShiftDown() {\n\t\tm |= ModShift\n\t}\n\tif ControlDown() {\n\t\tm |= ModControl\n\t}\n\tif AltDown() {\n\t\tm |= ModAlt\n\t}\n\n\treturn m\n}\n\ntype Shortcut struct {\n\tModifiers Modifiers\n\tKey       Key\n}\n\nfunc (s Shortcut) String() string {\n\tm := s.Modifiers.String()\n\tif m == \"\" {\n\t\treturn s.Key.String()\n\t}\n\n\tb := new(bytes.Buffer)\n\n\tb.WriteString(m)\n\tb.WriteRune('+')\n\tb.WriteString(s.Key.String())\n\n\treturn b.String()\n}\n\nfunc AltDown() bool {\n\treturn w32.GetKeyState(int32(KeyAlt))>>15 != 0\n}\n\nfunc ControlDown() bool {\n\treturn w32.GetKeyState(int32(KeyControl))>>15 != 0\n}\n\nfunc ShiftDown() bool {\n\treturn w32.GetKeyState(int32(KeyShift))>>15 != 0\n}\n"
  },
  {
    "path": "label.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Label struct {\n\tControlBase\n}\n\nfunc NewLabel(parent Controller) *Label {\n\tlb := new(Label)\n\n\tlb.InitControl(\"STATIC\", parent, 0, w32.WS_CHILD|w32.WS_VISIBLE|w32.SS_LEFTNOWORDWRAP)\n\tRegMsgHandler(lb)\n\n\tlb.SetFont(DefaultFont)\n\tlb.SetText(\"Label\")\n\tlb.SetSize(100, 25)\n\treturn lb\n}\n\nfunc (lb *Label) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\treturn w32.DefWindowProc(lb.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "layout.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\n// Dockable component must satisfy interface to be docked.\ntype Dockable interface {\n\tHandle() w32.HWND\n\n\tPos() (x, y int)\n\tWidth() int\n\tHeight() int\n\tVisible() bool\n\n\tSetPos(x, y int)\n\tSetSize(width, height int)\n\n\tOnMouseMove() *EventManager\n\tOnLBUp() *EventManager\n}\n\n// DockAllow is window, panel or other component that satisfies interface.\ntype DockAllow interface {\n\tHandle() w32.HWND\n\tClientWidth() int\n\tClientHeight() int\n\tSetLayout(mng LayoutManager)\n}\n\n// Various layout managers\ntype Direction int\n\nconst (\n\tTop Direction = iota\n\tBottom\n\tLeft\n\tRight\n\tFill\n)\n\ntype LayoutControl struct {\n\tchild Dockable\n\tdir   Direction\n}\n\ntype LayoutControls []*LayoutControl\n\ntype SimpleDock struct {\n\tparent      DockAllow\n\tlayoutCtl   LayoutControls\n\tloadedState bool\n}\n\n// DockState gets saved and loaded from json\ntype CtlState struct {\n\tX, Y, Width, Height int\n}\n\ntype LayoutState struct {\n\tWindowState string\n\tControls    []*CtlState\n}\n\nfunc (lc LayoutControls) Len() int           { return len(lc) }\nfunc (lc LayoutControls) Swap(i, j int)      { lc[i], lc[j] = lc[j], lc[i] }\nfunc (lc LayoutControls) Less(i, j int) bool { return lc[i].dir < lc[j].dir }\n\nfunc NewSimpleDock(parent DockAllow) *SimpleDock {\n\td := &SimpleDock{parent: parent}\n\tparent.SetLayout(d)\n\treturn d\n}\n\n// Layout management for the child controls.\nfunc (sd *SimpleDock) Dock(child Dockable, dir Direction) {\n\tsd.layoutCtl = append(sd.layoutCtl, &LayoutControl{child, dir})\n}\n\n// SaveState of the layout. Only works for Docks with parent set to main form.\nfunc (sd *SimpleDock) SaveState(w io.Writer) error {\n\tvar ls LayoutState\n\n\tvar wp w32.WINDOWPLACEMENT\n\twp.Length = uint32(unsafe.Sizeof(wp))\n\tif !w32.GetWindowPlacement(sd.parent.Handle(), &wp) {\n\t\treturn fmt.Errorf(\"GetWindowPlacement failed\")\n\t}\n\n\tls.WindowState = fmt.Sprint(\n\t\twp.Flags, wp.ShowCmd,\n\t\twp.PtMinPosition.X, wp.PtMinPosition.Y,\n\t\twp.PtMaxPosition.X, wp.PtMaxPosition.Y,\n\t\twp.RcNormalPosition.Left, wp.RcNormalPosition.Top,\n\t\twp.RcNormalPosition.Right, wp.RcNormalPosition.Bottom)\n\n\tfor _, c := range sd.layoutCtl {\n\t\tx, y := c.child.Pos()\n\t\tw, h := c.child.Width(), c.child.Height()\n\n\t\tctl := &CtlState{X: x, Y: y, Width: w, Height: h}\n\t\tls.Controls = append(ls.Controls, ctl)\n\t}\n\n\tif err := json.NewEncoder(w).Encode(ls); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// LoadState of the layout. Only works for Docks with parent set to main form.\nfunc (sd *SimpleDock) LoadState(r io.Reader) error {\n\tvar ls LayoutState\n\n\tif err := json.NewDecoder(r).Decode(&ls); err != nil {\n\t\treturn err\n\t}\n\n\tvar wp w32.WINDOWPLACEMENT\n\tif _, err := fmt.Sscan(ls.WindowState,\n\t\t&wp.Flags, &wp.ShowCmd,\n\t\t&wp.PtMinPosition.X, &wp.PtMinPosition.Y,\n\t\t&wp.PtMaxPosition.X, &wp.PtMaxPosition.Y,\n\t\t&wp.RcNormalPosition.Left, &wp.RcNormalPosition.Top,\n\t\t&wp.RcNormalPosition.Right, &wp.RcNormalPosition.Bottom); err != nil {\n\t\treturn err\n\t}\n\twp.Length = uint32(unsafe.Sizeof(wp))\n\n\tif !w32.SetWindowPlacement(sd.parent.Handle(), &wp) {\n\t\treturn fmt.Errorf(\"SetWindowPlacement failed\")\n\t}\n\n\t// if number of controls in the saved layout does not match\n\t// current number on screen - something changed and we do not reload\n\t// rest of control sizes from json\n\tif len(sd.layoutCtl) != len(ls.Controls) {\n\t\treturn nil\n\t}\n\n\tfor i, c := range sd.layoutCtl {\n\t\tc.child.SetPos(ls.Controls[i].X, ls.Controls[i].Y)\n\t\tc.child.SetSize(ls.Controls[i].Width, ls.Controls[i].Height)\n\t}\n\treturn nil\n}\n\n// SaveStateFile convenience function.\nfunc (sd *SimpleDock) SaveStateFile(file string) error {\n\tf, err := os.Create(file)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn sd.SaveState(f)\n}\n\n// LoadStateFile loads state ignores error if file is not found.\nfunc (sd *SimpleDock) LoadStateFile(file string) error {\n\tf, err := os.Open(file)\n\tif err != nil {\n\t\treturn nil // if file is not found or not accessible ignore it\n\t}\n\treturn sd.LoadState(f)\n}\n\n// Update is called to resize child items based on layout directions.\nfunc (sd *SimpleDock) Update() {\n\tsort.Stable(sd.layoutCtl)\n\n\tx, y := 0, 0\n\tw, h := sd.parent.ClientWidth(), sd.parent.ClientHeight()\n\twinw, winh := w, h\n\n\tfor _, c := range sd.layoutCtl {\n\t\t// Non visible controls do not preserve space.\n\t\tif !c.child.Visible() {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch c.dir {\n\t\tcase Top:\n\t\t\tc.child.SetPos(x, y)\n\t\t\tc.child.SetSize(w, c.child.Height())\n\t\t\th -= c.child.Height()\n\t\t\ty += c.child.Height()\n\t\tcase Bottom:\n\t\t\tc.child.SetPos(x, winh-c.child.Height())\n\t\t\tc.child.SetSize(w, c.child.Height())\n\t\t\th -= c.child.Height()\n\t\t\twinh -= c.child.Height()\n\t\tcase Left:\n\t\t\tc.child.SetPos(x, y)\n\t\t\tc.child.SetSize(c.child.Width(), h)\n\t\t\tw -= c.child.Width()\n\t\t\tx += c.child.Width()\n\t\tcase Right:\n\t\t\tc.child.SetPos(winw-c.child.Width(), y)\n\t\t\tc.child.SetSize(c.child.Width(), h)\n\t\t\tw -= c.child.Width()\n\t\t\twinw -= c.child.Width()\n\t\tcase Fill:\n\t\t\t// fill available space\n\t\t\tc.child.SetPos(x, y)\n\t\t\tc.child.SetSize(w, h)\n\t\t}\n\t\t//c.child.Invalidate(true)\n\t}\n}\n"
  },
  {
    "path": "listview.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\n// ListItem represents an item in a ListView widget.\ntype ListItem interface {\n\tText() []string  // Text returns the text of the multi-column item.\n\tImageIndex() int // ImageIndex is used only if SetImageList is called on the listview\n}\n\n// ListItemChecker is used for checkbox support in ListView.\ntype ListItemChecker interface {\n\tChecked() bool\n\tSetChecked(checked bool)\n}\n\n// ListItemSetter is used in OnEndLabelEdit event.\ntype ListItemSetter interface {\n\tSetText(s string) // set first item in the array via LabelEdit event\n}\n\n// StringListItem is helper for basic string lists.\ntype StringListItem struct {\n\tID    int\n\tData  string\n\tCheck bool\n}\n\nfunc (s StringListItem) Text() []string          { return []string{s.Data} }\nfunc (s StringListItem) Checked() bool           { return s.Check }\nfunc (s StringListItem) SetChecked(checked bool) { s.Check = checked }\nfunc (s StringListItem) ImageIndex() int         { return 0 }\n\ntype ListView struct {\n\tControlBase\n\n\timl       *ImageList\n\tlastIndex int\n\tcols      int // count of columns\n\n\titem2Handle map[ListItem]uintptr\n\thandle2Item map[uintptr]ListItem\n\n\tonEndLabelEdit EventManager\n\tonDoubleClick  EventManager\n\tonClick        EventManager\n\tonKeyDown      EventManager\n\tonItemChanging EventManager\n\tonItemChanged  EventManager\n\tonCheckChanged EventManager\n\tonViewChange   EventManager\n\tonEndScroll    EventManager\n}\n\nfunc NewListView(parent Controller) *ListView {\n\tlv := new(ListView)\n\n\tlv.InitControl(\"SysListView32\", parent /*w32.WS_EX_CLIENTEDGE*/, 0,\n\t\tw32.WS_CHILD|w32.WS_VISIBLE|w32.WS_TABSTOP|w32.LVS_REPORT|w32.LVS_EDITLABELS|w32.LVS_SHOWSELALWAYS)\n\n\tlv.item2Handle = make(map[ListItem]uintptr)\n\tlv.handle2Item = make(map[uintptr]ListItem)\n\n\tRegMsgHandler(lv)\n\n\tlv.SetFont(DefaultFont)\n\tlv.SetSize(200, 400)\n\n\tif err := lv.SetTheme(\"Explorer\"); err != nil {\n\t\t// theme error is ignored\n\t}\n\treturn lv\n}\n\n// FIXME: Changes the state of an item in a list-view control. Refer LVM_SETITEMSTATE message.\nfunc (lv *ListView) setItemState(i int, state, mask uint) {\n\tvar item w32.LVITEM\n\titem.State, item.StateMask = uint32(state), uint32(mask)\n\tw32.SendMessage(lv.hwnd, w32.LVM_SETITEMSTATE, uintptr(i), uintptr(unsafe.Pointer(&item)))\n}\n\nfunc (lv *ListView) EnableSingleSelect(enable bool) {\n\tToggleStyle(lv.hwnd, enable, w32.LVS_SINGLESEL)\n}\n\nfunc (lv *ListView) EnableSortHeader(enable bool) {\n\tToggleStyle(lv.hwnd, enable, w32.LVS_NOSORTHEADER)\n}\n\nfunc (lv *ListView) EnableSortAscending(enable bool) {\n\tToggleStyle(lv.hwnd, enable, w32.LVS_SORTASCENDING)\n}\n\nfunc (lv *ListView) EnableEditLabels(enable bool) {\n\tToggleStyle(lv.hwnd, enable, w32.LVS_EDITLABELS)\n}\n\nfunc (lv *ListView) EnableFullRowSelect(enable bool) {\n\tif enable {\n\t\tw32.SendMessage(lv.hwnd, w32.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, w32.LVS_EX_FULLROWSELECT)\n\t} else {\n\t\tw32.SendMessage(lv.hwnd, w32.LVM_SETEXTENDEDLISTVIEWSTYLE, w32.LVS_EX_FULLROWSELECT, 0)\n\t}\n}\n\nfunc (lv *ListView) EnableDoubleBuffer(enable bool) {\n\tif enable {\n\t\tw32.SendMessage(lv.hwnd, w32.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, w32.LVS_EX_DOUBLEBUFFER)\n\t} else {\n\t\tw32.SendMessage(lv.hwnd, w32.LVM_SETEXTENDEDLISTVIEWSTYLE, w32.LVS_EX_DOUBLEBUFFER, 0)\n\t}\n}\n\nfunc (lv *ListView) EnableHotTrack(enable bool) {\n\tif enable {\n\t\tw32.SendMessage(lv.hwnd, w32.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, w32.LVS_EX_TRACKSELECT)\n\t} else {\n\t\tw32.SendMessage(lv.hwnd, w32.LVM_SETEXTENDEDLISTVIEWSTYLE, w32.LVS_EX_TRACKSELECT, 0)\n\t}\n}\n\nfunc (lv *ListView) SetItemCount(count int) bool {\n\treturn w32.SendMessage(lv.hwnd, w32.LVM_SETITEMCOUNT, uintptr(count), 0) != 0\n}\n\nfunc (lv *ListView) ItemCount() int {\n\treturn int(w32.SendMessage(lv.hwnd, w32.LVM_GETITEMCOUNT, 0, 0))\n}\n\nfunc (lv *ListView) ItemAt(x, y int) ListItem {\n\thti := w32.LVHITTESTINFO{Pt: w32.POINT{int32(x), int32(y)}}\n\tw32.SendMessage(lv.hwnd, w32.LVM_HITTEST, 0, uintptr(unsafe.Pointer(&hti)))\n\treturn lv.findItemByIndex(int(hti.IItem))\n}\n\nfunc (lv *ListView) Items() (list []ListItem) {\n\tfor item := range lv.item2Handle {\n\t\tlist = append(list, item)\n\t}\n\treturn list\n}\n\nfunc (lv *ListView) AddColumn(caption string, width int) {\n\tvar lc w32.LVCOLUMN\n\tlc.Mask = w32.LVCF_TEXT\n\tif width != 0 {\n\t\tlc.Mask = lc.Mask | w32.LVCF_WIDTH\n\t\tlc.Cx = int32(width)\n\t}\n\tlc.PszText = syscall.StringToUTF16Ptr(caption)\n\tlv.insertLvColumn(&lc, lv.cols)\n\tlv.cols++\n}\n\n// StretchLastColumn makes the last column take up all remaining horizontal\n// space of the *ListView.\n// The effect of this is not persistent.\nfunc (lv *ListView) StretchLastColumn() error {\n\tif lv.cols == 0 {\n\t\treturn nil\n\t}\n\tif w32.SendMessage(lv.hwnd, w32.LVM_SETCOLUMNWIDTH, uintptr(lv.cols-1), w32.LVSCW_AUTOSIZE_USEHEADER) == 0 {\n\t\t//panic(\"LVM_SETCOLUMNWIDTH failed\")\n\t}\n\treturn nil\n}\n\n// CheckBoxes returns if the *TableView has check boxes.\nfunc (lv *ListView) CheckBoxes() bool {\n\treturn w32.SendMessage(lv.hwnd, w32.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)&w32.LVS_EX_CHECKBOXES > 0\n}\n\n// SetCheckBoxes sets if the *TableView has check boxes.\nfunc (lv *ListView) SetCheckBoxes(value bool) {\n\texStyle := w32.SendMessage(lv.hwnd, w32.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)\n\toldStyle := exStyle\n\tif value {\n\t\texStyle |= w32.LVS_EX_CHECKBOXES\n\t} else {\n\t\texStyle &^= w32.LVS_EX_CHECKBOXES\n\t}\n\tif exStyle != oldStyle {\n\t\tw32.SendMessage(lv.hwnd, w32.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, exStyle)\n\t}\n\n\tmask := w32.SendMessage(lv.hwnd, w32.LVM_GETCALLBACKMASK, 0, 0)\n\tif value {\n\t\tmask |= w32.LVIS_STATEIMAGEMASK\n\t} else {\n\t\tmask &^= w32.LVIS_STATEIMAGEMASK\n\t}\n\n\tif w32.SendMessage(lv.hwnd, w32.LVM_SETCALLBACKMASK, mask, 0) == w32.FALSE {\n\t\tpanic(\"SendMessage(LVM_SETCALLBACKMASK)\")\n\t}\n}\n\nfunc (lv *ListView) applyImage(lc *w32.LVITEM, imIndex int) {\n\tif lv.iml != nil {\n\t\tlc.Mask |= w32.LVIF_IMAGE\n\t\tlc.IImage = int32(imIndex)\n\t}\n}\n\nfunc (lv *ListView) AddItem(item ListItem) {\n\tlv.InsertItem(item, lv.ItemCount())\n}\n\nfunc (lv *ListView) InsertItem(item ListItem, index int) {\n\ttext := item.Text()\n\tli := &w32.LVITEM{\n\t\tMask:    w32.LVIF_TEXT | w32.LVIF_PARAM,\n\t\tPszText: syscall.StringToUTF16Ptr(text[0]),\n\t\tIItem:   int32(index),\n\t}\n\n\tlv.lastIndex++\n\tix := new(int)\n\t*ix = lv.lastIndex\n\tli.LParam = uintptr(*ix)\n\tlv.handle2Item[li.LParam] = item\n\tlv.item2Handle[item] = li.LParam\n\n\tlv.applyImage(li, item.ImageIndex())\n\tlv.insertLvItem(li)\n\n\tfor i := 1; i < len(text); i++ {\n\t\tli.Mask = w32.LVIF_TEXT\n\t\tli.PszText = syscall.StringToUTF16Ptr(text[i])\n\t\tli.ISubItem = int32(i)\n\t\tlv.setLvItem(li)\n\t}\n}\n\nfunc (lv *ListView) UpdateItem(item ListItem) bool {\n\tlparam, ok := lv.item2Handle[item]\n\tif !ok {\n\t\treturn false\n\t}\n\n\tindex := lv.findIndexByItem(item)\n\tif index == -1 {\n\t\treturn false\n\t}\n\n\ttext := item.Text()\n\tli := &w32.LVITEM{\n\t\tMask:    w32.LVIF_TEXT | w32.LVIF_PARAM,\n\t\tPszText: syscall.StringToUTF16Ptr(text[0]),\n\t\tLParam:  lparam,\n\t\tIItem:   int32(index),\n\t}\n\n\tlv.applyImage(li, item.ImageIndex())\n\tlv.setLvItem(li)\n\n\tfor i := 1; i < len(text); i++ {\n\t\tli.Mask = w32.LVIF_TEXT\n\t\tli.PszText = syscall.StringToUTF16Ptr(text[i])\n\t\tli.ISubItem = int32(i)\n\t\tlv.setLvItem(li)\n\t}\n\treturn true\n}\n\nfunc (lv *ListView) insertLvColumn(lvColumn *w32.LVCOLUMN, iCol int) {\n\tw32.SendMessage(lv.hwnd, w32.LVM_INSERTCOLUMN, uintptr(iCol), uintptr(unsafe.Pointer(lvColumn)))\n}\n\nfunc (lv *ListView) insertLvItem(lvItem *w32.LVITEM) {\n\tw32.SendMessage(lv.hwnd, w32.LVM_INSERTITEM, 0, uintptr(unsafe.Pointer(lvItem)))\n}\n\nfunc (lv *ListView) setLvItem(lvItem *w32.LVITEM) {\n\tw32.SendMessage(lv.hwnd, w32.LVM_SETITEM, 0, uintptr(unsafe.Pointer(lvItem)))\n}\n\nfunc (lv *ListView) DeleteAllItems() bool {\n\tif w32.SendMessage(lv.hwnd, w32.LVM_DELETEALLITEMS, 0, 0) == w32.TRUE {\n\t\tlv.item2Handle = make(map[ListItem]uintptr)\n\t\tlv.handle2Item = make(map[uintptr]ListItem)\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc (lv *ListView) DeleteItem(item ListItem) error {\n\tindex := lv.findIndexByItem(item)\n\tif index == -1 {\n\t\treturn errors.New(\"item not found\")\n\t}\n\n\tif w32.SendMessage(lv.hwnd, w32.LVM_DELETEITEM, uintptr(index), 0) == 0 {\n\t\treturn errors.New(\"SendMessage(TVM_DELETEITEM) failed\")\n\t}\n\n\th := lv.item2Handle[item]\n\tdelete(lv.item2Handle, item)\n\tdelete(lv.handle2Item, h)\n\treturn nil\n}\n\nfunc (lv *ListView) findIndexByItem(item ListItem) int {\n\tlparam, ok := lv.item2Handle[item]\n\tif !ok {\n\t\treturn -1\n\t}\n\n\tit := &w32.LVFINDINFO{\n\t\tFlags:  w32.LVFI_PARAM,\n\t\tLParam: lparam,\n\t}\n\tvar i int = -1\n\treturn int(w32.SendMessage(lv.hwnd, w32.LVM_FINDITEM, uintptr(i), uintptr(unsafe.Pointer(it))))\n}\n\nfunc (lv *ListView) findItemByIndex(i int) ListItem {\n\tit := &w32.LVITEM{\n\t\tMask:  w32.LVIF_PARAM,\n\t\tIItem: int32(i),\n\t}\n\n\tif w32.SendMessage(lv.hwnd, w32.LVM_GETITEM, 0, uintptr(unsafe.Pointer(it))) == w32.TRUE {\n\t\tif item, ok := lv.handle2Item[it.LParam]; ok {\n\t\t\treturn item\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (lv *ListView) EnsureVisible(item ListItem) bool {\n\tif i := lv.findIndexByItem(item); i != -1 {\n\t\treturn w32.SendMessage(lv.hwnd, w32.LVM_ENSUREVISIBLE, uintptr(i), 1) == 0\n\t}\n\treturn false\n}\n\nfunc (lv *ListView) SelectedItem() ListItem {\n\tif items := lv.SelectedItems(); len(items) > 0 {\n\t\treturn items[0]\n\t}\n\treturn nil\n}\n\nfunc (lv *ListView) SetSelectedItem(item ListItem) bool {\n\tif i := lv.findIndexByItem(item); i > -1 {\n\t\tlv.SetSelectedIndex(i)\n\t\treturn true\n\t}\n\treturn false\n}\n\n// mask is used to set the LVITEM.Mask for ListView.GetItem which indicates which attributes you'd like to receive\n// of LVITEM.\nfunc (lv *ListView) SelectedItems() []ListItem {\n\tvar items []ListItem\n\n\tvar i int = -1\n\tfor {\n\t\tif i = int(w32.SendMessage(lv.hwnd, w32.LVM_GETNEXTITEM, uintptr(i), uintptr(w32.LVNI_SELECTED))); i == -1 {\n\t\t\tbreak\n\t\t}\n\n\t\tif item := lv.findItemByIndex(i); item != nil {\n\t\t\titems = append(items, item)\n\t\t}\n\t}\n\treturn items\n}\n\nfunc (lv *ListView) SelectedCount() uint {\n\treturn uint(w32.SendMessage(lv.hwnd, w32.LVM_GETSELECTEDCOUNT, 0, 0))\n}\n\n// GetSelectedIndex first selected item index. Returns -1 if no item is selected.\nfunc (lv *ListView) SelectedIndex() int {\n\tvar i int = -1\n\treturn int(w32.SendMessage(lv.hwnd, w32.LVM_GETNEXTITEM, uintptr(i), uintptr(w32.LVNI_SELECTED)))\n}\n\n// Set i to -1 to select all items.\nfunc (lv *ListView) SetSelectedIndex(i int) {\n\tlv.setItemState(i, w32.LVIS_SELECTED, w32.LVIS_SELECTED)\n}\n\nfunc (lv *ListView) SetImageList(imageList *ImageList) {\n\tw32.SendMessage(lv.hwnd, w32.LVM_SETIMAGELIST, w32.LVSIL_SMALL, uintptr(imageList.Handle()))\n\tlv.iml = imageList\n}\n\n// Event publishers\nfunc (lv *ListView) OnEndLabelEdit() *EventManager {\n\treturn &lv.onEndLabelEdit\n}\n\nfunc (lv *ListView) OnDoubleClick() *EventManager {\n\treturn &lv.onDoubleClick\n}\n\nfunc (lv *ListView) OnClick() *EventManager {\n\treturn &lv.onClick\n}\n\nfunc (lv *ListView) OnKeyDown() *EventManager {\n\treturn &lv.onKeyDown\n}\n\nfunc (lv *ListView) OnItemChanging() *EventManager {\n\treturn &lv.onItemChanging\n}\n\nfunc (lv *ListView) OnItemChanged() *EventManager {\n\treturn &lv.onItemChanged\n}\n\nfunc (lv *ListView) OnCheckChanged() *EventManager {\n\treturn &lv.onCheckChanged\n}\n\nfunc (lv *ListView) OnViewChange() *EventManager {\n\treturn &lv.onViewChange\n}\n\nfunc (lv *ListView) OnEndScroll() *EventManager {\n\treturn &lv.onEndScroll\n}\n\n// Message processer\nfunc (lv *ListView) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\t/*case w32.WM_ERASEBKGND:\n\tlv.StretchLastColumn()\n\tprintln(\"case w32.WM_ERASEBKGND\")\n\treturn 1*/\n\n\tcase w32.WM_NOTIFY:\n\t\tnm := (*w32.NMHDR)(unsafe.Pointer(lparam))\n\t\tcode := int32(nm.Code)\n\n\t\tswitch code {\n\t\tcase w32.LVN_BEGINLABELEDITW:\n\t\t\t// println(\"Begin label edit\")\n\t\tcase w32.LVN_ENDLABELEDITW:\n\t\t\tnmdi := (*w32.NMLVDISPINFO)(unsafe.Pointer(lparam))\n\t\t\tif nmdi.Item.PszText != nil {\n\t\t\t\tfmt.Println(nmdi.Item.PszText, nmdi.Item)\n\t\t\t\tif item, ok := lv.handle2Item[nmdi.Item.LParam]; ok {\n\t\t\t\t\tlv.onEndLabelEdit.Fire(NewEvent(lv,\n\t\t\t\t\t\t&LabelEditEventData{Item: item,\n\t\t\t\t\t\t\tText: w32.UTF16PtrToString(nmdi.Item.PszText)}))\n\t\t\t\t}\n\t\t\t\treturn w32.TRUE\n\t\t\t}\n\t\tcase w32.NM_DBLCLK:\n\t\t\tlv.onDoubleClick.Fire(NewEvent(lv, nil))\n\n\t\tcase w32.NM_CLICK:\n\t\t\tac := (*w32.NMITEMACTIVATE)(unsafe.Pointer(lparam))\n\t\t\tvar hti w32.LVHITTESTINFO\n\t\t\thti.Pt = w32.POINT{ac.PtAction.X, ac.PtAction.Y}\n\t\t\tw32.SendMessage(lv.hwnd, w32.LVM_HITTEST, 0, uintptr(unsafe.Pointer(&hti)))\n\n\t\t\tif hti.Flags == w32.LVHT_ONITEMSTATEICON {\n\t\t\t\tif item := lv.findItemByIndex(int(hti.IItem)); item != nil {\n\t\t\t\t\tif item, ok := item.(ListItemChecker); ok {\n\t\t\t\t\t\tchecked := !item.Checked()\n\t\t\t\t\t\titem.SetChecked(checked)\n\t\t\t\t\t\tlv.onCheckChanged.Fire(NewEvent(lv, item))\n\n\t\t\t\t\t\tif w32.SendMessage(lv.hwnd, w32.LVM_UPDATE, uintptr(hti.IItem), 0) == w32.FALSE {\n\t\t\t\t\t\t\tpanic(\"SendMessage(LVM_UPDATE)\")\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thti.Pt = w32.POINT{ac.PtAction.X, ac.PtAction.Y}\n\t\t\tw32.SendMessage(lv.hwnd, w32.LVM_SUBITEMHITTEST, 0, uintptr(unsafe.Pointer(&hti)))\n\t\t\tlv.onClick.Fire(NewEvent(lv, hti.ISubItem))\n\n\t\tcase w32.LVN_KEYDOWN:\n\t\t\tnmkey := (*w32.NMLVKEYDOWN)(unsafe.Pointer(lparam))\n\t\t\tif nmkey.WVKey == w32.VK_SPACE && lv.CheckBoxes() {\n\t\t\t\tif item := lv.SelectedItem(); item != nil {\n\t\t\t\t\tif item, ok := item.(ListItemChecker); ok {\n\t\t\t\t\t\tchecked := !item.Checked()\n\t\t\t\t\t\titem.SetChecked(checked)\n\t\t\t\t\t\tlv.onCheckChanged.Fire(NewEvent(lv, item))\n\t\t\t\t\t}\n\n\t\t\t\t\tindex := lv.findIndexByItem(item)\n\t\t\t\t\tif w32.SendMessage(lv.hwnd, w32.LVM_UPDATE, uintptr(index), 0) == w32.FALSE {\n\t\t\t\t\t\tpanic(\"SendMessage(LVM_UPDATE)\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tlv.onKeyDown.Fire(NewEvent(lv, nmkey.WVKey))\n\t\t\tkey := nmkey.WVKey\n\t\t\tw32.SendMessage(lv.Parent().Handle(), w32.WM_KEYDOWN, uintptr(key), 0)\n\n\t\tcase w32.LVN_ITEMCHANGING:\n\t\t\t// This event also fires when listview has changed via code.\n\t\t\tnmlv := (*w32.NMLISTVIEW)(unsafe.Pointer(lparam))\n\t\t\titem := lv.findItemByIndex(int(nmlv.IItem))\n\t\t\tlv.onItemChanging.Fire(NewEvent(lv, item))\n\n\t\tcase w32.LVN_ITEMCHANGED:\n\t\t\t// This event also fires when listview has changed via code.\n\t\t\tnmlv := (*w32.NMLISTVIEW)(unsafe.Pointer(lparam))\n\t\t\titem := lv.findItemByIndex(int(nmlv.IItem))\n\t\t\tlv.onItemChanged.Fire(NewEvent(lv, item))\n\n\t\tcase w32.LVN_GETDISPINFO:\n\t\t\tnmdi := (*w32.NMLVDISPINFO)(unsafe.Pointer(lparam))\n\t\t\tif nmdi.Item.StateMask&w32.LVIS_STATEIMAGEMASK > 0 {\n\t\t\t\tif item, ok := lv.handle2Item[nmdi.Item.LParam]; ok {\n\t\t\t\t\tif item, ok := item.(ListItemChecker); ok {\n\n\t\t\t\t\t\tchecked := item.Checked()\n\t\t\t\t\t\tif checked {\n\t\t\t\t\t\t\tnmdi.Item.State = 0x2000\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnmdi.Item.State = 0x1000\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlv.onViewChange.Fire(NewEvent(lv, nil))\n\n\t\tcase w32.LVN_ENDSCROLL:\n\t\t\tlv.onEndScroll.Fire(NewEvent(lv, nil))\n\t\t}\n\t}\n\treturn w32.DefWindowProc(lv.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "menu.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\nvar (\n\tnextMenuItemID  uint16 = 3\n\tactionsByID            = make(map[uint16]*MenuItem)\n\tshortcut2Action        = make(map[Shortcut]*MenuItem)\n\tmenuItems              = make(map[w32.HMENU][]*MenuItem)\n\tradioGroups            = make(map[*MenuItem]*RadioGroup)\n\tinitialised     bool\n)\n\nvar NoShortcut = Shortcut{}\n\n// Menu for main window and context menus on controls.\n// Most methods used for both main window menu and context menu.\ntype Menu struct {\n\thMenu w32.HMENU\n\thwnd  w32.HWND // hwnd might be nil if it is context menu.\n}\n\ntype MenuItem struct {\n\thMenu    w32.HMENU\n\thSubMenu w32.HMENU // Non zero if this item is in itself a submenu.\n\n\ttext     string\n\ttoolTip  string\n\timage    *Bitmap\n\tshortcut Shortcut\n\tenabled  bool\n\n\tcheckable bool\n\tchecked   bool\n\tisRadio   bool\n\n\tid uint16\n\n\tonClick EventManager\n}\n\ntype RadioGroup struct {\n\tmembers []*MenuItem\n\thwnd    w32.HWND\n}\n\nfunc NewContextMenu() *MenuItem {\n\thMenu := w32.CreatePopupMenu()\n\tif hMenu == 0 {\n\t\tpanic(\"failed CreateMenu\")\n\t}\n\n\titem := &MenuItem{\n\t\thMenu:    hMenu,\n\t\thSubMenu: hMenu,\n\t}\n\treturn item\n}\n\nfunc (m *Menu) Dispose() {\n\tif m.hMenu != 0 {\n\t\tw32.DestroyMenu(m.hMenu)\n\t\tm.hMenu = 0\n\t}\n}\n\nfunc (m *Menu) IsDisposed() bool {\n\treturn m.hMenu == 0\n}\n\nfunc initMenuItemInfoFromAction(mii *w32.MENUITEMINFO, a *MenuItem) {\n\tmii.CbSize = uint32(unsafe.Sizeof(*mii))\n\tmii.FMask = w32.MIIM_FTYPE | w32.MIIM_ID | w32.MIIM_STATE | w32.MIIM_STRING\n\tif a.image != nil {\n\t\tmii.FMask |= w32.MIIM_BITMAP\n\t\tmii.HbmpItem = a.image.handle\n\t}\n\tif a.IsSeparator() {\n\t\tmii.FType = w32.MFT_SEPARATOR\n\t} else {\n\t\tmii.FType = w32.MFT_STRING\n\t\tvar text string\n\t\tif s := a.shortcut; s.Key != 0 {\n\t\t\ttext = fmt.Sprintf(\"%s\\t%s\", a.text, s.String())\n\t\t\tshortcut2Action[a.shortcut] = a\n\t\t} else {\n\t\t\ttext = a.text\n\t\t}\n\t\tmii.DwTypeData = syscall.StringToUTF16Ptr(text)\n\t\tmii.Cch = uint32(len([]rune(a.text)))\n\t}\n\tmii.WID = uint32(a.id)\n\n\tif a.Enabled() {\n\t\tmii.FState &^= w32.MFS_DISABLED\n\t} else {\n\t\tmii.FState |= w32.MFS_DISABLED\n\t}\n\n\tif a.Checkable() {\n\t\tmii.FMask |= w32.MIIM_CHECKMARKS\n\t}\n\tif a.Checked() {\n\t\tmii.FState |= w32.MFS_CHECKED\n\t}\n\n\tif a.hSubMenu != 0 {\n\t\tmii.FMask |= w32.MIIM_SUBMENU\n\t\tmii.HSubMenu = a.hSubMenu\n\t}\n}\n\n// Show menu on the main window.\nfunc (m *Menu) Show() {\n\tinitialised = true\n\tupdateRadioGroups()\n\tif !w32.DrawMenuBar(m.hwnd) {\n\t\tpanic(\"DrawMenuBar failed\")\n\t}\n}\n\n// AddSubMenu returns item that is used as submenu to perform AddItem(s).\nfunc (m *Menu) AddSubMenu(text string) *MenuItem {\n\thSubMenu := w32.CreateMenu()\n\tif hSubMenu == 0 {\n\t\tpanic(\"failed CreateMenu\")\n\t}\n\treturn addMenuItem(m.hMenu, hSubMenu, text, Shortcut{}, nil, false)\n}\n\n// This method will iterate through the menu items, group radio items together, build a\n// quick access map and set the initial items\nfunc updateRadioGroups() {\n\n\tif !initialised {\n\t\treturn\n\t}\n\n\tradioItemsChecked := []*MenuItem{}\n\tradioGroups = make(map[*MenuItem]*RadioGroup)\n\tvar currentRadioGroupMembers []*MenuItem\n\t// Iterate the menus\n\tfor _, menu := range menuItems {\n\t\tmenuLength := len(menu)\n\t\tfor index, menuItem := range menu {\n\t\t\tif menuItem.isRadio {\n\t\t\t\tcurrentRadioGroupMembers = append(currentRadioGroupMembers, menuItem)\n\t\t\t\tif menuItem.checked {\n\t\t\t\t\tradioItemsChecked = append(radioItemsChecked, menuItem)\n\t\t\t\t}\n\n\t\t\t\t// If end of menu\n\t\t\t\tif index == menuLength-1 {\n\t\t\t\t\tradioGroup := &RadioGroup{\n\t\t\t\t\t\tmembers: currentRadioGroupMembers,\n\t\t\t\t\t\thwnd:    menuItem.hMenu,\n\t\t\t\t\t}\n\t\t\t\t\t// Save the group to each member iin the radiomap\n\t\t\t\t\tfor _, member := range currentRadioGroupMembers {\n\t\t\t\t\t\tradioGroups[member] = radioGroup\n\t\t\t\t\t}\n\t\t\t\t\tcurrentRadioGroupMembers = []*MenuItem{}\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Not a radio item\n\t\t\tif len(currentRadioGroupMembers) > 0 {\n\t\t\t\tradioGroup := &RadioGroup{\n\t\t\t\t\tmembers: currentRadioGroupMembers,\n\t\t\t\t\thwnd:    menuItem.hMenu,\n\t\t\t\t}\n\t\t\t\t// Save the group to each member iin the radiomap\n\t\t\t\tfor _, member := range currentRadioGroupMembers {\n\t\t\t\t\tradioGroups[member] = radioGroup\n\t\t\t\t}\n\t\t\t\tcurrentRadioGroupMembers = []*MenuItem{}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Enable the checked items\n\tfor _, item := range radioItemsChecked {\n\t\tradioGroup := radioGroups[item]\n\t\tstartID := radioGroup.members[0].id\n\t\tendID := radioGroup.members[len(radioGroup.members)-1].id\n\t\tw32.SelectRadioMenuItem(item.id, startID, endID, radioGroup.hwnd)\n\t}\n\n}\n\nfunc (mi *MenuItem) OnClick() *EventManager {\n\treturn &mi.onClick\n}\n\nfunc (mi *MenuItem) AddSeparator() {\n\taddMenuItem(mi.hSubMenu, 0, \"-\", Shortcut{}, nil, false)\n}\n\n// AddItem adds plain menu item.\nfunc (mi *MenuItem) AddItem(text string, shortcut Shortcut) *MenuItem {\n\treturn addMenuItem(mi.hSubMenu, 0, text, shortcut, nil, false)\n}\n\n// AddItemCheckable adds plain menu item that can have a checkmark.\nfunc (mi *MenuItem) AddItemCheckable(text string, shortcut Shortcut) *MenuItem {\n\treturn addMenuItem(mi.hSubMenu, 0, text, shortcut, nil, true)\n}\n\n// AddItemRadio adds plain menu item that can have a checkmark and is part of a radio group.\nfunc (mi *MenuItem) AddItemRadio(text string, shortcut Shortcut) *MenuItem {\n\tmenuItem := addMenuItem(mi.hSubMenu, 0, text, shortcut, nil, true)\n\tmenuItem.isRadio = true\n\treturn menuItem\n}\n\n// AddItemWithBitmap adds menu item with shortcut and bitmap.\nfunc (mi *MenuItem) AddItemWithBitmap(text string, shortcut Shortcut, image *Bitmap) *MenuItem {\n\treturn addMenuItem(mi.hSubMenu, 0, text, shortcut, image, false)\n}\n\n// AddSubMenu adds a submenu.\nfunc (mi *MenuItem) AddSubMenu(text string) *MenuItem {\n\thSubMenu := w32.CreatePopupMenu()\n\tif hSubMenu == 0 {\n\t\tpanic(\"failed CreatePopupMenu\")\n\t}\n\treturn addMenuItem(mi.hSubMenu, hSubMenu, text, Shortcut{}, nil, false)\n}\n\n// AddItem to the menu, set text to \"-\" for separators.\nfunc addMenuItem(hMenu, hSubMenu w32.HMENU, text string, shortcut Shortcut, image *Bitmap, checkable bool) *MenuItem {\n\titem := &MenuItem{\n\t\thMenu:     hMenu,\n\t\thSubMenu:  hSubMenu,\n\t\ttext:      text,\n\t\tshortcut:  shortcut,\n\t\timage:     image,\n\t\tenabled:   true,\n\t\tid:        nextMenuItemID,\n\t\tcheckable: checkable,\n\t\tisRadio:   false,\n\t\t//visible:  true,\n\t}\n\tnextMenuItemID++\n\tactionsByID[item.id] = item\n\tmenuItems[hMenu] = append(menuItems[hMenu], item)\n\n\tvar mii w32.MENUITEMINFO\n\tinitMenuItemInfoFromAction(&mii, item)\n\n\tindex := -1\n\tif !w32.InsertMenuItem(hMenu, uint32(index), true, &mii) {\n\t\tpanic(\"InsertMenuItem failed\")\n\t}\n\treturn item\n}\n\nfunc indexInObserver(a *MenuItem) int {\n\tvar idx int\n\tfor _, mi := range menuItems[a.hMenu] {\n\t\tif mi == a {\n\t\t\treturn idx\n\t\t}\n\t\tidx++\n\t}\n\treturn -1\n}\n\nfunc findMenuItemByID(id int) *MenuItem {\n\treturn actionsByID[uint16(id)]\n}\n\nfunc (mi *MenuItem) update() {\n\tvar mii w32.MENUITEMINFO\n\tinitMenuItemInfoFromAction(&mii, mi)\n\n\tif !w32.SetMenuItemInfo(mi.hMenu, uint32(indexInObserver(mi)), true, &mii) {\n\t\tpanic(\"SetMenuItemInfo failed\")\n\t}\n\tif mi.isRadio {\n\t\tmi.updateRadioGroup()\n\t}\n}\n\nfunc (mi *MenuItem) IsSeparator() bool { return mi.text == \"-\" }\nfunc (mi *MenuItem) SetSeparator()     { mi.text = \"-\" }\n\nfunc (mi *MenuItem) Enabled() bool     { return mi.enabled }\nfunc (mi *MenuItem) SetEnabled(b bool) { mi.enabled = b; mi.update() }\n\nfunc (mi *MenuItem) Checkable() bool     { return mi.checkable }\nfunc (mi *MenuItem) SetCheckable(b bool) { mi.checkable = b; mi.update() }\n\nfunc (mi *MenuItem) Checked() bool { return mi.checked }\nfunc (mi *MenuItem) SetChecked(b bool) {\n\tif mi.isRadio {\n\t\tradioGroup := radioGroups[mi]\n\t\tif radioGroup != nil {\n\t\t\tfor _, member := range radioGroup.members {\n\t\t\t\tmember.checked = false\n\t\t\t}\n\t\t}\n\n\t}\n\tmi.checked = b\n\tmi.update()\n}\n\nfunc (mi *MenuItem) Text() string     { return mi.text }\nfunc (mi *MenuItem) SetText(s string) { mi.text = s; mi.update() }\n\nfunc (mi *MenuItem) Image() *Bitmap     { return mi.image }\nfunc (mi *MenuItem) SetImage(b *Bitmap) { mi.image = b; mi.update() }\n\nfunc (mi *MenuItem) ToolTip() string     { return mi.toolTip }\nfunc (mi *MenuItem) SetToolTip(s string) { mi.toolTip = s; mi.update() }\n\nfunc (mi *MenuItem) updateRadioGroup() {\n\tradioGroup := radioGroups[mi]\n\tif radioGroup == nil {\n\t\treturn\n\t}\n\tstartID := radioGroup.members[0].id\n\tendID := radioGroup.members[len(radioGroup.members)-1].id\n\tw32.SelectRadioMenuItem(mi.id, startID, endID, radioGroup.hwnd)\n}\n"
  },
  {
    "path": "mousecontrol.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\n// MouseControl used for creating custom controls that need mouse hover or mouse leave events.\ntype MouseControl struct {\n\tControlBase\n\tisMouseLeft bool\n}\n\nfunc (cc *MouseControl) Init(parent Controller, className string, exStyle, style uint) {\n\tRegClassOnlyOnce(className)\n\tcc.hwnd = CreateWindow(className, parent, exStyle, style)\n\tcc.parent = parent\n\tRegMsgHandler(cc)\n\n\tcc.isMouseLeft = true\n\tcc.SetFont(DefaultFont)\n}\n\nfunc (cc *MouseControl) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tsender := GetMsgHandler(cc.hwnd)\n\tswitch msg {\n\tcase w32.WM_CREATE:\n\t\tinternalTrackMouseEvent(cc.hwnd)\n\t\tcc.onCreate.Fire(NewEvent(sender, nil))\n\tcase w32.WM_CLOSE:\n\t\tcc.onClose.Fire(NewEvent(sender, nil))\n\tcase w32.WM_MOUSEMOVE:\n\t\t//if cc.isMouseLeft {\n\n\t\tcc.onMouseHover.Fire(NewEvent(sender, nil))\n\t\t//internalTrackMouseEvent(cc.hwnd)\n\t\tcc.isMouseLeft = false\n\n\t\t//}\n\tcase w32.WM_MOUSELEAVE:\n\t\tcc.onMouseLeave.Fire(NewEvent(sender, nil))\n\t\tcc.isMouseLeft = true\n\t}\n\treturn w32.DefWindowProc(cc.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "msghandlerregistry.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\nfunc RegMsgHandler(controller Controller) {\n\tgControllerRegistry[controller.Handle()] = controller\n}\n\nfunc UnRegMsgHandler(hwnd w32.HWND) {\n\tdelete(gControllerRegistry, hwnd)\n}\n\nfunc GetMsgHandler(hwnd w32.HWND) Controller {\n\tif controller, isExists := gControllerRegistry[hwnd]; isExists {\n\t\treturn controller\n\t}\n\n\treturn nil\n}\n"
  },
  {
    "path": "panel.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Panel struct {\n\tControlBase\n\tlayoutMng LayoutManager\n}\n\nfunc NewPanel(parent Controller) *Panel {\n\tpa := new(Panel)\n\n\tRegClassOnlyOnce(\"winc_Panel\")\n\tpa.hwnd = CreateWindow(\"winc_Panel\", parent, w32.WS_EX_CONTROLPARENT, w32.WS_CHILD|w32.WS_VISIBLE)\n\tpa.parent = parent\n\tRegMsgHandler(pa)\n\n\tpa.SetFont(DefaultFont)\n\tpa.SetText(\"\")\n\tpa.SetSize(200, 65)\n\treturn pa\n}\n\n// SetLayout panel implements DockAllow interface.\nfunc (pa *Panel) SetLayout(mng LayoutManager) {\n\tpa.layoutMng = mng\n}\n\nfunc (pa *Panel) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_SIZE, w32.WM_PAINT:\n\t\tif pa.layoutMng != nil {\n\t\t\tpa.layoutMng.Update()\n\t\t}\n\t}\n\treturn w32.DefWindowProc(pa.hwnd, msg, wparam, lparam)\n}\n\nvar errorPanelPen = NewPen(w32.PS_GEOMETRIC, 2, NewSolidColorBrush(RGB(255, 128, 128)))\nvar errorPanelOkPen = NewPen(w32.PS_GEOMETRIC, 2, NewSolidColorBrush(RGB(220, 220, 220)))\n\n// ErrorPanel shows errors or important messages.\n// It is meant to stand out of other on screen controls.\ntype ErrorPanel struct {\n\tControlBase\n\tpen    *Pen\n\tmargin int\n}\n\n// NewErrorPanel.\nfunc NewErrorPanel(parent Controller) *ErrorPanel {\n\tf := new(ErrorPanel)\n\tf.init(parent)\n\n\tf.SetFont(DefaultFont)\n\tf.SetText(\"No errors\")\n\tf.SetSize(200, 65)\n\tf.margin = 5\n\tf.pen = errorPanelOkPen\n\treturn f\n}\n\nfunc (epa *ErrorPanel) init(parent Controller) {\n\tRegClassOnlyOnce(\"winc_ErrorPanel\")\n\n\tepa.hwnd = CreateWindow(\"winc_ErrorPanel\", parent, w32.WS_EX_CONTROLPARENT, w32.WS_CHILD|w32.WS_VISIBLE)\n\tepa.parent = parent\n\n\tRegMsgHandler(epa)\n}\n\nfunc (epa *ErrorPanel) SetMargin(margin int) {\n\tepa.margin = margin\n}\n\nfunc (epa *ErrorPanel) Printf(format string, v ...interface{}) {\n\tepa.SetText(fmt.Sprintf(format, v...))\n\tepa.ShowAsError(false)\n}\n\nfunc (epa *ErrorPanel) Errorf(format string, v ...interface{}) {\n\tepa.SetText(fmt.Sprintf(format, v...))\n\tepa.ShowAsError(true)\n}\n\nfunc (epa *ErrorPanel) ShowAsError(show bool) {\n\tif show {\n\t\tepa.pen = errorPanelPen\n\t} else {\n\t\tepa.pen = errorPanelOkPen\n\t}\n\tepa.Invalidate(true)\n}\n\nfunc (epa *ErrorPanel) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_ERASEBKGND:\n\t\tcanvas := NewCanvasFromHDC(w32.HDC(wparam))\n\t\tr := epa.Bounds()\n\t\tr.rect.Left += int32(epa.margin)\n\t\tr.rect.Right -= int32(epa.margin)\n\t\tr.rect.Top += int32(epa.margin)\n\t\tr.rect.Bottom -= int32(epa.margin)\n\t\t// old code used NewSystemColorBrush(w32.COLOR_BTNFACE)\n\t\tcanvas.DrawFillRect(r, epa.pen, NewSystemColorBrush(w32.COLOR_WINDOW))\n\n\t\tr.rect.Left += 5\n\t\tcanvas.DrawText(epa.Text(), r, 0, epa.Font(), RGB(0, 0, 0))\n\t\tcanvas.Dispose()\n\t\treturn 1\n\t}\n\treturn w32.DefWindowProc(epa.hwnd, msg, wparam, lparam)\n}\n\n// MultiPanel contains other panels and only makes one of them visible.\ntype MultiPanel struct {\n\tControlBase\n\tcurrent int\n\tpanels  []*Panel\n}\n\nfunc NewMultiPanel(parent Controller) *MultiPanel {\n\tmpa := new(MultiPanel)\n\n\tRegClassOnlyOnce(\"winc_MultiPanel\")\n\tmpa.hwnd = CreateWindow(\"winc_MultiPanel\", parent, w32.WS_EX_CONTROLPARENT, w32.WS_CHILD|w32.WS_VISIBLE)\n\tmpa.parent = parent\n\tRegMsgHandler(mpa)\n\n\tmpa.SetFont(DefaultFont)\n\tmpa.SetText(\"\")\n\tmpa.SetSize(300, 200)\n\tmpa.current = -1\n\treturn mpa\n}\n\nfunc (mpa *MultiPanel) Count() int { return len(mpa.panels) }\n\n// AddPanel adds panels to the internal list, first panel is visible all others are hidden.\nfunc (mpa *MultiPanel) AddPanel(panel *Panel) {\n\tif len(mpa.panels) > 0 {\n\t\tpanel.Hide()\n\t}\n\tmpa.current = 0\n\tmpa.panels = append(mpa.panels, panel)\n}\n\n// ReplacePanel replaces panel, useful for refreshing controls on screen.\nfunc (mpa *MultiPanel) ReplacePanel(index int, panel *Panel) {\n\tmpa.panels[index] = panel\n}\n\n// DeletePanel removed panel.\nfunc (mpa *MultiPanel) DeletePanel(index int) {\n\tmpa.panels = append(mpa.panels[:index], mpa.panels[index+1:]...)\n}\n\nfunc (mpa *MultiPanel) Current() int {\n\treturn mpa.current\n}\n\nfunc (mpa *MultiPanel) SetCurrent(index int) {\n\tif index >= len(mpa.panels) {\n\t\tpanic(\"index greater than number of panels\")\n\t}\n\tif mpa.current == -1 {\n\t\tpanic(\"no current panel, add panels first\")\n\t}\n\tfor i := range mpa.panels {\n\t\tif i != index {\n\t\t\tmpa.panels[i].Hide()\n\t\t\tmpa.panels[i].Invalidate(true)\n\t\t}\n\t}\n\tmpa.panels[index].Show()\n\tmpa.panels[index].Invalidate(true)\n\tmpa.current = index\n}\n\nfunc (mpa *MultiPanel) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_SIZE:\n\t\t// resize contained panels\n\t\tfor _, p := range mpa.panels {\n\t\t\tp.SetPos(0, 0)\n\t\t\tp.SetSize(mpa.Size())\n\t\t}\n\t}\n\treturn w32.DefWindowProc(mpa.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "path.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"syscall\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\nfunc knownFolderPath(id w32.CSIDL) (string, error) {\n\tvar buf [w32.MAX_PATH]uint16\n\n\tif !w32.SHGetSpecialFolderPath(0, &buf[0], id, false) {\n\t\treturn \"\", fmt.Errorf(\"SHGetSpecialFolderPath failed\")\n\t}\n\n\treturn syscall.UTF16ToString(buf[0:]), nil\n}\n\nfunc AppDataPath() (string, error) {\n\treturn knownFolderPath(w32.CSIDL_APPDATA)\n}\n\nfunc CommonAppDataPath() (string, error) {\n\treturn knownFolderPath(w32.CSIDL_COMMON_APPDATA)\n}\n\nfunc LocalAppDataPath() (string, error) {\n\treturn knownFolderPath(w32.CSIDL_LOCAL_APPDATA)\n}\n\n// EnsureAppDataPath uses AppDataPath to ensure storage for local settings and databases.\nfunc EnsureAppDataPath(company, product string) (string, error) {\n\tpath, err := AppDataPath()\n\tif err != nil {\n\t\treturn path, err\n\t}\n\tp := filepath.Join(path, company, product)\n\n\tif _, err := os.Stat(p); os.IsNotExist(err) {\n\t\t// path/to/whatever does not exist\n\t\tif err := os.MkdirAll(p, os.ModePerm); err != nil {\n\t\t\treturn p, err\n\t\t}\n\t}\n\treturn p, nil\n}\n\nfunc DriveNames() ([]string, error) {\n\tbufLen := w32.GetLogicalDriveStrings(0, nil)\n\tif bufLen == 0 {\n\t\treturn nil, fmt.Errorf(\"GetLogicalDriveStrings failed\")\n\t}\n\tbuf := make([]uint16, bufLen+1)\n\n\tbufLen = w32.GetLogicalDriveStrings(bufLen+1, &buf[0])\n\tif bufLen == 0 {\n\t\treturn nil, fmt.Errorf(\"GetLogicalDriveStrings failed\")\n\t}\n\n\tvar names []string\n\tfor i := 0; i < len(buf)-2; {\n\t\tname := syscall.UTF16ToString(buf[i:])\n\t\tnames = append(names, name)\n\t\ti += len(name) + 1\n\t}\n\treturn names, nil\n}\n"
  },
  {
    "path": "pen.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Pen struct {\n\thPen  w32.HPEN\n\tstyle uint\n\tbrush *Brush\n}\n\nfunc NewPen(style uint, width uint, brush *Brush) *Pen {\n\tif brush == nil {\n\t\tpanic(\"Brush cannot be nil\")\n\t}\n\n\thPen := w32.ExtCreatePen(style, width, brush.GetLOGBRUSH(), 0, nil)\n\tif hPen == 0 {\n\t\tpanic(\"Failed to create pen\")\n\t}\n\n\treturn &Pen{hPen, style, brush}\n}\n\nfunc NewNullPen() *Pen {\n\tlb := w32.LOGBRUSH{LbStyle: w32.BS_NULL}\n\n\thPen := w32.ExtCreatePen(w32.PS_COSMETIC|w32.PS_NULL, 1, &lb, 0, nil)\n\tif hPen == 0 {\n\t\tpanic(\"failed to create null brush\")\n\t}\n\n\treturn &Pen{hPen: hPen}\n}\n\nfunc (pen *Pen) Style() uint {\n\treturn pen.style\n}\n\nfunc (pen *Pen) Brush() *Brush {\n\treturn pen.brush\n}\n\nfunc (pen *Pen) GetHPEN() w32.HPEN {\n\treturn pen.hPen\n}\n\nfunc (pen *Pen) Dispose() {\n\tif pen.hPen != 0 {\n\t\tw32.DeleteObject(w32.HGDIOBJ(pen.hPen))\n\t\tpen.hPen = 0\n\t}\n}\n"
  },
  {
    "path": "progressbar.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype ProgressBar struct {\n\tControlBase\n}\n\nfunc NewProgressBar(parent Controller) *ProgressBar {\n\tpb := new(ProgressBar)\n\n\tpb.InitControl(w32.PROGRESS_CLASS, parent, 0, w32.WS_CHILD|w32.WS_VISIBLE)\n\tRegMsgHandler(pb)\n\n\tpb.SetSize(200, 22)\n\treturn pb\n}\n\nfunc (pr *ProgressBar) Value() int {\n\tret := w32.SendMessage(pr.hwnd, w32.PBM_GETPOS, 0, 0)\n\treturn int(ret)\n}\n\nfunc (pr *ProgressBar) SetValue(v int) {\n\tw32.SendMessage(pr.hwnd, w32.PBM_SETPOS, uintptr(v), 0)\n}\n\nfunc (pr *ProgressBar) Range() (min, max uint) {\n\tmin = uint(w32.SendMessage(pr.hwnd, w32.PBM_GETRANGE, uintptr(w32.BoolToBOOL(true)), 0))\n\tmax = uint(w32.SendMessage(pr.hwnd, w32.PBM_GETRANGE, uintptr(w32.BoolToBOOL(false)), 0))\n\treturn\n}\n\nfunc (pr *ProgressBar) SetRange(min, max int) {\n\tw32.SendMessage(pr.hwnd, w32.PBM_SETRANGE32, uintptr(min), uintptr(max))\n}\n\nfunc (pr *ProgressBar) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\treturn w32.DefWindowProc(pr.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "rect.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Rect struct {\n\trect w32.RECT\n}\n\nfunc NewEmptyRect() *Rect {\n\tvar newRect Rect\n\tw32.SetRectEmpty(&newRect.rect)\n\n\treturn &newRect\n}\n\nfunc NewRect(left, top, right, bottom int) *Rect {\n\tvar newRect Rect\n\tw32.SetRectEmpty(&newRect.rect)\n\tnewRect.Set(left, top, right, bottom)\n\n\treturn &newRect\n}\n\nfunc (re *Rect) Data() (left, top, right, bottom int32) {\n\tleft = re.rect.Left\n\ttop = re.rect.Top\n\tright = re.rect.Right\n\tbottom = re.rect.Bottom\n\treturn\n}\n\nfunc (re *Rect) Width() int {\n\treturn int(re.rect.Right - re.rect.Left)\n}\n\nfunc (re *Rect) Height() int {\n\treturn int(re.rect.Bottom - re.rect.Top)\n}\n\nfunc (re *Rect) GetW32Rect() *w32.RECT {\n\treturn &re.rect\n}\n\nfunc (re *Rect) Set(left, top, right, bottom int) {\n\tw32.SetRect(&re.rect, left, top, right, bottom)\n}\n\nfunc (re *Rect) IsEqual(rect *Rect) bool {\n\treturn w32.EqualRect(&re.rect, &rect.rect)\n}\n\nfunc (re *Rect) Inflate(x, y int) {\n\tw32.InflateRect(&re.rect, x, y)\n}\n\nfunc (re *Rect) Intersect(src *Rect) {\n\tw32.IntersectRect(&re.rect, &re.rect, &src.rect)\n}\n\nfunc (re *Rect) IsEmpty() bool {\n\treturn w32.IsRectEmpty(&re.rect)\n}\n\nfunc (re *Rect) Offset(x, y int) {\n\tw32.OffsetRect(&re.rect, x, y)\n}\n\nfunc (re *Rect) IsPointIn(x, y int) bool {\n\treturn w32.PtInRect(&re.rect, x, y)\n}\n\nfunc (re *Rect) Substract(src *Rect) {\n\tw32.SubtractRect(&re.rect, &re.rect, &src.rect)\n}\n\nfunc (re *Rect) Union(src *Rect) {\n\tw32.UnionRect(&re.rect, &re.rect, &src.rect)\n}\n"
  },
  {
    "path": "resizer.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype VResizer struct {\n\tControlBase\n\n\tcontrol1 Dockable\n\tcontrol2 Dockable\n\tdir      Direction\n\n\tmouseLeft bool\n\tdrag      bool\n}\n\nfunc NewVResizer(parent Controller) *VResizer {\n\tsp := new(VResizer)\n\n\tRegClassOnlyOnce(\"winc_VResizer\")\n\tsp.hwnd = CreateWindow(\"winc_VResizer\", parent, w32.WS_EX_CONTROLPARENT, w32.WS_CHILD|w32.WS_VISIBLE)\n\tsp.parent = parent\n\tsp.mouseLeft = true\n\tRegMsgHandler(sp)\n\n\tsp.SetFont(DefaultFont)\n\tsp.SetText(\"\")\n\tsp.SetSize(20, 100)\n\treturn sp\n}\n\nfunc (sp *VResizer) SetControl(control1, control2 Dockable, dir Direction, minSize int) {\n\tsp.control1 = control1\n\tsp.control2 = control2\n\tif dir != Left && dir != Right {\n\t\tpanic(\"invalid direction\")\n\t}\n\tsp.dir = dir\n\n\t// TODO(vi): ADDED\n\t/*internalTrackMouseEvent(control1.Handle())\n\tinternalTrackMouseEvent(control2.Handle())\n\n\tcontrol1.OnMouseMove().Bind(func(e *Event) {\n\t\tif sp.drag {\n\t\t\tx := e.Data.(*MouseEventData).X\n\t\t\tsp.update(x)\n\t\t\tw32.SetCursor(w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_SIZEWE)))\n\n\t\t}\n\t\tfmt.Println(\"control1.OnMouseMove\")\n\t})\n\n\tcontrol2.OnMouseMove().Bind(func(e *Event) {\n\t\tif sp.drag {\n\t\t\tx := e.Data.(*MouseEventData).X\n\t\t\tsp.update(x)\n\t\t\tw32.SetCursor(w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_SIZEWE)))\n\n\t\t}\n\t\tfmt.Println(\"control2.OnMouseMove\")\n\t})\n\n\tcontrol1.OnLBUp().Bind(func(e *Event) {\n\t\tsp.drag = false\n\t\tsp.mouseLeft = true\n\t\tfmt.Println(\"control1.OnLBUp\")\n\t})\n\n\tcontrol2.OnLBUp().Bind(func(e *Event) {\n\t\tsp.drag = false\n\t\tsp.mouseLeft = true\n\t\tfmt.Println(\"control2.OnLBUp\")\n\t})*/\n\n\t// ---- finish ADDED\n\n}\n\nfunc (sp *VResizer) update(x int) {\n\tpos := x - 10\n\n\tw1, h1 := sp.control1.Width(), sp.control1.Height()\n\tif sp.dir == Left {\n\t\tw1 += pos\n\t} else {\n\t\tw1 -= pos\n\t}\n\tsp.control1.SetSize(w1, h1)\n\tfm := sp.parent.(*Form)\n\tfm.UpdateLayout()\n\n\tw32.SetCursor(w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_ARROW)))\n}\n\nfunc (sp *VResizer) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_CREATE:\n\t\tinternalTrackMouseEvent(sp.hwnd)\n\n\tcase w32.WM_MOUSEMOVE:\n\t\tif sp.drag {\n\t\t\tx, _ := genPoint(lparam)\n\t\t\tsp.update(x)\n\t\t} else {\n\t\t\tw32.SetCursor(w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_SIZEWE)))\n\t\t}\n\n\t\tif sp.mouseLeft {\n\t\t\tinternalTrackMouseEvent(sp.hwnd)\n\t\t\tsp.mouseLeft = false\n\t\t}\n\n\tcase w32.WM_MOUSELEAVE:\n\t\tsp.drag = false\n\t\tsp.mouseLeft = true\n\n\tcase w32.WM_LBUTTONUP:\n\t\tsp.drag = false\n\n\tcase w32.WM_LBUTTONDOWN:\n\t\tsp.drag = true\n\t}\n\treturn w32.DefWindowProc(sp.hwnd, msg, wparam, lparam)\n}\n\ntype HResizer struct {\n\tControlBase\n\n\tcontrol1  Dockable\n\tcontrol2  Dockable\n\tdir       Direction\n\tmouseLeft bool\n\tdrag      bool\n}\n\nfunc NewHResizer(parent Controller) *HResizer {\n\tsp := new(HResizer)\n\n\tRegClassOnlyOnce(\"winc_HResizer\")\n\tsp.hwnd = CreateWindow(\"winc_HResizer\", parent, w32.WS_EX_CONTROLPARENT, w32.WS_CHILD|w32.WS_VISIBLE)\n\tsp.parent = parent\n\tsp.mouseLeft = true\n\tRegMsgHandler(sp)\n\n\tsp.SetFont(DefaultFont)\n\tsp.SetText(\"\")\n\tsp.SetSize(100, 20)\n\n\treturn sp\n}\n\nfunc (sp *HResizer) SetControl(control1, control2 Dockable, dir Direction, minSize int) {\n\tsp.control1 = control1\n\tsp.control2 = control2\n\tif dir != Top && dir != Bottom {\n\t\tpanic(\"invalid direction\")\n\t}\n\tsp.dir = dir\n\n}\n\nfunc (sp *HResizer) update(y int) {\n\tpos := y - 10\n\n\tw1, h1 := sp.control1.Width(), sp.control1.Height()\n\tif sp.dir == Top {\n\t\th1 += pos\n\t} else {\n\t\th1 -= pos\n\t}\n\tsp.control1.SetSize(w1, h1)\n\n\tfm := sp.parent.(*Form)\n\tfm.UpdateLayout()\n\n\tw32.SetCursor(w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_ARROW)))\n}\n\nfunc (sp *HResizer) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_CREATE:\n\t\tinternalTrackMouseEvent(sp.hwnd)\n\n\tcase w32.WM_MOUSEMOVE:\n\t\tif sp.drag {\n\t\t\t_, y := genPoint(lparam)\n\t\t\tsp.update(y)\n\t\t} else {\n\t\t\tw32.SetCursor(w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_SIZENS)))\n\t\t}\n\n\t\tif sp.mouseLeft {\n\t\t\tinternalTrackMouseEvent(sp.hwnd)\n\t\t\tsp.mouseLeft = false\n\t\t}\n\n\tcase w32.WM_MOUSELEAVE:\n\t\tsp.drag = false\n\t\tsp.mouseLeft = true\n\n\tcase w32.WM_LBUTTONUP:\n\t\tsp.drag = false\n\n\tcase w32.WM_LBUTTONDOWN:\n\t\tsp.drag = true\n\t}\n\treturn w32.DefWindowProc(sp.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "scrollview.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype ScrollView struct {\n\tControlBase\n\tchild Dockable\n}\n\nfunc NewScrollView(parent Controller) *ScrollView {\n\tsv := new(ScrollView)\n\n\tRegClassOnlyOnce(\"winc_ScrollView\")\n\tsv.hwnd = CreateWindow(\"winc_ScrollView\", parent, w32.WS_EX_CONTROLPARENT,\n\t\tw32.WS_CHILD|w32.WS_HSCROLL|w32.WS_VISIBLE|w32.WS_VSCROLL)\n\tsv.parent = parent\n\tRegMsgHandler(sv)\n\n\tsv.SetFont(DefaultFont)\n\tsv.SetText(\"\")\n\tsv.SetSize(200, 200)\n\treturn sv\n}\n\nfunc (sv *ScrollView) SetChild(child Dockable) {\n\tsv.child = child\n}\n\nfunc (sv *ScrollView) UpdateScrollBars() {\n\tw, h := sv.child.Width(), sv.child.Height()\n\tsw, sh := sv.Size()\n\n\tvar si w32.SCROLLINFO\n\tsi.CbSize = uint32(unsafe.Sizeof(si))\n\tsi.FMask = w32.SIF_PAGE | w32.SIF_RANGE\n\n\tsi.NMax = int32(w - 1)\n\tsi.NPage = uint32(sw)\n\tw32.SetScrollInfo(sv.hwnd, w32.SB_HORZ, &si, true)\n\tx := sv.scroll(w32.SB_HORZ, w32.SB_THUMBPOSITION)\n\n\tsi.NMax = int32(h)\n\tsi.NPage = uint32(sh)\n\tw32.SetScrollInfo(sv.hwnd, w32.SB_VERT, &si, true)\n\ty := sv.scroll(w32.SB_VERT, w32.SB_THUMBPOSITION)\n\n\tsv.child.SetPos(x, y)\n}\n\nfunc (sv *ScrollView) scroll(sb int32, cmd uint16) int {\n\tvar pos int32\n\tvar si w32.SCROLLINFO\n\tsi.CbSize = uint32(unsafe.Sizeof(si))\n\tsi.FMask = w32.SIF_PAGE | w32.SIF_POS | w32.SIF_RANGE | w32.SIF_TRACKPOS\n\n\tw32.GetScrollInfo(sv.hwnd, sb, &si)\n\tpos = si.NPos\n\n\tswitch cmd {\n\tcase w32.SB_LINELEFT: // == win.SB_LINEUP\n\t\tpos -= 20\n\n\tcase w32.SB_LINERIGHT: // == win.SB_LINEDOWN\n\t\tpos += 20\n\n\tcase w32.SB_PAGELEFT: // == win.SB_PAGEUP\n\t\tpos -= int32(si.NPage)\n\n\tcase w32.SB_PAGERIGHT: // == win.SB_PAGEDOWN\n\t\tpos += int32(si.NPage)\n\n\tcase w32.SB_THUMBTRACK:\n\t\tpos = si.NTrackPos\n\t}\n\n\tif pos < 0 {\n\t\tpos = 0\n\t}\n\tif pos > si.NMax+1-int32(si.NPage) {\n\t\tpos = si.NMax + 1 - int32(si.NPage)\n\t}\n\n\tsi.FMask = w32.SIF_POS\n\tsi.NPos = pos\n\tw32.SetScrollInfo(sv.hwnd, sb, &si, true)\n\n\treturn -int(pos)\n}\n\nfunc (sv *ScrollView) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tif sv.child != nil {\n\t\tswitch msg {\n\t\tcase w32.WM_PAINT:\n\t\t\tsv.UpdateScrollBars()\n\n\t\tcase w32.WM_HSCROLL:\n\t\t\tx, y := sv.child.Pos()\n\t\t\tx = sv.scroll(w32.SB_HORZ, w32.LOWORD(uint32(wparam)))\n\t\t\tsv.child.SetPos(x, y)\n\n\t\tcase w32.WM_VSCROLL:\n\t\t\tx, y := sv.child.Pos()\n\t\t\ty = sv.scroll(w32.SB_VERT, w32.LOWORD(uint32(wparam)))\n\t\t\tsv.child.SetPos(x, y)\n\n\t\tcase w32.WM_SIZE, w32.WM_SIZING:\n\t\t\tsv.UpdateScrollBars()\n\t\t}\n\t}\n\treturn w32.DefWindowProc(sv.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "slider.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport \"github.com/tadvi/winc/w32\"\n\ntype Slider struct {\n\tControlBase\n\tprevPos int\n\n\tonScroll EventManager\n}\n\nfunc NewSlider(parent Controller) *Slider {\n\ttb := new(Slider)\n\n\ttb.InitControl(\"msctls_trackbar32\", parent, 0, w32.WS_TABSTOP|w32.WS_VISIBLE|w32.WS_CHILD /*|w32.TBS_AUTOTICKS*/)\n\tRegMsgHandler(tb)\n\n\ttb.SetFont(DefaultFont)\n\ttb.SetText(\"Slider\")\n\ttb.SetSize(200, 32)\n\n\ttb.SetRange(0, 100)\n\ttb.SetPage(10)\n\treturn tb\n}\n\nfunc (tb *Slider) OnScroll() *EventManager {\n\treturn &tb.onScroll\n}\n\nfunc (tb *Slider) Value() int {\n\tret := w32.SendMessage(tb.hwnd, w32.TBM_GETPOS, 0, 0)\n\treturn int(ret)\n}\n\nfunc (tb *Slider) SetValue(v int) {\n\ttb.prevPos = v\n\tw32.SendMessage(tb.hwnd, w32.TBM_SETPOS, uintptr(w32.BoolToBOOL(true)), uintptr(v))\n}\n\nfunc (tb *Slider) Range() (min, max int) {\n\tmin = int(w32.SendMessage(tb.hwnd, w32.TBM_GETRANGEMIN, 0, 0))\n\tmax = int(w32.SendMessage(tb.hwnd, w32.TBM_GETRANGEMAX, 0, 0))\n\treturn min, max\n}\n\nfunc (tb *Slider) SetRange(min, max int) {\n\tw32.SendMessage(tb.hwnd, w32.TBM_SETRANGE, uintptr(w32.BoolToBOOL(true)), uintptr(w32.MAKELONG(uint16(min), uint16(max))))\n}\n\nfunc (tb *Slider) SetPage(pagesize int) {\n\tw32.SendMessage(tb.hwnd, w32.TBM_SETPAGESIZE, 0, uintptr(pagesize))\n}\n\nfunc (tb *Slider) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\t/*\n\t\t// REMOVE:\n\t\t// following code did not work, used workaround below\n\t\tcode := w32.LOWORD(uint32(wparam))\n\n\t\tswitch code {\n\t\tcase w32.TB_ENDTRACK:\n\t\t\ttb.onScroll.Fire(NewEvent(tb, nil))\n\t\t}*/\n\n\tnewPos := tb.Value()\n\tif newPos != tb.prevPos {\n\t\ttb.onScroll.Fire(NewEvent(tb, nil))\n\t\ttb.prevPos = newPos\n\t}\n\n\treturn w32.DefWindowProc(tb.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "tabview.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\n// TabView creates MultiPanel internally and manages tabs as panels.\ntype TabView struct {\n\tControlBase\n\n\tpanels           *MultiPanel\n\tonSelectedChange EventManager\n}\n\nfunc NewTabView(parent Controller) *TabView {\n\ttv := new(TabView)\n\n\ttv.InitControl(\"SysTabControl32\", parent, 0,\n\t\tw32.WS_CHILD|w32.WS_VISIBLE|w32.WS_TABSTOP|w32.WS_CLIPSIBLINGS)\n\tRegMsgHandler(tv)\n\n\ttv.panels = NewMultiPanel(parent)\n\n\ttv.SetFont(DefaultFont)\n\ttv.SetSize(200, 24)\n\treturn tv\n}\n\nfunc (tv *TabView) Panels() *MultiPanel {\n\treturn tv.panels\n}\n\nfunc (tv *TabView) tcitemFromPage(panel *Panel) *w32.TCITEM {\n\ttext := syscall.StringToUTF16(panel.Text())\n\titem := &w32.TCITEM{\n\t\tMask:       w32.TCIF_TEXT,\n\t\tPszText:    &text[0],\n\t\tCchTextMax: int32(len(text)),\n\t}\n\treturn item\n}\n\nfunc (tv *TabView) AddPanel(text string) *Panel {\n\tpanel := NewPanel(tv.panels)\n\tpanel.SetText(text)\n\n\titem := tv.tcitemFromPage(panel)\n\tindex := tv.panels.Count()\n\tidx := int(w32.SendMessage(tv.hwnd, w32.TCM_INSERTITEM, uintptr(index), uintptr(unsafe.Pointer(item))))\n\tif idx == -1 {\n\t\tpanic(\"SendMessage(TCM_INSERTITEM) failed\")\n\t}\n\n\ttv.panels.AddPanel(panel)\n\ttv.SetCurrent(idx)\n\treturn panel\n}\n\nfunc (tv *TabView) DeletePanel(index int) {\n\tw32.SendMessage(tv.hwnd, w32.TCM_DELETEITEM, uintptr(index), 0)\n\ttv.panels.DeletePanel(index)\n\tswitch {\n\tcase tv.panels.Count() > index:\n\t\ttv.SetCurrent(index)\n\tcase tv.panels.Count() == 0:\n\t\ttv.SetCurrent(0)\n\t}\n}\n\nfunc (tv *TabView) Current() int {\n\treturn tv.panels.Current()\n}\n\nfunc (tv *TabView) SetCurrent(index int) {\n\tif index < 0 || index >= tv.panels.Count() {\n\t\tpanic(\"invalid index\")\n\t}\n\tif ret := int(w32.SendMessage(tv.hwnd, w32.TCM_SETCURSEL, uintptr(index), 0)); ret == -1 {\n\t\tpanic(\"SendMessage(TCM_SETCURSEL) failed\")\n\t}\n\ttv.panels.SetCurrent(index)\n}\n\nfunc (tv *TabView) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_NOTIFY:\n\t\tnmhdr := (*w32.NMHDR)(unsafe.Pointer(lparam))\n\n\t\tswitch int32(nmhdr.Code) {\n\t\tcase w32.TCN_SELCHANGE:\n\t\t\tcur := int(w32.SendMessage(tv.hwnd, w32.TCM_GETCURSEL, 0, 0))\n\t\t\ttv.SetCurrent(cur)\n\n\t\t\ttv.onSelectedChange.Fire(NewEvent(tv, nil))\n\t\t}\n\t}\n\treturn w32.DefWindowProc(tv.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "toolbar.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype Toolbar struct {\n\tControlBase\n\timl *ImageList\n\n\tbuttons []*ToolButton\n}\n\ntype ToolButton struct {\n\ttb *Toolbar\n\n\ttext      string\n\tenabled   bool\n\tcheckable bool\n\tchecked   bool\n\timage     int\n\n\tonClick EventManager\n}\n\nfunc (bt *ToolButton) OnClick() *EventManager {\n\treturn &bt.onClick\n}\n\nfunc (bt *ToolButton) update() { bt.tb.update(bt) }\n\nfunc (bt *ToolButton) IsSeparator() bool { return bt.text == \"-\" }\nfunc (bt *ToolButton) SetSeparator()     { bt.text = \"-\" }\n\nfunc (bt *ToolButton) Enabled() bool     { return bt.enabled }\nfunc (bt *ToolButton) SetEnabled(b bool) { bt.enabled = b; bt.update() }\n\nfunc (bt *ToolButton) Checkable() bool     { return bt.checkable }\nfunc (bt *ToolButton) SetCheckable(b bool) { bt.checkable = b; bt.update() }\n\nfunc (bt *ToolButton) Checked() bool     { return bt.checked }\nfunc (bt *ToolButton) SetChecked(b bool) { bt.checked = b; bt.update() }\n\nfunc (bt *ToolButton) Text() string     { return bt.text }\nfunc (bt *ToolButton) SetText(s string) { bt.text = s; bt.update() }\n\nfunc (bt *ToolButton) Image() int     { return bt.image }\nfunc (bt *ToolButton) SetImage(i int) { bt.image = i; bt.update() }\n\n// NewHToolbar creates horizontal toolbar with text on same line as image.\nfunc NewHToolbar(parent Controller) *Toolbar {\n\treturn newToolbar(parent, w32.CCS_NODIVIDER|w32.TBSTYLE_FLAT|w32.TBSTYLE_TOOLTIPS|w32.TBSTYLE_WRAPABLE|\n\t\tw32.WS_CHILD|w32.TBSTYLE_LIST)\n}\n\n// NewToolbar creates toolbar with text below the image.\nfunc NewToolbar(parent Controller) *Toolbar {\n\treturn newToolbar(parent, w32.CCS_NODIVIDER|w32.TBSTYLE_FLAT|w32.TBSTYLE_TOOLTIPS|w32.TBSTYLE_WRAPABLE|\n\t\tw32.WS_CHILD /*|w32.TBSTYLE_TRANSPARENT*/)\n}\n\nfunc newToolbar(parent Controller, style uint) *Toolbar {\n\ttb := new(Toolbar)\n\n\ttb.InitControl(\"ToolbarWindow32\", parent, 0, style)\n\n\texStyle := w32.SendMessage(tb.hwnd, w32.TB_GETEXTENDEDSTYLE, 0, 0)\n\texStyle |= w32.TBSTYLE_EX_DRAWDDARROWS | w32.TBSTYLE_EX_MIXEDBUTTONS\n\tw32.SendMessage(tb.hwnd, w32.TB_SETEXTENDEDSTYLE, 0, exStyle)\n\tRegMsgHandler(tb)\n\n\ttb.SetFont(DefaultFont)\n\ttb.SetPos(0, 0)\n\ttb.SetSize(200, 40)\n\n\treturn tb\n}\n\nfunc (tb *Toolbar) SetImageList(imageList *ImageList) {\n\tw32.SendMessage(tb.hwnd, w32.TB_SETIMAGELIST, 0, uintptr(imageList.Handle()))\n\ttb.iml = imageList\n}\n\nfunc (tb *Toolbar) initButton(btn *ToolButton, state, style *byte, image *int32, text *uintptr) {\n\t*style |= w32.BTNS_AUTOSIZE\n\n\tif btn.checked {\n\t\t*state |= w32.TBSTATE_CHECKED\n\t}\n\n\tif btn.enabled {\n\t\t*state |= w32.TBSTATE_ENABLED\n\t}\n\n\tif btn.checkable {\n\t\t*style |= w32.BTNS_CHECK\n\t}\n\n\tif len(btn.Text()) > 0 {\n\t\t*style |= w32.BTNS_SHOWTEXT\n\t}\n\n\tif btn.IsSeparator() {\n\t\t*style = w32.BTNS_SEP\n\t}\n\n\t*image = int32(btn.Image())\n\t*text = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(btn.Text())))\n}\n\nfunc (tb *Toolbar) update(btn *ToolButton) {\n\ttbbi := w32.TBBUTTONINFO{\n\t\tDwMask: w32.TBIF_IMAGE | w32.TBIF_STATE | w32.TBIF_STYLE | w32.TBIF_TEXT,\n\t}\n\n\ttbbi.CbSize = uint32(unsafe.Sizeof(tbbi))\n\n\tvar i int\n\tfor i = range tb.buttons {\n\t\tif tb.buttons[i] == btn {\n\t\t\tbreak\n\t\t}\n\t}\n\n\ttb.initButton(btn, &tbbi.FsState, &tbbi.FsStyle, &tbbi.IImage, &tbbi.PszText)\n\tif w32.SendMessage(tb.hwnd, w32.TB_SETBUTTONINFO, uintptr(i), uintptr(unsafe.Pointer(&tbbi))) == 0 {\n\t\tpanic(\"SendMessage(TB_SETBUTTONINFO) failed\")\n\t}\n}\n\nfunc (tb *Toolbar) AddSeparator() {\n\ttb.AddButton(\"-\", 0)\n}\n\n// AddButton creates and adds button to the toolbar. Use returned toolbutton to setup OnClick event.\nfunc (tb *Toolbar) AddButton(text string, image int) *ToolButton {\n\tbt := &ToolButton{\n\t\ttb:      tb, // points to parent\n\t\ttext:    text,\n\t\timage:   image,\n\t\tenabled: true,\n\t}\n\ttb.buttons = append(tb.buttons, bt)\n\tindex := len(tb.buttons) - 1\n\n\ttbb := w32.TBBUTTON{\n\t\tIdCommand: int32(index),\n\t}\n\n\ttb.initButton(bt, &tbb.FsState, &tbb.FsStyle, &tbb.IBitmap, &tbb.IString)\n\tw32.SendMessage(tb.hwnd, w32.TB_BUTTONSTRUCTSIZE, uintptr(unsafe.Sizeof(tbb)), 0)\n\n\tif w32.SendMessage(tb.hwnd, w32.TB_INSERTBUTTON, uintptr(index), uintptr(unsafe.Pointer(&tbb))) == w32.FALSE {\n\t\tpanic(\"SendMessage(TB_ADDBUTTONS)\")\n\t}\n\n\tw32.SendMessage(tb.hwnd, w32.TB_AUTOSIZE, 0, 0)\n\treturn bt\n}\n\nfunc (tb *Toolbar) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_COMMAND:\n\t\tswitch w32.HIWORD(uint32(wparam)) {\n\t\tcase w32.BN_CLICKED:\n\t\t\tid := uint16(w32.LOWORD(uint32(wparam)))\n\t\t\tbtn := tb.buttons[id]\n\t\t\tbtn.onClick.Fire(NewEvent(tb, nil))\n\t\t}\n\t}\n\treturn w32.DefWindowProc(tb.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "tooltip.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\ntype ToolTip struct {\n\tControlBase\n}\n\nfunc NewToolTip(parent Controller) *ToolTip {\n\ttp := new(ToolTip)\n\n\ttp.InitControl(\"tooltips_class32\", parent, w32.WS_EX_TOPMOST, w32.WS_POPUP|w32.TTS_NOPREFIX|w32.TTS_ALWAYSTIP)\n\tw32.SetWindowPos(tp.Handle(), w32.HWND_TOPMOST, 0, 0, 0, 0, w32.SWP_NOMOVE|w32.SWP_NOSIZE|w32.SWP_NOACTIVATE)\n\n\treturn tp\n}\n\nfunc (tp *ToolTip) SetTip(tool Controller, tip string) bool {\n\tvar ti w32.TOOLINFO\n\tti.CbSize = uint32(unsafe.Sizeof(ti))\n\tif tool.Parent() != nil {\n\t\tti.Hwnd = tool.Parent().Handle()\n\t}\n\tti.UFlags = w32.TTF_IDISHWND | w32.TTF_SUBCLASS /* | TTF_ABSOLUTE */\n\tti.UId = uintptr(tool.Handle())\n\tti.LpszText = syscall.StringToUTF16Ptr(tip)\n\n\treturn w32.SendMessage(tp.Handle(), w32.TTM_ADDTOOL, 0, uintptr(unsafe.Pointer(&ti))) != w32.FALSE\n}\n\nfunc (tp *ToolTip) WndProc(msg uint, wparam, lparam uintptr) uintptr {\n\treturn w32.DefWindowProc(tp.hwnd, uint32(msg), wparam, lparam)\n}\n"
  },
  {
    "path": "treeview.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"errors\"\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\n// TreeItem represents an item in a TreeView widget.\ntype TreeItem interface {\n\tText() string    // Text returns the text of the item.\n\tImageIndex() int // ImageIndex is used only if SetImageList is called on the treeview\n}\n\ntype treeViewItemInfo struct {\n\thandle       w32.HTREEITEM\n\tchild2Handle map[TreeItem]w32.HTREEITEM\n}\n\n// StringTreeItem is helper for basic string lists.\ntype StringTreeItem struct {\n\tData  string\n\tImage int\n}\n\nfunc (s StringTreeItem) Text() string    { return s.Data }\nfunc (s StringTreeItem) ImageIndex() int { return s.Image }\n\ntype TreeView struct {\n\tControlBase\n\n\timl         *ImageList\n\titem2Info   map[TreeItem]*treeViewItemInfo\n\thandle2Item map[w32.HTREEITEM]TreeItem\n\tcurrItem    TreeItem\n\n\tonSelectedChange EventManager\n\tonExpand         EventManager\n\tonCollapse       EventManager\n\tonViewChange     EventManager\n}\n\nfunc NewTreeView(parent Controller) *TreeView {\n\ttv := new(TreeView)\n\n\ttv.InitControl(\"SysTreeView32\", parent, 0, w32.WS_CHILD|w32.WS_VISIBLE|\n\t\tw32.WS_BORDER|w32.TVS_HASBUTTONS|w32.TVS_LINESATROOT|w32.TVS_SHOWSELALWAYS|\n\t\tw32.TVS_TRACKSELECT /*|w32.WS_EX_CLIENTEDGE*/)\n\n\ttv.item2Info = make(map[TreeItem]*treeViewItemInfo)\n\ttv.handle2Item = make(map[w32.HTREEITEM]TreeItem)\n\n\tRegMsgHandler(tv)\n\n\ttv.SetFont(DefaultFont)\n\ttv.SetSize(200, 400)\n\n\tif err := tv.SetTheme(\"Explorer\"); err != nil {\n\t\t// theme error is ignored\n\t}\n\treturn tv\n}\n\nfunc (tv *TreeView) EnableDoubleBuffer(enable bool) {\n\tif enable {\n\t\tw32.SendMessage(tv.hwnd, w32.TVM_SETEXTENDEDSTYLE, 0, w32.TVS_EX_DOUBLEBUFFER)\n\t} else {\n\t\tw32.SendMessage(tv.hwnd, w32.TVM_SETEXTENDEDSTYLE, w32.TVS_EX_DOUBLEBUFFER, 0)\n\t}\n}\n\n// SelectedItem is current selected item after OnSelectedChange event.\nfunc (tv *TreeView) SelectedItem() TreeItem {\n\treturn tv.currItem\n}\n\nfunc (tv *TreeView) SetSelectedItem(item TreeItem) bool {\n\tvar handle w32.HTREEITEM\n\tif item != nil {\n\t\tif info := tv.item2Info[item]; info == nil {\n\t\t\treturn false // invalid item\n\t\t} else {\n\t\t\thandle = info.handle\n\t\t}\n\t}\n\n\tif w32.SendMessage(tv.hwnd, w32.TVM_SELECTITEM, w32.TVGN_CARET, uintptr(handle)) == 0 {\n\t\treturn false // set selected failed\n\t}\n\ttv.currItem = item\n\treturn true\n}\n\nfunc (tv *TreeView) ItemAt(x, y int) TreeItem {\n\thti := w32.TVHITTESTINFO{Pt: w32.POINT{int32(x), int32(y)}}\n\tw32.SendMessage(tv.hwnd, w32.TVM_HITTEST, 0, uintptr(unsafe.Pointer(&hti)))\n\tif item, ok := tv.handle2Item[hti.HItem]; ok {\n\t\treturn item\n\t}\n\treturn nil\n}\n\nfunc (tv *TreeView) Items() (list []TreeItem) {\n\tfor item := range tv.item2Info {\n\t\tlist = append(list, item)\n\t}\n\treturn list\n}\n\nfunc (tv *TreeView) InsertItem(item, parent, insertAfter TreeItem) error {\n\tvar tvins w32.TVINSERTSTRUCT\n\ttvi := &tvins.Item\n\n\ttvi.Mask = w32.TVIF_TEXT                                                     // w32.TVIF_CHILDREN | w32.TVIF_TEXT\n\ttvi.PszText = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(item.Text()))) // w32.LPSTR_TEXTCALLBACK\n\ttvi.CChildren = 0                                                            // w32.I_CHILDRENCALLBACK\n\n\tif parent == nil {\n\t\ttvins.HParent = w32.TVI_ROOT\n\t} else {\n\t\tinfo := tv.item2Info[parent]\n\t\tif info == nil {\n\t\t\treturn errors.New(\"winc: invalid parent\")\n\t\t}\n\t\ttvins.HParent = info.handle\n\t}\n\n\tif insertAfter == nil {\n\t\ttvins.HInsertAfter = w32.TVI_LAST\n\t} else {\n\t\tinfo := tv.item2Info[insertAfter]\n\t\tif info == nil {\n\t\t\treturn errors.New(\"winc: invalid prev item\")\n\t\t}\n\t\ttvins.HInsertAfter = info.handle\n\t}\n\n\ttv.applyImage(tvi, item)\n\n\thItem := w32.HTREEITEM(w32.SendMessage(tv.hwnd, w32.TVM_INSERTITEM, 0, uintptr(unsafe.Pointer(&tvins))))\n\tif hItem == 0 {\n\t\treturn errors.New(\"winc: TVM_INSERTITEM failed\")\n\t}\n\ttv.item2Info[item] = &treeViewItemInfo{hItem, make(map[TreeItem]w32.HTREEITEM)}\n\ttv.handle2Item[hItem] = item\n\treturn nil\n}\n\nfunc (tv *TreeView) UpdateItem(item TreeItem) bool {\n\tit := tv.item2Info[item]\n\tif it == nil {\n\t\treturn false\n\t}\n\n\ttvi := &w32.TVITEM{\n\t\tMask:    w32.TVIF_TEXT,\n\t\tHItem:   it.handle,\n\t\tPszText: uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(item.Text()))),\n\t}\n\ttv.applyImage(tvi, item)\n\n\tif w32.SendMessage(tv.hwnd, w32.TVM_SETITEM, 0, uintptr(unsafe.Pointer(tvi))) == 0 {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc (tv *TreeView) DeleteItem(item TreeItem) bool {\n\tit := tv.item2Info[item]\n\tif it == nil {\n\t\treturn false\n\t}\n\n\tif w32.SendMessage(tv.hwnd, w32.TVM_DELETEITEM, 0, uintptr(it.handle)) == 0 {\n\t\treturn false\n\t}\n\n\tdelete(tv.item2Info, item)\n\tdelete(tv.handle2Item, it.handle)\n\treturn true\n}\n\nfunc (tv *TreeView) DeleteAllItems() bool {\n\tif w32.SendMessage(tv.hwnd, w32.TVM_DELETEITEM, 0, 0) == 0 {\n\t\treturn false\n\t}\n\n\ttv.item2Info = make(map[TreeItem]*treeViewItemInfo)\n\ttv.handle2Item = make(map[w32.HTREEITEM]TreeItem)\n\treturn true\n}\n\nfunc (tv *TreeView) Expand(item TreeItem) bool {\n\tif w32.SendMessage(tv.hwnd, w32.TVM_EXPAND, w32.TVE_EXPAND, uintptr(tv.item2Info[item].handle)) == 0 {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc (tv *TreeView) Collapse(item TreeItem) bool {\n\tif w32.SendMessage(tv.hwnd, w32.TVM_EXPAND, w32.TVE_COLLAPSE, uintptr(tv.item2Info[item].handle)) == 0 {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc (tv *TreeView) EnsureVisible(item TreeItem) bool {\n\tif info := tv.item2Info[item]; info != nil {\n\t\treturn w32.SendMessage(tv.hwnd, w32.TVM_ENSUREVISIBLE, 0, uintptr(info.handle)) != 0\n\t}\n\treturn false\n}\n\nfunc (tv *TreeView) SetImageList(imageList *ImageList) {\n\tw32.SendMessage(tv.hwnd, w32.TVM_SETIMAGELIST, 0, uintptr(imageList.Handle()))\n\ttv.iml = imageList\n}\n\nfunc (tv *TreeView) applyImage(tc *w32.TVITEM, item TreeItem) {\n\tif tv.iml != nil {\n\t\ttc.Mask |= w32.TVIF_IMAGE | w32.TVIF_SELECTEDIMAGE\n\t\ttc.IImage = int32(item.ImageIndex())\n\t\ttc.ISelectedImage = int32(item.ImageIndex())\n\t}\n}\n\nfunc (tv *TreeView) OnSelectedChange() *EventManager {\n\treturn &tv.onSelectedChange\n}\n\nfunc (tv *TreeView) OnExpand() *EventManager {\n\treturn &tv.onExpand\n}\n\nfunc (tv *TreeView) OnCollapse() *EventManager {\n\treturn &tv.onCollapse\n}\n\nfunc (tv *TreeView) OnViewChange() *EventManager {\n\treturn &tv.onViewChange\n}\n\n// Message processer\nfunc (tv *TreeView) WndProc(msg uint32, wparam, lparam uintptr) uintptr {\n\tswitch msg {\n\tcase w32.WM_NOTIFY:\n\t\tnm := (*w32.NMHDR)(unsafe.Pointer(lparam))\n\n\t\tswitch nm.Code {\n\t\tcase w32.TVN_ITEMEXPANDED:\n\t\t\tnmtv := (*w32.NMTREEVIEW)(unsafe.Pointer(lparam))\n\n\t\t\tswitch nmtv.Action {\n\t\t\tcase w32.TVE_COLLAPSE:\n\t\t\t\ttv.onCollapse.Fire(NewEvent(tv, nil))\n\n\t\t\tcase w32.TVE_COLLAPSERESET:\n\n\t\t\tcase w32.TVE_EXPAND:\n\t\t\t\ttv.onExpand.Fire(NewEvent(tv, nil))\n\n\t\t\tcase w32.TVE_EXPANDPARTIAL:\n\n\t\t\tcase w32.TVE_TOGGLE:\n\t\t\t}\n\n\t\tcase w32.TVN_SELCHANGED:\n\t\t\tnmtv := (*w32.NMTREEVIEW)(unsafe.Pointer(lparam))\n\t\t\ttv.currItem = tv.handle2Item[nmtv.ItemNew.HItem]\n\t\t\ttv.onSelectedChange.Fire(NewEvent(tv, nil))\n\n\t\tcase w32.TVN_GETDISPINFO:\n\t\t\ttv.onViewChange.Fire(NewEvent(tv, nil))\n\t\t}\n\n\t}\n\treturn w32.DefWindowProc(tv.hwnd, msg, wparam, lparam)\n}\n"
  },
  {
    "path": "utils.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"fmt\"\n\t\"syscall\"\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\nfunc internalTrackMouseEvent(hwnd w32.HWND) {\n\tvar tme w32.TRACKMOUSEEVENT\n\ttme.CbSize = uint32(unsafe.Sizeof(tme))\n\ttme.DwFlags = w32.TME_LEAVE\n\ttme.HwndTrack = hwnd\n\ttme.DwHoverTime = w32.HOVER_DEFAULT\n\n\tw32.TrackMouseEvent(&tme)\n}\n\nfunc ToggleStyle(hwnd w32.HWND, b bool, style int) {\n\toriginalStyle := int(w32.GetWindowLongPtr(hwnd, w32.GWL_STYLE))\n\tif originalStyle != 0 {\n\t\tif b {\n\t\t\toriginalStyle |= style\n\t\t} else {\n\t\t\toriginalStyle ^= style\n\t\t}\n\t\tw32.SetWindowLongPtr(hwnd, w32.GWL_STYLE, uintptr(originalStyle))\n\t}\n}\n\nfunc ToggleExStyle(hwnd w32.HWND, b bool, style int) {\n\toriginalStyle := int(w32.GetWindowLongPtr(hwnd, w32.GWL_EXSTYLE))\n\tif originalStyle != 0 {\n\t\tif b {\n\t\t\toriginalStyle |= style\n\t\t} else {\n\t\t\toriginalStyle ^= style\n\t\t}\n\t\tw32.SetWindowLongPtr(hwnd, w32.GWL_EXSTYLE, uintptr(originalStyle))\n\t}\n}\n\nfunc CreateWindow(className string, parent Controller, exStyle, style uint) w32.HWND {\n\tinstance := GetAppInstance()\n\tvar parentHwnd w32.HWND\n\tif parent != nil {\n\t\tparentHwnd = parent.Handle()\n\t}\n\tvar hwnd w32.HWND\n\thwnd = w32.CreateWindowEx(\n\t\texStyle,\n\t\tsyscall.StringToUTF16Ptr(className),\n\t\tnil,\n\t\tstyle,\n\t\tw32.CW_USEDEFAULT,\n\t\tw32.CW_USEDEFAULT,\n\t\tw32.CW_USEDEFAULT,\n\t\tw32.CW_USEDEFAULT,\n\t\tparentHwnd,\n\t\t0,\n\t\tinstance,\n\t\tnil)\n\n\tif hwnd == 0 {\n\t\terrStr := fmt.Sprintf(\"Error occurred in CreateWindow(%s, %v, %d, %d)\", className, parent, exStyle, style)\n\t\tpanic(errStr)\n\t}\n\n\treturn hwnd\n}\n\nfunc RegisterClass(className string, wndproc uintptr) {\n\tinstance := GetAppInstance()\n\ticon := w32.LoadIcon(instance, w32.MakeIntResource(w32.IDI_APPLICATION))\n\n\tvar wc w32.WNDCLASSEX\n\twc.Size = uint32(unsafe.Sizeof(wc))\n\twc.Style = w32.CS_HREDRAW | w32.CS_VREDRAW\n\twc.WndProc = wndproc\n\twc.Instance = instance\n\twc.Background = w32.COLOR_BTNFACE + 1\n\twc.Icon = icon\n\twc.Cursor = w32.LoadCursor(0, w32.MakeIntResource(w32.IDC_ARROW))\n\twc.ClassName = syscall.StringToUTF16Ptr(className)\n\twc.MenuName = nil\n\twc.IconSm = icon\n\n\tif ret := w32.RegisterClassEx(&wc); ret == 0 {\n\t\tpanic(syscall.GetLastError())\n\t}\n}\n\nfunc getMonitorInfo(hwnd w32.HWND) *w32.MONITORINFO {\n\tcurrentMonitor := w32.MonitorFromWindow(hwnd, w32.MONITOR_DEFAULTTONEAREST)\n\tvar info w32.MONITORINFO\n\tinfo.CbSize = uint32(unsafe.Sizeof(info))\n\tw32.GetMonitorInfo(currentMonitor, &info)\n\treturn &info\n}\nfunc getWindowInfo(hwnd w32.HWND) *w32.WINDOWINFO {\n\tvar info w32.WINDOWINFO\n\tinfo.CbSize = uint32(unsafe.Sizeof(info))\n\tw32.GetWindowInfo(hwnd, &info)\n\treturn &info\n}\n\nfunc RegClassOnlyOnce(className string) {\n\tisExists := false\n\tfor _, class := range gRegisteredClasses {\n\t\tif class == className {\n\t\t\tisExists = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !isExists {\n\t\tRegisterClass(className, GeneralWndprocCallBack)\n\t\tgRegisteredClasses = append(gRegisteredClasses, className)\n\t}\n}\n\nfunc ScreenToClientRect(hwnd w32.HWND, rect *w32.RECT) *Rect {\n\tl, t, r, b := rect.Left, rect.Top, rect.Right, rect.Bottom\n\tl1, t1, _ := w32.ScreenToClient(hwnd, int(l), int(t))\n\tr1, b1, _ := w32.ScreenToClient(hwnd, int(r), int(b))\n\treturn NewRect(l1, t1, r1, b1)\n}\n"
  },
  {
    "path": "w32/comctl32.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmodcomctl32 = syscall.NewLazyDLL(\"comctl32.dll\")\n\n\tprocInitCommonControlsEx    = modcomctl32.NewProc(\"InitCommonControlsEx\")\n\tprocImageList_Create        = modcomctl32.NewProc(\"ImageList_Create\")\n\tprocImageList_Destroy       = modcomctl32.NewProc(\"ImageList_Destroy\")\n\tprocImageList_GetImageCount = modcomctl32.NewProc(\"ImageList_GetImageCount\")\n\tprocImageList_SetImageCount = modcomctl32.NewProc(\"ImageList_SetImageCount\")\n\tprocImageList_Add           = modcomctl32.NewProc(\"ImageList_Add\")\n\tprocImageList_ReplaceIcon   = modcomctl32.NewProc(\"ImageList_ReplaceIcon\")\n\tprocImageList_Remove        = modcomctl32.NewProc(\"ImageList_Remove\")\n\tprocTrackMouseEvent         = modcomctl32.NewProc(\"_TrackMouseEvent\")\n)\n\nfunc InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool {\n\tret, _, _ := procInitCommonControlsEx.Call(\n\t\tuintptr(unsafe.Pointer(lpInitCtrls)))\n\n\treturn ret != 0\n}\n\nfunc ImageList_Create(cx, cy int, flags uint, cInitial, cGrow int) HIMAGELIST {\n\tret, _, _ := procImageList_Create.Call(\n\t\tuintptr(cx),\n\t\tuintptr(cy),\n\t\tuintptr(flags),\n\t\tuintptr(cInitial),\n\t\tuintptr(cGrow))\n\n\tif ret == 0 {\n\t\tpanic(\"Create image list failed\")\n\t}\n\n\treturn HIMAGELIST(ret)\n}\n\nfunc ImageList_Destroy(himl HIMAGELIST) bool {\n\tret, _, _ := procImageList_Destroy.Call(\n\t\tuintptr(himl))\n\n\treturn ret != 0\n}\n\nfunc ImageList_GetImageCount(himl HIMAGELIST) int {\n\tret, _, _ := procImageList_GetImageCount.Call(\n\t\tuintptr(himl))\n\n\treturn int(ret)\n}\n\nfunc ImageList_SetImageCount(himl HIMAGELIST, uNewCount uint) bool {\n\tret, _, _ := procImageList_SetImageCount.Call(\n\t\tuintptr(himl),\n\t\tuintptr(uNewCount))\n\n\treturn ret != 0\n}\n\nfunc ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int {\n\tret, _, _ := procImageList_Add.Call(\n\t\tuintptr(himl),\n\t\tuintptr(hbmImage),\n\t\tuintptr(hbmMask))\n\n\treturn int(ret)\n}\n\nfunc ImageList_ReplaceIcon(himl HIMAGELIST, i int, hicon HICON) int {\n\tret, _, _ := procImageList_ReplaceIcon.Call(\n\t\tuintptr(himl),\n\t\tuintptr(i),\n\t\tuintptr(hicon))\n\n\treturn int(ret)\n}\n\nfunc ImageList_AddIcon(himl HIMAGELIST, hicon HICON) int {\n\treturn ImageList_ReplaceIcon(himl, -1, hicon)\n}\n\nfunc ImageList_Remove(himl HIMAGELIST, i int) bool {\n\tret, _, _ := procImageList_Remove.Call(\n\t\tuintptr(himl),\n\t\tuintptr(i))\n\n\treturn ret != 0\n}\n\nfunc ImageList_RemoveAll(himl HIMAGELIST) bool {\n\treturn ImageList_Remove(himl, -1)\n}\n\nfunc TrackMouseEvent(tme *TRACKMOUSEEVENT) bool {\n\tret, _, _ := procTrackMouseEvent.Call(\n\t\tuintptr(unsafe.Pointer(tme)))\n\n\treturn ret != 0\n}\n"
  },
  {
    "path": "w32/comdlg32.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmodcomdlg32 = syscall.NewLazyDLL(\"comdlg32.dll\")\n\n\tprocGetSaveFileName      = modcomdlg32.NewProc(\"GetSaveFileNameW\")\n\tprocGetOpenFileName      = modcomdlg32.NewProc(\"GetOpenFileNameW\")\n\tprocCommDlgExtendedError = modcomdlg32.NewProc(\"CommDlgExtendedError\")\n)\n\nfunc GetOpenFileName(ofn *OPENFILENAME) bool {\n\tret, _, _ := procGetOpenFileName.Call(\n\t\tuintptr(unsafe.Pointer(ofn)))\n\n\treturn ret != 0\n}\n\nfunc GetSaveFileName(ofn *OPENFILENAME) bool {\n\tret, _, _ := procGetSaveFileName.Call(\n\t\tuintptr(unsafe.Pointer(ofn)))\n\n\treturn ret != 0\n}\n\nfunc CommDlgExtendedError() uint {\n\tret, _, _ := procCommDlgExtendedError.Call()\n\n\treturn uint(ret)\n}\n"
  },
  {
    "path": "w32/constants.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nconst (\n\tFALSE = 0\n\tTRUE  = 1\n)\n\nconst (\n\tNO_ERROR                         = 0\n\tERROR_SUCCESS                    = 0\n\tERROR_FILE_NOT_FOUND             = 2\n\tERROR_PATH_NOT_FOUND             = 3\n\tERROR_ACCESS_DENIED              = 5\n\tERROR_INVALID_HANDLE             = 6\n\tERROR_BAD_FORMAT                 = 11\n\tERROR_INVALID_NAME               = 123\n\tERROR_MORE_DATA                  = 234\n\tERROR_NO_MORE_ITEMS              = 259\n\tERROR_INVALID_SERVICE_CONTROL    = 1052\n\tERROR_SERVICE_REQUEST_TIMEOUT    = 1053\n\tERROR_SERVICE_NO_THREAD          = 1054\n\tERROR_SERVICE_DATABASE_LOCKED    = 1055\n\tERROR_SERVICE_ALREADY_RUNNING    = 1056\n\tERROR_SERVICE_DISABLED           = 1058\n\tERROR_SERVICE_DOES_NOT_EXIST     = 1060\n\tERROR_SERVICE_CANNOT_ACCEPT_CTRL = 1061\n\tERROR_SERVICE_NOT_ACTIVE         = 1062\n\tERROR_DATABASE_DOES_NOT_EXIST    = 1065\n\tERROR_SERVICE_DEPENDENCY_FAIL    = 1068\n\tERROR_SERVICE_LOGON_FAILED       = 1069\n\tERROR_SERVICE_MARKED_FOR_DELETE  = 1072\n\tERROR_SERVICE_DEPENDENCY_DELETED = 1075\n)\n\nconst (\n\tSE_ERR_FNF             = 2\n\tSE_ERR_PNF             = 3\n\tSE_ERR_ACCESSDENIED    = 5\n\tSE_ERR_OOM             = 8\n\tSE_ERR_DLLNOTFOUND     = 32\n\tSE_ERR_SHARE           = 26\n\tSE_ERR_ASSOCINCOMPLETE = 27\n\tSE_ERR_DDETIMEOUT      = 28\n\tSE_ERR_DDEFAIL         = 29\n\tSE_ERR_DDEBUSY         = 30\n\tSE_ERR_NOASSOC         = 31\n)\n\nconst (\n\tCW_USEDEFAULT = ^0x7fffffff\n)\n\nconst (\n\tIMAGE_BITMAP      = 0\n\tIMAGE_ICON        = 1\n\tIMAGE_CURSOR      = 2\n\tIMAGE_ENHMETAFILE = 3\n)\n\n// ShowWindow constants\nconst (\n\tSW_HIDE            = 0\n\tSW_NORMAL          = 1\n\tSW_SHOWNORMAL      = 1\n\tSW_SHOWMINIMIZED   = 2\n\tSW_MAXIMIZE        = 3\n\tSW_SHOWMAXIMIZED   = 3\n\tSW_SHOWNOACTIVATE  = 4\n\tSW_SHOW            = 5\n\tSW_MINIMIZE        = 6\n\tSW_SHOWMINNOACTIVE = 7\n\tSW_SHOWNA          = 8\n\tSW_RESTORE         = 9\n\tSW_SHOWDEFAULT     = 10\n\tSW_FORCEMINIMIZE   = 11\n)\n\n// Window class styles\nconst (\n\tCS_VREDRAW         = 0x00000001\n\tCS_HREDRAW         = 0x00000002\n\tCS_KEYCVTWINDOW    = 0x00000004\n\tCS_DBLCLKS         = 0x00000008\n\tCS_OWNDC           = 0x00000020\n\tCS_CLASSDC         = 0x00000040\n\tCS_PARENTDC        = 0x00000080\n\tCS_NOKEYCVT        = 0x00000100\n\tCS_NOCLOSE         = 0x00000200\n\tCS_SAVEBITS        = 0x00000800\n\tCS_BYTEALIGNCLIENT = 0x00001000\n\tCS_BYTEALIGNWINDOW = 0x00002000\n\tCS_GLOBALCLASS     = 0x00004000\n\tCS_IME             = 0x00010000\n\tCS_DROPSHADOW      = 0x00020000\n)\n\n// Predefined cursor constants\nconst (\n\tIDC_ARROW       = 32512\n\tIDC_IBEAM       = 32513\n\tIDC_WAIT        = 32514\n\tIDC_CROSS       = 32515\n\tIDC_UPARROW     = 32516\n\tIDC_SIZENWSE    = 32642\n\tIDC_SIZENESW    = 32643\n\tIDC_SIZEWE      = 32644\n\tIDC_SIZENS      = 32645\n\tIDC_SIZEALL     = 32646\n\tIDC_NO          = 32648\n\tIDC_HAND        = 32649\n\tIDC_APPSTARTING = 32650\n\tIDC_HELP        = 32651\n\tIDC_ICON        = 32641\n\tIDC_SIZE        = 32640\n)\n\n// Predefined icon constants\nconst (\n\tIDI_APPLICATION = 32512\n\tIDI_HAND        = 32513\n\tIDI_QUESTION    = 32514\n\tIDI_EXCLAMATION = 32515\n\tIDI_ASTERISK    = 32516\n\tIDI_WINLOGO     = 32517\n\tIDI_WARNING     = IDI_EXCLAMATION\n\tIDI_ERROR       = IDI_HAND\n\tIDI_INFORMATION = IDI_ASTERISK\n)\n\n// Button style constants\nconst (\n\tBS_3STATE          = 5\n\tBS_AUTO3STATE      = 6\n\tBS_AUTOCHECKBOX    = 3\n\tBS_AUTORADIOBUTTON = 9\n\tBS_BITMAP          = 128\n\tBS_BOTTOM          = 0x800\n\tBS_CENTER          = 0x300\n\tBS_CHECKBOX        = 2\n\tBS_DEFPUSHBUTTON   = 1\n\tBS_GROUPBOX        = 7\n\tBS_ICON            = 64\n\tBS_LEFT            = 256\n\tBS_LEFTTEXT        = 32\n\tBS_MULTILINE       = 0x2000\n\tBS_NOTIFY          = 0x4000\n\tBS_OWNERDRAW       = 0xB\n\tBS_PUSHBUTTON      = 0\n\tBS_PUSHLIKE        = 4096\n\tBS_RADIOBUTTON     = 4\n\tBS_RIGHT           = 512\n\tBS_RIGHTBUTTON     = 32\n\tBS_TEXT            = 0\n\tBS_TOP             = 0x400\n\tBS_USERBUTTON      = 8\n\tBS_VCENTER         = 0xC00\n\tBS_FLAT            = 0x8000\n\tBS_SPLITBUTTON     = 0x000C // >= Vista\n\tBS_DEFSPLITBUTTON  = 0x000D // >= Vista\n)\n\n// Button state constants\nconst (\n\tBST_CHECKED       = 1\n\tBST_INDETERMINATE = 2\n\tBST_UNCHECKED     = 0\n\tBST_FOCUS         = 8\n\tBST_PUSHED        = 4\n)\n\n// Predefined brushes constants\nconst (\n\tCOLOR_3DDKSHADOW              = 21\n\tCOLOR_3DFACE                  = 15\n\tCOLOR_3DHILIGHT               = 20\n\tCOLOR_3DHIGHLIGHT             = 20\n\tCOLOR_3DLIGHT                 = 22\n\tCOLOR_BTNHILIGHT              = 20\n\tCOLOR_3DSHADOW                = 16\n\tCOLOR_ACTIVEBORDER            = 10\n\tCOLOR_ACTIVECAPTION           = 2\n\tCOLOR_APPWORKSPACE            = 12\n\tCOLOR_BACKGROUND              = 1\n\tCOLOR_DESKTOP                 = 1\n\tCOLOR_BTNFACE                 = 15\n\tCOLOR_BTNHIGHLIGHT            = 20\n\tCOLOR_BTNSHADOW               = 16\n\tCOLOR_BTNTEXT                 = 18\n\tCOLOR_CAPTIONTEXT             = 9\n\tCOLOR_GRAYTEXT                = 17\n\tCOLOR_HIGHLIGHT               = 13\n\tCOLOR_HIGHLIGHTTEXT           = 14\n\tCOLOR_INACTIVEBORDER          = 11\n\tCOLOR_INACTIVECAPTION         = 3\n\tCOLOR_INACTIVECAPTIONTEXT     = 19\n\tCOLOR_INFOBK                  = 24\n\tCOLOR_INFOTEXT                = 23\n\tCOLOR_MENU                    = 4\n\tCOLOR_MENUTEXT                = 7\n\tCOLOR_SCROLLBAR               = 0\n\tCOLOR_WINDOW                  = 5\n\tCOLOR_WINDOWFRAME             = 6\n\tCOLOR_WINDOWTEXT              = 8\n\tCOLOR_HOTLIGHT                = 26\n\tCOLOR_GRADIENTACTIVECAPTION   = 27\n\tCOLOR_GRADIENTINACTIVECAPTION = 28\n)\n\n// Button message constants\nconst (\n\tBM_CLICK    = 245\n\tBM_GETCHECK = 240\n\tBM_GETIMAGE = 246\n\tBM_GETSTATE = 242\n\tBM_SETCHECK = 241\n\tBM_SETIMAGE = 247\n\tBM_SETSTATE = 243\n\tBM_SETSTYLE = 244\n)\n\n// Button notifications\nconst (\n\tBN_CLICKED       = 0\n\tBN_PAINT         = 1\n\tBN_HILITE        = 2\n\tBN_PUSHED        = BN_HILITE\n\tBN_UNHILITE      = 3\n\tBN_UNPUSHED      = BN_UNHILITE\n\tBN_DISABLE       = 4\n\tBN_DOUBLECLICKED = 5\n\tBN_DBLCLK        = BN_DOUBLECLICKED\n\tBN_SETFOCUS      = 6\n\tBN_KILLFOCUS     = 7\n)\n\n// TrackPopupMenu[Ex] flags\nconst (\n\tTPM_CENTERALIGN     = 0x0004\n\tTPM_LEFTALIGN       = 0x0000\n\tTPM_RIGHTALIGN      = 0x0008\n\tTPM_BOTTOMALIGN     = 0x0020\n\tTPM_TOPALIGN        = 0x0000\n\tTPM_VCENTERALIGN    = 0x0010\n\tTPM_NONOTIFY        = 0x0080\n\tTPM_RETURNCMD       = 0x0100\n\tTPM_LEFTBUTTON      = 0x0000\n\tTPM_RIGHTBUTTON     = 0x0002\n\tTPM_HORNEGANIMATION = 0x0800\n\tTPM_HORPOSANIMATION = 0x0400\n\tTPM_NOANIMATION     = 0x4000\n\tTPM_VERNEGANIMATION = 0x2000\n\tTPM_VERPOSANIMATION = 0x1000\n\tTPM_HORIZONTAL      = 0x0000\n\tTPM_VERTICAL        = 0x0040\n)\n\n// GetWindowLong and GetWindowLongPtr constants\nconst (\n\tGWL_EXSTYLE     = -20\n\tGWL_STYLE       = -16\n\tGWL_WNDPROC     = -4\n\tGWLP_WNDPROC    = -4\n\tGWL_HINSTANCE   = -6\n\tGWLP_HINSTANCE  = -6\n\tGWL_HWNDPARENT  = -8\n\tGWLP_HWNDPARENT = -8\n\tGWL_ID          = -12\n\tGWLP_ID         = -12\n\tGWL_USERDATA    = -21\n\tGWLP_USERDATA   = -21\n)\n\n// Window style constants\nconst (\n\tWS_OVERLAPPED       = 0x00000000\n\tWS_POPUP            = 0x80000000\n\tWS_CHILD            = 0x40000000\n\tWS_MINIMIZE         = 0x20000000\n\tWS_VISIBLE          = 0x10000000\n\tWS_DISABLED         = 0x08000000\n\tWS_CLIPSIBLINGS     = 0x04000000\n\tWS_CLIPCHILDREN     = 0x02000000\n\tWS_MAXIMIZE         = 0x01000000\n\tWS_CAPTION          = 0x00C00000\n\tWS_BORDER           = 0x00800000\n\tWS_DLGFRAME         = 0x00400000\n\tWS_VSCROLL          = 0x00200000\n\tWS_HSCROLL          = 0x00100000\n\tWS_SYSMENU          = 0x00080000\n\tWS_THICKFRAME       = 0x00040000\n\tWS_GROUP            = 0x00020000\n\tWS_TABSTOP          = 0x00010000\n\tWS_MINIMIZEBOX      = 0x00020000\n\tWS_MAXIMIZEBOX      = 0x00010000\n\tWS_TILED            = 0x00000000\n\tWS_ICONIC           = 0x20000000\n\tWS_SIZEBOX          = 0x00040000\n\tWS_OVERLAPPEDWINDOW = 0x00000000 | 0x00C00000 | 0x00080000 | 0x00040000 | 0x00020000 | 0x00010000\n\tWS_POPUPWINDOW      = 0x80000000 | 0x00800000 | 0x00080000\n\tWS_CHILDWINDOW      = 0x40000000\n)\n\n// Extended window style constants\nconst (\n\tWS_EX_DLGMODALFRAME       = 0x00000001\n\tWS_EX_NOPARENTNOTIFY      = 0x00000004\n\tWS_EX_TOPMOST             = 0x00000008\n\tWS_EX_ACCEPTFILES         = 0x00000010\n\tWS_EX_TRANSPARENT         = 0x00000020\n\tWS_EX_MDICHILD            = 0x00000040\n\tWS_EX_TOOLWINDOW          = 0x00000080\n\tWS_EX_WINDOWEDGE          = 0x00000100\n\tWS_EX_CLIENTEDGE          = 0x00000200\n\tWS_EX_CONTEXTHELP         = 0x00000400\n\tWS_EX_RIGHT               = 0x00001000\n\tWS_EX_LEFT                = 0x00000000\n\tWS_EX_RTLREADING          = 0x00002000\n\tWS_EX_LTRREADING          = 0x00000000\n\tWS_EX_LEFTSCROLLBAR       = 0x00004000\n\tWS_EX_RIGHTSCROLLBAR      = 0x00000000\n\tWS_EX_CONTROLPARENT       = 0x00010000\n\tWS_EX_STATICEDGE          = 0x00020000\n\tWS_EX_APPWINDOW           = 0x00040000\n\tWS_EX_OVERLAPPEDWINDOW    = 0x00000100 | 0x00000200\n\tWS_EX_PALETTEWINDOW       = 0x00000100 | 0x00000080 | 0x00000008\n\tWS_EX_LAYERED             = 0x00080000\n\tWS_EX_NOINHERITLAYOUT     = 0x00100000\n\tWS_EX_NOREDIRECTIONBITMAP = 0x00200000\n\tWS_EX_LAYOUTRTL           = 0x00400000\n\tWS_EX_NOACTIVATE          = 0x08000000\n)\n\n// Window message constants\nconst (\n\tWM_APP                    = 32768\n\tWM_ACTIVATE               = 6\n\tWM_ACTIVATEAPP            = 28\n\tWM_AFXFIRST               = 864\n\tWM_AFXLAST                = 895\n\tWM_ASKCBFORMATNAME        = 780\n\tWM_CANCELJOURNAL          = 75\n\tWM_CANCELMODE             = 31\n\tWM_CAPTURECHANGED         = 533\n\tWM_CHANGECBCHAIN          = 781\n\tWM_CHAR                   = 258\n\tWM_CHARTOITEM             = 47\n\tWM_CHILDACTIVATE          = 34\n\tWM_CLEAR                  = 771\n\tWM_CLOSE                  = 16\n\tWM_COMMAND                = 273\n\tWM_COMMNOTIFY             = 68 /* OBSOLETE */\n\tWM_COMPACTING             = 65\n\tWM_COMPAREITEM            = 57\n\tWM_CONTEXTMENU            = 123\n\tWM_COPY                   = 769\n\tWM_COPYDATA               = 74\n\tWM_CREATE                 = 1\n\tWM_CTLCOLORBTN            = 309\n\tWM_CTLCOLORDLG            = 310\n\tWM_CTLCOLOREDIT           = 307\n\tWM_CTLCOLORLISTBOX        = 308\n\tWM_CTLCOLORMSGBOX         = 306\n\tWM_CTLCOLORSCROLLBAR      = 311\n\tWM_CTLCOLORSTATIC         = 312\n\tWM_CUT                    = 768\n\tWM_DEADCHAR               = 259\n\tWM_DELETEITEM             = 45\n\tWM_DESTROY                = 2\n\tWM_DESTROYCLIPBOARD       = 775\n\tWM_DEVICECHANGE           = 537\n\tWM_DEVMODECHANGE          = 27\n\tWM_DISPLAYCHANGE          = 126\n\tWM_DRAWCLIPBOARD          = 776\n\tWM_DRAWITEM               = 43\n\tWM_DROPFILES              = 563\n\tWM_ENABLE                 = 10\n\tWM_ENDSESSION             = 22\n\tWM_ENTERIDLE              = 289\n\tWM_ENTERMENULOOP          = 529\n\tWM_ENTERSIZEMOVE          = 561\n\tWM_ERASEBKGND             = 20\n\tWM_EXITMENULOOP           = 530\n\tWM_EXITSIZEMOVE           = 562\n\tWM_FONTCHANGE             = 29\n\tWM_GETDLGCODE             = 135\n\tWM_GETFONT                = 49\n\tWM_GETHOTKEY              = 51\n\tWM_GETICON                = 127\n\tWM_GETMINMAXINFO          = 36\n\tWM_GETTEXT                = 13\n\tWM_GETTEXTLENGTH          = 14\n\tWM_HANDHELDFIRST          = 856\n\tWM_HANDHELDLAST           = 863\n\tWM_HELP                   = 83\n\tWM_HOTKEY                 = 786\n\tWM_HSCROLL                = 276\n\tWM_HSCROLLCLIPBOARD       = 782\n\tWM_ICONERASEBKGND         = 39\n\tWM_INITDIALOG             = 272\n\tWM_INITMENU               = 278\n\tWM_INITMENUPOPUP          = 279\n\tWM_INPUT                  = 0x00FF\n\tWM_INPUTLANGCHANGE        = 81\n\tWM_INPUTLANGCHANGEREQUEST = 80\n\tWM_KEYDOWN                = 256\n\tWM_KEYUP                  = 257\n\tWM_KILLFOCUS              = 8\n\tWM_MDIACTIVATE            = 546\n\tWM_MDICASCADE             = 551\n\tWM_MDICREATE              = 544\n\tWM_MDIDESTROY             = 545\n\tWM_MDIGETACTIVE           = 553\n\tWM_MDIICONARRANGE         = 552\n\tWM_MDIMAXIMIZE            = 549\n\tWM_MDINEXT                = 548\n\tWM_MDIREFRESHMENU         = 564\n\tWM_MDIRESTORE             = 547\n\tWM_MDISETMENU             = 560\n\tWM_MDITILE                = 550\n\tWM_MEASUREITEM            = 44\n\tWM_GETOBJECT              = 0x003D\n\tWM_CHANGEUISTATE          = 0x0127\n\tWM_UPDATEUISTATE          = 0x0128\n\tWM_QUERYUISTATE           = 0x0129\n\tWM_UNINITMENUPOPUP        = 0x0125\n\tWM_MENURBUTTONUP          = 290\n\tWM_MENUCOMMAND            = 0x0126\n\tWM_MENUGETOBJECT          = 0x0124\n\tWM_MENUDRAG               = 0x0123\n\tWM_APPCOMMAND             = 0x0319\n\tWM_MENUCHAR               = 288\n\tWM_MENUSELECT             = 287\n\tWM_MOVE                   = 3\n\tWM_MOVING                 = 534\n\tWM_NCACTIVATE             = 134\n\tWM_NCCALCSIZE             = 131\n\tWM_NCCREATE               = 129\n\tWM_NCDESTROY              = 130\n\tWM_NCHITTEST              = 132\n\tWM_NCLBUTTONDBLCLK        = 163\n\tWM_NCLBUTTONDOWN          = 161\n\tWM_NCLBUTTONUP            = 162\n\tWM_NCMBUTTONDBLCLK        = 169\n\tWM_NCMBUTTONDOWN          = 167\n\tWM_NCMBUTTONUP            = 168\n\tWM_NCXBUTTONDOWN          = 171\n\tWM_NCXBUTTONUP            = 172\n\tWM_NCXBUTTONDBLCLK        = 173\n\tWM_NCMOUSEHOVER           = 0x02A0\n\tWM_NCMOUSELEAVE           = 0x02A2\n\tWM_NCMOUSEMOVE            = 160\n\tWM_NCPAINT                = 133\n\tWM_NCRBUTTONDBLCLK        = 166\n\tWM_NCRBUTTONDOWN          = 164\n\tWM_NCRBUTTONUP            = 165\n\tWM_NEXTDLGCTL             = 40\n\tWM_NEXTMENU               = 531\n\tWM_NOTIFY                 = 78\n\tWM_NOTIFYFORMAT           = 85\n\tWM_NULL                   = 0\n\tWM_PAINT                  = 15\n\tWM_PAINTCLIPBOARD         = 777\n\tWM_PAINTICON              = 38\n\tWM_PALETTECHANGED         = 785\n\tWM_PALETTEISCHANGING      = 784\n\tWM_PARENTNOTIFY           = 528\n\tWM_PASTE                  = 770\n\tWM_PENWINFIRST            = 896\n\tWM_PENWINLAST             = 911\n\tWM_POWER                  = 72\n\tWM_POWERBROADCAST         = 536\n\tWM_PRINT                  = 791\n\tWM_PRINTCLIENT            = 792\n\tWM_QUERYDRAGICON          = 55\n\tWM_QUERYENDSESSION        = 17\n\tWM_QUERYNEWPALETTE        = 783\n\tWM_QUERYOPEN              = 19\n\tWM_QUEUESYNC              = 35\n\tWM_QUIT                   = 18\n\tWM_RENDERALLFORMATS       = 774\n\tWM_RENDERFORMAT           = 773\n\tWM_SETCURSOR              = 32\n\tWM_SETFOCUS               = 7\n\tWM_SETFONT                = 48\n\tWM_SETHOTKEY              = 50\n\tWM_SETICON                = 128\n\tWM_SETREDRAW              = 11\n\tWM_SETTEXT                = 12\n\tWM_SETTINGCHANGE          = 26\n\tWM_SHOWWINDOW             = 24\n\tWM_SIZE                   = 5\n\tWM_SIZECLIPBOARD          = 779\n\tWM_SIZING                 = 532\n\tWM_SPOOLERSTATUS          = 42\n\tWM_STYLECHANGED           = 125\n\tWM_STYLECHANGING          = 124\n\tWM_SYSCHAR                = 262\n\tWM_SYSCOLORCHANGE         = 21\n\tWM_SYSCOMMAND             = 274\n\tWM_SYSDEADCHAR            = 263\n\tWM_SYSKEYDOWN             = 260\n\tWM_SYSKEYUP               = 261\n\tWM_TCARD                  = 82\n\tWM_THEMECHANGED           = 794\n\tWM_TIMECHANGE             = 30\n\tWM_TIMER                  = 275\n\tWM_UNDO                   = 772\n\tWM_USER                   = 1024\n\tWM_USERCHANGED            = 84\n\tWM_VKEYTOITEM             = 46\n\tWM_VSCROLL                = 277\n\tWM_VSCROLLCLIPBOARD       = 778\n\tWM_WINDOWPOSCHANGED       = 71\n\tWM_WINDOWPOSCHANGING      = 70\n\tWM_WININICHANGE           = 26\n\tWM_KEYFIRST               = 256\n\tWM_KEYLAST                = 264\n\tWM_SYNCPAINT              = 136\n\tWM_MOUSEACTIVATE          = 33\n\tWM_MOUSEMOVE              = 512\n\tWM_LBUTTONDOWN            = 513\n\tWM_LBUTTONUP              = 514\n\tWM_LBUTTONDBLCLK          = 515\n\tWM_RBUTTONDOWN            = 516\n\tWM_RBUTTONUP              = 517\n\tWM_RBUTTONDBLCLK          = 518\n\tWM_MBUTTONDOWN            = 519\n\tWM_MBUTTONUP              = 520\n\tWM_MBUTTONDBLCLK          = 521\n\tWM_MOUSEWHEEL             = 522\n\tWM_MOUSEFIRST             = 512\n\tWM_XBUTTONDOWN            = 523\n\tWM_XBUTTONUP              = 524\n\tWM_XBUTTONDBLCLK          = 525\n\tWM_MOUSELAST              = 525\n\tWM_MOUSEHOVER             = 0x2A1\n\tWM_MOUSELEAVE             = 0x2A3\n\tWM_CLIPBOARDUPDATE        = 0x031D\n)\n\n// WM_ACTIVATE\nconst (\n\tWA_INACTIVE    = 0\n\tWA_ACTIVE      = 1\n\tWA_CLICKACTIVE = 2\n)\n\nconst LF_FACESIZE = 32\n\n// Font weight constants\nconst (\n\tFW_DONTCARE   = 0\n\tFW_THIN       = 100\n\tFW_EXTRALIGHT = 200\n\tFW_ULTRALIGHT = FW_EXTRALIGHT\n\tFW_LIGHT      = 300\n\tFW_NORMAL     = 400\n\tFW_REGULAR    = 400\n\tFW_MEDIUM     = 500\n\tFW_SEMIBOLD   = 600\n\tFW_DEMIBOLD   = FW_SEMIBOLD\n\tFW_BOLD       = 700\n\tFW_EXTRABOLD  = 800\n\tFW_ULTRABOLD  = FW_EXTRABOLD\n\tFW_HEAVY      = 900\n\tFW_BLACK      = FW_HEAVY\n)\n\n// Charset constants\nconst (\n\tANSI_CHARSET        = 0\n\tDEFAULT_CHARSET     = 1\n\tSYMBOL_CHARSET      = 2\n\tSHIFTJIS_CHARSET    = 128\n\tHANGEUL_CHARSET     = 129\n\tHANGUL_CHARSET      = 129\n\tGB2312_CHARSET      = 134\n\tCHINESEBIG5_CHARSET = 136\n\tGREEK_CHARSET       = 161\n\tTURKISH_CHARSET     = 162\n\tHEBREW_CHARSET      = 177\n\tARABIC_CHARSET      = 178\n\tBALTIC_CHARSET      = 186\n\tRUSSIAN_CHARSET     = 204\n\tTHAI_CHARSET        = 222\n\tEASTEUROPE_CHARSET  = 238\n\tOEM_CHARSET         = 255\n\tJOHAB_CHARSET       = 130\n\tVIETNAMESE_CHARSET  = 163\n\tMAC_CHARSET         = 77\n)\n\n// Font output precision constants\nconst (\n\tOUT_DEFAULT_PRECIS   = 0\n\tOUT_STRING_PRECIS    = 1\n\tOUT_CHARACTER_PRECIS = 2\n\tOUT_STROKE_PRECIS    = 3\n\tOUT_TT_PRECIS        = 4\n\tOUT_DEVICE_PRECIS    = 5\n\tOUT_RASTER_PRECIS    = 6\n\tOUT_TT_ONLY_PRECIS   = 7\n\tOUT_OUTLINE_PRECIS   = 8\n\tOUT_PS_ONLY_PRECIS   = 10\n)\n\n// Font clipping precision constants\nconst (\n\tCLIP_DEFAULT_PRECIS   = 0\n\tCLIP_CHARACTER_PRECIS = 1\n\tCLIP_STROKE_PRECIS    = 2\n\tCLIP_MASK             = 15\n\tCLIP_LH_ANGLES        = 16\n\tCLIP_TT_ALWAYS        = 32\n\tCLIP_EMBEDDED         = 128\n)\n\n// Font output quality constants\nconst (\n\tDEFAULT_QUALITY        = 0\n\tDRAFT_QUALITY          = 1\n\tPROOF_QUALITY          = 2\n\tNONANTIALIASED_QUALITY = 3\n\tANTIALIASED_QUALITY    = 4\n\tCLEARTYPE_QUALITY      = 5\n)\n\n// Font pitch constants\nconst (\n\tDEFAULT_PITCH  = 0\n\tFIXED_PITCH    = 1\n\tVARIABLE_PITCH = 2\n)\n\n// Font family constants\nconst (\n\tFF_DECORATIVE = 80\n\tFF_DONTCARE   = 0\n\tFF_MODERN     = 48\n\tFF_ROMAN      = 16\n\tFF_SCRIPT     = 64\n\tFF_SWISS      = 32\n)\n\n// DeviceCapabilities capabilities\nconst (\n\tDC_FIELDS            = 1\n\tDC_PAPERS            = 2\n\tDC_PAPERSIZE         = 3\n\tDC_MINEXTENT         = 4\n\tDC_MAXEXTENT         = 5\n\tDC_BINS              = 6\n\tDC_DUPLEX            = 7\n\tDC_SIZE              = 8\n\tDC_EXTRA             = 9\n\tDC_VERSION           = 10\n\tDC_DRIVER            = 11\n\tDC_BINNAMES          = 12\n\tDC_ENUMRESOLUTIONS   = 13\n\tDC_FILEDEPENDENCIES  = 14\n\tDC_TRUETYPE          = 15\n\tDC_PAPERNAMES        = 16\n\tDC_ORIENTATION       = 17\n\tDC_COPIES            = 18\n\tDC_BINADJUST         = 19\n\tDC_EMF_COMPLIANT     = 20\n\tDC_DATATYPE_PRODUCED = 21\n\tDC_COLLATE           = 22\n\tDC_MANUFACTURER      = 23\n\tDC_MODEL             = 24\n\tDC_PERSONALITY       = 25\n\tDC_PRINTRATE         = 26\n\tDC_PRINTRATEUNIT     = 27\n\tDC_PRINTERMEM        = 28\n\tDC_MEDIAREADY        = 29\n\tDC_STAPLE            = 30\n\tDC_PRINTRATEPPM      = 31\n\tDC_COLORDEVICE       = 32\n\tDC_NUP               = 33\n\tDC_MEDIATYPENAMES    = 34\n\tDC_MEDIATYPES        = 35\n)\n\n// GetDeviceCaps index constants\nconst (\n\tDRIVERVERSION   = 0\n\tTECHNOLOGY      = 2\n\tHORZSIZE        = 4\n\tVERTSIZE        = 6\n\tHORZRES         = 8\n\tVERTRES         = 10\n\tLOGPIXELSX      = 88\n\tLOGPIXELSY      = 90\n\tBITSPIXEL       = 12\n\tPLANES          = 14\n\tNUMBRUSHES      = 16\n\tNUMPENS         = 18\n\tNUMFONTS        = 22\n\tNUMCOLORS       = 24\n\tNUMMARKERS      = 20\n\tASPECTX         = 40\n\tASPECTY         = 42\n\tASPECTXY        = 44\n\tPDEVICESIZE     = 26\n\tCLIPCAPS        = 36\n\tSIZEPALETTE     = 104\n\tNUMRESERVED     = 106\n\tCOLORRES        = 108\n\tPHYSICALWIDTH   = 110\n\tPHYSICALHEIGHT  = 111\n\tPHYSICALOFFSETX = 112\n\tPHYSICALOFFSETY = 113\n\tSCALINGFACTORX  = 114\n\tSCALINGFACTORY  = 115\n\tVREFRESH        = 116\n\tDESKTOPHORZRES  = 118\n\tDESKTOPVERTRES  = 117\n\tBLTALIGNMENT    = 119\n\tSHADEBLENDCAPS  = 120\n\tCOLORMGMTCAPS   = 121\n\tRASTERCAPS      = 38\n\tCURVECAPS       = 28\n\tLINECAPS        = 30\n\tPOLYGONALCAPS   = 32\n\tTEXTCAPS        = 34\n)\n\n// GetDeviceCaps TECHNOLOGY constants\nconst (\n\tDT_PLOTTER    = 0\n\tDT_RASDISPLAY = 1\n\tDT_RASPRINTER = 2\n\tDT_RASCAMERA  = 3\n\tDT_CHARSTREAM = 4\n\tDT_METAFILE   = 5\n\tDT_DISPFILE   = 6\n)\n\n// GetDeviceCaps SHADEBLENDCAPS constants\nconst (\n\tSB_NONE          = 0x00\n\tSB_CONST_ALPHA   = 0x01\n\tSB_PIXEL_ALPHA   = 0x02\n\tSB_PREMULT_ALPHA = 0x04\n\tSB_GRAD_RECT     = 0x10\n\tSB_GRAD_TRI      = 0x20\n)\n\n// GetDeviceCaps COLORMGMTCAPS constants\nconst (\n\tCM_NONE       = 0x00\n\tCM_DEVICE_ICM = 0x01\n\tCM_GAMMA_RAMP = 0x02\n\tCM_CMYK_COLOR = 0x04\n)\n\n// GetDeviceCaps RASTERCAPS constants\nconst (\n\tRC_BANDING      = 2\n\tRC_BITBLT       = 1\n\tRC_BITMAP64     = 8\n\tRC_DI_BITMAP    = 128\n\tRC_DIBTODEV     = 512\n\tRC_FLOODFILL    = 4096\n\tRC_GDI20_OUTPUT = 16\n\tRC_PALETTE      = 256\n\tRC_SCALING      = 4\n\tRC_STRETCHBLT   = 2048\n\tRC_STRETCHDIB   = 8192\n\tRC_DEVBITS      = 0x8000\n\tRC_OP_DX_OUTPUT = 0x4000\n)\n\n// GetDeviceCaps CURVECAPS constants\nconst (\n\tCC_NONE       = 0\n\tCC_CIRCLES    = 1\n\tCC_PIE        = 2\n\tCC_CHORD      = 4\n\tCC_ELLIPSES   = 8\n\tCC_WIDE       = 16\n\tCC_STYLED     = 32\n\tCC_WIDESTYLED = 64\n\tCC_INTERIORS  = 128\n\tCC_ROUNDRECT  = 256\n)\n\n// GetDeviceCaps LINECAPS constants\nconst (\n\tLC_NONE       = 0\n\tLC_POLYLINE   = 2\n\tLC_MARKER     = 4\n\tLC_POLYMARKER = 8\n\tLC_WIDE       = 16\n\tLC_STYLED     = 32\n\tLC_WIDESTYLED = 64\n\tLC_INTERIORS  = 128\n)\n\n// GetDeviceCaps POLYGONALCAPS constants\nconst (\n\tPC_NONE        = 0\n\tPC_POLYGON     = 1\n\tPC_POLYPOLYGON = 256\n\tPC_PATHS       = 512\n\tPC_RECTANGLE   = 2\n\tPC_WINDPOLYGON = 4\n\tPC_SCANLINE    = 8\n\tPC_TRAPEZOID   = 4\n\tPC_WIDE        = 16\n\tPC_STYLED      = 32\n\tPC_WIDESTYLED  = 64\n\tPC_INTERIORS   = 128\n)\n\n// GetDeviceCaps TEXTCAPS constants\nconst (\n\tTC_OP_CHARACTER = 1\n\tTC_OP_STROKE    = 2\n\tTC_CP_STROKE    = 4\n\tTC_CR_90        = 8\n\tTC_CR_ANY       = 16\n\tTC_SF_X_YINDEP  = 32\n\tTC_SA_DOUBLE    = 64\n\tTC_SA_INTEGER   = 128\n\tTC_SA_CONTIN    = 256\n\tTC_EA_DOUBLE    = 512\n\tTC_IA_ABLE      = 1024\n\tTC_UA_ABLE      = 2048\n\tTC_SO_ABLE      = 4096\n\tTC_RA_ABLE      = 8192\n\tTC_VA_ABLE      = 16384\n\tTC_RESERVED     = 32768\n\tTC_SCROLLBLT    = 65536\n)\n\n// Static control styles\nconst (\n\tSS_BITMAP          = 14\n\tSS_BLACKFRAME      = 7\n\tSS_BLACKRECT       = 4\n\tSS_CENTER          = 1\n\tSS_CENTERIMAGE     = 512\n\tSS_EDITCONTROL     = 0x2000\n\tSS_ENHMETAFILE     = 15\n\tSS_ETCHEDFRAME     = 18\n\tSS_ETCHEDHORZ      = 16\n\tSS_ETCHEDVERT      = 17\n\tSS_GRAYFRAME       = 8\n\tSS_GRAYRECT        = 5\n\tSS_ICON            = 3\n\tSS_LEFT            = 0\n\tSS_LEFTNOWORDWRAP  = 0xc\n\tSS_NOPREFIX        = 128\n\tSS_NOTIFY          = 256\n\tSS_OWNERDRAW       = 0xd\n\tSS_REALSIZECONTROL = 0x040\n\tSS_REALSIZEIMAGE   = 0x800\n\tSS_RIGHT           = 2\n\tSS_RIGHTJUST       = 0x400\n\tSS_SIMPLE          = 11\n\tSS_SUNKEN          = 4096\n\tSS_WHITEFRAME      = 9\n\tSS_WHITERECT       = 6\n\tSS_USERITEM        = 10\n\tSS_TYPEMASK        = 0x0000001F\n\tSS_ENDELLIPSIS     = 0x00004000\n\tSS_PATHELLIPSIS    = 0x00008000\n\tSS_WORDELLIPSIS    = 0x0000C000\n\tSS_ELLIPSISMASK    = 0x0000C000\n)\n\n// Edit styles\nconst (\n\tES_LEFT        = 0x0000\n\tES_CENTER      = 0x0001\n\tES_RIGHT       = 0x0002\n\tES_MULTILINE   = 0x0004\n\tES_UPPERCASE   = 0x0008\n\tES_LOWERCASE   = 0x0010\n\tES_PASSWORD    = 0x0020\n\tES_AUTOVSCROLL = 0x0040\n\tES_AUTOHSCROLL = 0x0080\n\tES_NOHIDESEL   = 0x0100\n\tES_OEMCONVERT  = 0x0400\n\tES_READONLY    = 0x0800\n\tES_WANTRETURN  = 0x1000\n\tES_NUMBER      = 0x2000\n)\n\n// Edit notifications\nconst (\n\tEN_SETFOCUS     = 0x0100\n\tEN_KILLFOCUS    = 0x0200\n\tEN_CHANGE       = 0x0300\n\tEN_UPDATE       = 0x0400\n\tEN_ERRSPACE     = 0x0500\n\tEN_MAXTEXT      = 0x0501\n\tEN_HSCROLL      = 0x0601\n\tEN_VSCROLL      = 0x0602\n\tEN_ALIGN_LTR_EC = 0x0700\n\tEN_ALIGN_RTL_EC = 0x0701\n)\n\n// Edit messages\nconst (\n\tEM_GETSEL              = 0x00B0\n\tEM_SETSEL              = 0x00B1\n\tEM_GETRECT             = 0x00B2\n\tEM_SETRECT             = 0x00B3\n\tEM_SETRECTNP           = 0x00B4\n\tEM_SCROLL              = 0x00B5\n\tEM_LINESCROLL          = 0x00B6\n\tEM_SCROLLCARET         = 0x00B7\n\tEM_GETMODIFY           = 0x00B8\n\tEM_SETMODIFY           = 0x00B9\n\tEM_GETLINECOUNT        = 0x00BA\n\tEM_LINEINDEX           = 0x00BB\n\tEM_SETHANDLE           = 0x00BC\n\tEM_GETHANDLE           = 0x00BD\n\tEM_GETTHUMB            = 0x00BE\n\tEM_LINELENGTH          = 0x00C1\n\tEM_REPLACESEL          = 0x00C2\n\tEM_GETLINE             = 0x00C4\n\tEM_LIMITTEXT           = 0x00C5\n\tEM_CANUNDO             = 0x00C6\n\tEM_UNDO                = 0x00C7\n\tEM_FMTLINES            = 0x00C8\n\tEM_LINEFROMCHAR        = 0x00C9\n\tEM_SETTABSTOPS         = 0x00CB\n\tEM_SETPASSWORDCHAR     = 0x00CC\n\tEM_EMPTYUNDOBUFFER     = 0x00CD\n\tEM_GETFIRSTVISIBLELINE = 0x00CE\n\tEM_SETREADONLY         = 0x00CF\n\tEM_SETWORDBREAKPROC    = 0x00D0\n\tEM_GETWORDBREAKPROC    = 0x00D1\n\tEM_GETPASSWORDCHAR     = 0x00D2\n\tEM_SETMARGINS          = 0x00D3\n\tEM_GETMARGINS          = 0x00D4\n\tEM_SETLIMITTEXT        = EM_LIMITTEXT\n\tEM_GETLIMITTEXT        = 0x00D5\n\tEM_POSFROMCHAR         = 0x00D6\n\tEM_CHARFROMPOS         = 0x00D7\n\tEM_SETIMESTATUS        = 0x00D8\n\tEM_GETIMESTATUS        = 0x00D9\n\tEM_SETCUEBANNER        = 0x1501\n\tEM_GETCUEBANNER        = 0x1502\n)\n\nconst (\n\tCCM_FIRST            = 0x2000\n\tCCM_LAST             = CCM_FIRST + 0x200\n\tCCM_SETBKCOLOR       = 8193\n\tCCM_SETCOLORSCHEME   = 8194\n\tCCM_GETCOLORSCHEME   = 8195\n\tCCM_GETDROPTARGET    = 8196\n\tCCM_SETUNICODEFORMAT = 8197\n\tCCM_GETUNICODEFORMAT = 8198\n\tCCM_SETVERSION       = 0x2007\n\tCCM_GETVERSION       = 0x2008\n\tCCM_SETNOTIFYWINDOW  = 0x2009\n\tCCM_SETWINDOWTHEME   = 0x200b\n\tCCM_DPISCALE         = 0x200c\n)\n\n// Common controls styles\nconst (\n\tCCS_TOP           = 1\n\tCCS_NOMOVEY       = 2\n\tCCS_BOTTOM        = 3\n\tCCS_NORESIZE      = 4\n\tCCS_NOPARENTALIGN = 8\n\tCCS_ADJUSTABLE    = 32\n\tCCS_NODIVIDER     = 64\n\tCCS_VERT          = 128\n\tCCS_LEFT          = 129\n\tCCS_NOMOVEX       = 130\n\tCCS_RIGHT         = 131\n)\n\n// ProgressBar messages\nconst (\n\tPROGRESS_CLASS  = \"msctls_progress32\"\n\tPBM_SETPOS      = WM_USER + 2\n\tPBM_DELTAPOS    = WM_USER + 3\n\tPBM_SETSTEP     = WM_USER + 4\n\tPBM_STEPIT      = WM_USER + 5\n\tPBM_SETRANGE32  = 1030\n\tPBM_GETRANGE    = 1031\n\tPBM_GETPOS      = 1032\n\tPBM_SETBARCOLOR = 1033\n\tPBM_SETBKCOLOR  = CCM_SETBKCOLOR\n\tPBS_SMOOTH      = 1\n\tPBS_VERTICAL    = 4\n)\n\n// Trackbar messages and constants\nconst (\n\tTBS_AUTOTICKS      = 1\n\tTBS_VERT           = 2\n\tTBS_HORZ           = 0\n\tTBS_TOP            = 4\n\tTBS_BOTTOM         = 0\n\tTBS_LEFT           = 4\n\tTBS_RIGHT          = 0\n\tTBS_BOTH           = 8\n\tTBS_NOTICKS        = 16\n\tTBS_ENABLESELRANGE = 32\n\tTBS_FIXEDLENGTH    = 64\n\tTBS_NOTHUMB        = 128\n\tTBS_TOOLTIPS       = 0x0100\n)\n\nconst (\n\tTBM_GETPOS         = (WM_USER)\n\tTBM_GETRANGEMIN    = (WM_USER + 1)\n\tTBM_GETRANGEMAX    = (WM_USER + 2)\n\tTBM_GETTIC         = (WM_USER + 3)\n\tTBM_SETTIC         = (WM_USER + 4)\n\tTBM_SETPOS         = (WM_USER + 5)\n\tTBM_SETRANGE       = (WM_USER + 6)\n\tTBM_SETRANGEMIN    = (WM_USER + 7)\n\tTBM_SETRANGEMAX    = (WM_USER + 8)\n\tTBM_CLEARTICS      = (WM_USER + 9)\n\tTBM_SETSEL         = (WM_USER + 10)\n\tTBM_SETSELSTART    = (WM_USER + 11)\n\tTBM_SETSELEND      = (WM_USER + 12)\n\tTBM_GETPTICS       = (WM_USER + 14)\n\tTBM_GETTICPOS      = (WM_USER + 15)\n\tTBM_GETNUMTICS     = (WM_USER + 16)\n\tTBM_GETSELSTART    = (WM_USER + 17)\n\tTBM_GETSELEND      = (WM_USER + 18)\n\tTBM_CLEARSEL       = (WM_USER + 19)\n\tTBM_SETTICFREQ     = (WM_USER + 20)\n\tTBM_SETPAGESIZE    = (WM_USER + 21)\n\tTBM_GETPAGESIZE    = (WM_USER + 22)\n\tTBM_SETLINESIZE    = (WM_USER + 23)\n\tTBM_GETLINESIZE    = (WM_USER + 24)\n\tTBM_GETTHUMBRECT   = (WM_USER + 25)\n\tTBM_GETCHANNELRECT = (WM_USER + 26)\n\tTBM_SETTHUMBLENGTH = (WM_USER + 27)\n\tTBM_GETTHUMBLENGTH = (WM_USER + 28)\n\tTBM_SETTOOLTIPS    = (WM_USER + 29)\n\tTBM_GETTOOLTIPS    = (WM_USER + 30)\n\tTBM_SETTIPSIDE     = (WM_USER + 31)\n\tTBM_SETBUDDY       = (WM_USER + 32)\n\tTBM_GETBUDDY       = (WM_USER + 33)\n)\n\nconst (\n\tTB_LINEUP        = 0\n\tTB_LINEDOWN      = 1\n\tTB_PAGEUP        = 2\n\tTB_PAGEDOWN      = 3\n\tTB_THUMBPOSITION = 4\n\tTB_THUMBTRACK    = 5\n\tTB_TOP           = 6\n\tTB_BOTTOM        = 7\n\tTB_ENDTRACK      = 8\n)\n\n// GetOpenFileName and GetSaveFileName extended flags\nconst (\n\tOFN_EX_NOPLACESBAR = 0x00000001\n)\n\n// GetOpenFileName and GetSaveFileName flags\nconst (\n\tOFN_ALLOWMULTISELECT     = 0x00000200\n\tOFN_CREATEPROMPT         = 0x00002000\n\tOFN_DONTADDTORECENT      = 0x02000000\n\tOFN_ENABLEHOOK           = 0x00000020\n\tOFN_ENABLEINCLUDENOTIFY  = 0x00400000\n\tOFN_ENABLESIZING         = 0x00800000\n\tOFN_ENABLETEMPLATE       = 0x00000040\n\tOFN_ENABLETEMPLATEHANDLE = 0x00000080\n\tOFN_EXPLORER             = 0x00080000\n\tOFN_EXTENSIONDIFFERENT   = 0x00000400\n\tOFN_FILEMUSTEXIST        = 0x00001000\n\tOFN_FORCESHOWHIDDEN      = 0x10000000\n\tOFN_HIDEREADONLY         = 0x00000004\n\tOFN_LONGNAMES            = 0x00200000\n\tOFN_NOCHANGEDIR          = 0x00000008\n\tOFN_NODEREFERENCELINKS   = 0x00100000\n\tOFN_NOLONGNAMES          = 0x00040000\n\tOFN_NONETWORKBUTTON      = 0x00020000\n\tOFN_NOREADONLYRETURN     = 0x00008000\n\tOFN_NOTESTFILECREATE     = 0x00010000\n\tOFN_NOVALIDATE           = 0x00000100\n\tOFN_OVERWRITEPROMPT      = 0x00000002\n\tOFN_PATHMUSTEXIST        = 0x00000800\n\tOFN_READONLY             = 0x00000001\n\tOFN_SHAREAWARE           = 0x00004000\n\tOFN_SHOWHELP             = 0x00000010\n)\n\n//SHBrowseForFolder flags\nconst (\n\tBIF_RETURNONLYFSDIRS    = 0x00000001\n\tBIF_DONTGOBELOWDOMAIN   = 0x00000002\n\tBIF_STATUSTEXT          = 0x00000004\n\tBIF_RETURNFSANCESTORS   = 0x00000008\n\tBIF_EDITBOX             = 0x00000010\n\tBIF_VALIDATE            = 0x00000020\n\tBIF_NEWDIALOGSTYLE      = 0x00000040\n\tBIF_BROWSEINCLUDEURLS   = 0x00000080\n\tBIF_USENEWUI            = BIF_EDITBOX | BIF_NEWDIALOGSTYLE\n\tBIF_UAHINT              = 0x00000100\n\tBIF_NONEWFOLDERBUTTON   = 0x00000200\n\tBIF_NOTRANSLATETARGETS  = 0x00000400\n\tBIF_BROWSEFORCOMPUTER   = 0x00001000\n\tBIF_BROWSEFORPRINTER    = 0x00002000\n\tBIF_BROWSEINCLUDEFILES  = 0x00004000\n\tBIF_SHAREABLE           = 0x00008000\n\tBIF_BROWSEFILEJUNCTIONS = 0x00010000\n)\n\n//MessageBox flags\nconst (\n\tMB_OK                = 0x00000000\n\tMB_OKCANCEL          = 0x00000001\n\tMB_ABORTRETRYIGNORE  = 0x00000002\n\tMB_YESNOCANCEL       = 0x00000003\n\tMB_YESNO             = 0x00000004\n\tMB_RETRYCANCEL       = 0x00000005\n\tMB_CANCELTRYCONTINUE = 0x00000006\n\tMB_ICONHAND          = 0x00000010\n\tMB_ICONQUESTION      = 0x00000020\n\tMB_ICONEXCLAMATION   = 0x00000030\n\tMB_ICONASTERISK      = 0x00000040\n\tMB_USERICON          = 0x00000080\n\tMB_ICONWARNING       = MB_ICONEXCLAMATION\n\tMB_ICONERROR         = MB_ICONHAND\n\tMB_ICONINFORMATION   = MB_ICONASTERISK\n\tMB_ICONSTOP          = MB_ICONHAND\n\tMB_DEFBUTTON1        = 0x00000000\n\tMB_DEFBUTTON2        = 0x00000100\n\tMB_DEFBUTTON3        = 0x00000200\n\tMB_DEFBUTTON4        = 0x00000300\n)\n\n//COM\nconst (\n\tE_INVALIDARG  = 0x80070057\n\tE_OUTOFMEMORY = 0x8007000E\n\tE_UNEXPECTED  = 0x8000FFFF\n)\n\nconst (\n\tS_OK               = 0\n\tS_FALSE            = 0x0001\n\tRPC_E_CHANGED_MODE = 0x80010106\n)\n\n// GetSystemMetrics constants\nconst (\n\tSM_CXSCREEN             = 0\n\tSM_CYSCREEN             = 1\n\tSM_CXVSCROLL            = 2\n\tSM_CYHSCROLL            = 3\n\tSM_CYCAPTION            = 4\n\tSM_CXBORDER             = 5\n\tSM_CYBORDER             = 6\n\tSM_CXDLGFRAME           = 7\n\tSM_CYDLGFRAME           = 8\n\tSM_CYVTHUMB             = 9\n\tSM_CXHTHUMB             = 10\n\tSM_CXICON               = 11\n\tSM_CYICON               = 12\n\tSM_CXCURSOR             = 13\n\tSM_CYCURSOR             = 14\n\tSM_CYMENU               = 15\n\tSM_CXFULLSCREEN         = 16\n\tSM_CYFULLSCREEN         = 17\n\tSM_CYKANJIWINDOW        = 18\n\tSM_MOUSEPRESENT         = 19\n\tSM_CYVSCROLL            = 20\n\tSM_CXHSCROLL            = 21\n\tSM_DEBUG                = 22\n\tSM_SWAPBUTTON           = 23\n\tSM_RESERVED1            = 24\n\tSM_RESERVED2            = 25\n\tSM_RESERVED3            = 26\n\tSM_RESERVED4            = 27\n\tSM_CXMIN                = 28\n\tSM_CYMIN                = 29\n\tSM_CXSIZE               = 30\n\tSM_CYSIZE               = 31\n\tSM_CXFRAME              = 32\n\tSM_CYFRAME              = 33\n\tSM_CXMINTRACK           = 34\n\tSM_CYMINTRACK           = 35\n\tSM_CXDOUBLECLK          = 36\n\tSM_CYDOUBLECLK          = 37\n\tSM_CXICONSPACING        = 38\n\tSM_CYICONSPACING        = 39\n\tSM_MENUDROPALIGNMENT    = 40\n\tSM_PENWINDOWS           = 41\n\tSM_DBCSENABLED          = 42\n\tSM_CMOUSEBUTTONS        = 43\n\tSM_CXFIXEDFRAME         = SM_CXDLGFRAME\n\tSM_CYFIXEDFRAME         = SM_CYDLGFRAME\n\tSM_CXSIZEFRAME          = SM_CXFRAME\n\tSM_CYSIZEFRAME          = SM_CYFRAME\n\tSM_SECURE               = 44\n\tSM_CXEDGE               = 45\n\tSM_CYEDGE               = 46\n\tSM_CXMINSPACING         = 47\n\tSM_CYMINSPACING         = 48\n\tSM_CXSMICON             = 49\n\tSM_CYSMICON             = 50\n\tSM_CYSMCAPTION          = 51\n\tSM_CXSMSIZE             = 52\n\tSM_CYSMSIZE             = 53\n\tSM_CXMENUSIZE           = 54\n\tSM_CYMENUSIZE           = 55\n\tSM_ARRANGE              = 56\n\tSM_CXMINIMIZED          = 57\n\tSM_CYMINIMIZED          = 58\n\tSM_CXMAXTRACK           = 59\n\tSM_CYMAXTRACK           = 60\n\tSM_CXMAXIMIZED          = 61\n\tSM_CYMAXIMIZED          = 62\n\tSM_NETWORK              = 63\n\tSM_CLEANBOOT            = 67\n\tSM_CXDRAG               = 68\n\tSM_CYDRAG               = 69\n\tSM_SHOWSOUNDS           = 70\n\tSM_CXMENUCHECK          = 71\n\tSM_CYMENUCHECK          = 72\n\tSM_SLOWMACHINE          = 73\n\tSM_MIDEASTENABLED       = 74\n\tSM_MOUSEWHEELPRESENT    = 75\n\tSM_XVIRTUALSCREEN       = 76\n\tSM_YVIRTUALSCREEN       = 77\n\tSM_CXVIRTUALSCREEN      = 78\n\tSM_CYVIRTUALSCREEN      = 79\n\tSM_CMONITORS            = 80\n\tSM_SAMEDISPLAYFORMAT    = 81\n\tSM_IMMENABLED           = 82\n\tSM_CXFOCUSBORDER        = 83\n\tSM_CYFOCUSBORDER        = 84\n\tSM_TABLETPC             = 86\n\tSM_MEDIACENTER          = 87\n\tSM_STARTER              = 88\n\tSM_SERVERR2             = 89\n\tSM_CMETRICS             = 91\n\tSM_REMOTESESSION        = 0x1000\n\tSM_SHUTTINGDOWN         = 0x2000\n\tSM_REMOTECONTROL        = 0x2001\n\tSM_CARETBLINKINGENABLED = 0x2002\n)\n\nconst (\n\tCLSCTX_INPROC_SERVER   = 1\n\tCLSCTX_INPROC_HANDLER  = 2\n\tCLSCTX_LOCAL_SERVER    = 4\n\tCLSCTX_INPROC_SERVER16 = 8\n\tCLSCTX_REMOTE_SERVER   = 16\n\tCLSCTX_ALL             = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER\n\tCLSCTX_INPROC          = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER\n\tCLSCTX_SERVER          = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER\n)\n\nconst (\n\tCOINIT_APARTMENTTHREADED = 0x2\n\tCOINIT_MULTITHREADED     = 0x0\n\tCOINIT_DISABLE_OLE1DDE   = 0x4\n\tCOINIT_SPEED_OVER_MEMORY = 0x8\n)\n\nconst (\n\tDISPATCH_METHOD         = 1\n\tDISPATCH_PROPERTYGET    = 2\n\tDISPATCH_PROPERTYPUT    = 4\n\tDISPATCH_PROPERTYPUTREF = 8\n)\n\nconst (\n\tCC_FASTCALL = iota\n\tCC_CDECL\n\tCC_MSCPASCAL\n\tCC_PASCAL = CC_MSCPASCAL\n\tCC_MACPASCAL\n\tCC_STDCALL\n\tCC_FPFASTCALL\n\tCC_SYSCALL\n\tCC_MPWCDECL\n\tCC_MPWPASCAL\n\tCC_MAX = CC_MPWPASCAL\n)\n\nconst (\n\tVT_EMPTY           = 0x0\n\tVT_NULL            = 0x1\n\tVT_I2              = 0x2\n\tVT_I4              = 0x3\n\tVT_R4              = 0x4\n\tVT_R8              = 0x5\n\tVT_CY              = 0x6\n\tVT_DATE            = 0x7\n\tVT_BSTR            = 0x8\n\tVT_DISPATCH        = 0x9\n\tVT_ERROR           = 0xa\n\tVT_BOOL            = 0xb\n\tVT_VARIANT         = 0xc\n\tVT_UNKNOWN         = 0xd\n\tVT_DECIMAL         = 0xe\n\tVT_I1              = 0x10\n\tVT_UI1             = 0x11\n\tVT_UI2             = 0x12\n\tVT_UI4             = 0x13\n\tVT_I8              = 0x14\n\tVT_UI8             = 0x15\n\tVT_INT             = 0x16\n\tVT_UINT            = 0x17\n\tVT_VOID            = 0x18\n\tVT_HRESULT         = 0x19\n\tVT_PTR             = 0x1a\n\tVT_SAFEARRAY       = 0x1b\n\tVT_CARRAY          = 0x1c\n\tVT_USERDEFINED     = 0x1d\n\tVT_LPSTR           = 0x1e\n\tVT_LPWSTR          = 0x1f\n\tVT_RECORD          = 0x24\n\tVT_INT_PTR         = 0x25\n\tVT_UINT_PTR        = 0x26\n\tVT_FILETIME        = 0x40\n\tVT_BLOB            = 0x41\n\tVT_STREAM          = 0x42\n\tVT_STORAGE         = 0x43\n\tVT_STREAMED_OBJECT = 0x44\n\tVT_STORED_OBJECT   = 0x45\n\tVT_BLOB_OBJECT     = 0x46\n\tVT_CF              = 0x47\n\tVT_CLSID           = 0x48\n\tVT_BSTR_BLOB       = 0xfff\n\tVT_VECTOR          = 0x1000\n\tVT_ARRAY           = 0x2000\n\tVT_BYREF           = 0x4000\n\tVT_RESERVED        = 0x8000\n\tVT_ILLEGAL         = 0xffff\n\tVT_ILLEGALMASKED   = 0xfff\n\tVT_TYPEMASK        = 0xfff\n)\n\nconst (\n\tDISPID_UNKNOWN     = -1\n\tDISPID_VALUE       = 0\n\tDISPID_PROPERTYPUT = -3\n\tDISPID_NEWENUM     = -4\n\tDISPID_EVALUATE    = -5\n\tDISPID_CONSTRUCTOR = -6\n\tDISPID_DESTRUCTOR  = -7\n\tDISPID_COLLECT     = -8\n)\n\nconst (\n\tMONITOR_DEFAULTTONULL    = 0x00000000\n\tMONITOR_DEFAULTTOPRIMARY = 0x00000001\n\tMONITOR_DEFAULTTONEAREST = 0x00000002\n\n\tMONITORINFOF_PRIMARY = 0x00000001\n)\n\nconst (\n\tCCHDEVICENAME = 32\n\tCCHFORMNAME   = 32\n)\n\nconst (\n\tIDOK       = 1\n\tIDCANCEL   = 2\n\tIDABORT    = 3\n\tIDRETRY    = 4\n\tIDIGNORE   = 5\n\tIDYES      = 6\n\tIDNO       = 7\n\tIDCLOSE    = 8\n\tIDHELP     = 9\n\tIDTRYAGAIN = 10\n\tIDCONTINUE = 11\n\tIDTIMEOUT  = 32000\n)\n\n// Generic WM_NOTIFY notification codes\nconst (\n\tNM_FIRST           = 0\n\tNM_OUTOFMEMORY     = NM_FIRST - 1\n\tNM_CLICK           = NM_FIRST - 2\n\tNM_DBLCLK          = NM_FIRST - 3\n\tNM_RETURN          = NM_FIRST - 4\n\tNM_RCLICK          = NM_FIRST - 5\n\tNM_RDBLCLK         = NM_FIRST - 6\n\tNM_SETFOCUS        = NM_FIRST - 7\n\tNM_KILLFOCUS       = NM_FIRST - 8\n\tNM_CUSTOMDRAW      = NM_FIRST - 12\n\tNM_HOVER           = NM_FIRST - 13\n\tNM_NCHITTEST       = NM_FIRST - 14\n\tNM_KEYDOWN         = NM_FIRST - 15\n\tNM_RELEASEDCAPTURE = NM_FIRST - 16\n\tNM_SETCURSOR       = NM_FIRST - 17\n\tNM_CHAR            = NM_FIRST - 18\n\tNM_TOOLTIPSCREATED = NM_FIRST - 19\n\tNM_LAST            = NM_FIRST - 99\n)\n\n// ListView messages\nconst (\n\tLVM_FIRST                    = 0x1000\n\tLVM_GETITEMCOUNT             = LVM_FIRST + 4\n\tLVM_SETIMAGELIST             = LVM_FIRST + 3\n\tLVM_GETIMAGELIST             = LVM_FIRST + 2\n\tLVM_GETITEM                  = LVM_FIRST + 75\n\tLVM_SETITEM                  = LVM_FIRST + 76\n\tLVM_INSERTITEM               = LVM_FIRST + 77\n\tLVM_DELETEITEM               = LVM_FIRST + 8\n\tLVM_DELETEALLITEMS           = LVM_FIRST + 9\n\tLVM_GETCALLBACKMASK          = LVM_FIRST + 10\n\tLVM_SETCALLBACKMASK          = LVM_FIRST + 11\n\tLVM_SETUNICODEFORMAT         = CCM_SETUNICODEFORMAT\n\tLVM_GETNEXTITEM              = LVM_FIRST + 12\n\tLVM_FINDITEM                 = LVM_FIRST + 83\n\tLVM_GETITEMRECT              = LVM_FIRST + 14\n\tLVM_GETSTRINGWIDTH           = LVM_FIRST + 87\n\tLVM_HITTEST                  = LVM_FIRST + 18\n\tLVM_ENSUREVISIBLE            = LVM_FIRST + 19\n\tLVM_SCROLL                   = LVM_FIRST + 20\n\tLVM_REDRAWITEMS              = LVM_FIRST + 21\n\tLVM_ARRANGE                  = LVM_FIRST + 22\n\tLVM_EDITLABEL                = LVM_FIRST + 118\n\tLVM_GETEDITCONTROL           = LVM_FIRST + 24\n\tLVM_GETCOLUMN                = LVM_FIRST + 95\n\tLVM_SETCOLUMN                = LVM_FIRST + 96\n\tLVM_INSERTCOLUMN             = LVM_FIRST + 97\n\tLVM_DELETECOLUMN             = LVM_FIRST + 28\n\tLVM_GETCOLUMNWIDTH           = LVM_FIRST + 29\n\tLVM_SETCOLUMNWIDTH           = LVM_FIRST + 30\n\tLVM_GETHEADER                = LVM_FIRST + 31\n\tLVM_CREATEDRAGIMAGE          = LVM_FIRST + 33\n\tLVM_GETVIEWRECT              = LVM_FIRST + 34\n\tLVM_GETTEXTCOLOR             = LVM_FIRST + 35\n\tLVM_SETTEXTCOLOR             = LVM_FIRST + 36\n\tLVM_GETTEXTBKCOLOR           = LVM_FIRST + 37\n\tLVM_SETTEXTBKCOLOR           = LVM_FIRST + 38\n\tLVM_GETTOPINDEX              = LVM_FIRST + 39\n\tLVM_GETCOUNTPERPAGE          = LVM_FIRST + 40\n\tLVM_GETORIGIN                = LVM_FIRST + 41\n\tLVM_UPDATE                   = LVM_FIRST + 42\n\tLVM_SETITEMSTATE             = LVM_FIRST + 43\n\tLVM_GETITEMSTATE             = LVM_FIRST + 44\n\tLVM_GETITEMTEXT              = LVM_FIRST + 115\n\tLVM_SETITEMTEXT              = LVM_FIRST + 116\n\tLVM_SETITEMCOUNT             = LVM_FIRST + 47\n\tLVM_SORTITEMS                = LVM_FIRST + 48\n\tLVM_SETITEMPOSITION32        = LVM_FIRST + 49\n\tLVM_GETSELECTEDCOUNT         = LVM_FIRST + 50\n\tLVM_GETITEMSPACING           = LVM_FIRST + 51\n\tLVM_GETISEARCHSTRING         = LVM_FIRST + 117\n\tLVM_SETICONSPACING           = LVM_FIRST + 53\n\tLVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54\n\tLVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55\n\tLVM_GETSUBITEMRECT           = LVM_FIRST + 56\n\tLVM_SUBITEMHITTEST           = LVM_FIRST + 57\n\tLVM_SETCOLUMNORDERARRAY      = LVM_FIRST + 58\n\tLVM_GETCOLUMNORDERARRAY      = LVM_FIRST + 59\n\tLVM_SETHOTITEM               = LVM_FIRST + 60\n\tLVM_GETHOTITEM               = LVM_FIRST + 61\n\tLVM_SETHOTCURSOR             = LVM_FIRST + 62\n\tLVM_GETHOTCURSOR             = LVM_FIRST + 63\n\tLVM_APPROXIMATEVIEWRECT      = LVM_FIRST + 64\n\tLVM_SETWORKAREAS             = LVM_FIRST + 65\n\tLVM_GETWORKAREAS             = LVM_FIRST + 70\n\tLVM_GETNUMBEROFWORKAREAS     = LVM_FIRST + 73\n\tLVM_GETSELECTIONMARK         = LVM_FIRST + 66\n\tLVM_SETSELECTIONMARK         = LVM_FIRST + 67\n\tLVM_SETHOVERTIME             = LVM_FIRST + 71\n\tLVM_GETHOVERTIME             = LVM_FIRST + 72\n\tLVM_SETTOOLTIPS              = LVM_FIRST + 74\n\tLVM_GETTOOLTIPS              = LVM_FIRST + 78\n\tLVM_SORTITEMSEX              = LVM_FIRST + 81\n\tLVM_SETBKIMAGE               = LVM_FIRST + 138\n\tLVM_GETBKIMAGE               = LVM_FIRST + 139\n\tLVM_SETSELECTEDCOLUMN        = LVM_FIRST + 140\n\tLVM_SETVIEW                  = LVM_FIRST + 142\n\tLVM_GETVIEW                  = LVM_FIRST + 143\n\tLVM_INSERTGROUP              = LVM_FIRST + 145\n\tLVM_SETGROUPINFO             = LVM_FIRST + 147\n\tLVM_GETGROUPINFO             = LVM_FIRST + 149\n\tLVM_REMOVEGROUP              = LVM_FIRST + 150\n\tLVM_MOVEGROUP                = LVM_FIRST + 151\n\tLVM_GETGROUPCOUNT            = LVM_FIRST + 152\n\tLVM_GETGROUPINFOBYINDEX      = LVM_FIRST + 153\n\tLVM_MOVEITEMTOGROUP          = LVM_FIRST + 154\n\tLVM_GETGROUPRECT             = LVM_FIRST + 98\n\tLVM_SETGROUPMETRICS          = LVM_FIRST + 155\n\tLVM_GETGROUPMETRICS          = LVM_FIRST + 156\n\tLVM_ENABLEGROUPVIEW          = LVM_FIRST + 157\n\tLVM_SORTGROUPS               = LVM_FIRST + 158\n\tLVM_INSERTGROUPSORTED        = LVM_FIRST + 159\n\tLVM_REMOVEALLGROUPS          = LVM_FIRST + 160\n\tLVM_HASGROUP                 = LVM_FIRST + 161\n\tLVM_GETGROUPSTATE            = LVM_FIRST + 92\n\tLVM_GETFOCUSEDGROUP          = LVM_FIRST + 93\n\tLVM_SETTILEVIEWINFO          = LVM_FIRST + 162\n\tLVM_GETTILEVIEWINFO          = LVM_FIRST + 163\n\tLVM_SETTILEINFO              = LVM_FIRST + 164\n\tLVM_GETTILEINFO              = LVM_FIRST + 165\n\tLVM_SETINSERTMARK            = LVM_FIRST + 166\n\tLVM_GETINSERTMARK            = LVM_FIRST + 167\n\tLVM_INSERTMARKHITTEST        = LVM_FIRST + 168\n\tLVM_GETINSERTMARKRECT        = LVM_FIRST + 169\n\tLVM_SETINSERTMARKCOLOR       = LVM_FIRST + 170\n\tLVM_GETINSERTMARKCOLOR       = LVM_FIRST + 171\n\tLVM_SETINFOTIP               = LVM_FIRST + 173\n\tLVM_GETSELECTEDCOLUMN        = LVM_FIRST + 174\n\tLVM_ISGROUPVIEWENABLED       = LVM_FIRST + 175\n\tLVM_GETOUTLINECOLOR          = LVM_FIRST + 176\n\tLVM_SETOUTLINECOLOR          = LVM_FIRST + 177\n\tLVM_CANCELEDITLABEL          = LVM_FIRST + 179\n\tLVM_MAPINDEXTOID             = LVM_FIRST + 180\n\tLVM_MAPIDTOINDEX             = LVM_FIRST + 181\n\tLVM_ISITEMVISIBLE            = LVM_FIRST + 182\n\tLVM_GETNEXTITEMINDEX         = LVM_FIRST + 211\n)\n\n// ListView notifications\nconst (\n\tLVN_FIRST = -100\n\n\tLVN_ITEMCHANGING      = LVN_FIRST - 0\n\tLVN_ITEMCHANGED       = LVN_FIRST - 1\n\tLVN_INSERTITEM        = LVN_FIRST - 2\n\tLVN_DELETEITEM        = LVN_FIRST - 3\n\tLVN_DELETEALLITEMS    = LVN_FIRST - 4\n\tLVN_BEGINLABELEDITA   = LVN_FIRST - 5\n\tLVN_BEGINLABELEDITW   = LVN_FIRST - 75\n\tLVN_ENDLABELEDITA     = LVN_FIRST - 6\n\tLVN_ENDLABELEDITW     = LVN_FIRST - 76\n\tLVN_COLUMNCLICK       = LVN_FIRST - 8\n\tLVN_BEGINDRAG         = LVN_FIRST - 9\n\tLVN_BEGINRDRAG        = LVN_FIRST - 11\n\tLVN_ODCACHEHINT       = LVN_FIRST - 13\n\tLVN_ODFINDITEMA       = LVN_FIRST - 52\n\tLVN_ODFINDITEMW       = LVN_FIRST - 79\n\tLVN_ITEMACTIVATE      = LVN_FIRST - 14\n\tLVN_ODSTATECHANGED    = LVN_FIRST - 15\n\tLVN_HOTTRACK          = LVN_FIRST - 21\n\tLVN_GETDISPINFO       = LVN_FIRST - 77\n\tLVN_SETDISPINFO       = LVN_FIRST - 78\n\tLVN_KEYDOWN           = LVN_FIRST - 55\n\tLVN_MARQUEEBEGIN      = LVN_FIRST - 56\n\tLVN_GETINFOTIP        = LVN_FIRST - 58\n\tLVN_INCREMENTALSEARCH = LVN_FIRST - 63\n\tLVN_BEGINSCROLL       = LVN_FIRST - 80\n\tLVN_ENDSCROLL         = LVN_FIRST - 81\n)\n\nconst (\n\tLVSCW_AUTOSIZE           = ^uintptr(0)\n\tLVSCW_AUTOSIZE_USEHEADER = ^uintptr(1)\n)\n\n// ListView LVNI constants\nconst (\n\tLVNI_ALL         = 0\n\tLVNI_FOCUSED     = 1\n\tLVNI_SELECTED    = 2\n\tLVNI_CUT         = 4\n\tLVNI_DROPHILITED = 8\n\tLVNI_ABOVE       = 256\n\tLVNI_BELOW       = 512\n\tLVNI_TOLEFT      = 1024\n\tLVNI_TORIGHT     = 2048\n)\n\n// ListView styles\nconst (\n\tLVS_ICON            = 0x0000\n\tLVS_REPORT          = 0x0001\n\tLVS_SMALLICON       = 0x0002\n\tLVS_LIST            = 0x0003\n\tLVS_TYPEMASK        = 0x0003\n\tLVS_SINGLESEL       = 0x0004\n\tLVS_SHOWSELALWAYS   = 0x0008\n\tLVS_SORTASCENDING   = 0x0010\n\tLVS_SORTDESCENDING  = 0x0020\n\tLVS_SHAREIMAGELISTS = 0x0040\n\tLVS_NOLABELWRAP     = 0x0080\n\tLVS_AUTOARRANGE     = 0x0100\n\tLVS_EDITLABELS      = 0x0200\n\tLVS_OWNERDATA       = 0x1000\n\tLVS_NOSCROLL        = 0x2000\n\tLVS_TYPESTYLEMASK   = 0xfc00\n\tLVS_ALIGNTOP        = 0x0000\n\tLVS_ALIGNLEFT       = 0x0800\n\tLVS_ALIGNMASK       = 0x0c00\n\tLVS_OWNERDRAWFIXED  = 0x0400\n\tLVS_NOCOLUMNHEADER  = 0x4000\n\tLVS_NOSORTHEADER    = 0x8000\n)\n\n// ListView extended styles\nconst (\n\tLVS_EX_GRIDLINES        = 0x00000001\n\tLVS_EX_SUBITEMIMAGES    = 0x00000002\n\tLVS_EX_CHECKBOXES       = 0x00000004\n\tLVS_EX_TRACKSELECT      = 0x00000008\n\tLVS_EX_HEADERDRAGDROP   = 0x00000010\n\tLVS_EX_FULLROWSELECT    = 0x00000020\n\tLVS_EX_ONECLICKACTIVATE = 0x00000040\n\tLVS_EX_TWOCLICKACTIVATE = 0x00000080\n\tLVS_EX_FLATSB           = 0x00000100\n\tLVS_EX_REGIONAL         = 0x00000200\n\tLVS_EX_INFOTIP          = 0x00000400\n\tLVS_EX_UNDERLINEHOT     = 0x00000800\n\tLVS_EX_UNDERLINECOLD    = 0x00001000\n\tLVS_EX_MULTIWORKAREAS   = 0x00002000\n\tLVS_EX_LABELTIP         = 0x00004000\n\tLVS_EX_BORDERSELECT     = 0x00008000\n\tLVS_EX_DOUBLEBUFFER     = 0x00010000\n\tLVS_EX_HIDELABELS       = 0x00020000\n\tLVS_EX_SINGLEROW        = 0x00040000\n\tLVS_EX_SNAPTOGRID       = 0x00080000\n\tLVS_EX_SIMPLESELECT     = 0x00100000\n)\n\n// ListView column flags\nconst (\n\tLVCF_FMT     = 0x0001\n\tLVCF_WIDTH   = 0x0002\n\tLVCF_TEXT    = 0x0004\n\tLVCF_SUBITEM = 0x0008\n\tLVCF_IMAGE   = 0x0010\n\tLVCF_ORDER   = 0x0020\n)\n\n// ListView column format constants\nconst (\n\tLVCFMT_LEFT            = 0x0000\n\tLVCFMT_RIGHT           = 0x0001\n\tLVCFMT_CENTER          = 0x0002\n\tLVCFMT_JUSTIFYMASK     = 0x0003\n\tLVCFMT_IMAGE           = 0x0800\n\tLVCFMT_BITMAP_ON_RIGHT = 0x1000\n\tLVCFMT_COL_HAS_IMAGES  = 0x8000\n)\n\n// ListView item flags\nconst (\n\tLVIF_TEXT        = 0x00000001\n\tLVIF_IMAGE       = 0x00000002\n\tLVIF_PARAM       = 0x00000004\n\tLVIF_STATE       = 0x00000008\n\tLVIF_INDENT      = 0x00000010\n\tLVIF_NORECOMPUTE = 0x00000800\n\tLVIF_GROUPID     = 0x00000100\n\tLVIF_COLUMNS     = 0x00000200\n)\n\nconst LVFI_PARAM = 0x0001\n\n// ListView item states\nconst (\n\tLVIS_FOCUSED        = 1\n\tLVIS_SELECTED       = 2\n\tLVIS_CUT            = 4\n\tLVIS_DROPHILITED    = 8\n\tLVIS_OVERLAYMASK    = 0xF00\n\tLVIS_STATEIMAGEMASK = 0xF000\n)\n\n// ListView hit test constants\nconst (\n\tLVHT_NOWHERE         = 0x00000001\n\tLVHT_ONITEMICON      = 0x00000002\n\tLVHT_ONITEMLABEL     = 0x00000004\n\tLVHT_ONITEMSTATEICON = 0x00000008\n\tLVHT_ONITEM          = LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON\n\n\tLVHT_ABOVE   = 0x00000008\n\tLVHT_BELOW   = 0x00000010\n\tLVHT_TORIGHT = 0x00000020\n\tLVHT_TOLEFT  = 0x00000040\n)\n\n// ListView image list types\nconst (\n\tLVSIL_NORMAL      = 0\n\tLVSIL_SMALL       = 1\n\tLVSIL_STATE       = 2\n\tLVSIL_GROUPHEADER = 3\n)\n\n// InitCommonControlsEx flags\nconst (\n\tICC_LISTVIEW_CLASSES   = 1\n\tICC_TREEVIEW_CLASSES   = 2\n\tICC_BAR_CLASSES        = 4\n\tICC_TAB_CLASSES        = 8\n\tICC_UPDOWN_CLASS       = 16\n\tICC_PROGRESS_CLASS     = 32\n\tICC_HOTKEY_CLASS       = 64\n\tICC_ANIMATE_CLASS      = 128\n\tICC_WIN95_CLASSES      = 255\n\tICC_DATE_CLASSES       = 256\n\tICC_USEREX_CLASSES     = 512\n\tICC_COOL_CLASSES       = 1024\n\tICC_INTERNET_CLASSES   = 2048\n\tICC_PAGESCROLLER_CLASS = 4096\n\tICC_NATIVEFNTCTL_CLASS = 8192\n\tINFOTIPSIZE            = 1024\n\tICC_STANDARD_CLASSES   = 0x00004000\n\tICC_LINK_CLASS         = 0x00008000\n)\n\n// Dialog Codes\nconst (\n\tDLGC_WANTARROWS      = 0x0001\n\tDLGC_WANTTAB         = 0x0002\n\tDLGC_WANTALLKEYS     = 0x0004\n\tDLGC_WANTMESSAGE     = 0x0004\n\tDLGC_HASSETSEL       = 0x0008\n\tDLGC_DEFPUSHBUTTON   = 0x0010\n\tDLGC_UNDEFPUSHBUTTON = 0x0020\n\tDLGC_RADIOBUTTON     = 0x0040\n\tDLGC_WANTCHARS       = 0x0080\n\tDLGC_STATIC          = 0x0100\n\tDLGC_BUTTON          = 0x2000\n)\n\n// Get/SetWindowWord/Long offsets for use with WC_DIALOG windows\nconst (\n\tDWL_MSGRESULT = 0\n\tDWL_DLGPROC   = 4\n\tDWL_USER      = 8\n)\n\n// Registry predefined keys\nconst (\n\tHKEY_CLASSES_ROOT     HKEY = 0x80000000\n\tHKEY_CURRENT_USER     HKEY = 0x80000001\n\tHKEY_LOCAL_MACHINE    HKEY = 0x80000002\n\tHKEY_USERS            HKEY = 0x80000003\n\tHKEY_PERFORMANCE_DATA HKEY = 0x80000004\n\tHKEY_CURRENT_CONFIG   HKEY = 0x80000005\n\tHKEY_DYN_DATA         HKEY = 0x80000006\n)\n\n// Registry Key Security and Access Rights\nconst (\n\tKEY_ALL_ACCESS         = 0xF003F\n\tKEY_CREATE_SUB_KEY     = 0x0004\n\tKEY_ENUMERATE_SUB_KEYS = 0x0008\n\tKEY_NOTIFY             = 0x0010\n\tKEY_QUERY_VALUE        = 0x0001\n\tKEY_SET_VALUE          = 0x0002\n\tKEY_READ               = 0x20019\n\tKEY_WRITE              = 0x20006\n)\n\nconst (\n\tNFR_ANSI    = 1\n\tNFR_UNICODE = 2\n\tNF_QUERY    = 3\n\tNF_REQUERY  = 4\n)\n\n// Registry value types\nconst (\n\tRRF_RT_REG_NONE         = 0x00000001\n\tRRF_RT_REG_SZ           = 0x00000002\n\tRRF_RT_REG_EXPAND_SZ    = 0x00000004\n\tRRF_RT_REG_BINARY       = 0x00000008\n\tRRF_RT_REG_DWORD        = 0x00000010\n\tRRF_RT_REG_MULTI_SZ     = 0x00000020\n\tRRF_RT_REG_QWORD        = 0x00000040\n\tRRF_RT_DWORD            = (RRF_RT_REG_BINARY | RRF_RT_REG_DWORD)\n\tRRF_RT_QWORD            = (RRF_RT_REG_BINARY | RRF_RT_REG_QWORD)\n\tRRF_RT_ANY              = 0x0000ffff\n\tRRF_NOEXPAND            = 0x10000000\n\tRRF_ZEROONFAILURE       = 0x20000000\n\tREG_PROCESS_APPKEY      = 0x00000001\n\tREG_MUI_STRING_TRUNCATE = 0x00000001\n)\n\n// PeekMessage wRemoveMsg value\nconst (\n\tPM_NOREMOVE = 0x000\n\tPM_REMOVE   = 0x001\n\tPM_NOYIELD  = 0x002\n)\n\n// ImageList flags\nconst (\n\tILC_MASK             = 0x00000001\n\tILC_COLOR            = 0x00000000\n\tILC_COLORDDB         = 0x000000FE\n\tILC_COLOR4           = 0x00000004\n\tILC_COLOR8           = 0x00000008\n\tILC_COLOR16          = 0x00000010\n\tILC_COLOR24          = 0x00000018\n\tILC_COLOR32          = 0x00000020\n\tILC_PALETTE          = 0x00000800\n\tILC_MIRROR           = 0x00002000\n\tILC_PERITEMMIRROR    = 0x00008000\n\tILC_ORIGINALSIZE     = 0x00010000\n\tILC_HIGHQUALITYSCALE = 0x00020000\n)\n\n// Keystroke Message Flags\nconst (\n\tKF_EXTENDED = 0x0100\n\tKF_DLGMODE  = 0x0800\n\tKF_MENUMODE = 0x1000\n\tKF_ALTDOWN  = 0x2000\n\tKF_REPEAT   = 0x4000\n\tKF_UP       = 0x8000\n)\n\n// Virtual-Key Codes\n/*\nconst (\n\tVK_LBUTTON             = 0x01\n\tVK_RBUTTON             = 0x02\n\tVK_CANCEL              = 0x03\n\tVK_MBUTTON             = 0x04\n\tVK_XBUTTON1            = 0x05\n\tVK_XBUTTON2            = 0x06\n\tVK_BACK                = 0x08\n\tVK_TAB                 = 0x09\n\tVK_CLEAR               = 0x0C\n\tVK_RETURN              = 0x0D\n\tVK_SHIFT               = 0x10\n\tVK_CONTROL             = 0x11\n\tVK_MENU                = 0x12\n\tVK_PAUSE               = 0x13\n\tVK_CAPITAL             = 0x14\n\tVK_KANA                = 0x15\n\tVK_HANGEUL             = 0x15\n\tVK_HANGUL              = 0x15\n\tVK_JUNJA               = 0x17\n\tVK_FINAL               = 0x18\n\tVK_HANJA               = 0x19\n\tVK_KANJI               = 0x19\n\tVK_ESCAPE              = 0x1B\n\tVK_CONVERT             = 0x1C\n\tVK_NONCONVERT          = 0x1D\n\tVK_ACCEPT              = 0x1E\n\tVK_MODECHANGE          = 0x1F\n\tVK_SPACE               = 0x20\n\tVK_PRIOR               = 0x21\n\tVK_NEXT                = 0x22\n\tVK_END                 = 0x23\n\tVK_HOME                = 0x24\n\tVK_LEFT                = 0x25\n\tVK_UP                  = 0x26\n\tVK_RIGHT               = 0x27\n\tVK_DOWN                = 0x28\n\tVK_SELECT              = 0x29\n\tVK_PRINT               = 0x2A\n\tVK_EXECUTE             = 0x2B\n\tVK_SNAPSHOT            = 0x2C\n\tVK_INSERT              = 0x2D\n\tVK_DELETE              = 0x2E\n\tVK_HELP                = 0x2F\n\tVK_LWIN                = 0x5B\n\tVK_RWIN                = 0x5C\n\tVK_APPS                = 0x5D\n\tVK_SLEEP               = 0x5F\n\tVK_NUMPAD0             = 0x60\n\tVK_NUMPAD1             = 0x61\n\tVK_NUMPAD2             = 0x62\n\tVK_NUMPAD3             = 0x63\n\tVK_NUMPAD4             = 0x64\n\tVK_NUMPAD5             = 0x65\n\tVK_NUMPAD6             = 0x66\n\tVK_NUMPAD7             = 0x67\n\tVK_NUMPAD8             = 0x68\n\tVK_NUMPAD9             = 0x69\n\tVK_MULTIPLY            = 0x6A\n\tVK_ADD                 = 0x6B\n\tVK_SEPARATOR           = 0x6C\n\tVK_SUBTRACT            = 0x6D\n\tVK_DECIMAL             = 0x6E\n\tVK_DIVIDE              = 0x6F\n\tVK_F1                  = 0x70\n\tVK_F2                  = 0x71\n\tVK_F3                  = 0x72\n\tVK_F4                  = 0x73\n\tVK_F5                  = 0x74\n\tVK_F6                  = 0x75\n\tVK_F7                  = 0x76\n\tVK_F8                  = 0x77\n\tVK_F9                  = 0x78\n\tVK_F10                 = 0x79\n\tVK_F11                 = 0x7A\n\tVK_F12                 = 0x7B\n\tVK_F13                 = 0x7C\n\tVK_F14                 = 0x7D\n\tVK_F15                 = 0x7E\n\tVK_F16                 = 0x7F\n\tVK_F17                 = 0x80\n\tVK_F18                 = 0x81\n\tVK_F19                 = 0x82\n\tVK_F20                 = 0x83\n\tVK_F21                 = 0x84\n\tVK_F22                 = 0x85\n\tVK_F23                 = 0x86\n\tVK_F24                 = 0x87\n\tVK_NUMLOCK             = 0x90\n\tVK_SCROLL              = 0x91\n\tVK_OEM_NEC_EQUAL       = 0x92\n\tVK_OEM_FJ_JISHO        = 0x92\n\tVK_OEM_FJ_MASSHOU      = 0x93\n\tVK_OEM_FJ_TOUROKU      = 0x94\n\tVK_OEM_FJ_LOYA         = 0x95\n\tVK_OEM_FJ_ROYA         = 0x96\n\tVK_LSHIFT              = 0xA0\n\tVK_RSHIFT              = 0xA1\n\tVK_LCONTROL            = 0xA2\n\tVK_RCONTROL            = 0xA3\n\tVK_LMENU               = 0xA4\n\tVK_RMENU               = 0xA5\n\tVK_BROWSER_BACK        = 0xA6\n\tVK_BROWSER_FORWARD     = 0xA7\n\tVK_BROWSER_REFRESH     = 0xA8\n\tVK_BROWSER_STOP        = 0xA9\n\tVK_BROWSER_SEARCH      = 0xAA\n\tVK_BROWSER_FAVORITES   = 0xAB\n\tVK_BROWSER_HOME        = 0xAC\n\tVK_VOLUME_MUTE         = 0xAD\n\tVK_VOLUME_DOWN         = 0xAE\n\tVK_VOLUME_UP           = 0xAF\n\tVK_MEDIA_NEXT_TRACK    = 0xB0\n\tVK_MEDIA_PREV_TRACK    = 0xB1\n\tVK_MEDIA_STOP          = 0xB2\n\tVK_MEDIA_PLAY_PAUSE    = 0xB3\n\tVK_LAUNCH_MAIL         = 0xB4\n\tVK_LAUNCH_MEDIA_SELECT = 0xB5\n\tVK_LAUNCH_APP1         = 0xB6\n\tVK_LAUNCH_APP2         = 0xB7\n\tVK_OEM_1               = 0xBA\n\tVK_OEM_PLUS            = 0xBB\n\tVK_OEM_COMMA           = 0xBC\n\tVK_OEM_MINUS           = 0xBD\n\tVK_OEM_PERIOD          = 0xBE\n\tVK_OEM_2               = 0xBF\n\tVK_OEM_3               = 0xC0\n\tVK_OEM_4               = 0xDB\n\tVK_OEM_5               = 0xDC\n\tVK_OEM_6               = 0xDD\n\tVK_OEM_7               = 0xDE\n\tVK_OEM_8               = 0xDF\n\tVK_OEM_AX              = 0xE1\n\tVK_OEM_102             = 0xE2\n\tVK_ICO_HELP            = 0xE3\n\tVK_ICO_00              = 0xE4\n\tVK_PROCESSKEY          = 0xE5\n\tVK_ICO_CLEAR           = 0xE6\n\tVK_OEM_RESET           = 0xE9\n\tVK_OEM_JUMP            = 0xEA\n\tVK_OEM_PA1             = 0xEB\n\tVK_OEM_PA2             = 0xEC\n\tVK_OEM_PA3             = 0xED\n\tVK_OEM_WSCTRL          = 0xEE\n\tVK_OEM_CUSEL           = 0xEF\n\tVK_OEM_ATTN            = 0xF0\n\tVK_OEM_FINISH          = 0xF1\n\tVK_OEM_COPY            = 0xF2\n\tVK_OEM_AUTO            = 0xF3\n\tVK_OEM_ENLW            = 0xF4\n\tVK_OEM_BACKTAB         = 0xF5\n\tVK_ATTN                = 0xF6\n\tVK_CRSEL               = 0xF7\n\tVK_EXSEL               = 0xF8\n\tVK_EREOF               = 0xF9\n\tVK_PLAY                = 0xFA\n\tVK_ZOOM                = 0xFB\n\tVK_NONAME              = 0xFC\n\tVK_PA1                 = 0xFD\n\tVK_OEM_CLEAR           = 0xFE\n)*/\n\n// Registry Value Types\nconst (\n\tREG_NONE                       = 0\n\tREG_SZ                         = 1\n\tREG_EXPAND_SZ                  = 2\n\tREG_BINARY                     = 3\n\tREG_DWORD                      = 4\n\tREG_DWORD_LITTLE_ENDIAN        = 4\n\tREG_DWORD_BIG_ENDIAN           = 5\n\tREG_LINK                       = 6\n\tREG_MULTI_SZ                   = 7\n\tREG_RESOURCE_LIST              = 8\n\tREG_FULL_RESOURCE_DESCRIPTOR   = 9\n\tREG_RESOURCE_REQUIREMENTS_LIST = 10\n\tREG_QWORD                      = 11\n\tREG_QWORD_LITTLE_ENDIAN        = 11\n)\n\n// Tooltip styles\nconst (\n\tTTS_ALWAYSTIP      = 0x01\n\tTTS_NOPREFIX       = 0x02\n\tTTS_NOANIMATE      = 0x10\n\tTTS_NOFADE         = 0x20\n\tTTS_BALLOON        = 0x40\n\tTTS_CLOSE          = 0x80\n\tTTS_USEVISUALSTYLE = 0x100\n)\n\n// Tooltip messages\nconst (\n\tTTM_ACTIVATE        = (WM_USER + 1)\n\tTTM_SETDELAYTIME    = (WM_USER + 3)\n\tTTM_ADDTOOL         = (WM_USER + 50)\n\tTTM_DELTOOL         = (WM_USER + 51)\n\tTTM_NEWTOOLRECT     = (WM_USER + 52)\n\tTTM_RELAYEVENT      = (WM_USER + 7)\n\tTTM_GETTOOLINFO     = (WM_USER + 53)\n\tTTM_SETTOOLINFO     = (WM_USER + 54)\n\tTTM_HITTEST         = (WM_USER + 55)\n\tTTM_GETTEXT         = (WM_USER + 56)\n\tTTM_UPDATETIPTEXT   = (WM_USER + 57)\n\tTTM_GETTOOLCOUNT    = (WM_USER + 13)\n\tTTM_ENUMTOOLS       = (WM_USER + 58)\n\tTTM_GETCURRENTTOOL  = (WM_USER + 59)\n\tTTM_WINDOWFROMPOINT = (WM_USER + 16)\n\tTTM_TRACKACTIVATE   = (WM_USER + 17)\n\tTTM_TRACKPOSITION   = (WM_USER + 18)\n\tTTM_SETTIPBKCOLOR   = (WM_USER + 19)\n\tTTM_SETTIPTEXTCOLOR = (WM_USER + 20)\n\tTTM_GETDELAYTIME    = (WM_USER + 21)\n\tTTM_GETTIPBKCOLOR   = (WM_USER + 22)\n\tTTM_GETTIPTEXTCOLOR = (WM_USER + 23)\n\tTTM_SETMAXTIPWIDTH  = (WM_USER + 24)\n\tTTM_GETMAXTIPWIDTH  = (WM_USER + 25)\n\tTTM_SETMARGIN       = (WM_USER + 26)\n\tTTM_GETMARGIN       = (WM_USER + 27)\n\tTTM_POP             = (WM_USER + 28)\n\tTTM_UPDATE          = (WM_USER + 29)\n\tTTM_GETBUBBLESIZE   = (WM_USER + 30)\n\tTTM_ADJUSTRECT      = (WM_USER + 31)\n\tTTM_SETTITLE        = (WM_USER + 33)\n\tTTM_POPUP           = (WM_USER + 34)\n\tTTM_GETTITLE        = (WM_USER + 35)\n)\n\n// Tooltip icons\nconst (\n\tTTI_NONE          = 0\n\tTTI_INFO          = 1\n\tTTI_WARNING       = 2\n\tTTI_ERROR         = 3\n\tTTI_INFO_LARGE    = 4\n\tTTI_WARNING_LARGE = 5\n\tTTI_ERROR_LARGE   = 6\n)\n\n// Tooltip notifications\nconst (\n\tTTN_FIRST       = -520\n\tTTN_LAST        = -549\n\tTTN_GETDISPINFO = (TTN_FIRST - 10)\n\tTTN_SHOW        = (TTN_FIRST - 1)\n\tTTN_POP         = (TTN_FIRST - 2)\n\tTTN_LINKCLICK   = (TTN_FIRST - 3)\n\tTTN_NEEDTEXT    = TTN_GETDISPINFO\n)\n\nconst (\n\tTTF_IDISHWND    = 0x0001\n\tTTF_CENTERTIP   = 0x0002\n\tTTF_RTLREADING  = 0x0004\n\tTTF_SUBCLASS    = 0x0010\n\tTTF_TRACK       = 0x0020\n\tTTF_ABSOLUTE    = 0x0080\n\tTTF_TRANSPARENT = 0x0100\n\tTTF_PARSELINKS  = 0x1000\n\tTTF_DI_SETITEM  = 0x8000\n)\n\nconst (\n\tSWP_NOSIZE         = 0x0001\n\tSWP_NOMOVE         = 0x0002\n\tSWP_NOZORDER       = 0x0004\n\tSWP_NOREDRAW       = 0x0008\n\tSWP_NOACTIVATE     = 0x0010\n\tSWP_FRAMECHANGED   = 0x0020\n\tSWP_SHOWWINDOW     = 0x0040\n\tSWP_HIDEWINDOW     = 0x0080\n\tSWP_NOCOPYBITS     = 0x0100\n\tSWP_NOOWNERZORDER  = 0x0200\n\tSWP_NOSENDCHANGING = 0x0400\n\tSWP_DRAWFRAME      = SWP_FRAMECHANGED\n\tSWP_NOREPOSITION   = SWP_NOOWNERZORDER\n\tSWP_DEFERERASE     = 0x2000\n\tSWP_ASYNCWINDOWPOS = 0x4000\n)\n\n// Predefined window handles\nconst (\n\tHWND_BROADCAST = HWND(0xFFFF)\n\tHWND_BOTTOM    = HWND(1)\n\tHWND_NOTOPMOST = ^HWND(1) // -2\n\tHWND_TOP       = HWND(0)\n\tHWND_TOPMOST   = ^HWND(0) // -1\n\tHWND_DESKTOP   = HWND(0)\n\tHWND_MESSAGE   = ^HWND(2) // -3\n)\n\n// Pen types\nconst (\n\tPS_COSMETIC  = 0x00000000\n\tPS_GEOMETRIC = 0x00010000\n\tPS_TYPE_MASK = 0x000F0000\n)\n\n// Pen styles\nconst (\n\tPS_SOLID       = 0\n\tPS_DASH        = 1\n\tPS_DOT         = 2\n\tPS_DASHDOT     = 3\n\tPS_DASHDOTDOT  = 4\n\tPS_NULL        = 5\n\tPS_INSIDEFRAME = 6\n\tPS_USERSTYLE   = 7\n\tPS_ALTERNATE   = 8\n\tPS_STYLE_MASK  = 0x0000000F\n)\n\n// Pen cap types\nconst (\n\tPS_ENDCAP_ROUND  = 0x00000000\n\tPS_ENDCAP_SQUARE = 0x00000100\n\tPS_ENDCAP_FLAT   = 0x00000200\n\tPS_ENDCAP_MASK   = 0x00000F00\n)\n\n// Pen join types\nconst (\n\tPS_JOIN_ROUND = 0x00000000\n\tPS_JOIN_BEVEL = 0x00001000\n\tPS_JOIN_MITER = 0x00002000\n\tPS_JOIN_MASK  = 0x0000F000\n)\n\n// Hatch styles\nconst (\n\tHS_HORIZONTAL = 0\n\tHS_VERTICAL   = 1\n\tHS_FDIAGONAL  = 2\n\tHS_BDIAGONAL  = 3\n\tHS_CROSS      = 4\n\tHS_DIAGCROSS  = 5\n)\n\n// Stock Logical Objects\nconst (\n\tWHITE_BRUSH         = 0\n\tLTGRAY_BRUSH        = 1\n\tGRAY_BRUSH          = 2\n\tDKGRAY_BRUSH        = 3\n\tBLACK_BRUSH         = 4\n\tNULL_BRUSH          = 5\n\tHOLLOW_BRUSH        = NULL_BRUSH\n\tWHITE_PEN           = 6\n\tBLACK_PEN           = 7\n\tNULL_PEN            = 8\n\tOEM_FIXED_FONT      = 10\n\tANSI_FIXED_FONT     = 11\n\tANSI_VAR_FONT       = 12\n\tSYSTEM_FONT         = 13\n\tDEVICE_DEFAULT_FONT = 14\n\tDEFAULT_PALETTE     = 15\n\tSYSTEM_FIXED_FONT   = 16\n\tDEFAULT_GUI_FONT    = 17\n\tDC_BRUSH            = 18\n\tDC_PEN              = 19\n)\n\n// Brush styles\nconst (\n\tBS_SOLID         = 0\n\tBS_NULL          = 1\n\tBS_HOLLOW        = BS_NULL\n\tBS_HATCHED       = 2\n\tBS_PATTERN       = 3\n\tBS_INDEXED       = 4\n\tBS_DIBPATTERN    = 5\n\tBS_DIBPATTERNPT  = 6\n\tBS_PATTERN8X8    = 7\n\tBS_DIBPATTERN8X8 = 8\n\tBS_MONOPATTERN   = 9\n)\n\n// TRACKMOUSEEVENT flags\nconst (\n\tTME_HOVER     = 0x00000001\n\tTME_LEAVE     = 0x00000002\n\tTME_NONCLIENT = 0x00000010\n\tTME_QUERY     = 0x40000000\n\tTME_CANCEL    = 0x80000000\n\n\tHOVER_DEFAULT = 0xFFFFFFFF\n)\n\n// WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes\nconst (\n\tHTERROR       = (-2)\n\tHTTRANSPARENT = (-1)\n\tHTNOWHERE     = 0\n\tHTCLIENT      = 1\n\tHTCAPTION     = 2\n\tHTSYSMENU     = 3\n\tHTGROWBOX     = 4\n\tHTSIZE        = HTGROWBOX\n\tHTMENU        = 5\n\tHTHSCROLL     = 6\n\tHTVSCROLL     = 7\n\tHTMINBUTTON   = 8\n\tHTMAXBUTTON   = 9\n\tHTLEFT        = 10\n\tHTRIGHT       = 11\n\tHTTOP         = 12\n\tHTTOPLEFT     = 13\n\tHTTOPRIGHT    = 14\n\tHTBOTTOM      = 15\n\tHTBOTTOMLEFT  = 16\n\tHTBOTTOMRIGHT = 17\n\tHTBORDER      = 18\n\tHTREDUCE      = HTMINBUTTON\n\tHTZOOM        = HTMAXBUTTON\n\tHTSIZEFIRST   = HTLEFT\n\tHTSIZELAST    = HTBOTTOMRIGHT\n\tHTOBJECT      = 19\n\tHTCLOSE       = 20\n\tHTHELP        = 21\n)\n\n// DrawText[Ex] format flags\nconst (\n\tDT_TOP                  = 0x00000000\n\tDT_LEFT                 = 0x00000000\n\tDT_CENTER               = 0x00000001\n\tDT_RIGHT                = 0x00000002\n\tDT_VCENTER              = 0x00000004\n\tDT_BOTTOM               = 0x00000008\n\tDT_WORDBREAK            = 0x00000010\n\tDT_SINGLELINE           = 0x00000020\n\tDT_EXPANDTABS           = 0x00000040\n\tDT_TABSTOP              = 0x00000080\n\tDT_NOCLIP               = 0x00000100\n\tDT_EXTERNALLEADING      = 0x00000200\n\tDT_CALCRECT             = 0x00000400\n\tDT_NOPREFIX             = 0x00000800\n\tDT_INTERNAL             = 0x00001000\n\tDT_EDITCONTROL          = 0x00002000\n\tDT_PATH_ELLIPSIS        = 0x00004000\n\tDT_END_ELLIPSIS         = 0x00008000\n\tDT_MODIFYSTRING         = 0x00010000\n\tDT_RTLREADING           = 0x00020000\n\tDT_WORD_ELLIPSIS        = 0x00040000\n\tDT_NOFULLWIDTHCHARBREAK = 0x00080000\n\tDT_HIDEPREFIX           = 0x00100000\n\tDT_PREFIXONLY           = 0x00200000\n)\n\nconst CLR_INVALID = 0xFFFFFFFF\n\n// Background Modes\nconst (\n\tTRANSPARENT = 1\n\tOPAQUE      = 2\n\tBKMODE_LAST = 2\n)\n\n// Global Memory Flags\nconst (\n\tGMEM_FIXED          = 0x0000\n\tGMEM_MOVEABLE       = 0x0002\n\tGMEM_NOCOMPACT      = 0x0010\n\tGMEM_NODISCARD      = 0x0020\n\tGMEM_ZEROINIT       = 0x0040\n\tGMEM_MODIFY         = 0x0080\n\tGMEM_DISCARDABLE    = 0x0100\n\tGMEM_NOT_BANKED     = 0x1000\n\tGMEM_SHARE          = 0x2000\n\tGMEM_DDESHARE       = 0x2000\n\tGMEM_NOTIFY         = 0x4000\n\tGMEM_LOWER          = GMEM_NOT_BANKED\n\tGMEM_VALID_FLAGS    = 0x7F72\n\tGMEM_INVALID_HANDLE = 0x8000\n\tGHND                = (GMEM_MOVEABLE | GMEM_ZEROINIT)\n\tGPTR                = (GMEM_FIXED | GMEM_ZEROINIT)\n)\n\n// Ternary raster operations\nconst (\n\tSRCCOPY        = 0x00CC0020\n\tSRCPAINT       = 0x00EE0086\n\tSRCAND         = 0x008800C6\n\tSRCINVERT      = 0x00660046\n\tSRCERASE       = 0x00440328\n\tNOTSRCCOPY     = 0x00330008\n\tNOTSRCERASE    = 0x001100A6\n\tMERGECOPY      = 0x00C000CA\n\tMERGEPAINT     = 0x00BB0226\n\tPATCOPY        = 0x00F00021\n\tPATPAINT       = 0x00FB0A09\n\tPATINVERT      = 0x005A0049\n\tDSTINVERT      = 0x00550009\n\tBLACKNESS      = 0x00000042\n\tWHITENESS      = 0x00FF0062\n\tNOMIRRORBITMAP = 0x80000000\n\tCAPTUREBLT     = 0x40000000\n)\n\n// Clipboard formats\nconst (\n\tCF_TEXT            = 1\n\tCF_BITMAP          = 2\n\tCF_METAFILEPICT    = 3\n\tCF_SYLK            = 4\n\tCF_DIF             = 5\n\tCF_TIFF            = 6\n\tCF_OEMTEXT         = 7\n\tCF_DIB             = 8\n\tCF_PALETTE         = 9\n\tCF_PENDATA         = 10\n\tCF_RIFF            = 11\n\tCF_WAVE            = 12\n\tCF_UNICODETEXT     = 13\n\tCF_ENHMETAFILE     = 14\n\tCF_HDROP           = 15\n\tCF_LOCALE          = 16\n\tCF_DIBV5           = 17\n\tCF_MAX             = 18\n\tCF_OWNERDISPLAY    = 0x0080\n\tCF_DSPTEXT         = 0x0081\n\tCF_DSPBITMAP       = 0x0082\n\tCF_DSPMETAFILEPICT = 0x0083\n\tCF_DSPENHMETAFILE  = 0x008E\n\tCF_PRIVATEFIRST    = 0x0200\n\tCF_PRIVATELAST     = 0x02FF\n\tCF_GDIOBJFIRST     = 0x0300\n\tCF_GDIOBJLAST      = 0x03FF\n)\n\n// Bitmap compression formats\nconst (\n\tBI_RGB       = 0\n\tBI_RLE8      = 1\n\tBI_RLE4      = 2\n\tBI_BITFIELDS = 3\n\tBI_JPEG      = 4\n\tBI_PNG       = 5\n)\n\n// SetDIBitsToDevice fuColorUse\nconst (\n\tDIB_PAL_COLORS = 1\n\tDIB_RGB_COLORS = 0\n)\n\nconst (\n\tSTANDARD_RIGHTS_REQUIRED = 0x000F\n)\n\n// Service Control Manager object specific access types\nconst (\n\tSC_MANAGER_CONNECT            = 0x0001\n\tSC_MANAGER_CREATE_SERVICE     = 0x0002\n\tSC_MANAGER_ENUMERATE_SERVICE  = 0x0004\n\tSC_MANAGER_LOCK               = 0x0008\n\tSC_MANAGER_QUERY_LOCK_STATUS  = 0x0010\n\tSC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020\n\tSC_MANAGER_ALL_ACCESS         = STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG\n)\n\n// Service Types (Bit Mask)\nconst (\n\tSERVICE_KERNEL_DRIVER       = 0x00000001\n\tSERVICE_FILE_SYSTEM_DRIVER  = 0x00000002\n\tSERVICE_ADAPTER             = 0x00000004\n\tSERVICE_RECOGNIZER_DRIVER   = 0x00000008\n\tSERVICE_DRIVER              = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER\n\tSERVICE_WIN32_OWN_PROCESS   = 0x00000010\n\tSERVICE_WIN32_SHARE_PROCESS = 0x00000020\n\tSERVICE_WIN32               = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS\n\tSERVICE_INTERACTIVE_PROCESS = 0x00000100\n\tSERVICE_TYPE_ALL            = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS\n)\n\n// Service State -- for CurrentState\nconst (\n\tSERVICE_STOPPED          = 0x00000001\n\tSERVICE_START_PENDING    = 0x00000002\n\tSERVICE_STOP_PENDING     = 0x00000003\n\tSERVICE_RUNNING          = 0x00000004\n\tSERVICE_CONTINUE_PENDING = 0x00000005\n\tSERVICE_PAUSE_PENDING    = 0x00000006\n\tSERVICE_PAUSED           = 0x00000007\n)\n\n// Controls Accepted  (Bit Mask)\nconst (\n\tSERVICE_ACCEPT_STOP                  = 0x00000001\n\tSERVICE_ACCEPT_PAUSE_CONTINUE        = 0x00000002\n\tSERVICE_ACCEPT_SHUTDOWN              = 0x00000004\n\tSERVICE_ACCEPT_PARAMCHANGE           = 0x00000008\n\tSERVICE_ACCEPT_NETBINDCHANGE         = 0x00000010\n\tSERVICE_ACCEPT_HARDWAREPROFILECHANGE = 0x00000020\n\tSERVICE_ACCEPT_POWEREVENT            = 0x00000040\n\tSERVICE_ACCEPT_SESSIONCHANGE         = 0x00000080\n\tSERVICE_ACCEPT_PRESHUTDOWN           = 0x00000100\n\tSERVICE_ACCEPT_TIMECHANGE            = 0x00000200\n\tSERVICE_ACCEPT_TRIGGEREVENT          = 0x00000400\n)\n\n// Service object specific access type\nconst (\n\tSERVICE_QUERY_CONFIG         = 0x0001\n\tSERVICE_CHANGE_CONFIG        = 0x0002\n\tSERVICE_QUERY_STATUS         = 0x0004\n\tSERVICE_ENUMERATE_DEPENDENTS = 0x0008\n\tSERVICE_START                = 0x0010\n\tSERVICE_STOP                 = 0x0020\n\tSERVICE_PAUSE_CONTINUE       = 0x0040\n\tSERVICE_INTERROGATE          = 0x0080\n\tSERVICE_USER_DEFINED_CONTROL = 0x0100\n\n\tSERVICE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED |\n\t\tSERVICE_QUERY_CONFIG |\n\t\tSERVICE_CHANGE_CONFIG |\n\t\tSERVICE_QUERY_STATUS |\n\t\tSERVICE_ENUMERATE_DEPENDENTS |\n\t\tSERVICE_START |\n\t\tSERVICE_STOP |\n\t\tSERVICE_PAUSE_CONTINUE |\n\t\tSERVICE_INTERROGATE |\n\t\tSERVICE_USER_DEFINED_CONTROL\n)\n\n// MapVirtualKey maptypes\nconst (\n\tMAPVK_VK_TO_CHAR   = 2\n\tMAPVK_VK_TO_VSC    = 0\n\tMAPVK_VSC_TO_VK    = 1\n\tMAPVK_VSC_TO_VK_EX = 3\n)\n\n// ReadEventLog Flags\nconst (\n\tEVENTLOG_SEEK_READ       = 0x0002\n\tEVENTLOG_SEQUENTIAL_READ = 0x0001\n\tEVENTLOG_FORWARDS_READ   = 0x0004\n\tEVENTLOG_BACKWARDS_READ  = 0x0008\n)\n\n// CreateToolhelp32Snapshot flags\nconst (\n\tTH32CS_SNAPHEAPLIST = 0x00000001\n\tTH32CS_SNAPPROCESS  = 0x00000002\n\tTH32CS_SNAPTHREAD   = 0x00000004\n\tTH32CS_SNAPMODULE   = 0x00000008\n\tTH32CS_SNAPMODULE32 = 0x00000010\n\tTH32CS_INHERIT      = 0x80000000\n\tTH32CS_SNAPALL      = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD\n)\n\nconst (\n\tMAX_MODULE_NAME32 = 255\n\tMAX_PATH          = 260\n)\n\nconst (\n\tFOREGROUND_BLUE            = 0x0001\n\tFOREGROUND_GREEN           = 0x0002\n\tFOREGROUND_RED             = 0x0004\n\tFOREGROUND_INTENSITY       = 0x0008\n\tBACKGROUND_BLUE            = 0x0010\n\tBACKGROUND_GREEN           = 0x0020\n\tBACKGROUND_RED             = 0x0040\n\tBACKGROUND_INTENSITY       = 0x0080\n\tCOMMON_LVB_LEADING_BYTE    = 0x0100\n\tCOMMON_LVB_TRAILING_BYTE   = 0x0200\n\tCOMMON_LVB_GRID_HORIZONTAL = 0x0400\n\tCOMMON_LVB_GRID_LVERTICAL  = 0x0800\n\tCOMMON_LVB_GRID_RVERTICAL  = 0x1000\n\tCOMMON_LVB_REVERSE_VIDEO   = 0x4000\n\tCOMMON_LVB_UNDERSCORE      = 0x8000\n)\n\n// Flags used by the DWM_BLURBEHIND structure to indicate\n// which of its members contain valid information.\nconst (\n\tDWM_BB_ENABLE                = 0x00000001 //     A value for the fEnable member has been specified.\n\tDWM_BB_BLURREGION            = 0x00000002 //     A value for the hRgnBlur member has been specified.\n\tDWM_BB_TRANSITIONONMAXIMIZED = 0x00000004 //     A value for the fTransitionOnMaximized member has been specified.\n)\n\n// Flags used by the DwmEnableComposition  function\n// to change the state of Desktop Window Manager (DWM) composition.\nconst (\n\tDWM_EC_DISABLECOMPOSITION = 0 //     Disable composition\n\tDWM_EC_ENABLECOMPOSITION  = 1 //     Enable composition\n)\n\n// enum-lite implementation for the following constant structure\ntype DWM_SHOWCONTACT int32\n\nconst (\n\tDWMSC_DOWN      = 0x00000001\n\tDWMSC_UP        = 0x00000002\n\tDWMSC_DRAG      = 0x00000004\n\tDWMSC_HOLD      = 0x00000008\n\tDWMSC_PENBARREL = 0x00000010\n\tDWMSC_NONE      = 0x00000000\n\tDWMSC_ALL       = 0xFFFFFFFF\n)\n\n// enum-lite implementation for the following constant structure\ntype DWM_SOURCE_FRAME_SAMPLING int32\n\n// TODO: need to verify this construction\n// Flags used by the DwmSetPresentParameters function\n// to specify the frame sampling type\nconst (\n\tDWM_SOURCE_FRAME_SAMPLING_POINT = iota + 1\n\tDWM_SOURCE_FRAME_SAMPLING_COVERAGE\n\tDWM_SOURCE_FRAME_SAMPLING_LAST\n)\n\n// Flags used by the DWM_THUMBNAIL_PROPERTIES structure to\n// indicate which of its members contain valid information.\nconst (\n\tDWM_TNP_RECTDESTINATION      = 0x00000001 //    A value for the rcDestination member has been specified\n\tDWM_TNP_RECTSOURCE           = 0x00000002 //    A value for the rcSource member has been specified\n\tDWM_TNP_OPACITY              = 0x00000004 //    A value for the opacity member has been specified\n\tDWM_TNP_VISIBLE              = 0x00000008 //    A value for the fVisible member has been specified\n\tDWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 //    A value for the fSourceClientAreaOnly member has been specified\n)\n\n// enum-lite implementation for the following constant structure\ntype DWMFLIP3DWINDOWPOLICY int32\n\n// TODO: need to verify this construction\n// Flags used by the DwmSetWindowAttribute function\n// to specify the Flip3D window policy\nconst (\n\tDWMFLIP3D_DEFAULT = iota + 1\n\tDWMFLIP3D_EXCLUDEBELOW\n\tDWMFLIP3D_EXCLUDEABOVE\n\tDWMFLIP3D_LAST\n)\n\n// enum-lite implementation for the following constant structure\ntype DWMNCRENDERINGPOLICY int32\n\n// TODO: need to verify this construction\n// Flags used by the DwmSetWindowAttribute function\n// to specify the non-client area rendering policy\nconst (\n\tDWMNCRP_USEWINDOWSTYLE = iota + 1\n\tDWMNCRP_DISABLED\n\tDWMNCRP_ENABLED\n\tDWMNCRP_LAST\n)\n\n// enum-lite implementation for the following constant structure\ntype DWMTRANSITION_OWNEDWINDOW_TARGET int32\n\nconst (\n\tDWMTRANSITION_OWNEDWINDOW_NULL       = -1\n\tDWMTRANSITION_OWNEDWINDOW_REPOSITION = 0\n)\n\n// enum-lite implementation for the following constant structure\ntype DWMWINDOWATTRIBUTE int32\n\n// TODO: need to verify this construction\n// Flags used by the DwmGetWindowAttribute and DwmSetWindowAttribute functions\n// to specify window attributes for non-client rendering\nconst (\n\tDWMWA_NCRENDERING_ENABLED = iota + 1\n\tDWMWA_NCRENDERING_POLICY\n\tDWMWA_TRANSITIONS_FORCEDISABLED\n\tDWMWA_ALLOW_NCPAINT\n\tDWMWA_CAPTION_BUTTON_BOUNDS\n\tDWMWA_NONCLIENT_RTL_LAYOUT\n\tDWMWA_FORCE_ICONIC_REPRESENTATION\n\tDWMWA_FLIP3D_POLICY\n\tDWMWA_EXTENDED_FRAME_BOUNDS\n\tDWMWA_HAS_ICONIC_BITMAP\n\tDWMWA_DISALLOW_PEEK\n\tDWMWA_EXCLUDED_FROM_PEEK\n\tDWMWA_CLOAK\n\tDWMWA_CLOAKED\n\tDWMWA_FREEZE_REPRESENTATION\n\tDWMWA_LAST\n)\n\n// enum-lite implementation for the following constant structure\ntype GESTURE_TYPE int32\n\n// TODO: use iota?\n// Identifies the gesture type\nconst (\n\tGT_PEN_TAP                 = 0\n\tGT_PEN_DOUBLETAP           = 1\n\tGT_PEN_RIGHTTAP            = 2\n\tGT_PEN_PRESSANDHOLD        = 3\n\tGT_PEN_PRESSANDHOLDABORT   = 4\n\tGT_TOUCH_TAP               = 5\n\tGT_TOUCH_DOUBLETAP         = 6\n\tGT_TOUCH_RIGHTTAP          = 7\n\tGT_TOUCH_PRESSANDHOLD      = 8\n\tGT_TOUCH_PRESSANDHOLDABORT = 9\n\tGT_TOUCH_PRESSANDTAP       = 10\n)\n\n// Icons\nconst (\n\tICON_SMALL  = 0\n\tICON_BIG    = 1\n\tICON_SMALL2 = 2\n)\n\nconst (\n\tSIZE_RESTORED  = 0\n\tSIZE_MINIMIZED = 1\n\tSIZE_MAXIMIZED = 2\n\tSIZE_MAXSHOW   = 3\n\tSIZE_MAXHIDE   = 4\n)\n\n// XButton values\nconst (\n\tXBUTTON1 = 1\n\tXBUTTON2 = 2\n)\n\n// Devmode\nconst (\n\tDM_SPECVERSION = 0x0401\n\n\tDM_ORIENTATION        = 0x00000001\n\tDM_PAPERSIZE          = 0x00000002\n\tDM_PAPERLENGTH        = 0x00000004\n\tDM_PAPERWIDTH         = 0x00000008\n\tDM_SCALE              = 0x00000010\n\tDM_POSITION           = 0x00000020\n\tDM_NUP                = 0x00000040\n\tDM_DISPLAYORIENTATION = 0x00000080\n\tDM_COPIES             = 0x00000100\n\tDM_DEFAULTSOURCE      = 0x00000200\n\tDM_PRINTQUALITY       = 0x00000400\n\tDM_COLOR              = 0x00000800\n\tDM_DUPLEX             = 0x00001000\n\tDM_YRESOLUTION        = 0x00002000\n\tDM_TTOPTION           = 0x00004000\n\tDM_COLLATE            = 0x00008000\n\tDM_FORMNAME           = 0x00010000\n\tDM_LOGPIXELS          = 0x00020000\n\tDM_BITSPERPEL         = 0x00040000\n\tDM_PELSWIDTH          = 0x00080000\n\tDM_PELSHEIGHT         = 0x00100000\n\tDM_DISPLAYFLAGS       = 0x00200000\n\tDM_DISPLAYFREQUENCY   = 0x00400000\n\tDM_ICMMETHOD          = 0x00800000\n\tDM_ICMINTENT          = 0x01000000\n\tDM_MEDIATYPE          = 0x02000000\n\tDM_DITHERTYPE         = 0x04000000\n\tDM_PANNINGWIDTH       = 0x08000000\n\tDM_PANNINGHEIGHT      = 0x10000000\n\tDM_DISPLAYFIXEDOUTPUT = 0x20000000\n)\n\n// ChangeDisplaySettings\nconst (\n\tCDS_UPDATEREGISTRY  = 0x00000001\n\tCDS_TEST            = 0x00000002\n\tCDS_FULLSCREEN      = 0x00000004\n\tCDS_GLOBAL          = 0x00000008\n\tCDS_SET_PRIMARY     = 0x00000010\n\tCDS_VIDEOPARAMETERS = 0x00000020\n\tCDS_RESET           = 0x40000000\n\tCDS_NORESET         = 0x10000000\n\n\tDISP_CHANGE_SUCCESSFUL  = 0\n\tDISP_CHANGE_RESTART     = 1\n\tDISP_CHANGE_FAILED      = -1\n\tDISP_CHANGE_BADMODE     = -2\n\tDISP_CHANGE_NOTUPDATED  = -3\n\tDISP_CHANGE_BADFLAGS    = -4\n\tDISP_CHANGE_BADPARAM    = -5\n\tDISP_CHANGE_BADDUALVIEW = -6\n)\n\nconst (\n\tENUM_CURRENT_SETTINGS  = 0xFFFFFFFF\n\tENUM_REGISTRY_SETTINGS = 0xFFFFFFFE\n)\n\n// PIXELFORMATDESCRIPTOR\nconst (\n\tPFD_TYPE_RGBA       = 0\n\tPFD_TYPE_COLORINDEX = 1\n\n\tPFD_MAIN_PLANE     = 0\n\tPFD_OVERLAY_PLANE  = 1\n\tPFD_UNDERLAY_PLANE = -1\n\n\tPFD_DOUBLEBUFFER         = 0x00000001\n\tPFD_STEREO               = 0x00000002\n\tPFD_DRAW_TO_WINDOW       = 0x00000004\n\tPFD_DRAW_TO_BITMAP       = 0x00000008\n\tPFD_SUPPORT_GDI          = 0x00000010\n\tPFD_SUPPORT_OPENGL       = 0x00000020\n\tPFD_GENERIC_FORMAT       = 0x00000040\n\tPFD_NEED_PALETTE         = 0x00000080\n\tPFD_NEED_SYSTEM_PALETTE  = 0x00000100\n\tPFD_SWAP_EXCHANGE        = 0x00000200\n\tPFD_SWAP_COPY            = 0x00000400\n\tPFD_SWAP_LAYER_BUFFERS   = 0x00000800\n\tPFD_GENERIC_ACCELERATED  = 0x00001000\n\tPFD_SUPPORT_DIRECTDRAW   = 0x00002000\n\tPFD_DIRECT3D_ACCELERATED = 0x00004000\n\tPFD_SUPPORT_COMPOSITION  = 0x00008000\n\n\tPFD_DEPTH_DONTCARE        = 0x20000000\n\tPFD_DOUBLEBUFFER_DONTCARE = 0x40000000\n\tPFD_STEREO_DONTCARE       = 0x80000000\n)\n\nconst (\n\tINPUT_MOUSE    = 0\n\tINPUT_KEYBOARD = 1\n\tINPUT_HARDWARE = 2\n)\n\nconst (\n\tMOUSEEVENTF_ABSOLUTE        = 0x8000\n\tMOUSEEVENTF_HWHEEL          = 0x01000\n\tMOUSEEVENTF_MOVE            = 0x0001\n\tMOUSEEVENTF_MOVE_NOCOALESCE = 0x2000\n\tMOUSEEVENTF_LEFTDOWN        = 0x0002\n\tMOUSEEVENTF_LEFTUP          = 0x0004\n\tMOUSEEVENTF_RIGHTDOWN       = 0x0008\n\tMOUSEEVENTF_RIGHTUP         = 0x0010\n\tMOUSEEVENTF_MIDDLEDOWN      = 0x0020\n\tMOUSEEVENTF_MIDDLEUP        = 0x0040\n\tMOUSEEVENTF_VIRTUALDESK     = 0x4000\n\tMOUSEEVENTF_WHEEL           = 0x0800\n\tMOUSEEVENTF_XDOWN           = 0x0080\n\tMOUSEEVENTF_XUP             = 0x0100\n)\n\n// Windows Hooks (WH_*)\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx\nconst (\n\tWH_CALLWNDPROC     = 4\n\tWH_CALLWNDPROCRET  = 12\n\tWH_CBT             = 5\n\tWH_DEBUG           = 9\n\tWH_FOREGROUNDIDLE  = 11\n\tWH_GETMESSAGE      = 3\n\tWH_JOURNALPLAYBACK = 1\n\tWH_JOURNALRECORD   = 0\n\tWH_KEYBOARD        = 2\n\tWH_KEYBOARD_LL     = 13\n\tWH_MOUSE           = 7\n\tWH_MOUSE_LL        = 14\n\tWH_MSGFILTER       = -1\n\tWH_SHELL           = 10\n\tWH_SYSMSGFILTER    = 6\n)\n\n// ComboBox return values\nconst (\n\tCB_OKAY     = 0\n\tCB_ERR      = ^uintptr(0) // -1\n\tCB_ERRSPACE = ^uintptr(1) // -2\n)\n\n// ComboBox notifications\nconst (\n\tCBN_ERRSPACE     = -1\n\tCBN_SELCHANGE    = 1\n\tCBN_DBLCLK       = 2\n\tCBN_SETFOCUS     = 3\n\tCBN_KILLFOCUS    = 4\n\tCBN_EDITCHANGE   = 5\n\tCBN_EDITUPDATE   = 6\n\tCBN_DROPDOWN     = 7\n\tCBN_CLOSEUP      = 8\n\tCBN_SELENDOK     = 9\n\tCBN_SELENDCANCEL = 10\n)\n\n// ComboBox styles\nconst (\n\tCBS_SIMPLE            = 0x0001\n\tCBS_DROPDOWN          = 0x0002\n\tCBS_DROPDOWNLIST      = 0x0003\n\tCBS_OWNERDRAWFIXED    = 0x0010\n\tCBS_OWNERDRAWVARIABLE = 0x0020\n\tCBS_AUTOHSCROLL       = 0x0040\n\tCBS_OEMCONVERT        = 0x0080\n\tCBS_SORT              = 0x0100\n\tCBS_HASSTRINGS        = 0x0200\n\tCBS_NOINTEGRALHEIGHT  = 0x0400\n\tCBS_DISABLENOSCROLL   = 0x0800\n\tCBS_UPPERCASE         = 0x2000\n\tCBS_LOWERCASE         = 0x4000\n)\n\n// ComboBox messages\nconst (\n\tCB_GETEDITSEL            = 0x0140\n\tCB_LIMITTEXT             = 0x0141\n\tCB_SETEDITSEL            = 0x0142\n\tCB_ADDSTRING             = 0x0143\n\tCB_DELETESTRING          = 0x0144\n\tCB_DIR                   = 0x0145\n\tCB_GETCOUNT              = 0x0146\n\tCB_GETCURSEL             = 0x0147\n\tCB_GETLBTEXT             = 0x0148\n\tCB_GETLBTEXTLEN          = 0x0149\n\tCB_INSERTSTRING          = 0x014A\n\tCB_RESETCONTENT          = 0x014B\n\tCB_FINDSTRING            = 0x014C\n\tCB_SELECTSTRING          = 0x014D\n\tCB_SETCURSEL             = 0x014E\n\tCB_SHOWDROPDOWN          = 0x014F\n\tCB_GETITEMDATA           = 0x0150\n\tCB_SETITEMDATA           = 0x0151\n\tCB_GETDROPPEDCONTROLRECT = 0x0152\n\tCB_SETITEMHEIGHT         = 0x0153\n\tCB_GETITEMHEIGHT         = 0x0154\n\tCB_SETEXTENDEDUI         = 0x0155\n\tCB_GETEXTENDEDUI         = 0x0156\n\tCB_GETDROPPEDSTATE       = 0x0157\n\tCB_FINDSTRINGEXACT       = 0x0158\n\tCB_SETLOCALE             = 0x0159\n\tCB_GETLOCALE             = 0x015A\n\tCB_GETTOPINDEX           = 0x015b\n\tCB_SETTOPINDEX           = 0x015c\n\tCB_GETHORIZONTALEXTENT   = 0x015d\n\tCB_SETHORIZONTALEXTENT   = 0x015e\n\tCB_GETDROPPEDWIDTH       = 0x015f\n\tCB_SETDROPPEDWIDTH       = 0x0160\n\tCB_INITSTORAGE           = 0x0161\n\tCB_MULTIPLEADDSTRING     = 0x0163\n\tCB_GETCOMBOBOXINFO       = 0x0164\n)\n\n// TreeView styles\nconst (\n\tTVS_HASBUTTONS      = 0x0001\n\tTVS_HASLINES        = 0x0002\n\tTVS_LINESATROOT     = 0x0004\n\tTVS_EDITLABELS      = 0x0008\n\tTVS_DISABLEDRAGDROP = 0x0010\n\tTVS_SHOWSELALWAYS   = 0x0020\n\tTVS_RTLREADING      = 0x0040\n\tTVS_NOTOOLTIPS      = 0x0080\n\tTVS_CHECKBOXES      = 0x0100\n\tTVS_TRACKSELECT     = 0x0200\n\tTVS_SINGLEEXPAND    = 0x0400\n\tTVS_INFOTIP         = 0x0800\n\tTVS_FULLROWSELECT   = 0x1000\n\tTVS_NOSCROLL        = 0x2000\n\tTVS_NONEVENHEIGHT   = 0x4000\n\tTVS_NOHSCROLL       = 0x8000\n)\n\nconst (\n\tTVS_EX_NOSINGLECOLLAPSE    = 0x0001\n\tTVS_EX_MULTISELECT         = 0x0002\n\tTVS_EX_DOUBLEBUFFER        = 0x0004\n\tTVS_EX_NOINDENTSTATE       = 0x0008\n\tTVS_EX_RICHTOOLTIP         = 0x0010\n\tTVS_EX_AUTOHSCROLL         = 0x0020\n\tTVS_EX_FADEINOUTEXPANDOS   = 0x0040\n\tTVS_EX_PARTIALCHECKBOXES   = 0x0080\n\tTVS_EX_EXCLUSIONCHECKBOXES = 0x0100\n\tTVS_EX_DIMMEDCHECKBOXES    = 0x0200\n\tTVS_EX_DRAWIMAGEASYNC      = 0x0400\n)\n\nconst (\n\tTVIF_TEXT          = 0x0001\n\tTVIF_IMAGE         = 0x0002\n\tTVIF_PARAM         = 0x0004\n\tTVIF_STATE         = 0x0008\n\tTVIF_HANDLE        = 0x0010\n\tTVIF_SELECTEDIMAGE = 0x0020\n\tTVIF_CHILDREN      = 0x0040\n\tTVIF_INTEGRAL      = 0x0080\n\tTVIF_STATEEX       = 0x0100\n\tTVIF_EXPANDEDIMAGE = 0x0200\n)\n\nconst (\n\tTVIS_SELECTED       = 0x0002\n\tTVIS_CUT            = 0x0004\n\tTVIS_DROPHILITED    = 0x0008\n\tTVIS_BOLD           = 0x0010\n\tTVIS_EXPANDED       = 0x0020\n\tTVIS_EXPANDEDONCE   = 0x0040\n\tTVIS_EXPANDPARTIAL  = 0x0080\n\tTVIS_OVERLAYMASK    = 0x0F00\n\tTVIS_STATEIMAGEMASK = 0xF000\n\tTVIS_USERMASK       = 0xF000\n)\n\nconst (\n\tTVIS_EX_FLAT     = 0x0001\n\tTVIS_EX_DISABLED = 0x0002\n\tTVIS_EX_ALL      = 0x0002\n)\n\nconst (\n\tTVI_ROOT  = ^HTREEITEM(0xffff)\n\tTVI_FIRST = ^HTREEITEM(0xfffe)\n\tTVI_LAST  = ^HTREEITEM(0xfffd)\n\tTVI_SORT  = ^HTREEITEM(0xfffc)\n)\n\n// TVM_EXPAND action flags\nconst (\n\tTVE_COLLAPSE      = 0x0001\n\tTVE_EXPAND        = 0x0002\n\tTVE_TOGGLE        = 0x0003\n\tTVE_EXPANDPARTIAL = 0x4000\n\tTVE_COLLAPSERESET = 0x8000\n)\n\nconst (\n\tTVGN_CARET = 9\n)\n\n// TreeView messages\nconst (\n\tTV_FIRST = 0x1100\n\n\tTVM_INSERTITEM          = TV_FIRST + 50\n\tTVM_DELETEITEM          = TV_FIRST + 1\n\tTVM_EXPAND              = TV_FIRST + 2\n\tTVM_GETITEMRECT         = TV_FIRST + 4\n\tTVM_GETCOUNT            = TV_FIRST + 5\n\tTVM_GETINDENT           = TV_FIRST + 6\n\tTVM_SETINDENT           = TV_FIRST + 7\n\tTVM_GETIMAGELIST        = TV_FIRST + 8\n\tTVM_SETIMAGELIST        = TV_FIRST + 9\n\tTVM_GETNEXTITEM         = TV_FIRST + 10\n\tTVM_SELECTITEM          = TV_FIRST + 11\n\tTVM_GETITEM             = TV_FIRST + 62\n\tTVM_SETITEM             = TV_FIRST + 63\n\tTVM_EDITLABEL           = TV_FIRST + 65\n\tTVM_GETEDITCONTROL      = TV_FIRST + 15\n\tTVM_GETVISIBLECOUNT     = TV_FIRST + 16\n\tTVM_HITTEST             = TV_FIRST + 17\n\tTVM_CREATEDRAGIMAGE     = TV_FIRST + 18\n\tTVM_SORTCHILDREN        = TV_FIRST + 19\n\tTVM_ENSUREVISIBLE       = TV_FIRST + 20\n\tTVM_SORTCHILDRENCB      = TV_FIRST + 21\n\tTVM_ENDEDITLABELNOW     = TV_FIRST + 22\n\tTVM_GETISEARCHSTRING    = TV_FIRST + 64\n\tTVM_SETTOOLTIPS         = TV_FIRST + 24\n\tTVM_GETTOOLTIPS         = TV_FIRST + 25\n\tTVM_SETINSERTMARK       = TV_FIRST + 26\n\tTVM_SETUNICODEFORMAT    = CCM_SETUNICODEFORMAT\n\tTVM_GETUNICODEFORMAT    = CCM_GETUNICODEFORMAT\n\tTVM_SETITEMHEIGHT       = TV_FIRST + 27\n\tTVM_GETITEMHEIGHT       = TV_FIRST + 28\n\tTVM_SETBKCOLOR          = TV_FIRST + 29\n\tTVM_SETTEXTCOLOR        = TV_FIRST + 30\n\tTVM_GETBKCOLOR          = TV_FIRST + 31\n\tTVM_GETTEXTCOLOR        = TV_FIRST + 32\n\tTVM_SETSCROLLTIME       = TV_FIRST + 33\n\tTVM_GETSCROLLTIME       = TV_FIRST + 34\n\tTVM_SETINSERTMARKCOLOR  = TV_FIRST + 37\n\tTVM_GETINSERTMARKCOLOR  = TV_FIRST + 38\n\tTVM_GETITEMSTATE        = TV_FIRST + 39\n\tTVM_SETLINECOLOR        = TV_FIRST + 40\n\tTVM_GETLINECOLOR        = TV_FIRST + 41\n\tTVM_MAPACCIDTOHTREEITEM = TV_FIRST + 42\n\tTVM_MAPHTREEITEMTOACCID = TV_FIRST + 43\n\tTVM_SETEXTENDEDSTYLE    = TV_FIRST + 44\n\tTVM_GETEXTENDEDSTYLE    = TV_FIRST + 45\n\tTVM_SETAUTOSCROLLINFO   = TV_FIRST + 59\n)\n\n// TreeView notifications\nconst (\n\tTVN_FIRST = ^uint32(399)\n\n\tTVN_SELCHANGING    = TVN_FIRST - 50\n\tTVN_SELCHANGED     = TVN_FIRST - 51\n\tTVN_GETDISPINFO    = TVN_FIRST - 52\n\tTVN_ITEMEXPANDING  = TVN_FIRST - 54\n\tTVN_ITEMEXPANDED   = TVN_FIRST - 55\n\tTVN_BEGINDRAG      = TVN_FIRST - 56\n\tTVN_BEGINRDRAG     = TVN_FIRST - 57\n\tTVN_DELETEITEM     = TVN_FIRST - 58\n\tTVN_BEGINLABELEDIT = TVN_FIRST - 59\n\tTVN_ENDLABELEDIT   = TVN_FIRST - 60\n\tTVN_KEYDOWN        = TVN_FIRST - 12\n\tTVN_GETINFOTIP     = TVN_FIRST - 14\n\tTVN_SINGLEEXPAND   = TVN_FIRST - 15\n\tTVN_ITEMCHANGING   = TVN_FIRST - 17\n\tTVN_ITEMCHANGED    = TVN_FIRST - 19\n\tTVN_ASYNCDRAW      = TVN_FIRST - 20\n)\n\n// TreeView hit test constants\nconst (\n\tTVHT_NOWHERE         = 1\n\tTVHT_ONITEMICON      = 2\n\tTVHT_ONITEMLABEL     = 4\n\tTVHT_ONITEM          = TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMSTATEICON\n\tTVHT_ONITEMINDENT    = 8\n\tTVHT_ONITEMBUTTON    = 16\n\tTVHT_ONITEMRIGHT     = 32\n\tTVHT_ONITEMSTATEICON = 64\n\tTVHT_ABOVE           = 256\n\tTVHT_BELOW           = 512\n\tTVHT_TORIGHT         = 1024\n\tTVHT_TOLEFT          = 2048\n)\n\ntype HTREEITEM HANDLE\n\ntype TVITEM struct {\n\tMask           uint32\n\tHItem          HTREEITEM\n\tState          uint32\n\tStateMask      uint32\n\tPszText        uintptr\n\tCchTextMax     int32\n\tIImage         int32\n\tISelectedImage int32\n\tCChildren      int32\n\tLParam         uintptr\n}\n\n/*type TVITEMEX struct {\n\tmask           UINT\n\thItem          HTREEITEM\n\tstate          UINT\n\tstateMask      UINT\n\tpszText        LPWSTR\n\tcchTextMax     int\n\tiImage         int\n\tiSelectedImage int\n\tcChildren      int\n\tlParam         LPARAM\n\tiIntegral      int\n\tuStateEx       UINT\n\thwnd           HWND\n\tiExpandedImage int\n}*/\n\ntype TVINSERTSTRUCT struct {\n\tHParent      HTREEITEM\n\tHInsertAfter HTREEITEM\n\tItem         TVITEM\n\t//\titemex       TVITEMEX\n}\n\ntype NMTREEVIEW struct {\n\tHdr     NMHDR\n\tAction  uint32\n\tItemOld TVITEM\n\tItemNew TVITEM\n\tPtDrag  POINT\n}\n\ntype NMTVDISPINFO struct {\n\tHdr  NMHDR\n\tItem TVITEM\n}\n\ntype NMTVKEYDOWN struct {\n\tHdr   NMHDR\n\tWVKey uint16\n\tFlags uint32\n}\n\ntype TVHITTESTINFO struct {\n\tPt    POINT\n\tFlags uint32\n\tHItem HTREEITEM\n}\n\n// TabPage support\n\nconst TCM_FIRST = 0x1300\nconst TCN_FIRST = -550\n\nconst (\n\tTCS_SCROLLOPPOSITE    = 0x0001\n\tTCS_BOTTOM            = 0x0002\n\tTCS_RIGHT             = 0x0002\n\tTCS_MULTISELECT       = 0x0004\n\tTCS_FLATBUTTONS       = 0x0008\n\tTCS_FORCEICONLEFT     = 0x0010\n\tTCS_FORCELABELLEFT    = 0x0020\n\tTCS_HOTTRACK          = 0x0040\n\tTCS_VERTICAL          = 0x0080\n\tTCS_TABS              = 0x0000\n\tTCS_BUTTONS           = 0x0100\n\tTCS_SINGLELINE        = 0x0000\n\tTCS_MULTILINE         = 0x0200\n\tTCS_RIGHTJUSTIFY      = 0x0000\n\tTCS_FIXEDWIDTH        = 0x0400\n\tTCS_RAGGEDRIGHT       = 0x0800\n\tTCS_FOCUSONBUTTONDOWN = 0x1000\n\tTCS_OWNERDRAWFIXED    = 0x2000\n\tTCS_TOOLTIPS          = 0x4000\n\tTCS_FOCUSNEVER        = 0x8000\n)\n\nconst (\n\tTCS_EX_FLATSEPARATORS = 0x00000001\n\tTCS_EX_REGISTERDROP   = 0x00000002\n)\n\nconst (\n\tTCM_GETIMAGELIST     = TCM_FIRST + 2\n\tTCM_SETIMAGELIST     = TCM_FIRST + 3\n\tTCM_GETITEMCOUNT     = TCM_FIRST + 4\n\tTCM_GETITEM          = TCM_FIRST + 60\n\tTCM_SETITEM          = TCM_FIRST + 61\n\tTCM_INSERTITEM       = TCM_FIRST + 62\n\tTCM_DELETEITEM       = TCM_FIRST + 8\n\tTCM_DELETEALLITEMS   = TCM_FIRST + 9\n\tTCM_GETITEMRECT      = TCM_FIRST + 10\n\tTCM_GETCURSEL        = TCM_FIRST + 11\n\tTCM_SETCURSEL        = TCM_FIRST + 12\n\tTCM_HITTEST          = TCM_FIRST + 13\n\tTCM_SETITEMEXTRA     = TCM_FIRST + 14\n\tTCM_ADJUSTRECT       = TCM_FIRST + 40\n\tTCM_SETITEMSIZE      = TCM_FIRST + 41\n\tTCM_REMOVEIMAGE      = TCM_FIRST + 42\n\tTCM_SETPADDING       = TCM_FIRST + 43\n\tTCM_GETROWCOUNT      = TCM_FIRST + 44\n\tTCM_GETTOOLTIPS      = TCM_FIRST + 45\n\tTCM_SETTOOLTIPS      = TCM_FIRST + 46\n\tTCM_GETCURFOCUS      = TCM_FIRST + 47\n\tTCM_SETCURFOCUS      = TCM_FIRST + 48\n\tTCM_SETMINTABWIDTH   = TCM_FIRST + 49\n\tTCM_DESELECTALL      = TCM_FIRST + 50\n\tTCM_HIGHLIGHTITEM    = TCM_FIRST + 51\n\tTCM_SETEXTENDEDSTYLE = TCM_FIRST + 52\n\tTCM_GETEXTENDEDSTYLE = TCM_FIRST + 53\n\tTCM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT\n\tTCM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT\n)\n\nconst (\n\tTCIF_TEXT       = 0x0001\n\tTCIF_IMAGE      = 0x0002\n\tTCIF_RTLREADING = 0x0004\n\tTCIF_PARAM      = 0x0008\n\tTCIF_STATE      = 0x0010\n)\n\nconst (\n\tTCIS_BUTTONPRESSED = 0x0001\n\tTCIS_HIGHLIGHTED   = 0x0002\n)\n\nconst (\n\tTCHT_NOWHERE     = 0x0001\n\tTCHT_ONITEMICON  = 0x0002\n\tTCHT_ONITEMLABEL = 0x0004\n\tTCHT_ONITEM      = TCHT_ONITEMICON | TCHT_ONITEMLABEL\n)\n\nconst (\n\tTCN_KEYDOWN     = TCN_FIRST - 0\n\tTCN_SELCHANGE   = TCN_FIRST - 1\n\tTCN_SELCHANGING = TCN_FIRST - 2\n\tTCN_GETOBJECT   = TCN_FIRST - 3\n\tTCN_FOCUSCHANGE = TCN_FIRST - 4\n)\n\ntype TCITEMHEADER struct {\n\tMask        uint32\n\tLpReserved1 uint32\n\tLpReserved2 uint32\n\tPszText     *uint16\n\tCchTextMax  int32\n\tIImage      int32\n}\n\ntype TCITEM struct {\n\tMask        uint32\n\tDwState     uint32\n\tDwStateMask uint32\n\tPszText     *uint16\n\tCchTextMax  int32\n\tIImage      int32\n\tLParam      uintptr\n}\n\ntype TCHITTESTINFO struct {\n\tPt    POINT\n\tflags uint32\n}\n\ntype NMTCKEYDOWN struct {\n\tHdr   NMHDR\n\tWVKey uint16\n\tFlags uint32\n}\n\n// Menu support constants\n\n// Constants for MENUITEMINFO.fMask\nconst (\n\tMIIM_STATE      = 1\n\tMIIM_ID         = 2\n\tMIIM_SUBMENU    = 4\n\tMIIM_CHECKMARKS = 8\n\tMIIM_TYPE       = 16\n\tMIIM_DATA       = 32\n\tMIIM_STRING     = 64\n\tMIIM_BITMAP     = 128\n\tMIIM_FTYPE      = 256\n)\n\n// Constants for MENUITEMINFO.fType\nconst (\n\tMFT_BITMAP       = 4\n\tMFT_MENUBARBREAK = 32\n\tMFT_MENUBREAK    = 64\n\tMFT_OWNERDRAW    = 256\n\tMFT_RADIOCHECK   = 512\n\tMFT_RIGHTJUSTIFY = 0x4000\n\tMFT_SEPARATOR    = 0x800\n\tMFT_RIGHTORDER   = 0x2000\n\tMFT_STRING       = 0\n)\n\n// Constants for MENUITEMINFO.fState\nconst (\n\tMFS_CHECKED   = 8\n\tMFS_DEFAULT   = 4096\n\tMFS_DISABLED  = 3\n\tMFS_ENABLED   = 0\n\tMFS_GRAYED    = 3\n\tMFS_HILITE    = 128\n\tMFS_UNCHECKED = 0\n\tMFS_UNHILITE  = 0\n)\n\n// Constants for MENUITEMINFO.hbmp*\nconst (\n\tHBMMENU_CALLBACK        = -1\n\tHBMMENU_SYSTEM          = 1\n\tHBMMENU_MBAR_RESTORE    = 2\n\tHBMMENU_MBAR_MINIMIZE   = 3\n\tHBMMENU_MBAR_CLOSE      = 5\n\tHBMMENU_MBAR_CLOSE_D    = 6\n\tHBMMENU_MBAR_MINIMIZE_D = 7\n\tHBMMENU_POPUP_CLOSE     = 8\n\tHBMMENU_POPUP_RESTORE   = 9\n\tHBMMENU_POPUP_MAXIMIZE  = 10\n\tHBMMENU_POPUP_MINIMIZE  = 11\n)\n\n// MENUINFO mask constants\nconst (\n\tMIM_APPLYTOSUBMENUS = 0x80000000\n\tMIM_BACKGROUND      = 0x00000002\n\tMIM_HELPID          = 0x00000004\n\tMIM_MAXHEIGHT       = 0x00000001\n\tMIM_MENUDATA        = 0x00000008\n\tMIM_STYLE           = 0x00000010\n)\n\n// MENUINFO style constants\nconst (\n\tMNS_AUTODISMISS = 0x10000000\n\tMNS_CHECKORBMP  = 0x04000000\n\tMNS_DRAGDROP    = 0x20000000\n\tMNS_MODELESS    = 0x40000000\n\tMNS_NOCHECK     = 0x80000000\n\tMNS_NOTIFYBYPOS = 0x08000000\n)\n\nconst (\n\tMF_BYCOMMAND  = 0x00000000\n\tMF_BYPOSITION = 0x00000400\n)\n\ntype MENUITEMINFO struct {\n\tCbSize        uint32\n\tFMask         uint32\n\tFType         uint32\n\tFState        uint32\n\tWID           uint32\n\tHSubMenu      HMENU\n\tHbmpChecked   HBITMAP\n\tHbmpUnchecked HBITMAP\n\tDwItemData    uintptr\n\tDwTypeData    *uint16\n\tCch           uint32\n\tHbmpItem      HBITMAP\n}\n\ntype MENUINFO struct {\n\tCbSize          uint32\n\tFMask           uint32\n\tDwStyle         uint32\n\tCyMax           uint32\n\tHbrBack         HBRUSH\n\tDwContextHelpID uint32\n\tDwMenuData      uintptr\n}\n\n// UI state constants\nconst (\n\tUIS_SET        = 1\n\tUIS_CLEAR      = 2\n\tUIS_INITIALIZE = 3\n)\n\n// UI state constants\nconst (\n\tUISF_HIDEFOCUS = 0x1\n\tUISF_HIDEACCEL = 0x2\n\tUISF_ACTIVE    = 0x4\n)\n\n// Virtual key codes\nconst (\n\tVK_LBUTTON             = 1\n\tVK_RBUTTON             = 2\n\tVK_CANCEL              = 3\n\tVK_MBUTTON             = 4\n\tVK_XBUTTON1            = 5\n\tVK_XBUTTON2            = 6\n\tVK_BACK                = 8\n\tVK_TAB                 = 9\n\tVK_CLEAR               = 12\n\tVK_RETURN              = 13\n\tVK_SHIFT               = 16\n\tVK_CONTROL             = 17\n\tVK_MENU                = 18\n\tVK_PAUSE               = 19\n\tVK_CAPITAL             = 20\n\tVK_KANA                = 0x15\n\tVK_HANGEUL             = 0x15\n\tVK_HANGUL              = 0x15\n\tVK_JUNJA               = 0x17\n\tVK_FINAL               = 0x18\n\tVK_HANJA               = 0x19\n\tVK_KANJI               = 0x19\n\tVK_ESCAPE              = 0x1B\n\tVK_CONVERT             = 0x1C\n\tVK_NONCONVERT          = 0x1D\n\tVK_ACCEPT              = 0x1E\n\tVK_MODECHANGE          = 0x1F\n\tVK_SPACE               = 32\n\tVK_PRIOR               = 33\n\tVK_NEXT                = 34\n\tVK_END                 = 35\n\tVK_HOME                = 36\n\tVK_LEFT                = 37\n\tVK_UP                  = 38\n\tVK_RIGHT               = 39\n\tVK_DOWN                = 40\n\tVK_SELECT              = 41\n\tVK_PRINT               = 42\n\tVK_EXECUTE             = 43\n\tVK_SNAPSHOT            = 44\n\tVK_INSERT              = 45\n\tVK_DELETE              = 46\n\tVK_HELP                = 47\n\tVK_LWIN                = 0x5B\n\tVK_RWIN                = 0x5C\n\tVK_APPS                = 0x5D\n\tVK_SLEEP               = 0x5F\n\tVK_NUMPAD0             = 0x60\n\tVK_NUMPAD1             = 0x61\n\tVK_NUMPAD2             = 0x62\n\tVK_NUMPAD3             = 0x63\n\tVK_NUMPAD4             = 0x64\n\tVK_NUMPAD5             = 0x65\n\tVK_NUMPAD6             = 0x66\n\tVK_NUMPAD7             = 0x67\n\tVK_NUMPAD8             = 0x68\n\tVK_NUMPAD9             = 0x69\n\tVK_MULTIPLY            = 0x6A\n\tVK_ADD                 = 0x6B\n\tVK_SEPARATOR           = 0x6C\n\tVK_SUBTRACT            = 0x6D\n\tVK_DECIMAL             = 0x6E\n\tVK_DIVIDE              = 0x6F\n\tVK_F1                  = 0x70\n\tVK_F2                  = 0x71\n\tVK_F3                  = 0x72\n\tVK_F4                  = 0x73\n\tVK_F5                  = 0x74\n\tVK_F6                  = 0x75\n\tVK_F7                  = 0x76\n\tVK_F8                  = 0x77\n\tVK_F9                  = 0x78\n\tVK_F10                 = 0x79\n\tVK_F11                 = 0x7A\n\tVK_F12                 = 0x7B\n\tVK_F13                 = 0x7C\n\tVK_F14                 = 0x7D\n\tVK_F15                 = 0x7E\n\tVK_F16                 = 0x7F\n\tVK_F17                 = 0x80\n\tVK_F18                 = 0x81\n\tVK_F19                 = 0x82\n\tVK_F20                 = 0x83\n\tVK_F21                 = 0x84\n\tVK_F22                 = 0x85\n\tVK_F23                 = 0x86\n\tVK_F24                 = 0x87\n\tVK_NUMLOCK             = 0x90\n\tVK_SCROLL              = 0x91\n\tVK_LSHIFT              = 0xA0\n\tVK_RSHIFT              = 0xA1\n\tVK_LCONTROL            = 0xA2\n\tVK_RCONTROL            = 0xA3\n\tVK_LMENU               = 0xA4\n\tVK_RMENU               = 0xA5\n\tVK_BROWSER_BACK        = 0xA6\n\tVK_BROWSER_FORWARD     = 0xA7\n\tVK_BROWSER_REFRESH     = 0xA8\n\tVK_BROWSER_STOP        = 0xA9\n\tVK_BROWSER_SEARCH      = 0xAA\n\tVK_BROWSER_FAVORITES   = 0xAB\n\tVK_BROWSER_HOME        = 0xAC\n\tVK_VOLUME_MUTE         = 0xAD\n\tVK_VOLUME_DOWN         = 0xAE\n\tVK_VOLUME_UP           = 0xAF\n\tVK_MEDIA_NEXT_TRACK    = 0xB0\n\tVK_MEDIA_PREV_TRACK    = 0xB1\n\tVK_MEDIA_STOP          = 0xB2\n\tVK_MEDIA_PLAY_PAUSE    = 0xB3\n\tVK_LAUNCH_MAIL         = 0xB4\n\tVK_LAUNCH_MEDIA_SELECT = 0xB5\n\tVK_LAUNCH_APP1         = 0xB6\n\tVK_LAUNCH_APP2         = 0xB7\n\tVK_OEM_1               = 0xBA\n\tVK_OEM_PLUS            = 0xBB\n\tVK_OEM_COMMA           = 0xBC\n\tVK_OEM_MINUS           = 0xBD\n\tVK_OEM_PERIOD          = 0xBE\n\tVK_OEM_2               = 0xBF\n\tVK_OEM_3               = 0xC0\n\tVK_OEM_4               = 0xDB\n\tVK_OEM_5               = 0xDC\n\tVK_OEM_6               = 0xDD\n\tVK_OEM_7               = 0xDE\n\tVK_OEM_8               = 0xDF\n\tVK_OEM_102             = 0xE2\n\tVK_PROCESSKEY          = 0xE5\n\tVK_PACKET              = 0xE7\n\tVK_ATTN                = 0xF6\n\tVK_CRSEL               = 0xF7\n\tVK_EXSEL               = 0xF8\n\tVK_EREOF               = 0xF9\n\tVK_PLAY                = 0xFA\n\tVK_ZOOM                = 0xFB\n\tVK_NONAME              = 0xFC\n\tVK_PA1                 = 0xFD\n\tVK_OEM_CLEAR           = 0xFE\n)\n\n// ScrollBar constants\nconst (\n\tSB_HORZ = 0\n\tSB_VERT = 1\n\tSB_CTL  = 2\n\tSB_BOTH = 3\n)\n\n// ScrollBar commands\nconst (\n\tSB_LINEUP        = 0\n\tSB_LINELEFT      = 0\n\tSB_LINEDOWN      = 1\n\tSB_LINERIGHT     = 1\n\tSB_PAGEUP        = 2\n\tSB_PAGELEFT      = 2\n\tSB_PAGEDOWN      = 3\n\tSB_PAGERIGHT     = 3\n\tSB_THUMBPOSITION = 4\n\tSB_THUMBTRACK    = 5\n\tSB_TOP           = 6\n\tSB_LEFT          = 6\n\tSB_BOTTOM        = 7\n\tSB_RIGHT         = 7\n\tSB_ENDSCROLL     = 8\n)\n\n// [Get|Set]ScrollInfo mask constants\nconst (\n\tSIF_RANGE           = 1\n\tSIF_PAGE            = 2\n\tSIF_POS             = 4\n\tSIF_DISABLENOSCROLL = 8\n\tSIF_TRACKPOS        = 16\n\tSIF_ALL             = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS\n)\n"
  },
  {
    "path": "w32/gdi32.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmodgdi32 = syscall.NewLazyDLL(\"gdi32.dll\")\n\n\tprocGetDeviceCaps             = modgdi32.NewProc(\"GetDeviceCaps\")\n\tprocDeleteObject              = modgdi32.NewProc(\"DeleteObject\")\n\tprocCreateFontIndirect        = modgdi32.NewProc(\"CreateFontIndirectW\")\n\tprocAbortDoc                  = modgdi32.NewProc(\"AbortDoc\")\n\tprocBitBlt                    = modgdi32.NewProc(\"BitBlt\")\n\tprocPatBlt                    = modgdi32.NewProc(\"PatBlt\")\n\tprocCloseEnhMetaFile          = modgdi32.NewProc(\"CloseEnhMetaFile\")\n\tprocCopyEnhMetaFile           = modgdi32.NewProc(\"CopyEnhMetaFileW\")\n\tprocCreateBrushIndirect       = modgdi32.NewProc(\"CreateBrushIndirect\")\n\tprocCreateCompatibleDC        = modgdi32.NewProc(\"CreateCompatibleDC\")\n\tprocCreateDC                  = modgdi32.NewProc(\"CreateDCW\")\n\tprocCreateDIBSection          = modgdi32.NewProc(\"CreateDIBSection\")\n\tprocCreateEnhMetaFile         = modgdi32.NewProc(\"CreateEnhMetaFileW\")\n\tprocCreateIC                  = modgdi32.NewProc(\"CreateICW\")\n\tprocDeleteDC                  = modgdi32.NewProc(\"DeleteDC\")\n\tprocDeleteEnhMetaFile         = modgdi32.NewProc(\"DeleteEnhMetaFile\")\n\tprocEllipse                   = modgdi32.NewProc(\"Ellipse\")\n\tprocEndDoc                    = modgdi32.NewProc(\"EndDoc\")\n\tprocEndPage                   = modgdi32.NewProc(\"EndPage\")\n\tprocExtCreatePen              = modgdi32.NewProc(\"ExtCreatePen\")\n\tprocGetEnhMetaFile            = modgdi32.NewProc(\"GetEnhMetaFileW\")\n\tprocGetEnhMetaFileHeader      = modgdi32.NewProc(\"GetEnhMetaFileHeader\")\n\tprocGetObject                 = modgdi32.NewProc(\"GetObjectW\")\n\tprocGetStockObject            = modgdi32.NewProc(\"GetStockObject\")\n\tprocGetTextExtentExPoint      = modgdi32.NewProc(\"GetTextExtentExPointW\")\n\tprocGetTextExtentPoint32      = modgdi32.NewProc(\"GetTextExtentPoint32W\")\n\tprocGetTextMetrics            = modgdi32.NewProc(\"GetTextMetricsW\")\n\tprocLineTo                    = modgdi32.NewProc(\"LineTo\")\n\tprocMoveToEx                  = modgdi32.NewProc(\"MoveToEx\")\n\tprocPlayEnhMetaFile           = modgdi32.NewProc(\"PlayEnhMetaFile\")\n\tprocRectangle                 = modgdi32.NewProc(\"Rectangle\")\n\tprocResetDC                   = modgdi32.NewProc(\"ResetDCW\")\n\tprocSelectObject              = modgdi32.NewProc(\"SelectObject\")\n\tprocSetBkMode                 = modgdi32.NewProc(\"SetBkMode\")\n\tprocSetBrushOrgEx             = modgdi32.NewProc(\"SetBrushOrgEx\")\n\tprocSetStretchBltMode         = modgdi32.NewProc(\"SetStretchBltMode\")\n\tprocSetTextColor              = modgdi32.NewProc(\"SetTextColor\")\n\tprocSetBkColor                = modgdi32.NewProc(\"SetBkColor\")\n\tprocStartDoc                  = modgdi32.NewProc(\"StartDocW\")\n\tprocStartPage                 = modgdi32.NewProc(\"StartPage\")\n\tprocStretchBlt                = modgdi32.NewProc(\"StretchBlt\")\n\tprocSetDIBitsToDevice         = modgdi32.NewProc(\"SetDIBitsToDevice\")\n\tprocChoosePixelFormat         = modgdi32.NewProc(\"ChoosePixelFormat\")\n\tprocDescribePixelFormat       = modgdi32.NewProc(\"DescribePixelFormat\")\n\tprocGetEnhMetaFilePixelFormat = modgdi32.NewProc(\"GetEnhMetaFilePixelFormat\")\n\tprocGetPixelFormat            = modgdi32.NewProc(\"GetPixelFormat\")\n\tprocSetPixelFormat            = modgdi32.NewProc(\"SetPixelFormat\")\n\tprocSwapBuffers               = modgdi32.NewProc(\"SwapBuffers\")\n)\n\nfunc GetDeviceCaps(hdc HDC, index int) int {\n\tret, _, _ := procGetDeviceCaps.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(index))\n\n\treturn int(ret)\n}\n\nfunc DeleteObject(hObject HGDIOBJ) bool {\n\tret, _, _ := procDeleteObject.Call(\n\t\tuintptr(hObject))\n\n\treturn ret != 0\n}\n\nfunc CreateFontIndirect(logFont *LOGFONT) HFONT {\n\tret, _, _ := procCreateFontIndirect.Call(\n\t\tuintptr(unsafe.Pointer(logFont)))\n\n\treturn HFONT(ret)\n}\n\nfunc AbortDoc(hdc HDC) int {\n\tret, _, _ := procAbortDoc.Call(\n\t\tuintptr(hdc))\n\n\treturn int(ret)\n}\n\nfunc BitBlt(hdcDest HDC, nXDest, nYDest, nWidth, nHeight int, hdcSrc HDC, nXSrc, nYSrc int, dwRop uint) {\n\tret, _, _ := procBitBlt.Call(\n\t\tuintptr(hdcDest),\n\t\tuintptr(nXDest),\n\t\tuintptr(nYDest),\n\t\tuintptr(nWidth),\n\t\tuintptr(nHeight),\n\t\tuintptr(hdcSrc),\n\t\tuintptr(nXSrc),\n\t\tuintptr(nYSrc),\n\t\tuintptr(dwRop))\n\n\tif ret == 0 {\n\t\tpanic(\"BitBlt failed\")\n\t}\n}\n\nfunc PatBlt(hdc HDC, nXLeft, nYLeft, nWidth, nHeight int, dwRop uint) {\n\tret, _, _ := procPatBlt.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(nXLeft),\n\t\tuintptr(nYLeft),\n\t\tuintptr(nWidth),\n\t\tuintptr(nHeight),\n\t\tuintptr(dwRop))\n\n\tif ret == 0 {\n\t\tpanic(\"PatBlt failed\")\n\t}\n}\n\nfunc CloseEnhMetaFile(hdc HDC) HENHMETAFILE {\n\tret, _, _ := procCloseEnhMetaFile.Call(\n\t\tuintptr(hdc))\n\n\treturn HENHMETAFILE(ret)\n}\n\nfunc CopyEnhMetaFile(hemfSrc HENHMETAFILE, lpszFile *uint16) HENHMETAFILE {\n\tret, _, _ := procCopyEnhMetaFile.Call(\n\t\tuintptr(hemfSrc),\n\t\tuintptr(unsafe.Pointer(lpszFile)))\n\n\treturn HENHMETAFILE(ret)\n}\n\nfunc CreateBrushIndirect(lplb *LOGBRUSH) HBRUSH {\n\tret, _, _ := procCreateBrushIndirect.Call(\n\t\tuintptr(unsafe.Pointer(lplb)))\n\n\treturn HBRUSH(ret)\n}\n\nfunc CreateCompatibleDC(hdc HDC) HDC {\n\tret, _, _ := procCreateCompatibleDC.Call(\n\t\tuintptr(hdc))\n\n\tif ret == 0 {\n\t\tpanic(\"Create compatible DC failed\")\n\t}\n\n\treturn HDC(ret)\n}\n\nfunc CreateDC(lpszDriver, lpszDevice, lpszOutput *uint16, lpInitData *DEVMODE) HDC {\n\tret, _, _ := procCreateDC.Call(\n\t\tuintptr(unsafe.Pointer(lpszDriver)),\n\t\tuintptr(unsafe.Pointer(lpszDevice)),\n\t\tuintptr(unsafe.Pointer(lpszOutput)),\n\t\tuintptr(unsafe.Pointer(lpInitData)))\n\n\treturn HDC(ret)\n}\n\nfunc CreateDIBSection(hdc HDC, pbmi *BITMAPINFO, iUsage uint, ppvBits *unsafe.Pointer, hSection HANDLE, dwOffset uint) HBITMAP {\n\tret, _, _ := procCreateDIBSection.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(pbmi)),\n\t\tuintptr(iUsage),\n\t\tuintptr(unsafe.Pointer(ppvBits)),\n\t\tuintptr(hSection),\n\t\tuintptr(dwOffset))\n\n\treturn HBITMAP(ret)\n}\n\nfunc CreateEnhMetaFile(hdcRef HDC, lpFilename *uint16, lpRect *RECT, lpDescription *uint16) HDC {\n\tret, _, _ := procCreateEnhMetaFile.Call(\n\t\tuintptr(hdcRef),\n\t\tuintptr(unsafe.Pointer(lpFilename)),\n\t\tuintptr(unsafe.Pointer(lpRect)),\n\t\tuintptr(unsafe.Pointer(lpDescription)))\n\n\treturn HDC(ret)\n}\n\nfunc CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HDC {\n\tret, _, _ := procCreateIC.Call(\n\t\tuintptr(unsafe.Pointer(lpszDriver)),\n\t\tuintptr(unsafe.Pointer(lpszDevice)),\n\t\tuintptr(unsafe.Pointer(lpszOutput)),\n\t\tuintptr(unsafe.Pointer(lpdvmInit)))\n\n\treturn HDC(ret)\n}\n\nfunc DeleteDC(hdc HDC) bool {\n\tret, _, _ := procDeleteDC.Call(\n\t\tuintptr(hdc))\n\n\treturn ret != 0\n}\n\nfunc DeleteEnhMetaFile(hemf HENHMETAFILE) bool {\n\tret, _, _ := procDeleteEnhMetaFile.Call(\n\t\tuintptr(hemf))\n\n\treturn ret != 0\n}\n\nfunc Ellipse(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool {\n\tret, _, _ := procEllipse.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(nLeftRect),\n\t\tuintptr(nTopRect),\n\t\tuintptr(nRightRect),\n\t\tuintptr(nBottomRect))\n\n\treturn ret != 0\n}\n\nfunc EndDoc(hdc HDC) int {\n\tret, _, _ := procEndDoc.Call(\n\t\tuintptr(hdc))\n\n\treturn int(ret)\n}\n\nfunc EndPage(hdc HDC) int {\n\tret, _, _ := procEndPage.Call(\n\t\tuintptr(hdc))\n\n\treturn int(ret)\n}\n\nfunc ExtCreatePen(dwPenStyle, dwWidth uint, lplb *LOGBRUSH, dwStyleCount uint, lpStyle *uint) HPEN {\n\tret, _, _ := procExtCreatePen.Call(\n\t\tuintptr(dwPenStyle),\n\t\tuintptr(dwWidth),\n\t\tuintptr(unsafe.Pointer(lplb)),\n\t\tuintptr(dwStyleCount),\n\t\tuintptr(unsafe.Pointer(lpStyle)))\n\n\treturn HPEN(ret)\n}\n\nfunc GetEnhMetaFile(lpszMetaFile *uint16) HENHMETAFILE {\n\tret, _, _ := procGetEnhMetaFile.Call(\n\t\tuintptr(unsafe.Pointer(lpszMetaFile)))\n\n\treturn HENHMETAFILE(ret)\n}\n\nfunc GetEnhMetaFileHeader(hemf HENHMETAFILE, cbBuffer uint, lpemh *ENHMETAHEADER) uint {\n\tret, _, _ := procGetEnhMetaFileHeader.Call(\n\t\tuintptr(hemf),\n\t\tuintptr(cbBuffer),\n\t\tuintptr(unsafe.Pointer(lpemh)))\n\n\treturn uint(ret)\n}\n\nfunc GetObject(hgdiobj HGDIOBJ, cbBuffer uintptr, lpvObject unsafe.Pointer) int {\n\tret, _, _ := procGetObject.Call(\n\t\tuintptr(hgdiobj),\n\t\tuintptr(cbBuffer),\n\t\tuintptr(lpvObject))\n\n\treturn int(ret)\n}\n\nfunc GetStockObject(fnObject int) HGDIOBJ {\n\tret, _, _ := procGetDeviceCaps.Call(\n\t\tuintptr(fnObject))\n\n\treturn HGDIOBJ(ret)\n}\n\nfunc GetTextExtentExPoint(hdc HDC, lpszStr *uint16, cchString, nMaxExtent int, lpnFit, alpDx *int, lpSize *SIZE) bool {\n\tret, _, _ := procGetTextExtentExPoint.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(lpszStr)),\n\t\tuintptr(cchString),\n\t\tuintptr(nMaxExtent),\n\t\tuintptr(unsafe.Pointer(lpnFit)),\n\t\tuintptr(unsafe.Pointer(alpDx)),\n\t\tuintptr(unsafe.Pointer(lpSize)))\n\n\treturn ret != 0\n}\n\nfunc GetTextExtentPoint32(hdc HDC, lpString *uint16, c int, lpSize *SIZE) bool {\n\tret, _, _ := procGetTextExtentPoint32.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(lpString)),\n\t\tuintptr(c),\n\t\tuintptr(unsafe.Pointer(lpSize)))\n\n\treturn ret != 0\n}\n\nfunc GetTextMetrics(hdc HDC, lptm *TEXTMETRIC) bool {\n\tret, _, _ := procGetTextMetrics.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(lptm)))\n\n\treturn ret != 0\n}\n\nfunc LineTo(hdc HDC, nXEnd, nYEnd int32) bool {\n\tret, _, _ := procLineTo.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(nXEnd),\n\t\tuintptr(nYEnd))\n\n\treturn ret != 0\n}\n\nfunc MoveToEx(hdc HDC, x, y int, lpPoint *POINT) bool {\n\tret, _, _ := procMoveToEx.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t\tuintptr(unsafe.Pointer(lpPoint)))\n\n\treturn ret != 0\n}\n\nfunc PlayEnhMetaFile(hdc HDC, hemf HENHMETAFILE, lpRect *RECT) bool {\n\tret, _, _ := procPlayEnhMetaFile.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(hemf),\n\t\tuintptr(unsafe.Pointer(lpRect)))\n\n\treturn ret != 0\n}\n\nfunc Rectangle(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int32) bool {\n\tret, _, _ := procRectangle.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(nLeftRect),\n\t\tuintptr(nTopRect),\n\t\tuintptr(nRightRect),\n\t\tuintptr(nBottomRect))\n\n\treturn ret != 0\n}\n\nfunc ResetDC(hdc HDC, lpInitData *DEVMODE) HDC {\n\tret, _, _ := procResetDC.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(lpInitData)))\n\n\treturn HDC(ret)\n}\n\nfunc SelectObject(hdc HDC, hgdiobj HGDIOBJ) HGDIOBJ {\n\tret, _, _ := procSelectObject.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(hgdiobj))\n\n\tif ret == 0 {\n\t\tpanic(\"SelectObject failed\")\n\t}\n\n\treturn HGDIOBJ(ret)\n}\n\nfunc SetBkMode(hdc HDC, iBkMode int) int {\n\tret, _, _ := procSetBkMode.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(iBkMode))\n\n\tif ret == 0 {\n\t\tpanic(\"SetBkMode failed\")\n\t}\n\n\treturn int(ret)\n}\n\nfunc SetBrushOrgEx(hdc HDC, nXOrg, nYOrg int, lppt *POINT) bool {\n\tret, _, _ := procSetBrushOrgEx.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(nXOrg),\n\t\tuintptr(nYOrg),\n\t\tuintptr(unsafe.Pointer(lppt)))\n\n\treturn ret != 0\n}\n\nfunc SetStretchBltMode(hdc HDC, iStretchMode int) int {\n\tret, _, _ := procSetStretchBltMode.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(iStretchMode))\n\n\treturn int(ret)\n}\n\nfunc SetTextColor(hdc HDC, crColor COLORREF) COLORREF {\n\tret, _, _ := procSetTextColor.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(crColor))\n\n\tif ret == CLR_INVALID {\n\t\tpanic(\"SetTextColor failed\")\n\t}\n\n\treturn COLORREF(ret)\n}\n\nfunc SetBkColor(hdc HDC, crColor COLORREF) COLORREF {\n\tret, _, _ := procSetBkColor.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(crColor))\n\n\tif ret == CLR_INVALID {\n\t\tpanic(\"SetBkColor failed\")\n\t}\n\n\treturn COLORREF(ret)\n}\n\nfunc StartDoc(hdc HDC, lpdi *DOCINFO) int {\n\tret, _, _ := procStartDoc.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(lpdi)))\n\n\treturn int(ret)\n}\n\nfunc StartPage(hdc HDC) int {\n\tret, _, _ := procStartPage.Call(\n\t\tuintptr(hdc))\n\n\treturn int(ret)\n}\n\nfunc StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int, dwRop uint) {\n\tret, _, _ := procStretchBlt.Call(\n\t\tuintptr(hdcDest),\n\t\tuintptr(nXOriginDest),\n\t\tuintptr(nYOriginDest),\n\t\tuintptr(nWidthDest),\n\t\tuintptr(nHeightDest),\n\t\tuintptr(hdcSrc),\n\t\tuintptr(nXOriginSrc),\n\t\tuintptr(nYOriginSrc),\n\t\tuintptr(nWidthSrc),\n\t\tuintptr(nHeightSrc),\n\t\tuintptr(dwRop))\n\n\tif ret == 0 {\n\t\tpanic(\"StretchBlt failed\")\n\t}\n}\n\nfunc SetDIBitsToDevice(hdc HDC, xDest, yDest, dwWidth, dwHeight, xSrc, ySrc int, uStartScan, cScanLines uint, lpvBits []byte, lpbmi *BITMAPINFO, fuColorUse uint) int {\n\tret, _, _ := procSetDIBitsToDevice.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(xDest),\n\t\tuintptr(yDest),\n\t\tuintptr(dwWidth),\n\t\tuintptr(dwHeight),\n\t\tuintptr(xSrc),\n\t\tuintptr(ySrc),\n\t\tuintptr(uStartScan),\n\t\tuintptr(cScanLines),\n\t\tuintptr(unsafe.Pointer(&lpvBits[0])),\n\t\tuintptr(unsafe.Pointer(lpbmi)),\n\t\tuintptr(fuColorUse))\n\n\treturn int(ret)\n}\n\nfunc ChoosePixelFormat(hdc HDC, pfd *PIXELFORMATDESCRIPTOR) int {\n\tret, _, _ := procChoosePixelFormat.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(pfd)),\n\t)\n\treturn int(ret)\n}\n\nfunc DescribePixelFormat(hdc HDC, iPixelFormat int, nBytes uint, pfd *PIXELFORMATDESCRIPTOR) int {\n\tret, _, _ := procDescribePixelFormat.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(iPixelFormat),\n\t\tuintptr(nBytes),\n\t\tuintptr(unsafe.Pointer(pfd)),\n\t)\n\treturn int(ret)\n}\n\nfunc GetEnhMetaFilePixelFormat(hemf HENHMETAFILE, cbBuffer uint32, pfd *PIXELFORMATDESCRIPTOR) uint {\n\tret, _, _ := procGetEnhMetaFilePixelFormat.Call(\n\t\tuintptr(hemf),\n\t\tuintptr(cbBuffer),\n\t\tuintptr(unsafe.Pointer(pfd)),\n\t)\n\treturn uint(ret)\n}\n\nfunc GetPixelFormat(hdc HDC) int {\n\tret, _, _ := procGetPixelFormat.Call(\n\t\tuintptr(hdc),\n\t)\n\treturn int(ret)\n}\n\nfunc SetPixelFormat(hdc HDC, iPixelFormat int, pfd *PIXELFORMATDESCRIPTOR) bool {\n\tret, _, _ := procSetPixelFormat.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(iPixelFormat),\n\t\tuintptr(unsafe.Pointer(pfd)),\n\t)\n\treturn ret == TRUE\n}\n\nfunc SwapBuffers(hdc HDC) bool {\n\tret, _, _ := procSwapBuffers.Call(uintptr(hdc))\n\treturn ret == TRUE\n}\n"
  },
  {
    "path": "w32/gdiplus.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nconst (\n\tOk                        = 0\n\tGenericError              = 1\n\tInvalidParameter          = 2\n\tOutOfMemory               = 3\n\tObjectBusy                = 4\n\tInsufficientBuffer        = 5\n\tNotImplemented            = 6\n\tWin32Error                = 7\n\tWrongState                = 8\n\tAborted                   = 9\n\tFileNotFound              = 10\n\tValueOverflow             = 11\n\tAccessDenied              = 12\n\tUnknownImageFormat        = 13\n\tFontFamilyNotFound        = 14\n\tFontStyleNotFound         = 15\n\tNotTrueTypeFont           = 16\n\tUnsupportedGdiplusVersion = 17\n\tGdiplusNotInitialized     = 18\n\tPropertyNotFound          = 19\n\tPropertyNotSupported      = 20\n\tProfileNotFound           = 21\n)\n\nfunc GetGpStatus(s int32) string {\n\tswitch s {\n\tcase Ok:\n\t\treturn \"Ok\"\n\tcase GenericError:\n\t\treturn \"GenericError\"\n\tcase InvalidParameter:\n\t\treturn \"InvalidParameter\"\n\tcase OutOfMemory:\n\t\treturn \"OutOfMemory\"\n\tcase ObjectBusy:\n\t\treturn \"ObjectBusy\"\n\tcase InsufficientBuffer:\n\t\treturn \"InsufficientBuffer\"\n\tcase NotImplemented:\n\t\treturn \"NotImplemented\"\n\tcase Win32Error:\n\t\treturn \"Win32Error\"\n\tcase WrongState:\n\t\treturn \"WrongState\"\n\tcase Aborted:\n\t\treturn \"Aborted\"\n\tcase FileNotFound:\n\t\treturn \"FileNotFound\"\n\tcase ValueOverflow:\n\t\treturn \"ValueOverflow\"\n\tcase AccessDenied:\n\t\treturn \"AccessDenied\"\n\tcase UnknownImageFormat:\n\t\treturn \"UnknownImageFormat\"\n\tcase FontFamilyNotFound:\n\t\treturn \"FontFamilyNotFound\"\n\tcase FontStyleNotFound:\n\t\treturn \"FontStyleNotFound\"\n\tcase NotTrueTypeFont:\n\t\treturn \"NotTrueTypeFont\"\n\tcase UnsupportedGdiplusVersion:\n\t\treturn \"UnsupportedGdiplusVersion\"\n\tcase GdiplusNotInitialized:\n\t\treturn \"GdiplusNotInitialized\"\n\tcase PropertyNotFound:\n\t\treturn \"PropertyNotFound\"\n\tcase PropertyNotSupported:\n\t\treturn \"PropertyNotSupported\"\n\tcase ProfileNotFound:\n\t\treturn \"ProfileNotFound\"\n\t}\n\treturn \"Unknown Status Value\"\n}\n\nvar (\n\ttoken uintptr\n\n\tmodgdiplus = syscall.NewLazyDLL(\"gdiplus.dll\")\n\n\tprocGdipCreateBitmapFromFile     = modgdiplus.NewProc(\"GdipCreateBitmapFromFile\")\n\tprocGdipCreateBitmapFromHBITMAP  = modgdiplus.NewProc(\"GdipCreateBitmapFromHBITMAP\")\n\tprocGdipCreateHBITMAPFromBitmap  = modgdiplus.NewProc(\"GdipCreateHBITMAPFromBitmap\")\n\tprocGdipCreateBitmapFromResource = modgdiplus.NewProc(\"GdipCreateBitmapFromResource\")\n\tprocGdipCreateBitmapFromStream   = modgdiplus.NewProc(\"GdipCreateBitmapFromStream\")\n\tprocGdipDisposeImage             = modgdiplus.NewProc(\"GdipDisposeImage\")\n\tprocGdiplusShutdown              = modgdiplus.NewProc(\"GdiplusShutdown\")\n\tprocGdiplusStartup               = modgdiplus.NewProc(\"GdiplusStartup\")\n)\n\nfunc GdipCreateBitmapFromFile(filename string) (*uintptr, error) {\n\tvar bitmap *uintptr\n\tret, _, _ := procGdipCreateBitmapFromFile.Call(\n\t\tuintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(filename))),\n\t\tuintptr(unsafe.Pointer(&bitmap)))\n\n\tif ret != Ok {\n\t\treturn nil, errors.New(fmt.Sprintf(\"GdipCreateBitmapFromFile failed with status '%s' for file '%s'\", GetGpStatus(int32(ret)), filename))\n\t}\n\n\treturn bitmap, nil\n}\n\nfunc GdipCreateBitmapFromResource(instance HINSTANCE, resId *uint16) (*uintptr, error) {\n\tvar bitmap *uintptr\n\tret, _, _ := procGdipCreateBitmapFromResource.Call(\n\t\tuintptr(instance),\n\t\tuintptr(unsafe.Pointer(resId)),\n\t\tuintptr(unsafe.Pointer(&bitmap)))\n\n\tif ret != Ok {\n\t\treturn nil, errors.New(fmt.Sprintf(\"GdiCreateBitmapFromResource failed with status '%s'\", GetGpStatus(int32(ret))))\n\t}\n\n\treturn bitmap, nil\n}\n\nfunc GdipCreateBitmapFromStream(stream *IStream) (*uintptr, error) {\n\tvar bitmap *uintptr\n\tret, _, _ := procGdipCreateBitmapFromStream.Call(\n\t\tuintptr(unsafe.Pointer(stream)),\n\t\tuintptr(unsafe.Pointer(&bitmap)))\n\n\tif ret != Ok {\n\t\treturn nil, errors.New(fmt.Sprintf(\"GdipCreateBitmapFromStream failed with status '%s'\", GetGpStatus(int32(ret))))\n\t}\n\n\treturn bitmap, nil\n}\n\nfunc GdipCreateHBITMAPFromBitmap(bitmap *uintptr, background uint32) (HBITMAP, error) {\n\tvar hbitmap HBITMAP\n\tret, _, _ := procGdipCreateHBITMAPFromBitmap.Call(\n\t\tuintptr(unsafe.Pointer(bitmap)),\n\t\tuintptr(unsafe.Pointer(&hbitmap)),\n\t\tuintptr(background))\n\n\tif ret != Ok {\n\t\treturn 0, errors.New(fmt.Sprintf(\"GdipCreateHBITMAPFromBitmap failed with status '%s'\", GetGpStatus(int32(ret))))\n\t}\n\n\treturn hbitmap, nil\n}\n\nfunc GdipDisposeImage(image *uintptr) {\n\tprocGdipDisposeImage.Call(uintptr(unsafe.Pointer(image)))\n}\n\nfunc GdiplusShutdown() {\n\tprocGdiplusShutdown.Call(token)\n}\n\nfunc GdiplusStartup(input *GdiplusStartupInput, output *GdiplusStartupOutput) {\n\tret, _, _ := procGdiplusStartup.Call(\n\t\tuintptr(unsafe.Pointer(&token)),\n\t\tuintptr(unsafe.Pointer(input)),\n\t\tuintptr(unsafe.Pointer(output)))\n\n\tif ret != Ok {\n\t\tpanic(\"GdiplusStartup failed with status \" + GetGpStatus(int32(ret)))\n\t}\n}\n"
  },
  {
    "path": "w32/idispatch.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"unsafe\"\n)\n\ntype pIDispatchVtbl struct {\n\tpQueryInterface   uintptr\n\tpAddRef           uintptr\n\tpRelease          uintptr\n\tpGetTypeInfoCount uintptr\n\tpGetTypeInfo      uintptr\n\tpGetIDsOfNames    uintptr\n\tpInvoke           uintptr\n}\n\ntype IDispatch struct {\n\tlpVtbl *pIDispatchVtbl\n}\n\nfunc (this *IDispatch) QueryInterface(id *GUID) *IDispatch {\n\treturn ComQueryInterface((*IUnknown)(unsafe.Pointer(this)), id)\n}\n\nfunc (this *IDispatch) AddRef() int32 {\n\treturn ComAddRef((*IUnknown)(unsafe.Pointer(this)))\n}\n\nfunc (this *IDispatch) Release() int32 {\n\treturn ComRelease((*IUnknown)(unsafe.Pointer(this)))\n}\n\nfunc (this *IDispatch) GetIDsOfName(names []string) []int32 {\n\treturn ComGetIDsOfName(this, names)\n}\n\nfunc (this *IDispatch) Invoke(dispid int32, dispatch int16, params ...interface{}) *VARIANT {\n\treturn ComInvoke(this, dispid, dispatch, params...)\n}\n"
  },
  {
    "path": "w32/istream.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"unsafe\"\n)\n\ntype pIStreamVtbl struct {\n\tpQueryInterface uintptr\n\tpAddRef         uintptr\n\tpRelease        uintptr\n}\n\ntype IStream struct {\n\tlpVtbl *pIStreamVtbl\n}\n\nfunc (this *IStream) QueryInterface(id *GUID) *IDispatch {\n\treturn ComQueryInterface((*IUnknown)(unsafe.Pointer(this)), id)\n}\n\nfunc (this *IStream) AddRef() int32 {\n\treturn ComAddRef((*IUnknown)(unsafe.Pointer(this)))\n}\n\nfunc (this *IStream) Release() int32 {\n\treturn ComRelease((*IUnknown)(unsafe.Pointer(this)))\n}\n"
  },
  {
    "path": "w32/iunknown.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\ntype pIUnknownVtbl struct {\n\tpQueryInterface uintptr\n\tpAddRef         uintptr\n\tpRelease        uintptr\n}\n\ntype IUnknown struct {\n\tlpVtbl *pIUnknownVtbl\n}\n\nfunc (this *IUnknown) QueryInterface(id *GUID) *IDispatch {\n\treturn ComQueryInterface(this, id)\n}\n\nfunc (this *IUnknown) AddRef() int32 {\n\treturn ComAddRef(this)\n}\n\nfunc (this *IUnknown) Release() int32 {\n\treturn ComRelease(this)\n}\n"
  },
  {
    "path": "w32/kernel32.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmodkernel32 = syscall.NewLazyDLL(\"kernel32.dll\")\n\n\tprocGetModuleHandle            = modkernel32.NewProc(\"GetModuleHandleW\")\n\tprocMulDiv                     = modkernel32.NewProc(\"MulDiv\")\n\tprocGetConsoleWindow           = modkernel32.NewProc(\"GetConsoleWindow\")\n\tprocGetCurrentThread           = modkernel32.NewProc(\"GetCurrentThread\")\n\tprocGetCurrentThreadId         = modkernel32.NewProc(\"GetCurrentThreadId\")\n\tprocGetLogicalDrives           = modkernel32.NewProc(\"GetLogicalDrives\")\n\tprocGetLogicalDriveStrings     = modkernel32.NewProc(\"GetLogicalDriveStringsW\")\n\tprocGetUserDefaultLCID         = modkernel32.NewProc(\"GetUserDefaultLCID\")\n\tprocLstrlen                    = modkernel32.NewProc(\"lstrlenW\")\n\tprocLstrcpy                    = modkernel32.NewProc(\"lstrcpyW\")\n\tprocGlobalAlloc                = modkernel32.NewProc(\"GlobalAlloc\")\n\tprocGlobalFree                 = modkernel32.NewProc(\"GlobalFree\")\n\tprocGlobalLock                 = modkernel32.NewProc(\"GlobalLock\")\n\tprocGlobalUnlock               = modkernel32.NewProc(\"GlobalUnlock\")\n\tprocMoveMemory                 = modkernel32.NewProc(\"RtlMoveMemory\")\n\tprocFindResource               = modkernel32.NewProc(\"FindResourceW\")\n\tprocSizeofResource             = modkernel32.NewProc(\"SizeofResource\")\n\tprocLockResource               = modkernel32.NewProc(\"LockResource\")\n\tprocLoadResource               = modkernel32.NewProc(\"LoadResource\")\n\tprocGetLastError               = modkernel32.NewProc(\"GetLastError\")\n\tprocOpenProcess                = modkernel32.NewProc(\"OpenProcess\")\n\tprocTerminateProcess           = modkernel32.NewProc(\"TerminateProcess\")\n\tprocCloseHandle                = modkernel32.NewProc(\"CloseHandle\")\n\tprocCreateToolhelp32Snapshot   = modkernel32.NewProc(\"CreateToolhelp32Snapshot\")\n\tprocModule32First              = modkernel32.NewProc(\"Module32FirstW\")\n\tprocModule32Next               = modkernel32.NewProc(\"Module32NextW\")\n\tprocGetSystemTimes             = modkernel32.NewProc(\"GetSystemTimes\")\n\tprocGetConsoleScreenBufferInfo = modkernel32.NewProc(\"GetConsoleScreenBufferInfo\")\n\tprocSetConsoleTextAttribute    = modkernel32.NewProc(\"SetConsoleTextAttribute\")\n\tprocGetDiskFreeSpaceEx         = modkernel32.NewProc(\"GetDiskFreeSpaceExW\")\n\tprocGetProcessTimes            = modkernel32.NewProc(\"GetProcessTimes\")\n\tprocSetSystemTime              = modkernel32.NewProc(\"SetSystemTime\")\n\tprocGetSystemTime              = modkernel32.NewProc(\"GetSystemTime\")\n)\n\nfunc GetModuleHandle(modulename string) HINSTANCE {\n\tvar mn uintptr\n\tif modulename == \"\" {\n\t\tmn = 0\n\t} else {\n\t\tmn = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(modulename)))\n\t}\n\tret, _, _ := procGetModuleHandle.Call(mn)\n\treturn HINSTANCE(ret)\n}\n\nfunc MulDiv(number, numerator, denominator int) int {\n\tret, _, _ := procMulDiv.Call(\n\t\tuintptr(number),\n\t\tuintptr(numerator),\n\t\tuintptr(denominator))\n\n\treturn int(ret)\n}\n\nfunc GetConsoleWindow() HWND {\n\tret, _, _ := procGetConsoleWindow.Call()\n\n\treturn HWND(ret)\n}\n\nfunc GetCurrentThread() HANDLE {\n\tret, _, _ := procGetCurrentThread.Call()\n\n\treturn HANDLE(ret)\n}\n\nfunc GetCurrentThreadId() HANDLE {\n\tret, _, _ := procGetCurrentThreadId.Call()\n\n\treturn HANDLE(ret)\n}\n\nfunc GetLogicalDrives() uint32 {\n\tret, _, _ := procGetLogicalDrives.Call()\n\n\treturn uint32(ret)\n}\n\nfunc GetUserDefaultLCID() uint32 {\n\tret, _, _ := procGetUserDefaultLCID.Call()\n\n\treturn uint32(ret)\n}\n\nfunc Lstrlen(lpString *uint16) int {\n\tret, _, _ := procLstrlen.Call(uintptr(unsafe.Pointer(lpString)))\n\n\treturn int(ret)\n}\n\nfunc Lstrcpy(buf []uint16, lpString *uint16) {\n\tprocLstrcpy.Call(\n\t\tuintptr(unsafe.Pointer(&buf[0])),\n\t\tuintptr(unsafe.Pointer(lpString)))\n}\n\nfunc GlobalAlloc(uFlags uint, dwBytes uint32) HGLOBAL {\n\tret, _, _ := procGlobalAlloc.Call(\n\t\tuintptr(uFlags),\n\t\tuintptr(dwBytes))\n\n\tif ret == 0 {\n\t\tpanic(\"GlobalAlloc failed\")\n\t}\n\n\treturn HGLOBAL(ret)\n}\n\nfunc GlobalFree(hMem HGLOBAL) {\n\tret, _, _ := procGlobalFree.Call(uintptr(hMem))\n\n\tif ret != 0 {\n\t\tpanic(\"GlobalFree failed\")\n\t}\n}\n\nfunc GlobalLock(hMem HGLOBAL) unsafe.Pointer {\n\tret, _, _ := procGlobalLock.Call(uintptr(hMem))\n\n\tif ret == 0 {\n\t\tpanic(\"GlobalLock failed\")\n\t}\n\n\treturn unsafe.Pointer(ret)\n}\n\nfunc GlobalUnlock(hMem HGLOBAL) bool {\n\tret, _, _ := procGlobalUnlock.Call(uintptr(hMem))\n\n\treturn ret != 0\n}\n\nfunc MoveMemory(destination, source unsafe.Pointer, length uint32) {\n\tprocMoveMemory.Call(\n\t\tuintptr(unsafe.Pointer(destination)),\n\t\tuintptr(source),\n\t\tuintptr(length))\n}\n\nfunc FindResource(hModule HMODULE, lpName, lpType *uint16) (HRSRC, error) {\n\tret, _, _ := procFindResource.Call(\n\t\tuintptr(hModule),\n\t\tuintptr(unsafe.Pointer(lpName)),\n\t\tuintptr(unsafe.Pointer(lpType)))\n\n\tif ret == 0 {\n\t\treturn 0, syscall.GetLastError()\n\t}\n\n\treturn HRSRC(ret), nil\n}\n\nfunc SizeofResource(hModule HMODULE, hResInfo HRSRC) uint32 {\n\tret, _, _ := procSizeofResource.Call(\n\t\tuintptr(hModule),\n\t\tuintptr(hResInfo))\n\n\tif ret == 0 {\n\t\tpanic(\"SizeofResource failed\")\n\t}\n\n\treturn uint32(ret)\n}\n\nfunc LockResource(hResData HGLOBAL) unsafe.Pointer {\n\tret, _, _ := procLockResource.Call(uintptr(hResData))\n\n\tif ret == 0 {\n\t\tpanic(\"LockResource failed\")\n\t}\n\n\treturn unsafe.Pointer(ret)\n}\n\nfunc LoadResource(hModule HMODULE, hResInfo HRSRC) HGLOBAL {\n\tret, _, _ := procLoadResource.Call(\n\t\tuintptr(hModule),\n\t\tuintptr(hResInfo))\n\n\tif ret == 0 {\n\t\tpanic(\"LoadResource failed\")\n\t}\n\n\treturn HGLOBAL(ret)\n}\n\nfunc GetLastError() uint32 {\n\tret, _, _ := procGetLastError.Call()\n\treturn uint32(ret)\n}\n\nfunc OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) HANDLE {\n\tinherit := 0\n\tif inheritHandle {\n\t\tinherit = 1\n\t}\n\n\tret, _, _ := procOpenProcess.Call(\n\t\tuintptr(desiredAccess),\n\t\tuintptr(inherit),\n\t\tuintptr(processId))\n\treturn HANDLE(ret)\n}\n\nfunc TerminateProcess(hProcess HANDLE, uExitCode uint) bool {\n\tret, _, _ := procTerminateProcess.Call(\n\t\tuintptr(hProcess),\n\t\tuintptr(uExitCode))\n\treturn ret != 0\n}\n\nfunc CloseHandle(object HANDLE) bool {\n\tret, _, _ := procCloseHandle.Call(\n\t\tuintptr(object))\n\treturn ret != 0\n}\n\nfunc CreateToolhelp32Snapshot(flags, processId uint32) HANDLE {\n\tret, _, _ := procCreateToolhelp32Snapshot.Call(\n\t\tuintptr(flags),\n\t\tuintptr(processId))\n\n\tif ret <= 0 {\n\t\treturn HANDLE(0)\n\t}\n\n\treturn HANDLE(ret)\n}\n\nfunc Module32First(snapshot HANDLE, me *MODULEENTRY32) bool {\n\tret, _, _ := procModule32First.Call(\n\t\tuintptr(snapshot),\n\t\tuintptr(unsafe.Pointer(me)))\n\n\treturn ret != 0\n}\n\nfunc Module32Next(snapshot HANDLE, me *MODULEENTRY32) bool {\n\tret, _, _ := procModule32Next.Call(\n\t\tuintptr(snapshot),\n\t\tuintptr(unsafe.Pointer(me)))\n\n\treturn ret != 0\n}\n\nfunc GetSystemTimes(lpIdleTime, lpKernelTime, lpUserTime *FILETIME) bool {\n\tret, _, _ := procGetSystemTimes.Call(\n\t\tuintptr(unsafe.Pointer(lpIdleTime)),\n\t\tuintptr(unsafe.Pointer(lpKernelTime)),\n\t\tuintptr(unsafe.Pointer(lpUserTime)))\n\n\treturn ret != 0\n}\n\nfunc GetProcessTimes(hProcess HANDLE, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime *FILETIME) bool {\n\tret, _, _ := procGetProcessTimes.Call(\n\t\tuintptr(hProcess),\n\t\tuintptr(unsafe.Pointer(lpCreationTime)),\n\t\tuintptr(unsafe.Pointer(lpExitTime)),\n\t\tuintptr(unsafe.Pointer(lpKernelTime)),\n\t\tuintptr(unsafe.Pointer(lpUserTime)))\n\n\treturn ret != 0\n}\n\nfunc GetConsoleScreenBufferInfo(hConsoleOutput HANDLE) *CONSOLE_SCREEN_BUFFER_INFO {\n\tvar csbi CONSOLE_SCREEN_BUFFER_INFO\n\tret, _, _ := procGetConsoleScreenBufferInfo.Call(\n\t\tuintptr(hConsoleOutput),\n\t\tuintptr(unsafe.Pointer(&csbi)))\n\tif ret == 0 {\n\t\treturn nil\n\t}\n\treturn &csbi\n}\n\nfunc SetConsoleTextAttribute(hConsoleOutput HANDLE, wAttributes uint16) bool {\n\tret, _, _ := procSetConsoleTextAttribute.Call(\n\t\tuintptr(hConsoleOutput),\n\t\tuintptr(wAttributes))\n\treturn ret != 0\n}\n\nfunc GetDiskFreeSpaceEx(dirName string) (r bool,\n\tfreeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes uint64) {\n\tret, _, _ := procGetDiskFreeSpaceEx.Call(\n\t\tuintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(dirName))),\n\t\tuintptr(unsafe.Pointer(&freeBytesAvailable)),\n\t\tuintptr(unsafe.Pointer(&totalNumberOfBytes)),\n\t\tuintptr(unsafe.Pointer(&totalNumberOfFreeBytes)))\n\treturn ret != 0,\n\t\tfreeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes\n}\n\nfunc GetSystemTime() *SYSTEMTIME {\n\tvar time SYSTEMTIME\n\tprocGetSystemTime.Call(\n\t\tuintptr(unsafe.Pointer(&time)))\n\treturn &time\n}\n\nfunc SetSystemTime(time *SYSTEMTIME) bool {\n\tret, _, _ := procSetSystemTime.Call(\n\t\tuintptr(unsafe.Pointer(time)))\n\treturn ret != 0\n}\n\nfunc GetLogicalDriveStrings(nBufferLength uint32, lpBuffer *uint16) uint32 {\n\tret, _, _ := procGetLogicalDriveStrings.Call(\n\t\tuintptr(nBufferLength),\n\t\tuintptr(unsafe.Pointer(lpBuffer)),\n\t\t0)\n\n\treturn uint32(ret)\n}\n"
  },
  {
    "path": "w32/ole32.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmodole32 = syscall.NewLazyDLL(\"ole32.dll\")\n\n\tprocCoInitializeEx        = modole32.NewProc(\"CoInitializeEx\")\n\tprocCoInitialize          = modole32.NewProc(\"CoInitialize\")\n\tprocCoUninitialize        = modole32.NewProc(\"CoUninitialize\")\n\tprocCreateStreamOnHGlobal = modole32.NewProc(\"CreateStreamOnHGlobal\")\n)\n\nfunc CoInitializeEx(coInit uintptr) HRESULT {\n\tret, _, _ := procCoInitializeEx.Call(\n\t\t0,\n\t\tcoInit)\n\n\tswitch uint32(ret) {\n\tcase E_INVALIDARG:\n\t\tpanic(\"CoInitializeEx failed with E_INVALIDARG\")\n\tcase E_OUTOFMEMORY:\n\t\tpanic(\"CoInitializeEx failed with E_OUTOFMEMORY\")\n\tcase E_UNEXPECTED:\n\t\tpanic(\"CoInitializeEx failed with E_UNEXPECTED\")\n\t}\n\n\treturn HRESULT(ret)\n}\n\nfunc CoInitialize() {\n\tprocCoInitialize.Call(0)\n}\n\nfunc CoUninitialize() {\n\tprocCoUninitialize.Call()\n}\n\nfunc CreateStreamOnHGlobal(hGlobal HGLOBAL, fDeleteOnRelease bool) *IStream {\n\tstream := new(IStream)\n\tret, _, _ := procCreateStreamOnHGlobal.Call(\n\t\tuintptr(hGlobal),\n\t\tuintptr(BoolToBOOL(fDeleteOnRelease)),\n\t\tuintptr(unsafe.Pointer(&stream)))\n\n\tswitch uint32(ret) {\n\tcase E_INVALIDARG:\n\t\tpanic(\"CreateStreamOnHGlobal failed with E_INVALIDARG\")\n\tcase E_OUTOFMEMORY:\n\t\tpanic(\"CreateStreamOnHGlobal failed with E_OUTOFMEMORY\")\n\tcase E_UNEXPECTED:\n\t\tpanic(\"CreateStreamOnHGlobal failed with E_UNEXPECTED\")\n\t}\n\n\treturn stream\n}\n"
  },
  {
    "path": "w32/oleaut32.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmodoleaut32 = syscall.NewLazyDLL(\"oleaut32\")\n\n\tprocVariantInit        = modoleaut32.NewProc(\"VariantInit\")\n\tprocSysAllocString     = modoleaut32.NewProc(\"SysAllocString\")\n\tprocSysFreeString      = modoleaut32.NewProc(\"SysFreeString\")\n\tprocSysStringLen       = modoleaut32.NewProc(\"SysStringLen\")\n\tprocCreateDispTypeInfo = modoleaut32.NewProc(\"CreateDispTypeInfo\")\n\tprocCreateStdDispatch  = modoleaut32.NewProc(\"CreateStdDispatch\")\n)\n\nfunc VariantInit(v *VARIANT) {\n\thr, _, _ := procVariantInit.Call(uintptr(unsafe.Pointer(v)))\n\tif hr != 0 {\n\t\tpanic(\"Invoke VariantInit error.\")\n\t}\n\treturn\n}\n\nfunc SysAllocString(v string) (ss *int16) {\n\tpss, _, _ := procSysAllocString.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(v))))\n\tss = (*int16)(unsafe.Pointer(pss))\n\treturn\n}\n\nfunc SysFreeString(v *int16) {\n\thr, _, _ := procSysFreeString.Call(uintptr(unsafe.Pointer(v)))\n\tif hr != 0 {\n\t\tpanic(\"Invoke SysFreeString error.\")\n\t}\n\treturn\n}\n\nfunc SysStringLen(v *int16) uint {\n\tl, _, _ := procSysStringLen.Call(uintptr(unsafe.Pointer(v)))\n\treturn uint(l)\n}\n"
  },
  {
    "path": "w32/shcore.go",
    "content": "package w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmodshcore = syscall.NewLazyDLL(\"shcore.dll\")\n\n\tprocGetDpiForMonitor = modshcore.NewProc(\"GetDpiForMonitor\")\n)\n\nfunc GetDPIForMonitor(hmonitor HMONITOR, dpiType MONITOR_DPI_TYPE, dpiX *UINT, dpiY *UINT) uintptr {\n\tret, _, _ := procGetDpiForMonitor.Call(\n\t\thmonitor,\n\t\tuintptr(dpiType),\n\t\tuintptr(unsafe.Pointer(dpiX)),\n\t\tuintptr(unsafe.Pointer(dpiY)))\n\n\treturn ret\n}\n"
  },
  {
    "path": "w32/shell32.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"syscall\"\n\t\"unsafe\"\n)\n\ntype CSIDL uint32\n\nconst (\n\tCSIDL_DESKTOP                 = 0x00\n\tCSIDL_INTERNET                = 0x01\n\tCSIDL_PROGRAMS                = 0x02\n\tCSIDL_CONTROLS                = 0x03\n\tCSIDL_PRINTERS                = 0x04\n\tCSIDL_PERSONAL                = 0x05\n\tCSIDL_FAVORITES               = 0x06\n\tCSIDL_STARTUP                 = 0x07\n\tCSIDL_RECENT                  = 0x08\n\tCSIDL_SENDTO                  = 0x09\n\tCSIDL_BITBUCKET               = 0x0A\n\tCSIDL_STARTMENU               = 0x0B\n\tCSIDL_MYDOCUMENTS             = 0x0C\n\tCSIDL_MYMUSIC                 = 0x0D\n\tCSIDL_MYVIDEO                 = 0x0E\n\tCSIDL_DESKTOPDIRECTORY        = 0x10\n\tCSIDL_DRIVES                  = 0x11\n\tCSIDL_NETWORK                 = 0x12\n\tCSIDL_NETHOOD                 = 0x13\n\tCSIDL_FONTS                   = 0x14\n\tCSIDL_TEMPLATES               = 0x15\n\tCSIDL_COMMON_STARTMENU        = 0x16\n\tCSIDL_COMMON_PROGRAMS         = 0x17\n\tCSIDL_COMMON_STARTUP          = 0x18\n\tCSIDL_COMMON_DESKTOPDIRECTORY = 0x19\n\tCSIDL_APPDATA                 = 0x1A\n\tCSIDL_PRINTHOOD               = 0x1B\n\tCSIDL_LOCAL_APPDATA           = 0x1C\n\tCSIDL_ALTSTARTUP              = 0x1D\n\tCSIDL_COMMON_ALTSTARTUP       = 0x1E\n\tCSIDL_COMMON_FAVORITES        = 0x1F\n\tCSIDL_INTERNET_CACHE          = 0x20\n\tCSIDL_COOKIES                 = 0x21\n\tCSIDL_HISTORY                 = 0x22\n\tCSIDL_COMMON_APPDATA          = 0x23\n\tCSIDL_WINDOWS                 = 0x24\n\tCSIDL_SYSTEM                  = 0x25\n\tCSIDL_PROGRAM_FILES           = 0x26\n\tCSIDL_MYPICTURES              = 0x27\n\tCSIDL_PROFILE                 = 0x28\n\tCSIDL_SYSTEMX86               = 0x29\n\tCSIDL_PROGRAM_FILESX86        = 0x2A\n\tCSIDL_PROGRAM_FILES_COMMON    = 0x2B\n\tCSIDL_PROGRAM_FILES_COMMONX86 = 0x2C\n\tCSIDL_COMMON_TEMPLATES        = 0x2D\n\tCSIDL_COMMON_DOCUMENTS        = 0x2E\n\tCSIDL_COMMON_ADMINTOOLS       = 0x2F\n\tCSIDL_ADMINTOOLS              = 0x30\n\tCSIDL_CONNECTIONS             = 0x31\n\tCSIDL_COMMON_MUSIC            = 0x35\n\tCSIDL_COMMON_PICTURES         = 0x36\n\tCSIDL_COMMON_VIDEO            = 0x37\n\tCSIDL_RESOURCES               = 0x38\n\tCSIDL_RESOURCES_LOCALIZED     = 0x39\n\tCSIDL_COMMON_OEM_LINKS        = 0x3A\n\tCSIDL_CDBURN_AREA             = 0x3B\n\tCSIDL_COMPUTERSNEARME         = 0x3D\n\tCSIDL_FLAG_CREATE             = 0x8000\n\tCSIDL_FLAG_DONT_VERIFY        = 0x4000\n\tCSIDL_FLAG_NO_ALIAS           = 0x1000\n\tCSIDL_FLAG_PER_USER_INIT      = 0x8000\n\tCSIDL_FLAG_MASK               = 0xFF00\n)\n\nvar (\n\tmodshell32 = syscall.NewLazyDLL(\"shell32.dll\")\n\n\tprocSHBrowseForFolder    = modshell32.NewProc(\"SHBrowseForFolderW\")\n\tprocSHGetPathFromIDList  = modshell32.NewProc(\"SHGetPathFromIDListW\")\n\tprocDragAcceptFiles      = modshell32.NewProc(\"DragAcceptFiles\")\n\tprocDragQueryFile        = modshell32.NewProc(\"DragQueryFileW\")\n\tprocDragQueryPoint       = modshell32.NewProc(\"DragQueryPoint\")\n\tprocDragFinish           = modshell32.NewProc(\"DragFinish\")\n\tprocShellExecute         = modshell32.NewProc(\"ShellExecuteW\")\n\tprocExtractIcon          = modshell32.NewProc(\"ExtractIconW\")\n\tprocGetSpecialFolderPath = modshell32.NewProc(\"SHGetSpecialFolderPathW\")\n)\n\nfunc SHBrowseForFolder(bi *BROWSEINFO) uintptr {\n\tret, _, _ := procSHBrowseForFolder.Call(uintptr(unsafe.Pointer(bi)))\n\n\treturn ret\n}\n\nfunc SHGetPathFromIDList(idl uintptr) string {\n\tbuf := make([]uint16, 1024)\n\tprocSHGetPathFromIDList.Call(\n\t\tidl,\n\t\tuintptr(unsafe.Pointer(&buf[0])))\n\n\treturn syscall.UTF16ToString(buf)\n}\n\nfunc DragAcceptFiles(hwnd HWND, accept bool) {\n\tprocDragAcceptFiles.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(BoolToBOOL(accept)))\n}\n\nfunc DragQueryFile(hDrop HDROP, iFile uint) (fileName string, fileCount uint) {\n\tret, _, _ := procDragQueryFile.Call(\n\t\tuintptr(hDrop),\n\t\tuintptr(iFile),\n\t\t0,\n\t\t0)\n\n\tfileCount = uint(ret)\n\n\tif iFile != 0xFFFFFFFF {\n\t\tbuf := make([]uint16, fileCount+1)\n\n\t\tret, _, _ := procDragQueryFile.Call(\n\t\t\tuintptr(hDrop),\n\t\t\tuintptr(iFile),\n\t\t\tuintptr(unsafe.Pointer(&buf[0])),\n\t\t\tuintptr(fileCount+1))\n\n\t\tif ret == 0 {\n\t\t\tpanic(\"Invoke DragQueryFile error.\")\n\t\t}\n\n\t\tfileName = syscall.UTF16ToString(buf)\n\t}\n\n\treturn\n}\n\nfunc DragQueryPoint(hDrop HDROP) (x, y int, isClientArea bool) {\n\tvar pt POINT\n\tret, _, _ := procDragQueryPoint.Call(\n\t\tuintptr(hDrop),\n\t\tuintptr(unsafe.Pointer(&pt)))\n\n\treturn int(pt.X), int(pt.Y), (ret == 1)\n}\n\nfunc DragFinish(hDrop HDROP) {\n\tprocDragFinish.Call(uintptr(hDrop))\n}\n\nfunc ShellExecute(hwnd HWND, lpOperation, lpFile, lpParameters, lpDirectory string, nShowCmd int) error {\n\tvar op, param, directory uintptr\n\tif len(lpOperation) != 0 {\n\t\top = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpOperation)))\n\t}\n\tif len(lpParameters) != 0 {\n\t\tparam = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpParameters)))\n\t}\n\tif len(lpDirectory) != 0 {\n\t\tdirectory = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpDirectory)))\n\t}\n\n\tret, _, _ := procShellExecute.Call(\n\t\tuintptr(hwnd),\n\t\top,\n\t\tuintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpFile))),\n\t\tparam,\n\t\tdirectory,\n\t\tuintptr(nShowCmd))\n\n\terrorMsg := \"\"\n\tif ret != 0 && ret <= 32 {\n\t\tswitch int(ret) {\n\t\tcase ERROR_FILE_NOT_FOUND:\n\t\t\terrorMsg = \"The specified file was not found.\"\n\t\tcase ERROR_PATH_NOT_FOUND:\n\t\t\terrorMsg = \"The specified path was not found.\"\n\t\tcase ERROR_BAD_FORMAT:\n\t\t\terrorMsg = \"The .exe file is invalid (non-Win32 .exe or error in .exe image).\"\n\t\tcase SE_ERR_ACCESSDENIED:\n\t\t\terrorMsg = \"The operating system denied access to the specified file.\"\n\t\tcase SE_ERR_ASSOCINCOMPLETE:\n\t\t\terrorMsg = \"The file name association is incomplete or invalid.\"\n\t\tcase SE_ERR_DDEBUSY:\n\t\t\terrorMsg = \"The DDE transaction could not be completed because other DDE transactions were being processed.\"\n\t\tcase SE_ERR_DDEFAIL:\n\t\t\terrorMsg = \"The DDE transaction failed.\"\n\t\tcase SE_ERR_DDETIMEOUT:\n\t\t\terrorMsg = \"The DDE transaction could not be completed because the request timed out.\"\n\t\tcase SE_ERR_DLLNOTFOUND:\n\t\t\terrorMsg = \"The specified DLL was not found.\"\n\t\tcase SE_ERR_NOASSOC:\n\t\t\terrorMsg = \"There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.\"\n\t\tcase SE_ERR_OOM:\n\t\t\terrorMsg = \"There was not enough memory to complete the operation.\"\n\t\tcase SE_ERR_SHARE:\n\t\t\terrorMsg = \"A sharing violation occurred.\"\n\t\tdefault:\n\t\t\terrorMsg = fmt.Sprintf(\"Unknown error occurred with error code %v\", ret)\n\t\t}\n\t} else {\n\t\treturn nil\n\t}\n\n\treturn errors.New(errorMsg)\n}\n\nfunc ExtractIcon(lpszExeFileName string, nIconIndex int) HICON {\n\tret, _, _ := procExtractIcon.Call(\n\t\t0,\n\t\tuintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpszExeFileName))),\n\t\tuintptr(nIconIndex))\n\n\treturn HICON(ret)\n}\n\nfunc SHGetSpecialFolderPath(hwndOwner HWND, lpszPath *uint16, csidl CSIDL, fCreate bool) bool {\n\tret, _, _ := procGetSpecialFolderPath.Call(\n\t\tuintptr(hwndOwner),\n\t\tuintptr(unsafe.Pointer(lpszPath)),\n\t\tuintptr(csidl),\n\t\tuintptr(BoolToBOOL(fCreate)),\n\t\t0,\n\t\t0)\n\n\treturn ret != 0\n}\n"
  },
  {
    "path": "w32/shlwapi.go",
    "content": "package w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmodshlwapi = syscall.NewLazyDLL(\"shlwapi.dll\")\n\n\tprocSHCreateMemStream = modshlwapi.NewProc(\"SHCreateMemStream\")\n)\n\nfunc SHCreateMemStream(data []byte) (uintptr, error) {\n\tret, _, err := procSHCreateMemStream.Call(\n\t\tuintptr(unsafe.Pointer(&data[0])),\n\t\tuintptr(len(data)),\n\t)\n\tif ret == 0 {\n\t\treturn 0, err\n\t}\n\n\treturn ret, nil\n}\n"
  },
  {
    "path": "w32/toolbar.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\n// ToolBar messages\nconst (\n\tTB_ENABLEBUTTON          = WM_USER + 1\n\tTB_CHECKBUTTON           = WM_USER + 2\n\tTB_PRESSBUTTON           = WM_USER + 3\n\tTB_HIDEBUTTON            = WM_USER + 4\n\tTB_INDETERMINATE         = WM_USER + 5\n\tTB_MARKBUTTON            = WM_USER + 6\n\tTB_ISBUTTONENABLED       = WM_USER + 9\n\tTB_ISBUTTONCHECKED       = WM_USER + 10\n\tTB_ISBUTTONPRESSED       = WM_USER + 11\n\tTB_ISBUTTONHIDDEN        = WM_USER + 12\n\tTB_ISBUTTONINDETERMINATE = WM_USER + 13\n\tTB_ISBUTTONHIGHLIGHTED   = WM_USER + 14\n\tTB_SETSTATE              = WM_USER + 17\n\tTB_GETSTATE              = WM_USER + 18\n\tTB_ADDBITMAP             = WM_USER + 19\n\tTB_DELETEBUTTON          = WM_USER + 22\n\tTB_GETBUTTON             = WM_USER + 23\n\tTB_BUTTONCOUNT           = WM_USER + 24\n\tTB_COMMANDTOINDEX        = WM_USER + 25\n\tTB_SAVERESTORE           = WM_USER + 76\n\tTB_CUSTOMIZE             = WM_USER + 27\n\tTB_ADDSTRING             = WM_USER + 77\n\tTB_GETITEMRECT           = WM_USER + 29\n\tTB_BUTTONSTRUCTSIZE      = WM_USER + 30\n\tTB_SETBUTTONSIZE         = WM_USER + 31\n\tTB_SETBITMAPSIZE         = WM_USER + 32\n\tTB_AUTOSIZE              = WM_USER + 33\n\tTB_GETTOOLTIPS           = WM_USER + 35\n\tTB_SETTOOLTIPS           = WM_USER + 36\n\tTB_SETPARENT             = WM_USER + 37\n\tTB_SETROWS               = WM_USER + 39\n\tTB_GETROWS               = WM_USER + 40\n\tTB_GETBITMAPFLAGS        = WM_USER + 41\n\tTB_SETCMDID              = WM_USER + 42\n\tTB_CHANGEBITMAP          = WM_USER + 43\n\tTB_GETBITMAP             = WM_USER + 44\n\tTB_GETBUTTONTEXT         = WM_USER + 75\n\tTB_REPLACEBITMAP         = WM_USER + 46\n\tTB_GETBUTTONSIZE         = WM_USER + 58\n\tTB_SETBUTTONWIDTH        = WM_USER + 59\n\tTB_SETINDENT             = WM_USER + 47\n\tTB_SETIMAGELIST          = WM_USER + 48\n\tTB_GETIMAGELIST          = WM_USER + 49\n\tTB_LOADIMAGES            = WM_USER + 50\n\tTB_GETRECT               = WM_USER + 51\n\tTB_SETHOTIMAGELIST       = WM_USER + 52\n\tTB_GETHOTIMAGELIST       = WM_USER + 53\n\tTB_SETDISABLEDIMAGELIST  = WM_USER + 54\n\tTB_GETDISABLEDIMAGELIST  = WM_USER + 55\n\tTB_SETSTYLE              = WM_USER + 56\n\tTB_GETSTYLE              = WM_USER + 57\n\tTB_SETMAXTEXTROWS        = WM_USER + 60\n\tTB_GETTEXTROWS           = WM_USER + 61\n\tTB_GETOBJECT             = WM_USER + 62\n\tTB_GETBUTTONINFO         = WM_USER + 63\n\tTB_SETBUTTONINFO         = WM_USER + 64\n\tTB_INSERTBUTTON          = WM_USER + 67\n\tTB_ADDBUTTONS            = WM_USER + 68\n\tTB_HITTEST               = WM_USER + 69\n\tTB_SETDRAWTEXTFLAGS      = WM_USER + 70\n\tTB_GETHOTITEM            = WM_USER + 71\n\tTB_SETHOTITEM            = WM_USER + 72\n\tTB_SETANCHORHIGHLIGHT    = WM_USER + 73\n\tTB_GETANCHORHIGHLIGHT    = WM_USER + 74\n\tTB_GETINSERTMARK         = WM_USER + 79\n\tTB_SETINSERTMARK         = WM_USER + 80\n\tTB_INSERTMARKHITTEST     = WM_USER + 81\n\tTB_MOVEBUTTON            = WM_USER + 82\n\tTB_GETMAXSIZE            = WM_USER + 83\n\tTB_SETEXTENDEDSTYLE      = WM_USER + 84\n\tTB_GETEXTENDEDSTYLE      = WM_USER + 85\n\tTB_GETPADDING            = WM_USER + 86\n\tTB_SETPADDING            = WM_USER + 87\n\tTB_SETINSERTMARKCOLOR    = WM_USER + 88\n\tTB_GETINSERTMARKCOLOR    = WM_USER + 89\n\tTB_MAPACCELERATOR        = WM_USER + 90\n\tTB_GETSTRING             = WM_USER + 91\n\tTB_SETCOLORSCHEME        = CCM_SETCOLORSCHEME\n\tTB_GETCOLORSCHEME        = CCM_GETCOLORSCHEME\n\tTB_SETUNICODEFORMAT      = CCM_SETUNICODEFORMAT\n\tTB_GETUNICODEFORMAT      = CCM_GETUNICODEFORMAT\n)\n\n// ToolBar notifications\nconst (\n\tTBN_FIRST    = -700\n\tTBN_DROPDOWN = TBN_FIRST - 10\n)\n\n// TBN_DROPDOWN return codes\nconst (\n\tTBDDRET_DEFAULT      = 0\n\tTBDDRET_NODEFAULT    = 1\n\tTBDDRET_TREATPRESSED = 2\n)\n\n// ToolBar state constants\nconst (\n\tTBSTATE_CHECKED       = 1\n\tTBSTATE_PRESSED       = 2\n\tTBSTATE_ENABLED       = 4\n\tTBSTATE_HIDDEN        = 8\n\tTBSTATE_INDETERMINATE = 16\n\tTBSTATE_WRAP          = 32\n\tTBSTATE_ELLIPSES      = 0x40\n\tTBSTATE_MARKED        = 0x0080\n)\n\n// ToolBar style constants\nconst (\n\tTBSTYLE_BUTTON       = 0\n\tTBSTYLE_SEP          = 1\n\tTBSTYLE_CHECK        = 2\n\tTBSTYLE_GROUP        = 4\n\tTBSTYLE_CHECKGROUP   = TBSTYLE_GROUP | TBSTYLE_CHECK\n\tTBSTYLE_DROPDOWN     = 8\n\tTBSTYLE_AUTOSIZE     = 16\n\tTBSTYLE_NOPREFIX     = 32\n\tTBSTYLE_TOOLTIPS     = 256\n\tTBSTYLE_WRAPABLE     = 512\n\tTBSTYLE_ALTDRAG      = 1024\n\tTBSTYLE_FLAT         = 2048\n\tTBSTYLE_LIST         = 4096\n\tTBSTYLE_CUSTOMERASE  = 8192\n\tTBSTYLE_REGISTERDROP = 0x4000\n\tTBSTYLE_TRANSPARENT  = 0x8000\n)\n\n// ToolBar extended style constants\nconst (\n\tTBSTYLE_EX_DRAWDDARROWS       = 0x00000001\n\tTBSTYLE_EX_MIXEDBUTTONS       = 8\n\tTBSTYLE_EX_HIDECLIPPEDBUTTONS = 16\n\tTBSTYLE_EX_DOUBLEBUFFER       = 0x80\n)\n\n// ToolBar button style constants\nconst (\n\tBTNS_BUTTON        = TBSTYLE_BUTTON\n\tBTNS_SEP           = TBSTYLE_SEP\n\tBTNS_CHECK         = TBSTYLE_CHECK\n\tBTNS_GROUP         = TBSTYLE_GROUP\n\tBTNS_CHECKGROUP    = TBSTYLE_CHECKGROUP\n\tBTNS_DROPDOWN      = TBSTYLE_DROPDOWN\n\tBTNS_AUTOSIZE      = TBSTYLE_AUTOSIZE\n\tBTNS_NOPREFIX      = TBSTYLE_NOPREFIX\n\tBTNS_WHOLEDROPDOWN = 0x0080\n\tBTNS_SHOWTEXT      = 0x0040\n)\n\n// TBBUTTONINFO mask flags\nconst (\n\tTBIF_IMAGE   = 0x00000001\n\tTBIF_TEXT    = 0x00000002\n\tTBIF_STATE   = 0x00000004\n\tTBIF_STYLE   = 0x00000008\n\tTBIF_LPARAM  = 0x00000010\n\tTBIF_COMMAND = 0x00000020\n\tTBIF_SIZE    = 0x00000040\n\tTBIF_BYINDEX = 0x80000000\n)\n\ntype NMMOUSE struct {\n\tHdr        NMHDR\n\tDwItemSpec uintptr\n\tDwItemData uintptr\n\tPt         POINT\n\tDwHitInfo  uintptr\n}\n\ntype NMTOOLBAR struct {\n\tHdr      NMHDR\n\tIItem    int32\n\tTbButton TBBUTTON\n\tCchText  int32\n\tPszText  *uint16\n\tRcButton RECT\n}\n\ntype TBBUTTON struct {\n\tIBitmap   int32\n\tIdCommand int32\n\tFsState   byte\n\tFsStyle   byte\n\t//#ifdef _WIN64\n\t//    BYTE bReserved[6]          // padding for alignment\n\t//#elif defined(_WIN32)\n\tBReserved [2]byte // padding for alignment\n\t//#endif\n\tDwData  uintptr\n\tIString uintptr\n}\n\ntype TBBUTTONINFO struct {\n\tCbSize    uint32\n\tDwMask    uint32\n\tIdCommand int32\n\tIImage    int32\n\tFsState   byte\n\tFsStyle   byte\n\tCx        uint16\n\tLParam    uintptr\n\tPszText   uintptr\n\tCchText   int32\n}\n"
  },
  {
    "path": "w32/typedef.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"fmt\"\n\t\"unsafe\"\n)\n\n// From MSDN: Windows Data Types\n// http://msdn.microsoft.com/en-us/library/s3f49ktz.aspx\n// http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751.aspx\n// ATOM                  WORD\n// BOOL                  int32\n// BOOLEAN               byte\n// BYTE                  byte\n// CCHAR                 int8\n// CHAR                  int8\n// COLORREF              DWORD\n// DWORD                 uint32\n// DWORDLONG             ULONGLONG\n// DWORD_PTR             ULONG_PTR\n// DWORD32               uint32\n// DWORD64               uint64\n// FLOAT                 float32\n// HACCEL                HANDLE\n// HALF_PTR              struct{} // ???\n// HANDLE                PVOID\n// HBITMAP               HANDLE\n// HBRUSH                HANDLE\n// HCOLORSPACE           HANDLE\n// HCONV                 HANDLE\n// HCONVLIST             HANDLE\n// HCURSOR               HANDLE\n// HDC                   HANDLE\n// HDDEDATA              HANDLE\n// HDESK                 HANDLE\n// HDROP                 HANDLE\n// HDWP                  HANDLE\n// HENHMETAFILE          HANDLE\n// HFILE                 HANDLE\n// HFONT                 HANDLE\n// HGDIOBJ               HANDLE\n// HGLOBAL               HANDLE\n// HHOOK                 HANDLE\n// HICON                 HANDLE\n// HINSTANCE             HANDLE\n// HKEY                  HANDLE\n// HKL                   HANDLE\n// HLOCAL                HANDLE\n// HMENU                 HANDLE\n// HMETAFILE             HANDLE\n// HMODULE               HANDLE\n// HPALETTE              HANDLE\n// HPEN                  HANDLE\n// HRESULT               int32\n// HRGN                  HANDLE\n// HSZ                   HANDLE\n// HWINSTA               HANDLE\n// HWND                  HANDLE\n// INT                   int32\n// INT_PTR               uintptr\n// INT8                  int8\n// INT16                 int16\n// INT32                 int32\n// INT64                 int64\n// LANGID                WORD\n// LCID                  DWORD\n// LCTYPE                DWORD\n// LGRPID                DWORD\n// LONG                  int32\n// LONGLONG              int64\n// LONG_PTR              uintptr\n// LONG32                int32\n// LONG64                int64\n// LPARAM                LONG_PTR\n// LPBOOL                *BOOL\n// LPBYTE                *BYTE\n// LPCOLORREF            *COLORREF\n// LPCSTR                *int8\n// LPCTSTR               LPCWSTR\n// LPCVOID               unsafe.Pointer\n// LPCWSTR               *WCHAR\n// LPDWORD               *DWORD\n// LPHANDLE              *HANDLE\n// LPINT                 *INT\n// LPLONG                *LONG\n// LPSTR                 *CHAR\n// LPTSTR                LPWSTR\n// LPVOID                unsafe.Pointer\n// LPWORD                *WORD\n// LPWSTR                *WCHAR\n// LRESULT               LONG_PTR\n// PBOOL                 *BOOL\n// PBOOLEAN              *BOOLEAN\n// PBYTE                 *BYTE\n// PCHAR                 *CHAR\n// PCSTR                 *CHAR\n// PCTSTR                PCWSTR\n// PCWSTR                *WCHAR\n// PDWORD                *DWORD\n// PDWORDLONG            *DWORDLONG\n// PDWORD_PTR            *DWORD_PTR\n// PDWORD32              *DWORD32\n// PDWORD64              *DWORD64\n// PFLOAT                *FLOAT\n// PHALF_PTR             *HALF_PTR\n// PHANDLE               *HANDLE\n// PHKEY                 *HKEY\n// PINT_PTR              *INT_PTR\n// PINT8                 *INT8\n// PINT16                *INT16\n// PINT32                *INT32\n// PINT64                *INT64\n// PLCID                 *LCID\n// PLONG                 *LONG\n// PLONGLONG             *LONGLONG\n// PLONG_PTR             *LONG_PTR\n// PLONG32               *LONG32\n// PLONG64               *LONG64\n// POINTER_32            struct{} // ???\n// POINTER_64            struct{} // ???\n// POINTER_SIGNED        uintptr\n// POINTER_UNSIGNED      uintptr\n// PSHORT                *SHORT\n// PSIZE_T               *SIZE_T\n// PSSIZE_T              *SSIZE_T\n// PSTR                  *CHAR\n// PTBYTE                *TBYTE\n// PTCHAR                *TCHAR\n// PTSTR                 PWSTR\n// PUCHAR                *UCHAR\n// PUHALF_PTR            *UHALF_PTR\n// PUINT                 *UINT\n// PUINT_PTR             *UINT_PTR\n// PUINT8                *UINT8\n// PUINT16               *UINT16\n// PUINT32               *UINT32\n// PUINT64               *UINT64\n// PULONG                *ULONG\n// PULONGLONG            *ULONGLONG\n// PULONG_PTR            *ULONG_PTR\n// PULONG32              *ULONG32\n// PULONG64              *ULONG64\n// PUSHORT               *USHORT\n// PVOID                 unsafe.Pointer\n// PWCHAR                *WCHAR\n// PWORD                 *WORD\n// PWSTR                 *WCHAR\n// QWORD                 uint64\n// SC_HANDLE             HANDLE\n// SC_LOCK               LPVOID\n// SERVICE_STATUS_HANDLE HANDLE\n// SHORT                 int16\n// SIZE_T                ULONG_PTR\n// SSIZE_T               LONG_PTR\n// TBYTE                 WCHAR\n// TCHAR                 WCHAR\n// UCHAR                 uint8\n// UHALF_PTR             struct{} // ???\n// UINT                  uint32\n// UINT_PTR              uintptr\n// UINT8                 uint8\n// UINT16                uint16\n// UINT32                uint32\n// UINT64                uint64\n// ULONG                 uint32\n// ULONGLONG             uint64\n// ULONG_PTR             uintptr\n// ULONG32               uint32\n// ULONG64               uint64\n// USHORT                uint16\n// USN                   LONGLONG\n// WCHAR                 uint16\n// WORD                  uint16\n// WPARAM                UINT_PTR\ntype (\n\tATOM            = uint16\n\tBOOL            = int32\n\tCOLORREF        = uint32\n\tDWM_FRAME_COUNT = uint64\n\tWORD            = uint16\n\tDWORD           = uint32\n\tHACCEL          = HANDLE\n\tHANDLE          = uintptr\n\tHBITMAP         = HANDLE\n\tHBRUSH          = HANDLE\n\tHCURSOR         = HANDLE\n\tHDC             = HANDLE\n\tHDROP           = HANDLE\n\tHDWP            = HANDLE\n\tHENHMETAFILE    = HANDLE\n\tHFONT           = HANDLE\n\tHGDIOBJ         = HANDLE\n\tHGLOBAL         = HANDLE\n\tHGLRC           = HANDLE\n\tHHOOK           = HANDLE\n\tHICON           = HANDLE\n\tHIMAGELIST      = HANDLE\n\tHINSTANCE       = HANDLE\n\tHKEY            = HANDLE\n\tHKL             = HANDLE\n\tHMENU           = HANDLE\n\tHMODULE         = HANDLE\n\tHMONITOR        = HANDLE\n\tHPEN            = HANDLE\n\tHRESULT         = int32\n\tHRGN            = HANDLE\n\tHRSRC           = HANDLE\n\tHTHUMBNAIL      = HANDLE\n\tHWND            = HANDLE\n\tLPARAM          = uintptr\n\tLPCVOID         = unsafe.Pointer\n\tLRESULT         = uintptr\n\tPVOID           = unsafe.Pointer\n\tQPC_TIME        = uint64\n\tULONG_PTR       = uintptr\n\tSIZE_T          = ULONG_PTR\n\tWPARAM          = uintptr\n\tUINT            = uint\n)\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162805.aspx\ntype POINT struct {\n\tX, Y int32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162897.aspx\ntype RECT struct {\n\tLeft, Top, Right, Bottom int32\n}\n\nfunc (r *RECT) String() string {\n\treturn fmt.Sprintf(\"RECT (%p): Left: %d, Top: %d, Right: %d, Bottom: %d\", r, r.Left, r.Top, r.Right, r.Bottom)\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms633577.aspx\ntype WNDCLASSEX struct {\n\tSize       uint32\n\tStyle      uint32\n\tWndProc    uintptr\n\tClsExtra   int32\n\tWndExtra   int32\n\tInstance   HINSTANCE\n\tIcon       HICON\n\tCursor     HCURSOR\n\tBackground HBRUSH\n\tMenuName   *uint16\n\tClassName  *uint16\n\tIconSm     HICON\n}\n\ntype TPMPARAMS struct {\n\tCbSize    uint32\n\tRcExclude RECT\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms644958.aspx\ntype MSG struct {\n\tHwnd    HWND\n\tMessage uint32\n\tWParam  uintptr\n\tLParam  uintptr\n\tTime    uint32\n\tPt      POINT\n}\n\n// https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-minmaxinfo\ntype MINMAXINFO struct {\n\tPtReserved     POINT\n\tPtMaxSize      POINT\n\tPtMaxPosition  POINT\n\tPtMinTrackSize POINT\n\tPtMaxTrackSize POINT\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037.aspx\ntype LOGFONT struct {\n\tHeight         int32\n\tWidth          int32\n\tEscapement     int32\n\tOrientation    int32\n\tWeight         int32\n\tItalic         byte\n\tUnderline      byte\n\tStrikeOut      byte\n\tCharSet        byte\n\tOutPrecision   byte\n\tClipPrecision  byte\n\tQuality        byte\n\tPitchAndFamily byte\n\tFaceName       [LF_FACESIZE]uint16\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839.aspx\ntype OPENFILENAME struct {\n\tStructSize      uint32\n\tOwner           HWND\n\tInstance        HINSTANCE\n\tFilter          *uint16\n\tCustomFilter    *uint16\n\tMaxCustomFilter uint32\n\tFilterIndex     uint32\n\tFile            *uint16\n\tMaxFile         uint32\n\tFileTitle       *uint16\n\tMaxFileTitle    uint32\n\tInitialDir      *uint16\n\tTitle           *uint16\n\tFlags           uint32\n\tFileOffset      uint16\n\tFileExtension   uint16\n\tDefExt          *uint16\n\tCustData        uintptr\n\tFnHook          uintptr\n\tTemplateName    *uint16\n\tPvReserved      unsafe.Pointer\n\tDwReserved      uint32\n\tFlagsEx         uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb773205.aspx\ntype BROWSEINFO struct {\n\tOwner        HWND\n\tRoot         *uint16\n\tDisplayName  *uint16\n\tTitle        *uint16\n\tFlags        uint32\n\tCallbackFunc uintptr\n\tLParam       uintptr\n\tImage        int32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/aa373931.aspx\ntype GUID struct {\n\tData1 uint32\n\tData2 uint16\n\tData3 uint16\n\tData4 [8]byte\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms221627.aspx\ntype VARIANT struct {\n\tVT         uint16 //  2\n\tWReserved1 uint16 //  4\n\tWReserved2 uint16 //  6\n\tWReserved3 uint16 //  8\n\tVal        int64  // 16\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms221416.aspx\ntype DISPPARAMS struct {\n\tRgvarg            uintptr\n\tRgdispidNamedArgs uintptr\n\tCArgs             uint32\n\tCNamedArgs        uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms221133.aspx\ntype EXCEPINFO struct {\n\tWCode             uint16\n\tWReserved         uint16\n\tBstrSource        *uint16\n\tBstrDescription   *uint16\n\tBstrHelpFile      *uint16\n\tDwHelpContext     uint32\n\tPvReserved        uintptr\n\tPfnDeferredFillIn uintptr\n\tScode             int32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145035.aspx\ntype LOGBRUSH struct {\n\tLbStyle uint32\n\tLbColor COLORREF\n\tLbHatch uintptr\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565.aspx\ntype DEVMODE struct {\n\tDmDeviceName       [CCHDEVICENAME]uint16\n\tDmSpecVersion      uint16\n\tDmDriverVersion    uint16\n\tDmSize             uint16\n\tDmDriverExtra      uint16\n\tDmFields           uint32\n\tDmOrientation      int16\n\tDmPaperSize        int16\n\tDmPaperLength      int16\n\tDmPaperWidth       int16\n\tDmScale            int16\n\tDmCopies           int16\n\tDmDefaultSource    int16\n\tDmPrintQuality     int16\n\tDmColor            int16\n\tDmDuplex           int16\n\tDmYResolution      int16\n\tDmTTOption         int16\n\tDmCollate          int16\n\tDmFormName         [CCHFORMNAME]uint16\n\tDmLogPixels        uint16\n\tDmBitsPerPel       uint32\n\tDmPelsWidth        uint32\n\tDmPelsHeight       uint32\n\tDmDisplayFlags     uint32\n\tDmDisplayFrequency uint32\n\tDmICMMethod        uint32\n\tDmICMIntent        uint32\n\tDmMediaType        uint32\n\tDmDitherType       uint32\n\tDmReserved1        uint32\n\tDmReserved2        uint32\n\tDmPanningWidth     uint32\n\tDmPanningHeight    uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376.aspx\ntype BITMAPINFOHEADER struct {\n\tBiSize          uint32\n\tBiWidth         int32\n\tBiHeight        int32\n\tBiPlanes        uint16\n\tBiBitCount      uint16\n\tBiCompression   uint32\n\tBiSizeImage     uint32\n\tBiXPelsPerMeter int32\n\tBiYPelsPerMeter int32\n\tBiClrUsed       uint32\n\tBiClrImportant  uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162938.aspx\ntype RGBQUAD struct {\n\tRgbBlue     byte\n\tRgbGreen    byte\n\tRgbRed      byte\n\tRgbReserved byte\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183375.aspx\ntype BITMAPINFO struct {\n\tBmiHeader BITMAPINFOHEADER\n\tBmiColors *RGBQUAD\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183371.aspx\ntype BITMAP struct {\n\tBmType       int32\n\tBmWidth      int32\n\tBmHeight     int32\n\tBmWidthBytes int32\n\tBmPlanes     uint16\n\tBmBitsPixel  uint16\n\tBmBits       unsafe.Pointer\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183567.aspx\ntype DIBSECTION struct {\n\tDsBm        BITMAP\n\tDsBmih      BITMAPINFOHEADER\n\tDsBitfields [3]uint32\n\tDshSection  HANDLE\n\tDsOffset    uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162607.aspx\ntype ENHMETAHEADER struct {\n\tIType          uint32\n\tNSize          uint32\n\tRclBounds      RECT\n\tRclFrame       RECT\n\tDSignature     uint32\n\tNVersion       uint32\n\tNBytes         uint32\n\tNRecords       uint32\n\tNHandles       uint16\n\tSReserved      uint16\n\tNDescription   uint32\n\tOffDescription uint32\n\tNPalEntries    uint32\n\tSzlDevice      SIZE\n\tSzlMillimeters SIZE\n\tCbPixelFormat  uint32\n\tOffPixelFormat uint32\n\tBOpenGL        uint32\n\tSzlMicrometers SIZE\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145106.aspx\ntype SIZE struct {\n\tCX, CY int32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145132.aspx\ntype TEXTMETRIC struct {\n\tTmHeight           int32\n\tTmAscent           int32\n\tTmDescent          int32\n\tTmInternalLeading  int32\n\tTmExternalLeading  int32\n\tTmAveCharWidth     int32\n\tTmMaxCharWidth     int32\n\tTmWeight           int32\n\tTmOverhang         int32\n\tTmDigitizedAspectX int32\n\tTmDigitizedAspectY int32\n\tTmFirstChar        uint16\n\tTmLastChar         uint16\n\tTmDefaultChar      uint16\n\tTmBreakChar        uint16\n\tTmItalic           byte\n\tTmUnderlined       byte\n\tTmStruckOut        byte\n\tTmPitchAndFamily   byte\n\tTmCharSet          byte\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183574.aspx\ntype DOCINFO struct {\n\tCbSize       int32\n\tLpszDocName  *uint16\n\tLpszOutput   *uint16\n\tLpszDatatype *uint16\n\tFwType       uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb775514.aspx\ntype NMHDR struct {\n\tHwndFrom HWND\n\tIdFrom   uintptr\n\tCode     uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774743.aspx\ntype LVCOLUMN struct {\n\tMask       uint32\n\tFmt        int32\n\tCx         int32\n\tPszText    *uint16\n\tCchTextMax int32\n\tISubItem   int32\n\tIImage     int32\n\tIOrder     int32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774760.aspx\ntype LVITEM struct {\n\tMask       uint32\n\tIItem      int32\n\tISubItem   int32\n\tState      uint32\n\tStateMask  uint32\n\tPszText    *uint16\n\tCchTextMax int32\n\tIImage     int32\n\tLParam     uintptr\n\tIIndent    int32\n\tIGroupId   int32\n\tCColumns   uint32\n\tPuColumns  uint32\n}\n\ntype LVFINDINFO struct {\n\tFlags       uint32\n\tPszText     *uint16\n\tLParam      uintptr\n\tPt          POINT\n\tVkDirection uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774754.aspx\ntype LVHITTESTINFO struct {\n\tPt       POINT\n\tFlags    uint32\n\tIItem    int32\n\tISubItem int32\n\tIGroup   int32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774771.aspx\ntype NMITEMACTIVATE struct {\n\tHdr       NMHDR\n\tIItem     int32\n\tISubItem  int32\n\tUNewState uint32\n\tUOldState uint32\n\tUChanged  uint32\n\tPtAction  POINT\n\tLParam    uintptr\n\tUKeyFlags uint32\n}\n\ntype NMLVKEYDOWN struct {\n\tHdr   NMHDR\n\tWVKey uint16\n\tFlags uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774773.aspx\ntype NMLISTVIEW struct {\n\tHdr       NMHDR\n\tIItem     int32\n\tISubItem  int32\n\tUNewState uint32\n\tUOldState uint32\n\tUChanged  uint32\n\tPtAction  POINT\n\tLParam    uintptr\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774780.aspx\ntype NMLVDISPINFO struct {\n\tHdr  NMHDR\n\tItem LVITEM\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb775507.aspx\ntype INITCOMMONCONTROLSEX struct {\n\tDwSize uint32\n\tDwICC  uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb760256.aspx\ntype TOOLINFO struct {\n\tCbSize     uint32\n\tUFlags     uint32\n\tHwnd       HWND\n\tUId        uintptr\n\tRect       RECT\n\tHinst      HINSTANCE\n\tLpszText   *uint16\n\tLParam     uintptr\n\tLpReserved unsafe.Pointer\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms645604.aspx\ntype TRACKMOUSEEVENT struct {\n\tCbSize      uint32\n\tDwFlags     uint32\n\tHwndTrack   HWND\n\tDwHoverTime uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms534067.aspx\ntype GdiplusStartupInput struct {\n\tGdiplusVersion           uint32\n\tDebugEventCallback       uintptr\n\tSuppressBackgroundThread BOOL\n\tSuppressExternalCodecs   BOOL\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms534068.aspx\ntype GdiplusStartupOutput struct {\n\tNotificationHook   uintptr\n\tNotificationUnhook uintptr\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162768.aspx\ntype PAINTSTRUCT struct {\n\tHdc         HDC\n\tFErase      BOOL\n\tRcPaint     RECT\n\tFRestore    BOOL\n\tFIncUpdate  BOOL\n\tRgbReserved [32]byte\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/aa363646.aspx\ntype EVENTLOGRECORD struct {\n\tLength              uint32\n\tReserved            uint32\n\tRecordNumber        uint32\n\tTimeGenerated       uint32\n\tTimeWritten         uint32\n\tEventID             uint32\n\tEventType           uint16\n\tNumStrings          uint16\n\tEventCategory       uint16\n\tReservedFlags       uint16\n\tClosingRecordNumber uint32\n\tStringOffset        uint32\n\tUserSidLength       uint32\n\tUserSidOffset       uint32\n\tDataLength          uint32\n\tDataOffset          uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms685996.aspx\ntype SERVICE_STATUS struct {\n\tDwServiceType             uint32\n\tDwCurrentState            uint32\n\tDwControlsAccepted        uint32\n\tDwWin32ExitCode           uint32\n\tDwServiceSpecificExitCode uint32\n\tDwCheckPoint              uint32\n\tDwWaitHint                uint32\n}\n\n/* -------------------------\n    Undocumented API\n------------------------- */\n\ntype ACCENT_STATE DWORD\n\nconst (\n\tACCENT_DISABLED                   ACCENT_STATE = 0\n\tACCENT_ENABLE_GRADIENT            ACCENT_STATE = 1\n\tACCENT_ENABLE_TRANSPARENTGRADIENT ACCENT_STATE = 2\n\tACCENT_ENABLE_BLURBEHIND          ACCENT_STATE = 3\n\tACCENT_ENABLE_ACRYLICBLURBEHIND   ACCENT_STATE = 4 // RS4 1803\n\tACCENT_ENABLE_HOSTBACKDROP        ACCENT_STATE = 5 // RS5 1809\n\tACCENT_INVALID_STATE              ACCENT_STATE = 6\n)\n\ntype ACCENT_POLICY struct {\n\tAccentState   ACCENT_STATE\n\tAccentFlags   DWORD\n\tGradientColor DWORD\n\tAnimationId   DWORD\n}\n\ntype WINDOWCOMPOSITIONATTRIBDATA struct {\n\tAttrib WINDOWCOMPOSITIONATTRIB\n\tPvData PVOID\n\tCbData SIZE_T\n}\n\ntype WINDOWCOMPOSITIONATTRIB DWORD\n\nconst (\n\tWCA_UNDEFINED                     WINDOWCOMPOSITIONATTRIB = 0\n\tWCA_NCRENDERING_ENABLED           WINDOWCOMPOSITIONATTRIB = 1\n\tWCA_NCRENDERING_POLICY            WINDOWCOMPOSITIONATTRIB = 2\n\tWCA_TRANSITIONS_FORCEDISABLED     WINDOWCOMPOSITIONATTRIB = 3\n\tWCA_ALLOW_NCPAINT                 WINDOWCOMPOSITIONATTRIB = 4\n\tWCA_CAPTION_BUTTON_BOUNDS         WINDOWCOMPOSITIONATTRIB = 5\n\tWCA_NONCLIENT_RTL_LAYOUT          WINDOWCOMPOSITIONATTRIB = 6\n\tWCA_FORCE_ICONIC_REPRESENTATION   WINDOWCOMPOSITIONATTRIB = 7\n\tWCA_EXTENDED_FRAME_BOUNDS         WINDOWCOMPOSITIONATTRIB = 8\n\tWCA_HAS_ICONIC_BITMAP             WINDOWCOMPOSITIONATTRIB = 9\n\tWCA_THEME_ATTRIBUTES              WINDOWCOMPOSITIONATTRIB = 10\n\tWCA_NCRENDERING_EXILED            WINDOWCOMPOSITIONATTRIB = 11\n\tWCA_NCADORNMENTINFO               WINDOWCOMPOSITIONATTRIB = 12\n\tWCA_EXCLUDED_FROM_LIVEPREVIEW     WINDOWCOMPOSITIONATTRIB = 13\n\tWCA_VIDEO_OVERLAY_ACTIVE          WINDOWCOMPOSITIONATTRIB = 14\n\tWCA_FORCE_ACTIVEWINDOW_APPEARANCE WINDOWCOMPOSITIONATTRIB = 15\n\tWCA_DISALLOW_PEEK                 WINDOWCOMPOSITIONATTRIB = 16\n\tWCA_CLOAK                         WINDOWCOMPOSITIONATTRIB = 17\n\tWCA_CLOAKED                       WINDOWCOMPOSITIONATTRIB = 18\n\tWCA_ACCENT_POLICY                 WINDOWCOMPOSITIONATTRIB = 19\n\tWCA_FREEZE_REPRESENTATION         WINDOWCOMPOSITIONATTRIB = 20\n\tWCA_EVER_UNCLOAKED                WINDOWCOMPOSITIONATTRIB = 21\n\tWCA_VISUAL_OWNER                  WINDOWCOMPOSITIONATTRIB = 22\n\tWCA_HOLOGRAPHIC                   WINDOWCOMPOSITIONATTRIB = 23\n\tWCA_EXCLUDED_FROM_DDA             WINDOWCOMPOSITIONATTRIB = 24\n\tWCA_PASSIVEUPDATEMODE             WINDOWCOMPOSITIONATTRIB = 25\n\tWCA_USEDARKMODECOLORS             WINDOWCOMPOSITIONATTRIB = 26\n\tWCA_CORNER_STYLE                  WINDOWCOMPOSITIONATTRIB = 27\n\tWCA_PART_COLOR                    WINDOWCOMPOSITIONATTRIB = 28\n\tWCA_DISABLE_MOVESIZE_FEEDBACK     WINDOWCOMPOSITIONATTRIB = 29\n\tWCA_LAST                          WINDOWCOMPOSITIONATTRIB = 30\n)\n\n// -------------------------\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms684225.aspx\ntype MODULEENTRY32 struct {\n\tSize         uint32\n\tModuleID     uint32\n\tProcessID    uint32\n\tGlblcntUsage uint32\n\tProccntUsage uint32\n\tModBaseAddr  *uint8\n\tModBaseSize  uint32\n\tHModule      HMODULE\n\tSzModule     [MAX_MODULE_NAME32 + 1]uint16\n\tSzExePath    [MAX_PATH]uint16\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284.aspx\ntype FILETIME struct {\n\tDwLowDateTime  uint32\n\tDwHighDateTime uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119.aspx\ntype COORD struct {\n\tX, Y int16\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms686311.aspx\ntype SMALL_RECT struct {\n\tLeft, Top, Right, Bottom int16\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093.aspx\ntype CONSOLE_SCREEN_BUFFER_INFO struct {\n\tDwSize              COORD\n\tDwCursorPosition    COORD\n\tWAttributes         uint16\n\tSrWindow            SMALL_RECT\n\tDwMaximumWindowSize COORD\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/bb773244.aspx\ntype MARGINS struct {\n\tCxLeftWidth, CxRightWidth, CyTopHeight, CyBottomHeight int32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969500.aspx\ntype DWM_BLURBEHIND struct {\n\tDwFlags                uint32\n\tfEnable                BOOL\n\thRgnBlur               HRGN\n\tfTransitionOnMaximized BOOL\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969501.aspx\ntype DWM_PRESENT_PARAMETERS struct {\n\tcbSize             uint32\n\tfQueue             BOOL\n\tcRefreshStart      DWM_FRAME_COUNT\n\tcBuffer            uint32\n\tfUseSourceRate     BOOL\n\trateSource         UNSIGNED_RATIO\n\tcRefreshesPerFrame uint32\n\teSampling          DWM_SOURCE_FRAME_SAMPLING\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969502.aspx\ntype DWM_THUMBNAIL_PROPERTIES struct {\n\tdwFlags               uint32\n\trcDestination         RECT\n\trcSource              RECT\n\topacity               byte\n\tfVisible              BOOL\n\tfSourceClientAreaOnly BOOL\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969503.aspx\ntype DWM_TIMING_INFO struct {\n\tcbSize                 uint32\n\trateRefresh            UNSIGNED_RATIO\n\tqpcRefreshPeriod       QPC_TIME\n\trateCompose            UNSIGNED_RATIO\n\tqpcVBlank              QPC_TIME\n\tcRefresh               DWM_FRAME_COUNT\n\tcDXRefresh             uint32\n\tqpcCompose             QPC_TIME\n\tcFrame                 DWM_FRAME_COUNT\n\tcDXPresent             uint32\n\tcRefreshFrame          DWM_FRAME_COUNT\n\tcFrameSubmitted        DWM_FRAME_COUNT\n\tcDXPresentSubmitted    uint32\n\tcFrameConfirmed        DWM_FRAME_COUNT\n\tcDXPresentConfirmed    uint32\n\tcRefreshConfirmed      DWM_FRAME_COUNT\n\tcDXRefreshConfirmed    uint32\n\tcFramesLate            DWM_FRAME_COUNT\n\tcFramesOutstanding     uint32\n\tcFrameDisplayed        DWM_FRAME_COUNT\n\tqpcFrameDisplayed      QPC_TIME\n\tcRefreshFrameDisplayed DWM_FRAME_COUNT\n\tcFrameComplete         DWM_FRAME_COUNT\n\tqpcFrameComplete       QPC_TIME\n\tcFramePending          DWM_FRAME_COUNT\n\tqpcFramePending        QPC_TIME\n\tcFramesDisplayed       DWM_FRAME_COUNT\n\tcFramesComplete        DWM_FRAME_COUNT\n\tcFramesPending         DWM_FRAME_COUNT\n\tcFramesAvailable       DWM_FRAME_COUNT\n\tcFramesDropped         DWM_FRAME_COUNT\n\tcFramesMissed          DWM_FRAME_COUNT\n\tcRefreshNextDisplayed  DWM_FRAME_COUNT\n\tcRefreshNextPresented  DWM_FRAME_COUNT\n\tcRefreshesDisplayed    DWM_FRAME_COUNT\n\tcRefreshesPresented    DWM_FRAME_COUNT\n\tcRefreshStarted        DWM_FRAME_COUNT\n\tcPixelsReceived        uint64\n\tcPixelsDrawn           uint64\n\tcBuffersEmpty          DWM_FRAME_COUNT\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd389402.aspx\ntype MilMatrix3x2D struct {\n\tS_11, S_12, S_21, S_22 float64\n\tDX, DY                 float64\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969505.aspx\ntype UNSIGNED_RATIO struct {\n\tuiNumerator   uint32\n\tuiDenominator uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms632603.aspx\ntype CREATESTRUCT struct {\n\tCreateParams uintptr\n\tInstance     HINSTANCE\n\tMenu         HMENU\n\tParent       HWND\n\tCy, Cx       int32\n\tY, X         int32\n\tStyle        int32\n\tName         *uint16\n\tClass        *uint16\n\tdwExStyle    uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145065.aspx\ntype MONITORINFO struct {\n\tCbSize    uint32\n\tRcMonitor RECT\n\tRcWork    RECT\n\tDwFlags   uint32\n}\n\ntype WINDOWINFO struct {\n\tCbSize          DWORD\n\tRcWindow        RECT\n\tRcClient        RECT\n\tDwStyle         DWORD\n\tDwExStyle       DWORD\n\tDwWindowStatus  DWORD\n\tCxWindowBorders UINT\n\tCyWindowBorders UINT\n\tAtomWindowType  ATOM\n\tWCreatorVersion WORD\n}\n\ntype MONITOR_DPI_TYPE int32\n\nconst (\n\tMDT_EFFECTIVE_DPI MONITOR_DPI_TYPE = 0\n\tMDT_ANGULAR_DPI   MONITOR_DPI_TYPE = 1\n\tMDT_RAW_DPI       MONITOR_DPI_TYPE = 2\n\tMDT_DEFAULT       MONITOR_DPI_TYPE = 0\n)\n\nfunc (w *WINDOWINFO) isStyle(style DWORD) bool {\n\treturn w.DwStyle&style == style\n}\n\nfunc (w *WINDOWINFO) IsPopup() bool {\n\treturn w.isStyle(WS_POPUP)\n}\n\nfunc (m *MONITORINFO) Dump() {\n\tfmt.Printf(\"MONITORINFO (%p)\\n\", m)\n\tfmt.Printf(\"  CbSize   : %d\\n\", m.CbSize)\n\tfmt.Printf(\"  RcMonitor: %s\\n\", &m.RcMonitor)\n\tfmt.Printf(\"  RcWork   : %s\\n\", &m.RcWork)\n\tfmt.Printf(\"  DwFlags  : %d\\n\", m.DwFlags)\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145066.aspx\ntype MONITORINFOEX struct {\n\tMONITORINFO\n\tSzDevice [CCHDEVICENAME]uint16\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/dd368826.aspx\ntype PIXELFORMATDESCRIPTOR struct {\n\tSize                   uint16\n\tVersion                uint16\n\tDwFlags                uint32\n\tIPixelType             byte\n\tColorBits              byte\n\tRedBits, RedShift      byte\n\tGreenBits, GreenShift  byte\n\tBlueBits, BlueShift    byte\n\tAlphaBits, AlphaShift  byte\n\tAccumBits              byte\n\tAccumRedBits           byte\n\tAccumGreenBits         byte\n\tAccumBlueBits          byte\n\tAccumAlphaBits         byte\n\tDepthBits, StencilBits byte\n\tAuxBuffers             byte\n\tILayerType             byte\n\tReserved               byte\n\tDwLayerMask            uint32\n\tDwVisibleMask          uint32\n\tDwDamageMask           uint32\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646270(v=vs.85).aspx\ntype INPUT struct {\n\tType uint32\n\tMi   MOUSEINPUT\n\tKi   KEYBDINPUT\n\tHi   HARDWAREINPUT\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx\ntype MOUSEINPUT struct {\n\tDx          int32\n\tDy          int32\n\tMouseData   uint32\n\tDwFlags     uint32\n\tTime        uint32\n\tDwExtraInfo uintptr\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646271(v=vs.85).aspx\ntype KEYBDINPUT struct {\n\tWVk         uint16\n\tWScan       uint16\n\tDwFlags     uint32\n\tTime        uint32\n\tDwExtraInfo uintptr\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646269(v=vs.85).aspx\ntype HARDWAREINPUT struct {\n\tUMsg    uint32\n\tWParamL uint16\n\tWParamH uint16\n}\n\ntype KbdInput struct {\n\ttyp uint32\n\tki  KEYBDINPUT\n}\n\ntype MouseInput struct {\n\ttyp uint32\n\tmi  MOUSEINPUT\n}\n\ntype HardwareInput struct {\n\ttyp uint32\n\thi  HARDWAREINPUT\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx\ntype SYSTEMTIME struct {\n\tYear         uint16\n\tMonth        uint16\n\tDayOfWeek    uint16\n\tDay          uint16\n\tHour         uint16\n\tMinute       uint16\n\tSecond       uint16\n\tMilliseconds uint16\n}\n\n// http://msdn.microsoft.com/en-us/library/windows/desktop/ms644967(v=vs.85).aspx\ntype KBDLLHOOKSTRUCT struct {\n\tVkCode      DWORD\n\tScanCode    DWORD\n\tFlags       DWORD\n\tTime        DWORD\n\tDwExtraInfo ULONG_PTR\n}\n\ntype HOOKPROC func(int, WPARAM, LPARAM) LRESULT\n\ntype WINDOWPLACEMENT struct {\n\tLength           uint32\n\tFlags            uint32\n\tShowCmd          uint32\n\tPtMinPosition    POINT\n\tPtMaxPosition    POINT\n\tRcNormalPosition RECT\n}\n\ntype SCROLLINFO struct {\n\tCbSize    uint32\n\tFMask     uint32\n\tNMin      int32\n\tNMax      int32\n\tNPage     uint32\n\tNPos      int32\n\tNTrackPos int32\n}\n"
  },
  {
    "path": "w32/user32.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"fmt\"\n\t\"runtime\"\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nvar (\n\tmoduser32 = syscall.NewLazyDLL(\"user32.dll\")\n\n\tprocRegisterClassEx               = moduser32.NewProc(\"RegisterClassExW\")\n\tprocLoadIcon                      = moduser32.NewProc(\"LoadIconW\")\n\tprocLoadCursor                    = moduser32.NewProc(\"LoadCursorW\")\n\tprocShowWindow                    = moduser32.NewProc(\"ShowWindow\")\n\tprocShowWindowAsync               = moduser32.NewProc(\"ShowWindowAsync\")\n\tprocUpdateWindow                  = moduser32.NewProc(\"UpdateWindow\")\n\tprocCreateWindowEx                = moduser32.NewProc(\"CreateWindowExW\")\n\tprocAdjustWindowRect              = moduser32.NewProc(\"AdjustWindowRect\")\n\tprocAdjustWindowRectEx            = moduser32.NewProc(\"AdjustWindowRectEx\")\n\tprocDestroyWindow                 = moduser32.NewProc(\"DestroyWindow\")\n\tprocDefWindowProc                 = moduser32.NewProc(\"DefWindowProcW\")\n\tprocDefDlgProc                    = moduser32.NewProc(\"DefDlgProcW\")\n\tprocPostQuitMessage               = moduser32.NewProc(\"PostQuitMessage\")\n\tprocGetMessage                    = moduser32.NewProc(\"GetMessageW\")\n\tprocTranslateMessage              = moduser32.NewProc(\"TranslateMessage\")\n\tprocDispatchMessage               = moduser32.NewProc(\"DispatchMessageW\")\n\tprocSendMessage                   = moduser32.NewProc(\"SendMessageW\")\n\tprocPostMessage                   = moduser32.NewProc(\"PostMessageW\")\n\tprocWaitMessage                   = moduser32.NewProc(\"WaitMessage\")\n\tprocSetWindowText                 = moduser32.NewProc(\"SetWindowTextW\")\n\tprocGetWindowTextLength           = moduser32.NewProc(\"GetWindowTextLengthW\")\n\tprocGetWindowText                 = moduser32.NewProc(\"GetWindowTextW\")\n\tprocGetWindowRect                 = moduser32.NewProc(\"GetWindowRect\")\n\tprocGetWindowInfo                 = moduser32.NewProc(\"GetWindowInfo\")\n\tprocSetWindowCompositionAttribute = moduser32.NewProc(\"SetWindowCompositionAttribute\")\n\tprocMoveWindow                    = moduser32.NewProc(\"MoveWindow\")\n\tprocScreenToClient                = moduser32.NewProc(\"ScreenToClient\")\n\tprocCallWindowProc                = moduser32.NewProc(\"CallWindowProcW\")\n\tprocSetWindowLong                 = moduser32.NewProc(\"SetWindowLongW\")\n\tprocSetWindowLongPtr              = moduser32.NewProc(\"SetWindowLongW\")\n\tprocGetWindowLong                 = moduser32.NewProc(\"GetWindowLongW\")\n\tprocGetWindowLongPtr              = moduser32.NewProc(\"GetWindowLongW\")\n\tprocEnableWindow                  = moduser32.NewProc(\"EnableWindow\")\n\tprocIsWindowEnabled               = moduser32.NewProc(\"IsWindowEnabled\")\n\tprocIsWindowVisible               = moduser32.NewProc(\"IsWindowVisible\")\n\tprocSetFocus                      = moduser32.NewProc(\"SetFocus\")\n\tprocGetFocus                      = moduser32.NewProc(\"GetFocus\")\n\tprocSetActiveWindow               = moduser32.NewProc(\"SetActiveWindow\")\n\tprocSetForegroundWindow           = moduser32.NewProc(\"SetForegroundWindow\")\n\tprocBringWindowToTop              = moduser32.NewProc(\"BringWindowToTop\")\n\tprocInvalidateRect                = moduser32.NewProc(\"InvalidateRect\")\n\tprocGetClientRect                 = moduser32.NewProc(\"GetClientRect\")\n\tprocGetDC                         = moduser32.NewProc(\"GetDC\")\n\tprocReleaseDC                     = moduser32.NewProc(\"ReleaseDC\")\n\tprocSetCapture                    = moduser32.NewProc(\"SetCapture\")\n\tprocReleaseCapture                = moduser32.NewProc(\"ReleaseCapture\")\n\tprocGetWindowThreadProcessId      = moduser32.NewProc(\"GetWindowThreadProcessId\")\n\tprocMessageBox                    = moduser32.NewProc(\"MessageBoxW\")\n\tprocGetSystemMetrics              = moduser32.NewProc(\"GetSystemMetrics\")\n\tprocPostThreadMessageW            = moduser32.NewProc(\"PostThreadMessageW\")\n\t//procSysColorBrush            = moduser32.NewProc(\"GetSysColorBrush\")\n\tprocCopyRect          = moduser32.NewProc(\"CopyRect\")\n\tprocEqualRect         = moduser32.NewProc(\"EqualRect\")\n\tprocInflateRect       = moduser32.NewProc(\"InflateRect\")\n\tprocIntersectRect     = moduser32.NewProc(\"IntersectRect\")\n\tprocIsRectEmpty       = moduser32.NewProc(\"IsRectEmpty\")\n\tprocOffsetRect        = moduser32.NewProc(\"OffsetRect\")\n\tprocPtInRect          = moduser32.NewProc(\"PtInRect\")\n\tprocSetRect           = moduser32.NewProc(\"SetRect\")\n\tprocSetRectEmpty      = moduser32.NewProc(\"SetRectEmpty\")\n\tprocSubtractRect      = moduser32.NewProc(\"SubtractRect\")\n\tprocUnionRect         = moduser32.NewProc(\"UnionRect\")\n\tprocCreateDialogParam = moduser32.NewProc(\"CreateDialogParamW\")\n\tprocDialogBoxParam    = moduser32.NewProc(\"DialogBoxParamW\")\n\tprocGetDlgItem        = moduser32.NewProc(\"GetDlgItem\")\n\tprocDrawIcon          = moduser32.NewProc(\"DrawIcon\")\n\tprocCreateMenu        = moduser32.NewProc(\"CreateMenu\")\n\t//procSetMenu                  = moduser32.NewProc(\"SetMenu\")\n\tprocDestroyMenu        = moduser32.NewProc(\"DestroyMenu\")\n\tprocCreatePopupMenu    = moduser32.NewProc(\"CreatePopupMenu\")\n\tprocCheckMenuRadioItem = moduser32.NewProc(\"CheckMenuRadioItem\")\n\t//procDrawMenuBar     = moduser32.NewProc(\"DrawMenuBar\")\n\t//procInsertMenuItem                = moduser32.NewProc(\"InsertMenuItemW\") // FIXIT:\n\n\tprocClientToScreen                = moduser32.NewProc(\"ClientToScreen\")\n\tprocIsDialogMessage               = moduser32.NewProc(\"IsDialogMessageW\")\n\tprocIsWindow                      = moduser32.NewProc(\"IsWindow\")\n\tprocEndDialog                     = moduser32.NewProc(\"EndDialog\")\n\tprocPeekMessage                   = moduser32.NewProc(\"PeekMessageW\")\n\tprocTranslateAccelerator          = moduser32.NewProc(\"TranslateAcceleratorW\")\n\tprocSetWindowPos                  = moduser32.NewProc(\"SetWindowPos\")\n\tprocFillRect                      = moduser32.NewProc(\"FillRect\")\n\tprocDrawText                      = moduser32.NewProc(\"DrawTextW\")\n\tprocAddClipboardFormatListener    = moduser32.NewProc(\"AddClipboardFormatListener\")\n\tprocRemoveClipboardFormatListener = moduser32.NewProc(\"RemoveClipboardFormatListener\")\n\tprocOpenClipboard                 = moduser32.NewProc(\"OpenClipboard\")\n\tprocCloseClipboard                = moduser32.NewProc(\"CloseClipboard\")\n\tprocEnumClipboardFormats          = moduser32.NewProc(\"EnumClipboardFormats\")\n\tprocGetClipboardData              = moduser32.NewProc(\"GetClipboardData\")\n\tprocSetClipboardData              = moduser32.NewProc(\"SetClipboardData\")\n\tprocEmptyClipboard                = moduser32.NewProc(\"EmptyClipboard\")\n\tprocGetClipboardFormatName        = moduser32.NewProc(\"GetClipboardFormatNameW\")\n\tprocIsClipboardFormatAvailable    = moduser32.NewProc(\"IsClipboardFormatAvailable\")\n\tprocBeginPaint                    = moduser32.NewProc(\"BeginPaint\")\n\tprocEndPaint                      = moduser32.NewProc(\"EndPaint\")\n\tprocGetKeyboardState              = moduser32.NewProc(\"GetKeyboardState\")\n\tprocMapVirtualKey                 = moduser32.NewProc(\"MapVirtualKeyExW\")\n\tprocGetAsyncKeyState              = moduser32.NewProc(\"GetAsyncKeyState\")\n\tprocToAscii                       = moduser32.NewProc(\"ToAscii\")\n\tprocSwapMouseButton               = moduser32.NewProc(\"SwapMouseButton\")\n\tprocGetCursorPos                  = moduser32.NewProc(\"GetCursorPos\")\n\tprocSetCursorPos                  = moduser32.NewProc(\"SetCursorPos\")\n\tprocSetCursor                     = moduser32.NewProc(\"SetCursor\")\n\tprocCreateIcon                    = moduser32.NewProc(\"CreateIcon\")\n\tprocDestroyIcon                   = moduser32.NewProc(\"DestroyIcon\")\n\tprocMonitorFromPoint              = moduser32.NewProc(\"MonitorFromPoint\")\n\tprocMonitorFromRect               = moduser32.NewProc(\"MonitorFromRect\")\n\tprocMonitorFromWindow             = moduser32.NewProc(\"MonitorFromWindow\")\n\tprocGetMonitorInfo                = moduser32.NewProc(\"GetMonitorInfoW\")\n\tprocEnumDisplayMonitors           = moduser32.NewProc(\"EnumDisplayMonitors\")\n\tprocEnumDisplaySettingsEx         = moduser32.NewProc(\"EnumDisplaySettingsExW\")\n\tprocChangeDisplaySettingsEx       = moduser32.NewProc(\"ChangeDisplaySettingsExW\")\n\tprocSendInput                     = moduser32.NewProc(\"SendInput\")\n\tprocSetWindowsHookEx              = moduser32.NewProc(\"SetWindowsHookExW\")\n\tprocUnhookWindowsHookEx           = moduser32.NewProc(\"UnhookWindowsHookEx\")\n\tprocCallNextHookEx                = moduser32.NewProc(\"CallNextHookEx\")\n\n\tlibuser32, _        = syscall.LoadLibrary(\"user32.dll\")\n\tinsertMenuItem, _   = syscall.GetProcAddress(libuser32, \"InsertMenuItemW\")\n\tsetMenuItemInfo, _  = syscall.GetProcAddress(libuser32, \"SetMenuItemInfoW\")\n\tsetMenu, _          = syscall.GetProcAddress(libuser32, \"SetMenu\")\n\tdrawMenuBar, _      = syscall.GetProcAddress(libuser32, \"DrawMenuBar\")\n\ttrackPopupMenuEx, _ = syscall.GetProcAddress(libuser32, \"TrackPopupMenuEx\")\n\tgetKeyState, _      = syscall.GetProcAddress(libuser32, \"GetKeyState\")\n\tgetSysColorBrush, _ = syscall.GetProcAddress(libuser32, \"GetSysColorBrush\")\n\n\tgetWindowPlacement, _ = syscall.GetProcAddress(libuser32, \"GetWindowPlacement\")\n\tsetWindowPlacement, _ = syscall.GetProcAddress(libuser32, \"SetWindowPlacement\")\n\n\tsetScrollInfo, _ = syscall.GetProcAddress(libuser32, \"SetScrollInfo\")\n\tgetScrollInfo, _ = syscall.GetProcAddress(libuser32, \"GetScrollInfo\")\n\n\tmainThread HANDLE\n)\n\nfunc init() {\n\truntime.LockOSThread()\n\tmainThread = GetCurrentThreadId()\n}\n\nfunc GET_X_LPARAM(lp uintptr) int32 {\n\treturn int32(int16(LOWORD(uint32(lp))))\n}\n\nfunc GET_Y_LPARAM(lp uintptr) int32 {\n\treturn int32(int16(HIWORD(uint32(lp))))\n}\n\nfunc RegisterClassEx(wndClassEx *WNDCLASSEX) ATOM {\n\tret, _, _ := procRegisterClassEx.Call(uintptr(unsafe.Pointer(wndClassEx)))\n\treturn ATOM(ret)\n}\n\nfunc LoadIcon(instance HINSTANCE, iconName *uint16) HICON {\n\tret, _, _ := procLoadIcon.Call(\n\t\tuintptr(instance),\n\t\tuintptr(unsafe.Pointer(iconName)))\n\n\treturn HICON(ret)\n}\n\nfunc LoadCursor(instance HINSTANCE, cursorName *uint16) HCURSOR {\n\tret, _, _ := procLoadCursor.Call(\n\t\tuintptr(instance),\n\t\tuintptr(unsafe.Pointer(cursorName)))\n\n\treturn HCURSOR(ret)\n\n}\n\nfunc ShowWindow(hwnd HWND, cmdshow int) bool {\n\tret, _, _ := procShowWindow.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(cmdshow))\n\n\treturn ret != 0\n}\n\nfunc ShowWindowAsync(hwnd HWND, cmdshow int) bool {\n\tret, _, _ := procShowWindowAsync.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(cmdshow))\n\n\treturn ret != 0\n}\n\nfunc UpdateWindow(hwnd HWND) bool {\n\tret, _, _ := procUpdateWindow.Call(\n\t\tuintptr(hwnd))\n\treturn ret != 0\n}\n\nfunc PostThreadMessage(threadID HANDLE, msg int, wp, lp uintptr) {\n\tprocPostThreadMessageW.Call(threadID, uintptr(msg), wp, lp)\n}\n\nfunc PostMainThreadMessage(msg uint32, wp, lp uintptr) bool {\n\tret, _, _ := procPostThreadMessageW.Call(mainThread, uintptr(msg), wp, lp)\n\treturn ret != 0\n}\n\nfunc CreateWindowEx(exStyle uint, className, windowName *uint16,\n\tstyle uint, x, y, width, height int, parent HWND, menu HMENU,\n\tinstance HINSTANCE, param unsafe.Pointer) HWND {\n\tret, _, _ := procCreateWindowEx.Call(\n\t\tuintptr(exStyle),\n\t\tuintptr(unsafe.Pointer(className)),\n\t\tuintptr(unsafe.Pointer(windowName)),\n\t\tuintptr(style),\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t\tuintptr(width),\n\t\tuintptr(height),\n\t\tuintptr(parent),\n\t\tuintptr(menu),\n\t\tuintptr(instance),\n\t\tuintptr(param))\n\n\treturn HWND(ret)\n}\n\nfunc AdjustWindowRectEx(rect *RECT, style uint, menu bool, exStyle uint) bool {\n\tret, _, _ := procAdjustWindowRectEx.Call(\n\t\tuintptr(unsafe.Pointer(rect)),\n\t\tuintptr(style),\n\t\tuintptr(BoolToBOOL(menu)),\n\t\tuintptr(exStyle))\n\n\treturn ret != 0\n}\n\nfunc AdjustWindowRect(rect *RECT, style uint, menu bool) bool {\n\tret, _, _ := procAdjustWindowRect.Call(\n\t\tuintptr(unsafe.Pointer(rect)),\n\t\tuintptr(style),\n\t\tuintptr(BoolToBOOL(menu)))\n\n\treturn ret != 0\n}\n\nfunc DestroyWindow(hwnd HWND) bool {\n\tret, _, _ := procDestroyWindow.Call(hwnd)\n\treturn ret != 0\n}\n\nfunc SetWindowCompositionAttribute(hwnd HWND, data *WINDOWCOMPOSITIONATTRIBDATA) bool {\n\tif procSetWindowCompositionAttribute != nil {\n\t\tret, _, _ := procSetWindowCompositionAttribute.Call(\n\t\t\thwnd,\n\t\t\tuintptr(unsafe.Pointer(data)),\n\t\t)\n\t\treturn ret != 0\n\t}\n\treturn false\n}\n\nfunc DefWindowProc(hwnd HWND, msg uint32, wParam, lParam uintptr) uintptr {\n\tret, _, _ := procDefWindowProc.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(msg),\n\t\twParam,\n\t\tlParam)\n\n\treturn ret\n}\n\nfunc DefDlgProc(hwnd HWND, msg uint32, wParam, lParam uintptr) uintptr {\n\tret, _, _ := procDefDlgProc.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(msg),\n\t\twParam,\n\t\tlParam)\n\n\treturn ret\n}\n\nfunc PostQuitMessage(exitCode int) {\n\tprocPostQuitMessage.Call(\n\t\tuintptr(exitCode))\n}\n\nfunc GetMessage(msg *MSG, hwnd HWND, msgFilterMin, msgFilterMax uint32) int {\n\tret, _, _ := procGetMessage.Call(\n\t\tuintptr(unsafe.Pointer(msg)),\n\t\tuintptr(hwnd),\n\t\tuintptr(msgFilterMin),\n\t\tuintptr(msgFilterMax))\n\n\treturn int(ret)\n}\n\nfunc TranslateMessage(msg *MSG) bool {\n\tret, _, _ := procTranslateMessage.Call(\n\t\tuintptr(unsafe.Pointer(msg)))\n\n\treturn ret != 0\n\n}\n\nfunc DispatchMessage(msg *MSG) uintptr {\n\tret, _, _ := procDispatchMessage.Call(\n\t\tuintptr(unsafe.Pointer(msg)))\n\n\treturn ret\n\n}\n\nfunc SendMessage(hwnd HWND, msg uint32, wParam, lParam uintptr) uintptr {\n\tret, _, _ := procSendMessage.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(msg),\n\t\twParam,\n\t\tlParam)\n\n\treturn ret\n}\n\nfunc PostMessage(hwnd HWND, msg uint32, wParam, lParam uintptr) bool {\n\tret, _, _ := procPostMessage.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(msg),\n\t\twParam,\n\t\tlParam)\n\n\treturn ret != 0\n}\n\nfunc WaitMessage() bool {\n\tret, _, _ := procWaitMessage.Call()\n\treturn ret != 0\n}\n\nfunc SetWindowText(hwnd HWND, text string) {\n\tprocSetWindowText.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))))\n}\n\nfunc GetWindowTextLength(hwnd HWND) int {\n\tret, _, _ := procGetWindowTextLength.Call(\n\t\tuintptr(hwnd))\n\n\treturn int(ret)\n}\n\nfunc GetWindowInfo(hwnd HWND, info *WINDOWINFO) int {\n\tret, _, _ := procGetWindowInfo.Call(\n\t\thwnd,\n\t\tuintptr(unsafe.Pointer(info)),\n\t)\n\treturn int(ret)\n}\n\nfunc GetWindowText(hwnd HWND) string {\n\ttextLen := GetWindowTextLength(hwnd) + 1\n\n\tbuf := make([]uint16, textLen)\n\tprocGetWindowText.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(&buf[0])),\n\t\tuintptr(textLen))\n\n\treturn syscall.UTF16ToString(buf)\n}\n\nfunc GetWindowRect(hwnd HWND) *RECT {\n\tvar rect RECT\n\tprocGetWindowRect.Call(\n\t\thwnd,\n\t\tuintptr(unsafe.Pointer(&rect)))\n\n\treturn &rect\n}\n\nfunc MoveWindow(hwnd HWND, x, y, width, height int, repaint bool) bool {\n\tret, _, _ := procMoveWindow.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t\tuintptr(width),\n\t\tuintptr(height),\n\t\tuintptr(BoolToBOOL(repaint)))\n\n\treturn ret != 0\n\n}\n\nfunc ScreenToClient(hwnd HWND, x, y int) (X, Y int, ok bool) {\n\tpt := POINT{X: int32(x), Y: int32(y)}\n\tret, _, _ := procScreenToClient.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(&pt)))\n\n\treturn int(pt.X), int(pt.Y), ret != 0\n}\n\nfunc CallWindowProc(preWndProc uintptr, hwnd HWND, msg uint32, wParam, lParam uintptr) uintptr {\n\tret, _, _ := procCallWindowProc.Call(\n\t\tpreWndProc,\n\t\tuintptr(hwnd),\n\t\tuintptr(msg),\n\t\twParam,\n\t\tlParam)\n\n\treturn ret\n}\n\nfunc SetWindowLong(hwnd HWND, index int, value uint32) uint32 {\n\tret, _, _ := procSetWindowLong.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(index),\n\t\tuintptr(value))\n\n\treturn uint32(ret)\n}\n\nfunc SetWindowLongPtr(hwnd HWND, index int, value uintptr) uintptr {\n\tret, _, _ := procSetWindowLongPtr.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(index),\n\t\tvalue)\n\n\treturn ret\n}\n\nfunc GetWindowLong(hwnd HWND, index int) int32 {\n\tret, _, _ := procGetWindowLong.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(index))\n\n\treturn int32(ret)\n}\n\nfunc GetWindowLongPtr(hwnd HWND, index int) uintptr {\n\tret, _, _ := procGetWindowLongPtr.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(index))\n\n\treturn ret\n}\n\nfunc EnableWindow(hwnd HWND, b bool) bool {\n\tret, _, _ := procEnableWindow.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(BoolToBOOL(b)))\n\treturn ret != 0\n}\n\nfunc IsWindowEnabled(hwnd HWND) bool {\n\tret, _, _ := procIsWindowEnabled.Call(\n\t\tuintptr(hwnd))\n\n\treturn ret != 0\n}\n\nfunc IsWindowVisible(hwnd HWND) bool {\n\tret, _, _ := procIsWindowVisible.Call(\n\t\tuintptr(hwnd))\n\n\treturn ret != 0\n}\n\nfunc SetFocus(hwnd HWND) HWND {\n\tret, _, _ := procSetFocus.Call(\n\t\tuintptr(hwnd))\n\n\treturn HWND(ret)\n}\n\nfunc SetActiveWindow(hwnd HWND) HWND {\n\tret, _, _ := procSetActiveWindow.Call(\n\t\tuintptr(hwnd))\n\n\treturn HWND(ret)\n}\n\nfunc BringWindowToTop(hwnd HWND) bool {\n\tret, _, _ := procBringWindowToTop.Call(uintptr(hwnd))\n\treturn ret != 0\n}\n\nfunc SetForegroundWindow(hwnd HWND) HWND {\n\tret, _, _ := procSetForegroundWindow.Call(\n\t\tuintptr(hwnd))\n\n\treturn HWND(ret)\n}\n\nfunc GetFocus() HWND {\n\tret, _, _ := procGetFocus.Call()\n\treturn HWND(ret)\n}\n\nfunc InvalidateRect(hwnd HWND, rect *RECT, erase bool) bool {\n\tret, _, _ := procInvalidateRect.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(rect)),\n\t\tuintptr(BoolToBOOL(erase)))\n\n\treturn ret != 0\n}\n\nfunc GetClientRect(hwnd HWND) *RECT {\n\tvar rect RECT\n\tret, _, _ := procGetClientRect.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(&rect)))\n\n\tif ret == 0 {\n\t\tpanic(fmt.Sprintf(\"GetClientRect(%d) failed\", hwnd))\n\t}\n\n\treturn &rect\n}\n\nfunc GetDC(hwnd HWND) HDC {\n\tret, _, _ := procGetDC.Call(\n\t\tuintptr(hwnd))\n\n\treturn HDC(ret)\n}\n\nfunc ReleaseDC(hwnd HWND, hDC HDC) bool {\n\tret, _, _ := procReleaseDC.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(hDC))\n\n\treturn ret != 0\n}\n\nfunc SetCapture(hwnd HWND) HWND {\n\tret, _, _ := procSetCapture.Call(\n\t\tuintptr(hwnd))\n\n\treturn HWND(ret)\n}\n\nfunc ReleaseCapture() bool {\n\tret, _, _ := procReleaseCapture.Call()\n\n\treturn ret != 0\n}\n\nfunc GetWindowThreadProcessId(hwnd HWND) (HANDLE, int) {\n\tvar processId int\n\tret, _, _ := procGetWindowThreadProcessId.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(&processId)))\n\n\treturn HANDLE(ret), processId\n}\n\nfunc MessageBox(hwnd HWND, title, caption string, flags uint) int {\n\tret, _, _ := procMessageBox.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))),\n\t\tuintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),\n\t\tuintptr(flags))\n\n\treturn int(ret)\n}\n\nfunc GetSystemMetrics(index int) int {\n\tret, _, _ := procGetSystemMetrics.Call(\n\t\tuintptr(index))\n\n\treturn int(ret)\n}\n\nfunc GetSysColorBrush(nIndex int) HBRUSH {\n\t/*\n\t\tret, _, _ := procSysColorBrush.Call(1,\n\t\t\tuintptr(nIndex),\n\t\t\t0,\n\t\t\t0)\n\n\t\treturn HBRUSH(ret)\n\t*/\n\tret, _, _ := syscall.Syscall(getSysColorBrush, 1,\n\t\tuintptr(nIndex),\n\t\t0,\n\t\t0)\n\n\treturn HBRUSH(ret)\n}\n\nfunc CopyRect(dst, src *RECT) bool {\n\tret, _, _ := procCopyRect.Call(\n\t\tuintptr(unsafe.Pointer(dst)),\n\t\tuintptr(unsafe.Pointer(src)))\n\n\treturn ret != 0\n}\n\nfunc EqualRect(rect1, rect2 *RECT) bool {\n\tret, _, _ := procEqualRect.Call(\n\t\tuintptr(unsafe.Pointer(rect1)),\n\t\tuintptr(unsafe.Pointer(rect2)))\n\n\treturn ret != 0\n}\n\nfunc InflateRect(rect *RECT, dx, dy int) bool {\n\tret, _, _ := procInflateRect.Call(\n\t\tuintptr(unsafe.Pointer(rect)),\n\t\tuintptr(dx),\n\t\tuintptr(dy))\n\n\treturn ret != 0\n}\n\nfunc IntersectRect(dst, src1, src2 *RECT) bool {\n\tret, _, _ := procIntersectRect.Call(\n\t\tuintptr(unsafe.Pointer(dst)),\n\t\tuintptr(unsafe.Pointer(src1)),\n\t\tuintptr(unsafe.Pointer(src2)))\n\n\treturn ret != 0\n}\n\nfunc IsRectEmpty(rect *RECT) bool {\n\tret, _, _ := procIsRectEmpty.Call(\n\t\tuintptr(unsafe.Pointer(rect)))\n\n\treturn ret != 0\n}\n\nfunc OffsetRect(rect *RECT, dx, dy int) bool {\n\tret, _, _ := procOffsetRect.Call(\n\t\tuintptr(unsafe.Pointer(rect)),\n\t\tuintptr(dx),\n\t\tuintptr(dy))\n\n\treturn ret != 0\n}\n\nfunc PtInRect(rect *RECT, x, y int) bool {\n\tpt := POINT{X: int32(x), Y: int32(y)}\n\tret, _, _ := procPtInRect.Call(\n\t\tuintptr(unsafe.Pointer(rect)),\n\t\tuintptr(unsafe.Pointer(&pt)))\n\n\treturn ret != 0\n}\n\nfunc SetRect(rect *RECT, left, top, right, bottom int) bool {\n\tret, _, _ := procSetRect.Call(\n\t\tuintptr(unsafe.Pointer(rect)),\n\t\tuintptr(left),\n\t\tuintptr(top),\n\t\tuintptr(right),\n\t\tuintptr(bottom))\n\n\treturn ret != 0\n}\n\nfunc SetRectEmpty(rect *RECT) bool {\n\tret, _, _ := procSetRectEmpty.Call(\n\t\tuintptr(unsafe.Pointer(rect)))\n\n\treturn ret != 0\n}\n\nfunc SubtractRect(dst, src1, src2 *RECT) bool {\n\tret, _, _ := procSubtractRect.Call(\n\t\tuintptr(unsafe.Pointer(dst)),\n\t\tuintptr(unsafe.Pointer(src1)),\n\t\tuintptr(unsafe.Pointer(src2)))\n\n\treturn ret != 0\n}\n\nfunc UnionRect(dst, src1, src2 *RECT) bool {\n\tret, _, _ := procUnionRect.Call(\n\t\tuintptr(unsafe.Pointer(dst)),\n\t\tuintptr(unsafe.Pointer(src1)),\n\t\tuintptr(unsafe.Pointer(src2)))\n\n\treturn ret != 0\n}\n\nfunc CreateDialog(hInstance HINSTANCE, lpTemplate *uint16, hWndParent HWND, lpDialogProc uintptr) HWND {\n\tret, _, _ := procCreateDialogParam.Call(\n\t\tuintptr(hInstance),\n\t\tuintptr(unsafe.Pointer(lpTemplate)),\n\t\tuintptr(hWndParent),\n\t\tlpDialogProc,\n\t\t0)\n\n\treturn HWND(ret)\n}\n\nfunc DialogBox(hInstance HINSTANCE, lpTemplateName *uint16, hWndParent HWND, lpDialogProc uintptr) int {\n\tret, _, _ := procDialogBoxParam.Call(\n\t\tuintptr(hInstance),\n\t\tuintptr(unsafe.Pointer(lpTemplateName)),\n\t\tuintptr(hWndParent),\n\t\tlpDialogProc,\n\t\t0)\n\n\treturn int(ret)\n}\n\nfunc GetDlgItem(hDlg HWND, nIDDlgItem int) HWND {\n\tret, _, _ := procGetDlgItem.Call(\n\t\tuintptr(unsafe.Pointer(hDlg)),\n\t\tuintptr(nIDDlgItem))\n\n\treturn HWND(ret)\n}\n\nfunc DrawIcon(hDC HDC, x, y int, hIcon HICON) bool {\n\tret, _, _ := procDrawIcon.Call(\n\t\tuintptr(unsafe.Pointer(hDC)),\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t\tuintptr(unsafe.Pointer(hIcon)))\n\n\treturn ret != 0\n}\n\nfunc CreateMenu() HMENU {\n\tret, _, _ := procCreateMenu.Call(0,\n\t\t0,\n\t\t0,\n\t\t0)\n\n\treturn HMENU(ret)\n}\n\nfunc SetMenu(hWnd HWND, hMenu HMENU) bool {\n\tret, _, _ := syscall.Syscall(setMenu, 2,\n\t\tuintptr(hWnd),\n\t\tuintptr(hMenu),\n\t\t0)\n\n\treturn ret != 0\n}\n\n// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-checkmenuradioitem\nfunc SelectRadioMenuItem(menuID uint16, startID uint16, endID uint16, hwnd HWND) bool {\n\tret, _, _ := procCheckMenuRadioItem.Call(\n\t\thwnd,\n\t\tuintptr(startID),\n\t\tuintptr(endID),\n\t\tuintptr(menuID),\n\t\tMF_BYCOMMAND)\n\treturn ret != 0\n\n}\n\nfunc CreatePopupMenu() HMENU {\n\tret, _, _ := procCreatePopupMenu.Call(0,\n\t\t0,\n\t\t0,\n\t\t0)\n\n\treturn HMENU(ret)\n}\n\nfunc TrackPopupMenuEx(hMenu HMENU, fuFlags uint32, x, y int32, hWnd HWND, lptpm *TPMPARAMS) BOOL {\n\tret, _, _ := syscall.Syscall6(trackPopupMenuEx, 6,\n\t\tuintptr(hMenu),\n\t\tuintptr(fuFlags),\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t\tuintptr(hWnd),\n\t\tuintptr(unsafe.Pointer(lptpm)))\n\n\treturn BOOL(ret)\n}\n\nfunc DrawMenuBar(hWnd HWND) bool {\n\tret, _, _ := syscall.Syscall(drawMenuBar, 1,\n\t\tuintptr(hWnd),\n\t\t0,\n\t\t0)\n\n\treturn ret != 0\n}\n\nfunc InsertMenuItem(hMenu HMENU, uItem uint32, fByPosition bool, lpmii *MENUITEMINFO) bool {\n\tret, _, _ := syscall.Syscall6(insertMenuItem, 4,\n\t\tuintptr(hMenu),\n\t\tuintptr(uItem),\n\t\tuintptr(BoolToBOOL(fByPosition)),\n\t\tuintptr(unsafe.Pointer(lpmii)),\n\t\t0,\n\t\t0)\n\n\treturn ret != 0\n}\n\nfunc SetMenuItemInfo(hMenu HMENU, uItem uint32, fByPosition bool, lpmii *MENUITEMINFO) bool {\n\tret, _, _ := syscall.Syscall6(setMenuItemInfo, 4,\n\t\tuintptr(hMenu),\n\t\tuintptr(uItem),\n\t\tuintptr(BoolToBOOL(fByPosition)),\n\t\tuintptr(unsafe.Pointer(lpmii)),\n\t\t0,\n\t\t0)\n\n\treturn ret != 0\n}\n\nfunc ClientToScreen(hwnd HWND, x, y int) (int, int) {\n\tpt := POINT{X: int32(x), Y: int32(y)}\n\n\tprocClientToScreen.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(&pt)))\n\n\treturn int(pt.X), int(pt.Y)\n}\n\nfunc IsDialogMessage(hwnd HWND, msg *MSG) bool {\n\tret, _, _ := procIsDialogMessage.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(msg)))\n\n\treturn ret != 0\n}\n\nfunc IsWindow(hwnd HWND) bool {\n\tret, _, _ := procIsWindow.Call(\n\t\tuintptr(hwnd))\n\n\treturn ret != 0\n}\n\nfunc EndDialog(hwnd HWND, nResult uintptr) bool {\n\tret, _, _ := procEndDialog.Call(\n\t\tuintptr(hwnd),\n\t\tnResult)\n\n\treturn ret != 0\n}\n\nfunc PeekMessage(lpMsg *MSG, hwnd HWND, wMsgFilterMin, wMsgFilterMax, wRemoveMsg uint32) bool {\n\tret, _, _ := procPeekMessage.Call(\n\t\tuintptr(unsafe.Pointer(lpMsg)),\n\t\tuintptr(hwnd),\n\t\tuintptr(wMsgFilterMin),\n\t\tuintptr(wMsgFilterMax),\n\t\tuintptr(wRemoveMsg))\n\n\treturn ret != 0\n}\n\nfunc TranslateAccelerator(hwnd HWND, hAccTable HACCEL, lpMsg *MSG) bool {\n\tret, _, _ := procTranslateMessage.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(hAccTable),\n\t\tuintptr(unsafe.Pointer(lpMsg)))\n\n\treturn ret != 0\n}\n\nfunc SetWindowPos(hwnd, hWndInsertAfter HWND, x, y, cx, cy int, uFlags uint) bool {\n\tret, _, _ := procSetWindowPos.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(hWndInsertAfter),\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t\tuintptr(cx),\n\t\tuintptr(cy),\n\t\tuintptr(uFlags))\n\n\treturn ret != 0\n}\n\nfunc FillRect(hDC HDC, lprc *RECT, hbr HBRUSH) bool {\n\tret, _, _ := procFillRect.Call(\n\t\tuintptr(hDC),\n\t\tuintptr(unsafe.Pointer(lprc)),\n\t\tuintptr(hbr))\n\n\treturn ret != 0\n}\n\nfunc DrawText(hDC HDC, text string, uCount int, lpRect *RECT, uFormat uint) int {\n\tret, _, _ := procDrawText.Call(\n\t\tuintptr(hDC),\n\t\tuintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))),\n\t\tuintptr(uCount),\n\t\tuintptr(unsafe.Pointer(lpRect)),\n\t\tuintptr(uFormat))\n\n\treturn int(ret)\n}\n\nfunc AddClipboardFormatListener(hwnd HWND) bool {\n\tret, _, _ := procAddClipboardFormatListener.Call(\n\t\tuintptr(hwnd))\n\treturn ret != 0\n}\n\nfunc RemoveClipboardFormatListener(hwnd HWND) bool {\n\tret, _, _ := procRemoveClipboardFormatListener.Call(\n\t\tuintptr(hwnd))\n\treturn ret != 0\n}\n\nfunc OpenClipboard(hWndNewOwner HWND) bool {\n\tret, _, _ := procOpenClipboard.Call(\n\t\tuintptr(hWndNewOwner))\n\treturn ret != 0\n}\n\nfunc CloseClipboard() bool {\n\tret, _, _ := procCloseClipboard.Call()\n\treturn ret != 0\n}\n\nfunc EnumClipboardFormats(format uint) uint {\n\tret, _, _ := procEnumClipboardFormats.Call(\n\t\tuintptr(format))\n\treturn uint(ret)\n}\n\nfunc GetClipboardData(uFormat uint) HANDLE {\n\tret, _, _ := procGetClipboardData.Call(\n\t\tuintptr(uFormat))\n\treturn HANDLE(ret)\n}\n\nfunc SetClipboardData(uFormat uint, hMem HANDLE) HANDLE {\n\tret, _, _ := procSetClipboardData.Call(\n\t\tuintptr(uFormat),\n\t\tuintptr(hMem))\n\treturn HANDLE(ret)\n}\n\nfunc EmptyClipboard() bool {\n\tret, _, _ := procEmptyClipboard.Call()\n\treturn ret != 0\n}\n\nfunc GetClipboardFormatName(format uint) (string, bool) {\n\tcchMaxCount := 255\n\tbuf := make([]uint16, cchMaxCount)\n\tret, _, _ := procGetClipboardFormatName.Call(\n\t\tuintptr(format),\n\t\tuintptr(unsafe.Pointer(&buf[0])),\n\t\tuintptr(cchMaxCount))\n\n\tif ret > 0 {\n\t\treturn syscall.UTF16ToString(buf), true\n\t}\n\n\treturn \"Requested format does not exist or is predefined\", false\n}\n\nfunc IsClipboardFormatAvailable(format uint) bool {\n\tret, _, _ := procIsClipboardFormatAvailable.Call(uintptr(format))\n\treturn ret != 0\n}\n\nfunc BeginPaint(hwnd HWND, paint *PAINTSTRUCT) HDC {\n\tret, _, _ := procBeginPaint.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(paint)))\n\treturn HDC(ret)\n}\n\nfunc EndPaint(hwnd HWND, paint *PAINTSTRUCT) {\n\tprocEndPaint.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(paint)))\n}\n\nfunc GetKeyboardState(lpKeyState *[]byte) bool {\n\tret, _, _ := procGetKeyboardState.Call(\n\t\tuintptr(unsafe.Pointer(&(*lpKeyState)[0])))\n\treturn ret != 0\n}\n\nfunc MapVirtualKeyEx(uCode, uMapType uint, dwhkl HKL) uint {\n\tret, _, _ := procMapVirtualKey.Call(\n\t\tuintptr(uCode),\n\t\tuintptr(uMapType),\n\t\tuintptr(dwhkl))\n\treturn uint(ret)\n}\n\nfunc GetAsyncKeyState(vKey int) uint16 {\n\tret, _, _ := procGetAsyncKeyState.Call(uintptr(vKey))\n\treturn uint16(ret)\n}\n\nfunc ToAscii(uVirtKey, uScanCode uint, lpKeyState *byte, lpChar *uint16, uFlags uint) int {\n\tret, _, _ := procToAscii.Call(\n\t\tuintptr(uVirtKey),\n\t\tuintptr(uScanCode),\n\t\tuintptr(unsafe.Pointer(lpKeyState)),\n\t\tuintptr(unsafe.Pointer(lpChar)),\n\t\tuintptr(uFlags))\n\treturn int(ret)\n}\n\nfunc SwapMouseButton(fSwap bool) bool {\n\tret, _, _ := procSwapMouseButton.Call(\n\t\tuintptr(BoolToBOOL(fSwap)))\n\treturn ret != 0\n}\n\nfunc GetCursorPos() (x, y int, ok bool) {\n\tpt := POINT{}\n\tret, _, _ := procGetCursorPos.Call(uintptr(unsafe.Pointer(&pt)))\n\treturn int(pt.X), int(pt.Y), ret != 0\n}\n\nfunc SetCursorPos(x, y int) bool {\n\tret, _, _ := procSetCursorPos.Call(\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t)\n\treturn ret != 0\n}\n\nfunc SetCursor(cursor HCURSOR) HCURSOR {\n\tret, _, _ := procSetCursor.Call(\n\t\tuintptr(cursor),\n\t)\n\treturn HCURSOR(ret)\n}\n\nfunc CreateIcon(instance HINSTANCE, nWidth, nHeight int, cPlanes, cBitsPerPixel byte, ANDbits, XORbits *byte) HICON {\n\tret, _, _ := procCreateIcon.Call(\n\t\tuintptr(instance),\n\t\tuintptr(nWidth),\n\t\tuintptr(nHeight),\n\t\tuintptr(cPlanes),\n\t\tuintptr(cBitsPerPixel),\n\t\tuintptr(unsafe.Pointer(ANDbits)),\n\t\tuintptr(unsafe.Pointer(XORbits)),\n\t)\n\treturn HICON(ret)\n}\n\nfunc DestroyIcon(icon HICON) bool {\n\tret, _, _ := procDestroyIcon.Call(\n\t\tuintptr(icon),\n\t)\n\treturn ret != 0\n}\n\nfunc MonitorFromPoint(x, y int, dwFlags uint32) HMONITOR {\n\tret, _, _ := procMonitorFromPoint.Call(\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t\tuintptr(dwFlags),\n\t)\n\treturn HMONITOR(ret)\n}\n\nfunc MonitorFromRect(rc *RECT, dwFlags uint32) HMONITOR {\n\tret, _, _ := procMonitorFromRect.Call(\n\t\tuintptr(unsafe.Pointer(rc)),\n\t\tuintptr(dwFlags),\n\t)\n\treturn HMONITOR(ret)\n}\n\nfunc MonitorFromWindow(hwnd HWND, dwFlags uint32) HMONITOR {\n\tret, _, _ := procMonitorFromWindow.Call(\n\t\tuintptr(hwnd),\n\t\tuintptr(dwFlags),\n\t)\n\treturn HMONITOR(ret)\n}\n\nfunc GetMonitorInfo(hMonitor HMONITOR, lmpi *MONITORINFO) bool {\n\tret, _, _ := procGetMonitorInfo.Call(\n\t\tuintptr(hMonitor),\n\t\tuintptr(unsafe.Pointer(lmpi)),\n\t)\n\treturn ret != 0\n}\n\nfunc EnumDisplayMonitors(hdc HDC, clip *RECT, fnEnum, dwData uintptr) bool {\n\tret, _, _ := procEnumDisplayMonitors.Call(\n\t\tuintptr(hdc),\n\t\tuintptr(unsafe.Pointer(clip)),\n\t\tfnEnum,\n\t\tdwData,\n\t)\n\treturn ret != 0\n}\n\nfunc EnumDisplaySettingsEx(szDeviceName *uint16, iModeNum uint32, devMode *DEVMODE, dwFlags uint32) bool {\n\tret, _, _ := procEnumDisplaySettingsEx.Call(\n\t\tuintptr(unsafe.Pointer(szDeviceName)),\n\t\tuintptr(iModeNum),\n\t\tuintptr(unsafe.Pointer(devMode)),\n\t\tuintptr(dwFlags),\n\t)\n\treturn ret != 0\n}\n\nfunc ChangeDisplaySettingsEx(szDeviceName *uint16, devMode *DEVMODE, hwnd HWND, dwFlags uint32, lParam uintptr) int32 {\n\tret, _, _ := procChangeDisplaySettingsEx.Call(\n\t\tuintptr(unsafe.Pointer(szDeviceName)),\n\t\tuintptr(unsafe.Pointer(devMode)),\n\t\tuintptr(hwnd),\n\t\tuintptr(dwFlags),\n\t\tlParam,\n\t)\n\treturn int32(ret)\n}\n\n/*\nfunc SendInput(inputs []INPUT) uint32 {\n\tvar validInputs []C.INPUT\n\n\tfor _, oneInput := range inputs {\n\t\tinput := C.INPUT{_type: C.DWORD(oneInput.Type)}\n\n\t\tswitch oneInput.Type {\n\t\tcase INPUT_MOUSE:\n\t\t\t(*MouseInput)(unsafe.Pointer(&input)).mi = oneInput.Mi\n\t\tcase INPUT_KEYBOARD:\n\t\t\t(*KbdInput)(unsafe.Pointer(&input)).ki = oneInput.Ki\n\t\tcase INPUT_HARDWARE:\n\t\t\t(*HardwareInput)(unsafe.Pointer(&input)).hi = oneInput.Hi\n\t\tdefault:\n\t\t\tpanic(\"unkown type\")\n\t\t}\n\n\t\tvalidInputs = append(validInputs, input)\n\t}\n\n\tret, _, _ := procSendInput.Call(\n\t\tuintptr(len(validInputs)),\n\t\tuintptr(unsafe.Pointer(&validInputs[0])),\n\t\tuintptr(unsafe.Sizeof(C.INPUT{})),\n\t)\n\treturn uint32(ret)\n}*/\n\nfunc SetWindowsHookEx(idHook int, lpfn HOOKPROC, hMod HINSTANCE, dwThreadId DWORD) HHOOK {\n\tret, _, _ := procSetWindowsHookEx.Call(\n\t\tuintptr(idHook),\n\t\tuintptr(syscall.NewCallback(lpfn)),\n\t\tuintptr(hMod),\n\t\tuintptr(dwThreadId),\n\t)\n\treturn HHOOK(ret)\n}\n\nfunc UnhookWindowsHookEx(hhk HHOOK) bool {\n\tret, _, _ := procUnhookWindowsHookEx.Call(\n\t\tuintptr(hhk),\n\t)\n\treturn ret != 0\n}\n\nfunc CallNextHookEx(hhk HHOOK, nCode int, wParam WPARAM, lParam LPARAM) LRESULT {\n\tret, _, _ := procCallNextHookEx.Call(\n\t\tuintptr(hhk),\n\t\tuintptr(nCode),\n\t\tuintptr(wParam),\n\t\tuintptr(lParam),\n\t)\n\treturn LRESULT(ret)\n}\n\nfunc GetKeyState(nVirtKey int32) int16 {\n\tret, _, _ := syscall.Syscall(getKeyState, 1,\n\t\tuintptr(nVirtKey),\n\t\t0,\n\t\t0)\n\n\treturn int16(ret)\n}\n\nfunc DestroyMenu(hMenu HMENU) bool {\n\tret, _, _ := procDestroyMenu.Call(1,\n\t\tuintptr(hMenu),\n\t\t0,\n\t\t0)\n\n\treturn ret != 0\n}\n\nfunc GetWindowPlacement(hWnd HWND, lpwndpl *WINDOWPLACEMENT) bool {\n\tret, _, _ := syscall.Syscall(getWindowPlacement, 2,\n\t\tuintptr(hWnd),\n\t\tuintptr(unsafe.Pointer(lpwndpl)),\n\t\t0)\n\n\treturn ret != 0\n}\n\nfunc SetWindowPlacement(hWnd HWND, lpwndpl *WINDOWPLACEMENT) bool {\n\tret, _, _ := syscall.Syscall(setWindowPlacement, 2,\n\t\tuintptr(hWnd),\n\t\tuintptr(unsafe.Pointer(lpwndpl)),\n\t\t0)\n\n\treturn ret != 0\n}\n\nfunc SetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO, fRedraw bool) int32 {\n\tret, _, _ := syscall.Syscall6(setScrollInfo, 4,\n\t\thwnd,\n\t\tuintptr(fnBar),\n\t\tuintptr(unsafe.Pointer(lpsi)),\n\t\tuintptr(BoolToBOOL(fRedraw)),\n\t\t0,\n\t\t0)\n\n\treturn int32(ret)\n}\n\nfunc GetScrollInfo(hwnd HWND, fnBar int32, lpsi *SCROLLINFO) bool {\n\tret, _, _ := syscall.Syscall(getScrollInfo, 3,\n\t\thwnd,\n\t\tuintptr(fnBar),\n\t\tuintptr(unsafe.Pointer(lpsi)))\n\n\treturn ret != 0\n}\n"
  },
  {
    "path": "w32/utils.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"syscall\"\n\t\"unicode/utf16\"\n\t\"unsafe\"\n)\n\nfunc MustLoadLibrary(name string) uintptr {\n\tlib, err := syscall.LoadLibrary(name)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn uintptr(lib)\n}\n\nfunc MustGetProcAddress(lib uintptr, name string) uintptr {\n\taddr, err := syscall.GetProcAddress(syscall.Handle(lib), name)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn uintptr(addr)\n}\n\nfunc SUCCEEDED(hr HRESULT) bool {\n\treturn hr >= 0\n}\n\nfunc FAILED(hr HRESULT) bool {\n\treturn hr < 0\n}\n\nfunc MakeIntResource(id uint16) *uint16 {\n\treturn (*uint16)(unsafe.Pointer(uintptr(id)))\n}\n\nfunc LOWORD(dw uint32) uint16 {\n\treturn uint16(dw)\n}\n\nfunc HIWORD(dw uint32) uint16 {\n\treturn uint16(dw >> 16 & 0xffff)\n}\n\nfunc MAKELONG(lo, hi uint16) uint32 {\n\treturn uint32(uint32(lo) | ((uint32(hi)) << 16))\n}\n\nfunc BoolToBOOL(value bool) BOOL {\n\tif value {\n\t\treturn 1\n\t}\n\n\treturn 0\n}\n\nfunc UTF16PtrToString(cstr *uint16) string {\n\tif cstr != nil {\n\t\tus := make([]uint16, 0, 256)\n\t\tfor p := uintptr(unsafe.Pointer(cstr)); ; p += 2 {\n\t\t\tu := *(*uint16)(unsafe.Pointer(p))\n\t\t\tif u == 0 {\n\t\t\t\treturn string(utf16.Decode(us))\n\t\t\t}\n\t\t\tus = append(us, u)\n\t\t}\n\t}\n\n\treturn \"\"\n}\n\nfunc ComAddRef(unknown *IUnknown) int32 {\n\tret, _, _ := syscall.Syscall(unknown.lpVtbl.pAddRef, 1,\n\t\tuintptr(unsafe.Pointer(unknown)),\n\t\t0,\n\t\t0)\n\treturn int32(ret)\n}\n\nfunc ComRelease(unknown *IUnknown) int32 {\n\tret, _, _ := syscall.Syscall(unknown.lpVtbl.pRelease, 1,\n\t\tuintptr(unsafe.Pointer(unknown)),\n\t\t0,\n\t\t0)\n\treturn int32(ret)\n}\n\nfunc ComQueryInterface(unknown *IUnknown, id *GUID) *IDispatch {\n\tvar disp *IDispatch\n\thr, _, _ := syscall.Syscall(unknown.lpVtbl.pQueryInterface, 3,\n\t\tuintptr(unsafe.Pointer(unknown)),\n\t\tuintptr(unsafe.Pointer(id)),\n\t\tuintptr(unsafe.Pointer(&disp)))\n\tif hr != 0 {\n\t\tpanic(\"Invoke QieryInterface error.\")\n\t}\n\treturn disp\n}\n\nfunc ComGetIDsOfName(disp *IDispatch, names []string) []int32 {\n\twnames := make([]*uint16, len(names))\n\tdispid := make([]int32, len(names))\n\tfor i := 0; i < len(names); i++ {\n\t\twnames[i] = syscall.StringToUTF16Ptr(names[i])\n\t}\n\thr, _, _ := syscall.Syscall6(disp.lpVtbl.pGetIDsOfNames, 6,\n\t\tuintptr(unsafe.Pointer(disp)),\n\t\tuintptr(unsafe.Pointer(IID_NULL)),\n\t\tuintptr(unsafe.Pointer(&wnames[0])),\n\t\tuintptr(len(names)),\n\t\tuintptr(GetUserDefaultLCID()),\n\t\tuintptr(unsafe.Pointer(&dispid[0])))\n\tif hr != 0 {\n\t\tpanic(\"Invoke GetIDsOfName error.\")\n\t}\n\treturn dispid\n}\n\nfunc ComInvoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (result *VARIANT) {\n\tvar dispparams DISPPARAMS\n\n\tif dispatch&DISPATCH_PROPERTYPUT != 0 {\n\t\tdispnames := [1]int32{DISPID_PROPERTYPUT}\n\t\tdispparams.RgdispidNamedArgs = uintptr(unsafe.Pointer(&dispnames[0]))\n\t\tdispparams.CNamedArgs = 1\n\t}\n\tvar vargs []VARIANT\n\tif len(params) > 0 {\n\t\tvargs = make([]VARIANT, len(params))\n\t\tfor i, v := range params {\n\t\t\t//n := len(params)-i-1\n\t\t\tn := len(params) - i - 1\n\t\t\tVariantInit(&vargs[n])\n\t\t\tswitch v.(type) {\n\t\t\tcase bool:\n\t\t\t\tif v.(bool) {\n\t\t\t\t\tvargs[n] = VARIANT{VT_BOOL, 0, 0, 0, 0xffff}\n\t\t\t\t} else {\n\t\t\t\t\tvargs[n] = VARIANT{VT_BOOL, 0, 0, 0, 0}\n\t\t\t\t}\n\t\t\tcase *bool:\n\t\t\t\tvargs[n] = VARIANT{VT_BOOL | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*bool))))}\n\t\t\tcase byte:\n\t\t\t\tvargs[n] = VARIANT{VT_I1, 0, 0, 0, int64(v.(byte))}\n\t\t\tcase *byte:\n\t\t\t\tvargs[n] = VARIANT{VT_I1 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*byte))))}\n\t\t\tcase int16:\n\t\t\t\tvargs[n] = VARIANT{VT_I2, 0, 0, 0, int64(v.(int16))}\n\t\t\tcase *int16:\n\t\t\t\tvargs[n] = VARIANT{VT_I2 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*int16))))}\n\t\t\tcase uint16:\n\t\t\t\tvargs[n] = VARIANT{VT_UI2, 0, 0, 0, int64(v.(int16))}\n\t\t\tcase *uint16:\n\t\t\t\tvargs[n] = VARIANT{VT_UI2 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*uint16))))}\n\t\t\tcase int, int32:\n\t\t\t\tvargs[n] = VARIANT{VT_UI4, 0, 0, 0, int64(v.(int))}\n\t\t\tcase *int, *int32:\n\t\t\t\tvargs[n] = VARIANT{VT_I4 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*int))))}\n\t\t\tcase uint, uint32:\n\t\t\t\tvargs[n] = VARIANT{VT_UI4, 0, 0, 0, int64(v.(uint))}\n\t\t\tcase *uint, *uint32:\n\t\t\t\tvargs[n] = VARIANT{VT_UI4 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*uint))))}\n\t\t\tcase int64:\n\t\t\t\tvargs[n] = VARIANT{VT_I8, 0, 0, 0, v.(int64)}\n\t\t\tcase *int64:\n\t\t\t\tvargs[n] = VARIANT{VT_I8 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*int64))))}\n\t\t\tcase uint64:\n\t\t\t\tvargs[n] = VARIANT{VT_UI8, 0, 0, 0, int64(v.(uint64))}\n\t\t\tcase *uint64:\n\t\t\t\tvargs[n] = VARIANT{VT_UI8 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*uint64))))}\n\t\t\tcase float32:\n\t\t\t\tvargs[n] = VARIANT{VT_R4, 0, 0, 0, int64(v.(float32))}\n\t\t\tcase *float32:\n\t\t\t\tvargs[n] = VARIANT{VT_R4 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*float32))))}\n\t\t\tcase float64:\n\t\t\t\tvargs[n] = VARIANT{VT_R8, 0, 0, 0, int64(v.(float64))}\n\t\t\tcase *float64:\n\t\t\t\tvargs[n] = VARIANT{VT_R8 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*float64))))}\n\t\t\tcase string:\n\t\t\t\tvargs[n] = VARIANT{VT_BSTR, 0, 0, 0, int64(uintptr(unsafe.Pointer(SysAllocString(v.(string)))))}\n\t\t\tcase *string:\n\t\t\t\tvargs[n] = VARIANT{VT_BSTR | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*string))))}\n\t\t\tcase *IDispatch:\n\t\t\t\tvargs[n] = VARIANT{VT_DISPATCH, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*IDispatch))))}\n\t\t\tcase **IDispatch:\n\t\t\t\tvargs[n] = VARIANT{VT_DISPATCH | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(**IDispatch))))}\n\t\t\tcase nil:\n\t\t\t\tvargs[n] = VARIANT{VT_NULL, 0, 0, 0, 0}\n\t\t\tcase *VARIANT:\n\t\t\t\tvargs[n] = VARIANT{VT_VARIANT | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*VARIANT))))}\n\t\t\tdefault:\n\t\t\t\tpanic(\"unknown type\")\n\t\t\t}\n\t\t}\n\t\tdispparams.Rgvarg = uintptr(unsafe.Pointer(&vargs[0]))\n\t\tdispparams.CArgs = uint32(len(params))\n\t}\n\n\tvar ret VARIANT\n\tvar excepInfo EXCEPINFO\n\tVariantInit(&ret)\n\thr, _, _ := syscall.Syscall9(disp.lpVtbl.pInvoke, 8,\n\t\tuintptr(unsafe.Pointer(disp)),\n\t\tuintptr(dispid),\n\t\tuintptr(unsafe.Pointer(IID_NULL)),\n\t\tuintptr(GetUserDefaultLCID()),\n\t\tuintptr(dispatch),\n\t\tuintptr(unsafe.Pointer(&dispparams)),\n\t\tuintptr(unsafe.Pointer(&ret)),\n\t\tuintptr(unsafe.Pointer(&excepInfo)),\n\t\t0)\n\tif hr != 0 {\n\t\tif excepInfo.BstrDescription != nil {\n\t\t\tbs := UTF16PtrToString(excepInfo.BstrDescription)\n\t\t\tpanic(bs)\n\t\t}\n\t}\n\tfor _, varg := range vargs {\n\t\tif varg.VT == VT_BSTR && varg.Val != 0 {\n\t\t\tSysFreeString(((*int16)(unsafe.Pointer(uintptr(varg.Val)))))\n\t\t}\n\t}\n\tresult = &ret\n\treturn\n}\n"
  },
  {
    "path": "w32/uxtheme.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nimport (\n\t\"syscall\"\n\t\"unsafe\"\n)\n\n// LISTVIEW parts\nconst (\n\tLVP_LISTITEM         = 1\n\tLVP_LISTGROUP        = 2\n\tLVP_LISTDETAIL       = 3\n\tLVP_LISTSORTEDDETAIL = 4\n\tLVP_EMPTYTEXT        = 5\n\tLVP_GROUPHEADER      = 6\n\tLVP_GROUPHEADERLINE  = 7\n\tLVP_EXPANDBUTTON     = 8\n\tLVP_COLLAPSEBUTTON   = 9\n\tLVP_COLUMNDETAIL     = 10\n)\n\n// LVP_LISTITEM states\nconst (\n\tLISS_NORMAL           = 1\n\tLISS_HOT              = 2\n\tLISS_SELECTED         = 3\n\tLISS_DISABLED         = 4\n\tLISS_SELECTEDNOTFOCUS = 5\n\tLISS_HOTSELECTED      = 6\n)\n\n// TREEVIEW parts\nconst (\n\tTVP_TREEITEM = 1\n\tTVP_GLYPH    = 2\n\tTVP_BRANCH   = 3\n\tTVP_HOTGLYPH = 4\n)\n\n// TVP_TREEITEM states\nconst (\n\tTREIS_NORMAL           = 1\n\tTREIS_HOT              = 2\n\tTREIS_SELECTED         = 3\n\tTREIS_DISABLED         = 4\n\tTREIS_SELECTEDNOTFOCUS = 5\n\tTREIS_HOTSELECTED      = 6\n)\n\ntype HTHEME HANDLE\n\nvar (\n\t// Library\n\tlibuxtheme uintptr\n\n\t// Functions\n\tcloseThemeData      uintptr\n\tdrawThemeBackground uintptr\n\tdrawThemeText       uintptr\n\tgetThemeTextExtent  uintptr\n\topenThemeData       uintptr\n\tsetWindowTheme      uintptr\n)\n\nfunc init() {\n\t// Library\n\tlibuxtheme = MustLoadLibrary(\"uxtheme.dll\")\n\n\t// Functions\n\tcloseThemeData = MustGetProcAddress(libuxtheme, \"CloseThemeData\")\n\tdrawThemeBackground = MustGetProcAddress(libuxtheme, \"DrawThemeBackground\")\n\tdrawThemeText = MustGetProcAddress(libuxtheme, \"DrawThemeText\")\n\tgetThemeTextExtent = MustGetProcAddress(libuxtheme, \"GetThemeTextExtent\")\n\topenThemeData = MustGetProcAddress(libuxtheme, \"OpenThemeData\")\n\tsetWindowTheme = MustGetProcAddress(libuxtheme, \"SetWindowTheme\")\n}\n\nfunc CloseThemeData(hTheme HTHEME) HRESULT {\n\tret, _, _ := syscall.Syscall(closeThemeData, 1,\n\t\tuintptr(hTheme),\n\t\t0,\n\t\t0)\n\n\treturn HRESULT(ret)\n}\n\nfunc DrawThemeBackground(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pRect, pClipRect *RECT) HRESULT {\n\tret, _, _ := syscall.Syscall6(drawThemeBackground, 6,\n\t\tuintptr(hTheme),\n\t\tuintptr(hdc),\n\t\tuintptr(iPartId),\n\t\tuintptr(iStateId),\n\t\tuintptr(unsafe.Pointer(pRect)),\n\t\tuintptr(unsafe.Pointer(pClipRect)))\n\n\treturn HRESULT(ret)\n}\n\nfunc DrawThemeText(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwTextFlags, dwTextFlags2 uint32, pRect *RECT) HRESULT {\n\tret, _, _ := syscall.Syscall9(drawThemeText, 9,\n\t\tuintptr(hTheme),\n\t\tuintptr(hdc),\n\t\tuintptr(iPartId),\n\t\tuintptr(iStateId),\n\t\tuintptr(unsafe.Pointer(pszText)),\n\t\tuintptr(iCharCount),\n\t\tuintptr(dwTextFlags),\n\t\tuintptr(dwTextFlags2),\n\t\tuintptr(unsafe.Pointer(pRect)))\n\n\treturn HRESULT(ret)\n}\n\nfunc GetThemeTextExtent(hTheme HTHEME, hdc HDC, iPartId, iStateId int32, pszText *uint16, iCharCount int32, dwTextFlags uint32, pBoundingRect, pExtentRect *RECT) HRESULT {\n\tret, _, _ := syscall.Syscall9(getThemeTextExtent, 9,\n\t\tuintptr(hTheme),\n\t\tuintptr(hdc),\n\t\tuintptr(iPartId),\n\t\tuintptr(iStateId),\n\t\tuintptr(unsafe.Pointer(pszText)),\n\t\tuintptr(iCharCount),\n\t\tuintptr(dwTextFlags),\n\t\tuintptr(unsafe.Pointer(pBoundingRect)),\n\t\tuintptr(unsafe.Pointer(pExtentRect)))\n\n\treturn HRESULT(ret)\n}\n\nfunc OpenThemeData(hwnd HWND, pszClassList *uint16) HTHEME {\n\tret, _, _ := syscall.Syscall(openThemeData, 2,\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(pszClassList)),\n\t\t0)\n\n\treturn HTHEME(ret)\n}\n\nfunc SetWindowTheme(hwnd HWND, pszSubAppName, pszSubIdList *uint16) HRESULT {\n\tret, _, _ := syscall.Syscall(setWindowTheme, 3,\n\t\tuintptr(hwnd),\n\t\tuintptr(unsafe.Pointer(pszSubAppName)),\n\t\tuintptr(unsafe.Pointer(pszSubIdList)))\n\n\treturn HRESULT(ret)\n}\n"
  },
  {
    "path": "w32/vars.go",
    "content": "/*\n * Copyright (C) 2019 Tad Vizbaras. All Rights Reserved.\n * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.\n */\n\npackage w32\n\nvar (\n\tIID_NULL                      = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}\n\tIID_IUnknown                  = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}\n\tIID_IDispatch                 = &GUID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}\n\tIID_IConnectionPointContainer = &GUID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}}\n\tIID_IConnectionPoint          = &GUID{0xB196B286, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}}\n)\n"
  },
  {
    "path": "wndproc.go",
    "content": "/*\n * Copyright (C) 2019 The Winc Authors. All Rights Reserved.\n * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.\n */\n\npackage winc\n\nimport (\n\t\"unsafe\"\n\n\t\"github.com/tadvi/winc/w32\"\n)\n\nfunc genPoint(p uintptr) (x, y int) {\n\tx = int(w32.LOWORD(uint32(p)))\n\ty = int(w32.HIWORD(uint32(p)))\n\treturn\n}\n\nfunc genMouseEventArg(wparam, lparam uintptr) *MouseEventData {\n\tvar data MouseEventData\n\tdata.Button = int(wparam)\n\tdata.X, data.Y = genPoint(lparam)\n\n\treturn &data\n}\n\nfunc genDropFilesEventArg(wparam uintptr) *DropFilesEventData {\n\thDrop := w32.HDROP(wparam)\n\n\tvar data DropFilesEventData\n\t_, fileCount := w32.DragQueryFile(hDrop, 0xFFFFFFFF)\n\tdata.Files = make([]string, fileCount)\n\n\tvar i uint\n\tfor i = 0; i < fileCount; i++ {\n\t\tdata.Files[i], _ = w32.DragQueryFile(hDrop, i)\n\t}\n\n\tdata.X, data.Y, _ = w32.DragQueryPoint(hDrop)\n\tw32.DragFinish(hDrop)\n\treturn &data\n}\n\nfunc generalWndProc(hwnd w32.HWND, msg uint32, wparam, lparam uintptr) uintptr {\n\n\tswitch msg {\n\tcase w32.WM_HSCROLL:\n\t\t//println(\"case w32.WM_HSCROLL\")\n\n\tcase w32.WM_VSCROLL:\n\t\t//println(\"case w32.WM_VSCROLL\")\n\t}\n\n\tif controller := GetMsgHandler(hwnd); controller != nil {\n\t\tret := controller.WndProc(msg, wparam, lparam)\n\n\t\tswitch msg {\n\t\tcase w32.WM_NOTIFY: //Reflect notification to control\n\t\t\tnm := (*w32.NMHDR)(unsafe.Pointer(lparam))\n\t\t\tif controller := GetMsgHandler(nm.HwndFrom); controller != nil {\n\t\t\t\tret := controller.WndProc(msg, wparam, lparam)\n\t\t\t\tif ret != 0 {\n\t\t\t\t\tw32.SetWindowLong(hwnd, w32.DWL_MSGRESULT, uint32(ret))\n\t\t\t\t\treturn w32.TRUE\n\t\t\t\t}\n\t\t\t}\n\t\tcase w32.WM_COMMAND:\n\t\t\tif lparam != 0 { //Reflect message to control\n\t\t\t\th := w32.HWND(lparam)\n\t\t\t\tif controller := GetMsgHandler(h); controller != nil {\n\t\t\t\t\tret := controller.WndProc(msg, wparam, lparam)\n\t\t\t\t\tif ret != 0 {\n\t\t\t\t\t\tw32.SetWindowLong(hwnd, w32.DWL_MSGRESULT, uint32(ret))\n\t\t\t\t\t\treturn w32.TRUE\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase w32.WM_CLOSE:\n\t\t\tcontroller.OnClose().Fire(NewEvent(controller, nil))\n\t\tcase w32.WM_KILLFOCUS:\n\t\t\tcontroller.OnKillFocus().Fire(NewEvent(controller, nil))\n\t\tcase w32.WM_SETFOCUS:\n\t\t\tcontroller.OnSetFocus().Fire(NewEvent(controller, nil))\n\t\tcase w32.WM_DROPFILES:\n\t\t\tcontroller.OnDropFiles().Fire(NewEvent(controller, genDropFilesEventArg(wparam)))\n\t\tcase w32.WM_CONTEXTMENU:\n\t\t\tif wparam != 0 { //Reflect message to control\n\t\t\t\th := w32.HWND(wparam)\n\t\t\t\tif controller := GetMsgHandler(h); controller != nil {\n\t\t\t\t\tcontextMenu := controller.ContextMenu()\n\t\t\t\t\tx, y := genPoint(lparam)\n\n\t\t\t\t\tif contextMenu != nil {\n\t\t\t\t\t\tid := w32.TrackPopupMenuEx(\n\t\t\t\t\t\t\tcontextMenu.hMenu,\n\t\t\t\t\t\t\tw32.TPM_NOANIMATION|w32.TPM_RETURNCMD,\n\t\t\t\t\t\t\tint32(x),\n\t\t\t\t\t\t\tint32(y),\n\t\t\t\t\t\t\tcontroller.Handle(),\n\t\t\t\t\t\t\tnil)\n\n\t\t\t\t\t\titem := findMenuItemByID(int(id))\n\t\t\t\t\t\tif item != nil {\n\t\t\t\t\t\t\titem.OnClick().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn 0\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase w32.WM_LBUTTONDOWN:\n\t\t\tcontroller.OnLBDown().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_LBUTTONUP:\n\t\t\tcontroller.OnLBUp().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_LBUTTONDBLCLK:\n\t\t\tcontroller.OnLBDbl().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_MBUTTONDOWN:\n\t\t\tcontroller.OnMBDown().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_MBUTTONUP:\n\t\t\tcontroller.OnMBUp().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_RBUTTONDOWN:\n\t\t\tcontroller.OnRBDown().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_RBUTTONUP:\n\t\t\tcontroller.OnRBUp().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_RBUTTONDBLCLK:\n\t\t\tcontroller.OnRBDbl().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_MOUSEMOVE:\n\t\t\tcontroller.OnMouseMove().Fire(NewEvent(controller, genMouseEventArg(wparam, lparam)))\n\t\tcase w32.WM_PAINT:\n\t\t\tcanvas := NewCanvasFromHwnd(hwnd)\n\t\t\tdefer canvas.Dispose()\n\t\t\tcontroller.OnPaint().Fire(NewEvent(controller, &PaintEventData{Canvas: canvas}))\n\t\tcase w32.WM_KEYUP:\n\t\t\tcontroller.OnKeyUp().Fire(NewEvent(controller, &KeyUpEventData{int(wparam), int(lparam)}))\n\t\tcase w32.WM_SIZE:\n\t\t\tx, y := genPoint(lparam)\n\t\t\tcontroller.OnSize().Fire(NewEvent(controller, &SizeEventData{uint(wparam), x, y}))\n\n\t\t}\n\t\treturn ret\n\t}\n\n\treturn w32.DefWindowProc(hwnd, uint32(msg), wparam, lparam)\n}\n"
  }
]