- 热门点击:
- 禁止显示"开始"菜单中的"windows升级菜单"
- Vista:仅以序列号区分七个版本?
- win vista
- 卡巴斯基指责Vista不安全 微软不做评价
- vista 价格
- OEM版Vista将和电脑终生绑定
- 杀木马
- 木马清除
- 灰鸽子木马正在加速传播 位居病毒排行之首
- 反木马
请教一个困扰了我很久的问题:WinForm程序被执行之后,……………
问题:
我在 vs.net 环境中新建了一个 form 窗体,在form 窗体的 [design] 时中,我先从
toolbox(工具箱)中拖出一个button放在form 窗体上,当我用鼠标点击button控件后,
因为button控件被选中了,所以button控件的周围会出现 八个 小白框,白框把button
控件包围住,小白框的底部还有一圈阴影。
然而,当: winform程序被执行之后,点击它里面的 button 之后,button控件的周围不会出现
八个 小白框,请问用何种方式能做到:在程序运行中,button 控件被点击之后,可以出现八个
小白框????
谢谢!!!!
运行态的控件当然不行了,可以生成一个设计态的按钮.看看sharpdevelop源码吧
现成的接口不是没有,但要跟envdte那些家伙打交道,就是说获取designerservice那些,比用gdi+实现麻烦得多。
制作一个控件,重写onpaint方法,里面用状态判断
bool isdesign;
protected override void onpaint(painteventargs e){
if(isdesign){
//画设计状态
}
else{
//画普通状态
}
}
isdesign改变的时候invalidate控件
以前我作出来的就是这种效果。根据sharpdevelop来做的,控件不是平常new出来的控件的,是利用.net底层接口,用定义的host生成出来的,放在窗体上就有四周的方框。当时我看了一个来月的sharpdevelop源码才做出来,好好看看吧。
呵呵,楼主和我做的差不多啊,不知道是做什么用的,有空交流一下
在.net中我知道的实现有两种方式:
1.利用framework的自带的结构,有个例子,链接找不到了,用formdesigner查应该可以查到
sharpdevelop用的也是这个,不过比较复杂,不易看懂
2.自己动手实现,虽然有点麻烦,不过还是不难的,这个也有程序可以参考,有本书叫<基于组件的开发>
第10章就是移动的例子,不过书有点贵
我用的是第2种方式,他的好处是不依赖framework,很方便支持图形组件的移动等
唉,我当初也是看的头晕,不过公司原因没有做下去,怀念那段日子呀,真想坚持做下去。
http://www.52dotnet.com/form.jpg
host = new defaultdesignerhost();
componentchangeservice changeservice = new componentchangeservice();
host.addservice(typeof(system.componentmodel.design.icomponentchangeservice), changeservice);
host.addservice(typeof(system.componentmodel.design.idesigneroptionservice), new icsharpcode.sharpdevelop.formdesigner.services.designeroptionservice());
host.addservice(typeof(system.componentmodel.design.itypedescriptorfilterservice), new typedescriptorfilterservice());
host.addservice(typeof(system.drawing.design.ipropertyvalueuiservice), new propertyvalueuiservice());
extenderservice extenderservice = new extenderservice();
host.addservice(typeof(system.componentmodel.design.iextenderlistservice), extenderservice);
host.addservice(typeof(system.componentmodel.design.iextenderproviderservice),extenderservice);
host.addservice(typeof(system.componentmodel.design.idesignerhost), host);
host.addservice(typeof(system.componentmodel.icontainer), host.container);
host.addservice(typeof(system.componentmodel.design.idictionaryservice), new dictionaryservice());
host.addservice(typeof(system.componentmodel.design.ieventbindingservice), new eventbindingservice(host));
host.addservice(typeof(system.componentmodel.design.iselectionservice), new selectionservice(host));
host.addservice(typeof(system.componentmodel.design.serialization.inamecreationservice), new namecreationservice(host));
host.addservice(typeof(system.componentmodel.design.idesignereventservice), new designereventservice());
host.addservice(typeof(system.componentmodel.design.ireferenceservice), new referenceservice(host));
host.addservice(typeof(system.componentmodel.design.serialization.idesignerserializationservice), new formdesign.designerserializationservice(host));
// add toolbox service
host.addservice(typeof(itoolboxservice), listview1);
populatetoolbox(listview1);
host.activate();
// host.transactionclosed += new designertransactioncloseeventhandler(transactionfinished);
if (designpanel == null)
{
designpanel = new designpanel(host);
}
else
{
designpanel.host = host;
}
// host.addservice(typeof(system.componentmodel.design.imenucommandservice), new menucommandservice(host, designpanel));
host.addservice(typeof(designpanel), designpanel);
host.addservice(typeof(system.componentmodel.design.imenucommandservice), new cmconfig.menucommandservice(host, designpanel));
designpanel.location = new point(0, 0);
designpanel.dock = dockstyle.fill;
// this.panel1.controls.add(designpanel);
listview1.designpanel = designpanel;
- · 关于数据库视图的问题,急急急!
- · 我完了,这都不会弄了.
- · 求?Image上建Rectangle选区后,怎样使区域反选
- · 我完了,这都不会弄了.
- · 哪位高人能把这两个PHP函数转成asp代码
- · ASP程序要怎样做防盗链?高分请教?
- · 新手问题!散分了!
- · 如何让一列数据在dbgrid中总是显示在最前面
- · 散分活动三!庆祝java电子杂志样刊完成!
- · 关于SQL Server视图?急!!!!
- · DOS那一代的程序员现在都干嘛呢? <ZT>
- · 哪位高人能把这两个PHP函数转成asp代码
- · 基础基础之基基础:请教关于MFC成员函数的声明格式
- · 怎么广东成绩还没出?都干什么了?难道他们不知道考生要的是他们的分数吗?
- · 请教各位高手,为什么原本鲜明的图标变得很黯淡呢??????????
- · 求教一个算法,高分求教
- · 有那位大虾能告诉我HTTP MIME type 里边有什么样的类型
- · 热烈祝贺我老公过生日 25号!!!
- · 请问一个DataGrid,没有分页,有下拉滚动条,无分页,点击某项时,能记住其位置
- · 赶在2004年末,问个小问题.在线急不可耐的等你们的回答
- · 整一个简单的。。
- · 请问一下C++ 跟VC有什么关系??新手来的
- · 如何让SMARTUPLOAD返回UTF-8编码?
- · TChart 中的Delete(0)有没有用?
- · 高手拿分来呀!!
- · 求! windows 的网卡共享(NAT)的一些实现细节
- · 反汇编软件谁有(motorola)
- · DataGrid显示主从表的数据,能否单击主表前的+号,直接把从表数据显示而不是还要再单击一次后再显示
- · 03115错误原因(急)
- · 怎么定义指针类型
- · [在线等]比较复杂的问题,高手和斑竹进来看看,解决就结贴
- · 大家要帮帮我啊,我有些亲戚竟然做传销了~~~
