Esempio n. 1
1
func main() {
	var hwnd win.HWND
	cxScreen := win.GetSystemMetrics(win.SM_CXSCREEN)
	cyScreen := win.GetSystemMetrics(win.SM_CYSCREEN)
	win.MessageBox(hwnd, _TEXT("屏幕长:"+_toString(cxScreen)+"宽:"+_toString(cyScreen)), _TEXT("消息"), win.MB_OK)
}
Esempio n. 2
0
// 获取居中坐标
func screenCenter(w, h int) (x, y int) {
	srcWidth := win.GetSystemMetrics(win.SM_CXSCREEN)
	srcHeight := win.GetSystemMetrics(win.SM_CYSCREEN)
	x = (int(srcWidth) - w) / 2
	y = (int(srcHeight) - h) / 2
	// fmt.Println("dec main:", srcWidth, srcHeight, w, h, x, y)
	return
}
Esempio n. 3
0
func imageListForImage(image interface{}) (hIml win.HIMAGELIST, isSysIml bool, err error) {
	if filePath, ok := image.(string); ok {
		_, hIml = iconIndexAndHImlForFilePath(filePath)
		isSysIml = hIml != 0
	} else {
		w, h := win.GetSystemMetrics(win.SM_CXSMICON), win.GetSystemMetrics(win.SM_CYSMICON)

		hIml = win.ImageList_Create(w, h, win.ILC_MASK|win.ILC_COLOR32, 8, 8)
		if hIml == 0 {
			return 0, false, newError("ImageList_Create failed")
		}
	}

	return
}
Esempio n. 4
0
func fitRectToScreen(hWnd win.HWND, r Rectangle) Rectangle {
	var mi win.MONITORINFO
	mi.CbSize = uint32(unsafe.Sizeof(mi))

	if !win.GetMonitorInfo(win.MonitorFromWindow(
		hWnd, win.MONITOR_DEFAULTTOPRIMARY), &mi) {

		return r
	}

	mon := rectangleFromRECT(mi.RcWork)

	mon.Height -= int(win.GetSystemMetrics(win.SM_CYCAPTION))

	if r.Width <= mon.Width {
		switch {
		case r.X < mon.X:
			r.X = mon.X
		case r.X+r.Width > mon.X+mon.Width:
			r.X = mon.X + mon.Width - r.Width
		}
	}

	if r.Height <= mon.Height {
		switch {
		case r.Y < mon.Y:
			r.Y = mon.Y
		case r.Y+r.Height > mon.Y+mon.Height:
			r.Y = mon.Y + mon.Height - r.Height
		}
	}

	return r
}
Esempio n. 5
0
func (cb *CheckBox) MinSizeHint() Size {
	defaultSize := cb.dialogBaseUnitsToPixels(Size{50, 10})
	textSize := cb.calculateTextSizeImpl("n" + windowText(cb.hWnd))

	// FIXME: Use GetThemePartSize instead of GetSystemMetrics?
	w := textSize.Width + int(win.GetSystemMetrics(win.SM_CXMENUCHECK))
	h := maxi(defaultSize.Height, textSize.Height)

	return Size{w, h}
}
Esempio n. 6
0
func osGetScreenSize() (int, int) {
	w := win.GetSystemMetrics(win.SM_CXSCREEN)
	h := win.GetSystemMetrics(win.SM_CYSCREEN)
	return int(w), int(h)
}
Esempio n. 7
0
File: icon.go Progetto: Archs/walk
func (i *Icon) Size() Size {
	return Size{int(win.GetSystemMetrics(win.SM_CXICON)), int(win.GetSystemMetrics(win.SM_CYICON))}
}