popup窗口,点击按钮就是弹不出提醒窗口,哪位知道是什么问题呀?

wufayou433024 2010-11-06 08:16:09
所有代码我都是照书上源代码复制出来的,原来的程序能运行,按原样新建程序,把代码复制过来就不行,窗体名字都是一样的。
错误提示为
警告 1 “Popup.Controls.Frm_Popup.Show()”隐藏了继承的成员“System.Windows.Forms.Control.Show()”。如果是有意隐藏,请使用关键字 new。 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Frm_Popup\Frm_Popup\Frm_Popup.cs 92 21 Frm_Popup


//以下是Frm_Popup 窗体代码
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;
using System.Runtime.InteropServices;

namespace Popup.Controls
{
partial class Frm_Popup : System.Windows.Forms.Form
{

#region 变量
private InformStyle InfoStyle = InformStyle.Vanish;//定义变量为隐藏
private System.Drawing.Rectangle Rect;//定义一个存储矩形框的数组
private bool isMouseMove = false;//是否在窗体中移动
static private Frm_Popup F_Popup = new Frm_Popup();//实例化当前窗体
#endregion

#region 内置属性
/// <summary>
/// 定义一个任务通知器的枚举值
/// </summary>//InformStyle
protected enum InformStyle
{
/// <summary>
/// 隐藏
/// </summary>
Vanish = 0,
/// <summary>
/// 显视
/// </summary>
Display = 1,
/// <summary>
/// 显视中
/// </summary>
Displaying = 2,
/// <summary>
/// 隐藏中
/// </summary>
Vanishing = 3
}

/// <summary>
/// 获取或设置当前的操作状态
/// </summary>
protected InformStyle InfoState
{
get { return this.InfoStyle; }
set { this.InfoStyle = value; }
}
#endregion

public Frm_Popup()
{
this.InitializeComponent();
this.timer1.Stop();//停止计时器
//初始化工作区大小
System.Drawing.Rectangle rect = System.Windows.Forms.Screen.GetWorkingArea(this);
this.Rect = new System.Drawing.Rectangle(rect.Right - this.Width - 1, rect.Bottom - this.Height - 1, this.Width, this.Height);
}

#region 返回当前窗体的实例化
/// <summary>
/// 返回此对象的实例
/// </summary>
/// <returns></returns>
static public Frm_Popup Instance()
{
return F_Popup;
}
#endregion

#region 声明WinAPI
/// <summary>
/// 显示窗体
/// </summary>
/// <param name="hWnd"></param>
/// <param name="nCmdShow"></param>
/// <returns></returns>
[DllImport("user32.dll")]
private static extern Boolean ShowWindow(IntPtr hWnd, Int32 nCmdShow);
#endregion

#region 方法
/// <summary>
/// 显示窗体
/// </summary>
public void Show()
{
switch (this.InfoState)
{
case InformStyle.Vanish://窗体隐藏
this.InfoState = InformStyle.Displaying;//设置窗体的操作状态为显示中
this.SetBounds(Rect.X, Rect.Y + Rect.Height, Rect.Width, 0);//显示Popup窗体,并放置到屏幕的底部
ShowWindow(this.Handle, 4);//显示窗体
this.timer1.Interval = 100;//设置时间间隔为100
this.timer1.Start();//启动计时器
break;
case InformStyle.Display://窗体显示
this.timer1.Stop();//停止计时器
this.timer1.Interval = 5000;//设置时间间隔为5000
this.timer1.Start();//启动记时器
break;
}
}
#endregion

#region 事件
private void timer1_Tick(object sender, System.EventArgs e)
{
switch (this.InfoState)
{
case InformStyle.Display://显示当前窗体
this.timer1.Stop();//停止计时器
this.timer1.Interval = 100;//设置时间间隔为100
if (!(this.isMouseMove))//如果鼠标不在窗体中移动
this.InfoState = InformStyle.Vanishing;//设置当前窗体的操作状态为隐藏中
this.timer1.Start();//启动计时器
break;
case InformStyle.Displaying://当前窗体显示中
if (this.Height <= this.Rect.Height - 12)//当窗体没有完全显示时
this.SetBounds(Rect.X, this.Top - 12, Rect.Width, this.Height + 12);//使窗体不断上移
else
{
this.timer1.Stop();//停止计时器
this.SetBounds(Rect.X, Rect.Y, Rect.Width, Rect.Height);//设置当前窗体的边界
this.InfoState = InformStyle.Display;//设置当前窗体的操作状态为显示
this.timer1.Interval = 5000;//设置时间间隔为5000
this.timer1.Start();//启动计时器
}
break;
case InformStyle.Vanishing://隐藏当前窗体
if (this.isMouseMove)//如果鼠标在窗体中移动
this.InfoState = InformStyle.Displaying;//设置窗体的操作状态为显示
else
{
if (this.Top <= this.Rect.Bottom - 12)//如果窗体没有完全隐藏
this.SetBounds(Rect.X, this.Top + 12, Rect.Width, this.Height - 12);//使窗体不断下移
else
{
this.Hide();//隐藏当前窗体
this.InfoState = InformStyle.Vanish;//设置窗体的操作状态为隐藏
}
}
break;
}
}

private void Frm_Popup_MouseMove(object sender, MouseEventArgs e)
{
this.isMouseMove = true;//当鼠标移入时,设为true
}

private void Frm_Popup_MouseLeave(object sender, EventArgs e)
{
this.isMouseMove = false;//当鼠标移出时,设为false
}

private void pictureBox1_Click(object sender, EventArgs e)
{
if (this.InfoState != InformStyle.Vanish)//如果窗体的状态不是隐藏
{
this.timer1.Stop();//停止计时器
this.InfoState = InformStyle.Vanish;//设置窗体的操作状态为隐藏
base.Hide();//隐藏当前窗体
}
}

private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
pictureBox1.Image = null;
pictureBox1.Image = Image.FromFile("Close1.bmp");
}

private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.Image = null;
pictureBox1.Image = Image.FromFile("Close2.bmp");
}
#endregion
}
}


//以下是Form1的代码 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 Frm_Popup
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Popup.Controls.Frm_Popup.Instance().Show();
}
}
}

...全文
615 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
闪耀星星 2010-11-06
  • 打赏
  • 举报
回复
Rect计算看不懂,用这个System.Drawing.Rectangle rect = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
下面两句位置调换一下
this.SetBounds(Rect.X,Rect.Y,Rect.Width,Rect.Height);
//显示Popup窗体,并放置到屏幕的底部
ShowWindow(this.Handle,4);

private enum WindowShowStyle
{
///<summary> Hides the window and activates another window.</summary>
///<remarks> See SW_HIDE </remarks>
Hide = 0,
/// <summary> Activates and displays a window. If the window is minimized
/// or maximized, the system restores it to its original size and
/// position. An application should specify this flag when displaying
/// the window for the first time. </summary>
/// <remarks> See SW_SHOWNORMAL </remarks>
ShowNormal = 1,
/// <summary> Activates the window and displays it as a minimized window. </summary>
/// <remarks> See SW_SHOWMINIMIZED </remarks>
ShowMinimized = 2,
/// <summary> Activates the window and displays it as a maximized window. </summary>
/// <remarks> See SW_SHOWMAXIMIZED </remarks>
ShowMaximized = 3,
/// <summary> Maximizes the specified window. </summary>
/// <remarks> See SW_MAXIMIZE </remarks>
Maximize = 3,
/// <summary> Displays a window in its most recent size and position.
/// This value is similar to "ShowNormal ", except the window is not
/// actived. </summary>
/// <remarks> See SW_SHOWNOACTIVATE </remarks>
ShowNormalNoActivate = 4,
/// <summary> Activates the window and displays it in its current size
/// and position. </summary>
/// <remarks> See SW_SHOW </remarks>
Show = 5,
/// <summary> Minimizes the specified window and activates the next
/// top-level window in the Z order. </summary>
/// <remarks> See SW_MINIMIZE </remarks>
Minimize = 6,
/// <summary> Displays the window as a minimized window. This value is
/// similar to "ShowMinimized ", except the window is not activated. </summary>
/// <remarks> See SW_SHOWMINNOACTIVE </remarks>
ShowMinNoActivate = 7,
/// <summary> Displays the window in its current size and position. This
/// value is similar to "Show ", except the window is not activated. </summary>
/// <remarks> See SW_SHOWNA </remarks>
ShowNoActivate = 8,
/// <summary> Activates and displays the window. If the window is
/// minimized or maximized, the system restores it to its original size
/// and position. An application should specify this flag when restoring
/// a minimized window. </summary>
/// <remarks> See SW_RESTORE </remarks>
Restore = 9,
/// <summary> Sets the show state based on the SW_ value specified in the
/// STARTUPINFO structure passed to the CreateProcess function by the
/// program that started the application. </summary>
/// <remarks> See SW_SHOWDEFAULT </remarks>
ShowDefault = 10,
/// <summary> Windows 2000/XP: Minimizes a window, even if the thread
/// that owns the window is hung. This flag should only be used when
/// minimizing windows from a different thread. </summary>
/// <remarks> See SW_FORCEMINIMIZE </remarks>
ForceMinimized = 11
}
wufayou433024 2010-11-06
  • 打赏
  • 举报
回复
我试了各位的方法还是不行,错误是没有了,点按钮后就是弹不出提醒窗口
Ny-6000 2010-11-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 sito_hongta 的回复:]
代码太长了~~帮顶一下
[/Quote]

到底哪儿错了.说明就行,这么长谁有时间一行行看哪!@!@
LorenLiu 2010-11-06
  • 打赏
  • 举报
回复
sorry看错了,你这个本来就是warning,那可以忽略我写的第三种解决方法
LorenLiu 2010-11-06
  • 打赏
  • 举报
回复
提示不是写的很清楚了吗?你得把

partial class Frm_Popup : System.Windows.Forms.Form
这个类中的
public void Show()

这个方法改一下,因为对于它的基类Form也有一个Show方法,你有几种选择:
1. 把这个方法改成 public new void Show()
2. 修改方法名为ShowForm这种不会和Form中方法重名的
3. 看看你的工程属性里是不是把Build选项卡中的Treat warning as errors设置成了All,如果是的话,把它设置成None就可以看到这个问题作为warning出现,而不会编译错误了
兔子-顾问 2010-11-06
  • 打赏
  • 举报
回复
下次贴代码用UBB排版一下。
例如

你的代码


按提示,你尝试吧
public void Show()
改为:
public new void Show()
wufayou433024 2010-11-06
  • 打赏
  • 举报
回复
知道了,timer的单击事件,没关联上。
LorenLiu 2010-11-06
  • 打赏
  • 举报
回复
你加个断点进到timer的tick响应事件中,打个断点看看是不是Form的位置不对了。
LorenLiu 2010-11-06
  • 打赏
  • 举报
回复
Sorry,看错了,你上面有这句话。。。
LorenLiu 2010-11-06
  • 打赏
  • 举报
回复
貌似你在

public void Show()
{
switch (this.InfoState)
{
case InformStyle.Vanish://窗体隐藏
this.InfoState = InformStyle.Displaying;//设置窗体的操作状态为显示中
this.SetBounds(Rect.X, Rect.Y + Rect.Height, Rect.Width, 0);//显示Popup窗体,并放置到屏幕的底部
ShowWindow(this.Handle, 4);//显示窗体
this.timer1.Interval = 100;//设置时间间隔为100
this.timer1.Start();//启动计时器
break;

这部分里面没有设置InfoStyle。

尝试加入this.InfoState = InformStyle.Displaying;
wufayou433024 2010-11-06
  • 打赏
  • 举报
回复
显示出一个标题栏,没在右下方,窗体像是没到右下方,也没显示出来,代码都是从书的源代码拷过来的,不知要设置什么控件的属性,看了timer时间设置是一样的100没错。哪位知道怎么解呀?
内容概要:本文档详细介绍了“南方数码房地一体内外业软件”的操作流程,涵盖从数据准备、外业调查、内外业数据对接,到内业数据处理与成果输出的完整工作链。主要包括调查底图制作(支持DWG、MDB、SHP及倾斜三维模型等多种数据源)、导出外业IDB工程文件、平板端外业调查(宗地与房屋核实、电子签章表确认、照片导出)、内外业数据对接(DB与照片数据导入),以及内业的宗地信息完善、界址属性设置、自然幢生成、房屋面积计算、户属性录入,并最终输出宗地图、房产分户图、各类报表及MDB数据库等成果。; 适合人群:从事农村房地一体权籍调查的测绘、不动产登记及相关地理信息行业的内业处理人员、外业调查员和技术管理人员,需具备基础GIS或CAD操作能力; 使用场景及目标:①指导用户系统完成从原始数据到不动产登记成果的全流程作业;②实现外业调查数据高效采集与内业自动化处理衔接,提升房地一体确权登记工作的标准化与效率; 阅读建议:建议结合实际项目按章节顺序操作,重点关注数据格式转换、IDB工程交互逻辑及成果图输出设置,配合软件界面逐步实践,确保各环节数据完整性与准确性。
内容概要:本文围绕“面向高精度电流控制的PMSM多参数PSO辨识模型研究”,结合Simulink仿真实现,系统探讨了在高性能电机控制背景下,如何利用粒子群优化算法(PSO)对永磁同步电机(PMSM)电流环的关键参数进行多参数协同辨识。研究通过建立PMSM的精确动态数学模型,设计基于PSO的参数辨识框架,实现了对电机电感、电阻、反电动势常数等核心参数的高效在线或离线辨识,有效提升了电流控制的精度与系统鲁棒性。文中详细阐述了PSO算法的实现机制,包括适应度函数构造、参数编码策略与收敛判据,并在Simulink中构建了完整的联合仿真平台,通过大量仿真实验验证了该方法相较于传统辨识技术在准确性、稳定性和适应性方面的显著优势,为高动态性能电机驱动系统的参数获取提供了可靠的技术路径。; 适合人群:自动化、电气工程、控制科学与工程等相关专业的研究生、科研人员及从事高性能电机驱动系统开发的工程师。; 使用场景及目标:①应用于高端制造、新能源汽车、航空航天等领域中对电流控制精度要求极高的PMSM控制系统开发;②作为智能优化算法(如PSO)在电机参数辨识领域应用的典型案例,服务于教学演示与学术研究;③为后续开展自适应控制、智能容错控制及多物理场耦合建模等前沿课题提供坚实的参数辨识基础和技术参考。; 阅读建议:读者应具备扎实的电机控制理论基础(如FOC矢量控制、现代控制理论)以及熟练的MATLAB/Simulink仿真能力,建议在学习过程中结合文中的仿真模型,动手复现PSO参数辨识的完整流程,深入分析算法参数设置对辨识结果的影响,从而全面掌握其工程应用精髓。

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧