summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comctl_windows.go86
-rw-r--r--common_windows.go1
-rw-r--r--init_windows.go4
-rw-r--r--sysdata_windows.go2
4 files changed, 92 insertions, 1 deletions
diff --git a/comctl_windows.go b/comctl_windows.go
new file mode 100644
index 0000000..6c472e8
--- /dev/null
+++ b/comctl_windows.go
@@ -0,0 +1,86 @@
+// 25 february 2014
+package ui
+
+import (
+ "fmt"
+// "syscall"
+ "unsafe"
+)
+
+// pretty much every constant here except _WM_USER is from commctrl.h
+// TODO for all: filter out constants not available in Windows 2000
+
+// InitCommonControlsEx constants.
+const (
+ _ICC_LISTVIEW_CLASSES = 0x00000001
+ _ICC_TREEVIEW_CLASSES = 0x00000002
+ _ICC_BAR_CLASSES = 0x00000004
+ _ICC_TAB_CLASSES = 0x00000008
+ _ICC_UPDOWN_CLASS = 0x00000010
+ _ICC_PROGRESS_CLASS = 0x00000020
+ _ICC_HOTKEY_CLASS = 0x00000040
+ _ICC_ANIMATE_CLASS = 0x00000080
+ _ICC_WIN95_CLASSES = 0x000000FF
+ _ICC_DATE_CLASSES = 0x00000100
+ _ICC_USEREX_CLASSES = 0x00000200
+ _ICC_COOL_CLASSES = 0x00000400
+ _ICC_INTERNET_CLASSES = 0x00000800
+ _ICC_PAGESCROLLER_CLASS = 0x00001000
+ _ICC_NATIVEFNTCTL_CLASS = 0x00002000
+ _ICC_STANDARD_CLASSES = 0x00004000
+ _ICC_LINK_CLASS = 0x00008000
+)
+
+var (
+ _initCommonControlsEx = comctl32.NewProc("InitCommonControlsEx")
+)
+
+func initCommonControls() (err error) {
+ var icc struct {
+ dwSize uint32
+ dwICC uint32
+ }
+
+ icc.dwSize = uint32(unsafe.Sizeof(icc))
+ icc.dwICC = _ICC_PROGRESS_CLASS
+ r1, _, err := _initCommonControlsEx.Call(uintptr(unsafe.Pointer(&icc)))
+ if r1 == _FALSE { // failure
+ // TODO does it set GetLastError()?
+ return fmt.Errorf("error initializing Common Controls (comctl32.dll): %v", err)
+ }
+ return nil
+}
+
+// Common Controls class names.
+const (
+ _PROGRESS_CLASS = "msctls_progress32"
+)
+
+// Shared Common Controls styles.
+const (
+ _WM_USER = 0x0400
+ _CCM_FIRST = 0x2000
+ _CCM_SETBKCOLOR = (_CCM_FIRST + 1)
+)
+
+// TODO move _WM_USER here?
+
+// Progress Bar styles.
+const (
+ _PBS_SMOOTH = 0x01
+ _PBS_VERTICAL = 0x04
+)
+
+// Progress Bar messages.
+const (
+ _PBM_SETRANGE = (_WM_USER + 1)
+ _PBM_SETPOS = (_WM_USER + 2)
+ _PBM_DELTAPOS = (_WM_USER + 3)
+ _PBM_SETSTEP = (_WM_USER + 4)
+ _PBM_STEPIT = (_WM_USER + 5)
+ _PBM_SETRANGE32 = (_WM_USER + 6)
+ _PBM_GETRANGE = (_WM_USER + 7)
+ _PBM_GETPOS = (_WM_USER + 8)
+ _PBM_SETBARCOLOR = (_WM_USER + 9)
+ _PBM_SETBKCOLOR = _CCM_SETBKCOLOR
+)
diff --git a/common_windows.go b/common_windows.go
index 029bef3..cb6d2a3 100644
--- a/common_windows.go
+++ b/common_windows.go
@@ -10,6 +10,7 @@ var (
user32 = syscall.NewLazyDLL("user32.dll")
kernel32 = syscall.NewLazyDLL("kernel32.dll")
gdi32 = syscall.NewLazyDLL("gdi32.dll")
+ comctl32 = syscall.NewLazyDLL("comctl32.dll")
)
type _HANDLE uintptr
diff --git a/init_windows.go b/init_windows.go
index eaf4816..fdd28bb 100644
--- a/init_windows.go
+++ b/init_windows.go
@@ -70,6 +70,10 @@ func doWindowsInit() (err error) {
if err != nil {
return fmt.Errorf("error getting standard window fonts: %v", err)
}
+ err = initCommonControls()
+ if err != nil {
+ return fmt.Errorf("error initializing Common Controls (comctl32.dll): %v", err)
+ }
// TODO others
return nil // all ready to go
}
diff --git a/sysdata_windows.go b/sysdata_windows.go
index cd5d8c8..81a2d11 100644
--- a/sysdata_windows.go
+++ b/sysdata_windows.go
@@ -93,7 +93,7 @@ var classTypes = [nctypes]*classData{
addSpaceErr: _LB_ERRSPACE,
},
c_progressbar: &classData{
- name: XXXXX,
+ name: _PROGRESS_CLASS,
style: _PBS_SMOOTH | controlstyle,
xstyle: 0 | controlxstyle,
},