GDI操作基础(1)——拷贝A窗体的内容到B窗体上
来源:互联网 发布:充话费软件利润 编辑:程序博客网 时间:2024/06/04 01:20
Form2中的代码:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace DrawOnDesktop
- {
- public partial class Form2 : Form
- {
- private Form1 f1 = new Form1();
- private IntPtr f1_hdc = IntPtr.Zero;
- private IntPtr f2_hdc = IntPtr.Zero;
- public Form2()
- {
- InitializeComponent();
- f1.Show();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- f1_hdc = Win.GetDC(f1.Handle);
- f2_hdc = Win.GetDC(this.Handle);
- DrawOnDesktop.Win.Rect rect;
- Win.GetClientRect(f1.Handle, out rect);
- Win.BitBlt(f2_hdc, 0, 0, rect.right, rect.bottom, f1_hdc, 0, 0, 13369376);
- Win.ReleaseDC(f1.Handle, f1_hdc);
- Win.ReleaseDC(this.Handle, f2_hdc);
- }
- }
- }
Win.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Runtime.InteropServices;
- namespace DrawOnDesktop
- {
- public static class Win
- {
- [StructLayout(LayoutKind.Sequential) ]
- public struct Rect
- {
- public int left;
- public int top;
- public int right;
- public int bottom;
- }
- [DllImport("user32")]
- public static extern IntPtr GetDC(IntPtr hwnd);
- [DllImport("user32")]
- public static extern bool GetClientRect(IntPtr hWnd, out Rect rect);
- [DllImport("gdi32")]
- public static extern bool BitBlt(
- IntPtr hdcDest, // handle to destination DC
- int nXDest, // x-coord of destination upper-left corner
- int nYDest, // y-coord of destination upper-left corner
- int nWidth, // width of destination rectangle
- int nHeight, // height of destination rectangle
- IntPtr hdcSrc, // handle to source DC
- int nXSrc, // x-coordinate of source upper-left corner
- int nYSrc, // y-coordinate of source upper-left corner
- int dwRop // raster operation code
- );
- [DllImport("user32")]
- public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
- }
- }
Form1没有写代码,在Form中有一个定时器,触发事件为100ms。
- GDI操作基础(1)——拷贝A窗体的内容到B窗体上
- A窗体点按钮,弹出B窗体,B窗体修改了内容后,将数据传递回来到A窗体
- C# 窗体A跳转到窗体B 窗体B关闭后 A继续运行
- 如何在A窗体操作,让B窗体做出响应。
- 用委托实现B窗体刷新A窗体的数据
- 【C#】B窗体关闭时刷新A窗体的DataGridView
- 线程中操作窗体上的控件
- 打开的窗体1中”返回“按钮到窗体2
- 包含GDI+绘图的窗体滚动
- vb.net GDI窗体
- GDI+实现不规则窗体
- GDI+实现不规则窗体
- C#中一个窗体怎样对另外一个窗体操作,使窗体上的数据得到刷新?
- 选择子窗体上的GridView中的记录,传递到主窗体上去!
- C# 第一个窗体的数据传递到第二个窗体上应用
- winform窗体上的超链接怎么跳转到网页?
- C#子窗体进行数据操作后关闭,父窗体藏到后面问题的解决
- 权限系统收获——将一个窗体上的多条数据在另一个窗体上显示
- 如何快速切换静态和动态ip
- windows程序中怎样使用自定义鼠标(含动态鼠标)
- Swing App
- 调试器工作原理(译)
- [转贴]《雷神之锤III》里求平方根倒数的函数(快速平方根(倒数)算法)
- GDI操作基础(1)——拷贝A窗体的内容到B窗体上
- Set
- myeclipse 中使用Hql editor编辑器出现错误
- Oracle聚焦网格和开发工具
- 忘掉VIsta:10多个版本的OsX操作系统明年推出
- SOA加速政府信息资源共享
- FlowLayout 救助
- 转过来的 暗恋
- 机器视觉软件EVision介绍