Пример #1
0
func defaultDialogProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr {
	switch msg {
	case win.WM_COMMAND:
		fmt.Printf("WM_COMMAND msg=%v\n", msg)
		if lParam != 0 { //Reflect message to control
			h := win.HWND(lParam)
			fmt.Printf("WM_COMMAND h=%v\n", h)
			if handler := GetMsgHandler(h); handler != nil {
				fmt.Println("WM_COMMAND handler.WndProc")
				ret := handler.WndProc(msg, wParam, lParam)
				if ret != 0 {
					//win.SetWindowLong(hwnd, win.DWL_MSGRESULT, int32(ret))
					fmt.Println("WM_COMMAND TRUE")
					return win.TRUE
				}
			}
		}
		fmt.Println("WM_COMMAND DONE")
		return 0
	case win.WM_CLOSE:
		win.DestroyWindow(hwnd)
		return 0
	case win.WM_DESTROY:
		win.PostQuitMessage(0)
		return 1
	}

	return 0
}
Пример #2
0
func WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) (result uintptr) {
	switch msg {
	case win.WM_CREATE:
		result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	case win.WM_SIZE:
		// 最小化时不能调整Cef窗体,否则恢复时界面一片空白
		if wParam == win.SIZE_RESTORED || wParam == win.SIZE_MAXIMIZED {
			cef.WindowResized(unsafe.Pointer(hwnd))
		}
	case win.WM_CLOSE:
		win.DestroyWindow(hwnd)
	case win.WM_DESTROY:
		cef.QuitMessageLoop()
	default:
		result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	}
	return
}
Пример #3
0
func TransparentWndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) (result uintptr) {
	switch msg {
	case win.WM_CREATE:
		//a := *(*uintptr)(unsafe.Pointer(lParam))
		//fmt.Printf("WM_CREATE %v\n", a)
		result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	//case win.WM_NCPAINT:
	//	result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	case win.WM_LBUTTONDOWN:
		//fmt.Printf("WM_LBUTTONDOWN\n")
		if isEnableDrag {
			win.SetCapture(hwnd)

			win.GetWindowRect(hwnd, &rcWindow)
			win.GetCursorPos(&dragPoint)

			isDrag = true
		}
		result = 0
	case win.WM_LBUTTONUP:
		if win.GetCapture() == hwnd {
			win.ReleaseCapture()
		}
		isDrag = false
		result = 0
	case win.WM_NCCALCSIZE:
		wpCaptionLess := uintptr(win.GetProp(hwnd, WindowProp_CaptionLess))
		//fmt.Printf("wpCaptionLess=%v\n", wpCaptionLess)
		if wpCaptionLess == 1 && win.BOOL(wParam) == win.TRUE {
			var size_param *win.NCCALCSIZE_PARAMS = (*win.NCCALCSIZE_PARAMS)(unsafe.Pointer(lParam))
			size_param.Rgrc[2] = size_param.Rgrc[1]
			size_param.Rgrc[1] = size_param.Rgrc[0]
			result = 0
		} else {
			result = win.DefWindowProc(hwnd, msg, wParam, lParam)
		}
	//case win.WM_NCHITTEST:
	//x := win.LOWORD(uint32(lParam))
	//y := win.HIWORD(uint32(lParam))
	//s := fmt.Sprintf("WM_NCHITTEST x,y=%v,%v\n", x, y)

	//result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	case win.WM_MOUSEMOVE:
		//fmt.Printf("WM_MOUSEMOVE\n")
		if isDrag {
			var pe win.POINT
			win.GetCursorPos(&pe) // The new position for cursor pointer

			left := rcWindow.Left + (pe.X - dragPoint.X) // The horizontal position of the new window
			top := rcWindow.Top + (pe.Y - dragPoint.Y)   // The vertical position of the new windows

			//win.MoveWindow(hwnd,reWindow.Left,reWindow.Top,reWindow.Right,reWindow.Bottom,true);// Moving window
			win.SetWindowPos(hwnd, 0, left, top, 0, 0, win.SWP_NOSIZE|win.SWP_NOZORDER)
		}
	case win.WM_SIZE:
		// 最小化时不能调整Cef窗体,否则恢复时界面一片空白
		if wParam == win.SIZE_RESTORED || wParam == win.SIZE_MAXIMIZED {
			cef.WindowResized(unsafe.Pointer(hwnd))
		}
	case win.WM_CLOSE:
		win.DestroyWindow(hwnd)
	case win.WM_DESTROY:
		cef.QuitMessageLoop()
	default:
		result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	}
	//result = win.DefWindowProc(hwnd, msg, wParam, lParam)
	return
}