用资源文件重绘窗体的问题,总提示如下错误,代码我贴出来,请大家帮忙!!!1
其它信息:未将对象的引用设置到对象的实例
生成资源文件的代码如下:
public frmMain()
{
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
ResourceWriter rw = new ResourceWriter ("My.resources");
Image bottomLeft = Image.FromFile ("bottom_left.bmp");
rw.AddResource ("bottom_left.bmp" , bottomLeft);
rw.Generate();
rw.Close();
}
调用资源文件代码如下:
using System;
using System.Resources;
using System.Reflection;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ZHWebClient
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private ResourceManager rm;
private Image Bottom_Left;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
rm = new ResourceManager("ZHWebClient.My", Assembly.GetExecutingAssembly());
Bottom_Left = (Bitmap)rm.GetObject("bottomLeft");
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Form1";
this.Text = "Form1";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g=e.Graphics;
DrawMiddle_Left(e.Graphics);
}
private void DrawMiddle_Left(Graphics g)
{
Rectangle rect = new Rectangle(0, 0, Bottom_Left.Width, Bottom_Left.Height);
Brush brush = new TextureBrush(Bottom_Left, rect);
Rectangle rect1 = new Rectangle(Width - Bottom_Left.Width, 0, Bottom_Left.Width, Bottom_Left.Height);
g.FillRectangle(brush, rect1);
}
}
}
相关推荐
dx9.0c(DirectX 9.0c)
DirectX 9.0c 是由微软公司推出的一款应用于 Windows 平台的多媒体编程接口。 DirectX 9.0c 包含多个组件,各组件及其功能如下 : Direct Graphics:包括 Direct3D 和 DirectDraw,主要负责 3D 图形的渲染和 2D 图形的绘制,为游戏和其他图形应用程序提供了强大的图形处理能力。 Direct Input:用于处理用户输入设备,如键盘、鼠标、游戏手柄等,通过设备映射功能,使应用程序能够更简单地支持各种输入设备。 Direct Play:专注于多人游戏的网络通信和会话管理,提高了多人游戏的性能和可扩展性,还提供了 IP 声音通讯功能,增强了游戏的互动性。 Direct Sound 与 Direct Music:分别用于处理声音的播放和音乐的合成,强化了这两个组件的接口,简化了应用扩展,DLS2 音频合成功能提高了乐器音频的真实感,为游戏和多媒体应用程序提供了高质量的音频效果。 Direct Show:提供了音频 / 视频的实时合成和即时编辑功能,支持 Windows 媒体音频和视频(WMA 和 WMV)的读写,还支持 Micro
MFC窗口重绘实战:从原理到自定义皮肤实现
在Windows桌面开发中,GDI绘图和消息机制是构建图形用户界面的基础技术。GDI(图形设备接口)提供了底层的绘图能力,而消息循环机制则负责响应用户交互。理解窗口绘制的分层原理,特别是非客户区与客户区的划分,对于实现高度自定义的界面至关重要。这项技术的核心价值在于能够突破系统默认主题的限制,实现像素级的界面控制,从而打造独特品牌风格或适配特定业务场景的应用。通过处理WM_NCPAINT、WM_ERASEBKGND等关键消息,并结合双缓冲绘图技术,开发者可以高效地重绘窗口的各个部分,包括标题栏、边框和控件。
DX9.0c_X86_最终版(网吧装上这个游戏基本没问题的了)
DX9.0c_X86_最终版(网吧装上这个游戏基本没问题的了)
Microsoft_DX9.0c_CP_5.4.0.3900.zip
Microsoft_DX9.0c_CP_5.4.0.3900.zip
directx龙书/DX93D游戏程序设计入门中文版
directx龙书/DX93D游戏程序设计入门 包括原版和中文版


