You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
3.2 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Container.Common;
namespace Container.ChildWindows
{
/// <summary>
/// BGPage.xaml 的交互逻辑
/// </summary>
public partial class BGPage : Window
{
Class_Log log = new Class_Log();
App app = ((App)System.Windows.Application.Current);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string IpClassName, string IpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uflags);
public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); //窗体置顶
public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); //取消窗体置顶
public static readonly IntPtr HWND_BOTTOM = new IntPtr(1); //取消窗体置顶
public const uint SWP_NOMOVE = 0x0002; //不调整窗体位置
public const uint SWP_NOSIZE = 0x0001; //不调整窗体大小
public BGPage()
{
InitializeComponent();
}
public void LoadImage(string pageUrl) {
if (string.IsNullOrEmpty(pageUrl)) {
this.Width = 0;
this.Height = 0;
this.bgPage.Width = 0;
this.bgPage.Height = 0;
this.WindowState = WindowState.Minimized;
}
else
{
this.Width = app.ScreenWidth;
this.Height = app.ScreenHeight;
this.bgPage.Width = app.ScreenWidth;
this.bgPage.Height = app.ScreenHeight;
this.WindowState = WindowState.Maximized;
if (File.Exists(pageUrl) == true)
{
Uri uri = new Uri(pageUrl, UriKind.Absolute);
ImageBrush ib = new ImageBrush();
ib.ImageSource = new BitmapImage(uri);
this.bgPage.Background = ib;
}
}
IntPtr WinMain = FindWindow(null, "MainWindow"); //Win_h5Page是我的程序中需要置顶的窗体的名字
if (WinMain != null)
{
SetWindowPos(WinMain, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
IntPtr Win = FindWindow(null, "BGPage"); //Win_h5Page是我的程序中需要置顶的窗体的名字
if (Win != null)
{
SetWindowPos(Win, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
}
private void BGPage_Load(object sender, RoutedEventArgs e)
{
//log.WriteLogFile("信发是否启用:" + pcstart.ToString());
// IntPtr Win = FindWindow(null, "ADInsert"); //取消置顶
}
}
}