github.com/secoba/wails/v2@v2.6.4/internal/frontend/desktop/windows/winc/w32/comctl32.go (about)

     1  //go:build windows
     2  
     3  /*
     4   * Copyright (C) 2019 The Winc Authors. All Rights Reserved.
     5   * Copyright (C) 2010-2012 The W32 Authors. All Rights Reserved.
     6   */
     7  
     8  package w32
     9  
    10  import (
    11  	"syscall"
    12  	"unsafe"
    13  )
    14  
    15  var (
    16  	modcomctl32 = syscall.NewLazyDLL("comctl32.dll")
    17  
    18  	procInitCommonControlsEx    = modcomctl32.NewProc("InitCommonControlsEx")
    19  	procImageList_Create        = modcomctl32.NewProc("ImageList_Create")
    20  	procImageList_Destroy       = modcomctl32.NewProc("ImageList_Destroy")
    21  	procImageList_GetImageCount = modcomctl32.NewProc("ImageList_GetImageCount")
    22  	procImageList_SetImageCount = modcomctl32.NewProc("ImageList_SetImageCount")
    23  	procImageList_Add           = modcomctl32.NewProc("ImageList_Add")
    24  	procImageList_ReplaceIcon   = modcomctl32.NewProc("ImageList_ReplaceIcon")
    25  	procImageList_Remove        = modcomctl32.NewProc("ImageList_Remove")
    26  	procTrackMouseEvent         = modcomctl32.NewProc("_TrackMouseEvent")
    27  )
    28  
    29  func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool {
    30  	ret, _, _ := procInitCommonControlsEx.Call(
    31  		uintptr(unsafe.Pointer(lpInitCtrls)))
    32  
    33  	return ret != 0
    34  }
    35  
    36  func ImageList_Create(cx, cy int, flags uint, cInitial, cGrow int) HIMAGELIST {
    37  	ret, _, _ := procImageList_Create.Call(
    38  		uintptr(cx),
    39  		uintptr(cy),
    40  		uintptr(flags),
    41  		uintptr(cInitial),
    42  		uintptr(cGrow))
    43  
    44  	if ret == 0 {
    45  		panic("Create image list failed")
    46  	}
    47  
    48  	return HIMAGELIST(ret)
    49  }
    50  
    51  func ImageList_Destroy(himl HIMAGELIST) bool {
    52  	ret, _, _ := procImageList_Destroy.Call(
    53  		uintptr(himl))
    54  
    55  	return ret != 0
    56  }
    57  
    58  func ImageList_GetImageCount(himl HIMAGELIST) int {
    59  	ret, _, _ := procImageList_GetImageCount.Call(
    60  		uintptr(himl))
    61  
    62  	return int(ret)
    63  }
    64  
    65  func ImageList_SetImageCount(himl HIMAGELIST, uNewCount uint) bool {
    66  	ret, _, _ := procImageList_SetImageCount.Call(
    67  		uintptr(himl),
    68  		uintptr(uNewCount))
    69  
    70  	return ret != 0
    71  }
    72  
    73  func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int {
    74  	ret, _, _ := procImageList_Add.Call(
    75  		uintptr(himl),
    76  		uintptr(hbmImage),
    77  		uintptr(hbmMask))
    78  
    79  	return int(ret)
    80  }
    81  
    82  func ImageList_ReplaceIcon(himl HIMAGELIST, i int, hicon HICON) int {
    83  	ret, _, _ := procImageList_ReplaceIcon.Call(
    84  		uintptr(himl),
    85  		uintptr(i),
    86  		uintptr(hicon))
    87  
    88  	return int(ret)
    89  }
    90  
    91  func ImageList_AddIcon(himl HIMAGELIST, hicon HICON) int {
    92  	return ImageList_ReplaceIcon(himl, -1, hicon)
    93  }
    94  
    95  func ImageList_Remove(himl HIMAGELIST, i int) bool {
    96  	ret, _, _ := procImageList_Remove.Call(
    97  		uintptr(himl),
    98  		uintptr(i))
    99  
   100  	return ret != 0
   101  }
   102  
   103  func ImageList_RemoveAll(himl HIMAGELIST) bool {
   104  	return ImageList_Remove(himl, -1)
   105  }
   106  
   107  func TrackMouseEvent(tme *TRACKMOUSEEVENT) bool {
   108  	ret, _, _ := procTrackMouseEvent.Call(
   109  		uintptr(unsafe.Pointer(tme)))
   110  
   111  	return ret != 0
   112  }