jquery dialogbox详解怎么打开一个网页

1944人阅读
Windows API(25)
一般菜单项的后面加省略号(...)提示该菜单会激活一个对话框。
对话框的坐标X轴以对话框所用字体宽度的1/4为单位,Y轴以字体高度的1/8为单位。
对话框处理过程与窗口处理过程很相似,但也有一些不同,对话框过程不是窗口过程。一般在对话框处理过程中,我们只需要处理子窗口控件的初始化、子窗口控件消息和结束对话框。下面是一个对话框过程:BOOL CALLBACK DlgProc(HWND hDlg,UINT message,WPARAM wParam,lParam)
switch(message)
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
case IDOK:
case IDCANCEL:
EndDialog(hDlg,0);
return TURE;
return FALSE;
}&可以看出,虽然它与窗口过程参数相同,但返回值为BOOL型;窗口处理过程把不处理的消息交由DefWindowProc处理,而对话框消息不这样,对于处理的消息返回TRUE,不处理的消息返回FALSE;对话框消息不处理WM_PAINT与WM_DESTORY消息,也不会收到WM_CREATE消息。WM_INITDIALOG消息返回TRUE,对话框窗口会把输入焦点设为第一个可TAB停靠的控件,也可以在这个消息中用SetFocus指定输入焦点控件,但要返回FALSE。
模态对话框的消息不会进入程序的消息队列,但WndProc还会接收消息。
模态对话框
DialogBox(hInstance,MAKEINTRESOURCE(IDM_MYDIALOGBOX),hwnd,DlgProc):激活对话框,返回值是DlgProc中EndDialog的第二个参数。
DialogBox实际上调用了CreateWindow函数,CreateWindow的参数从对话框模板中获取,对话框模板可以提供几乎所有的参数(包括窗口类),如果没有定义窗口类,CreateWindow会注册一个特殊的窗口类。
如果要动态创建对话框,可以使用DialogBoxIndirect这个函数。模板中常用的一些控件类型有PUSHBUTTON、CHECKBOX、RADIOBUTTON、BROUPBOX、LTEXT、CTEXT、RTEXT、ICON、EDITTEXT、SCROLLBAR、LISTBOX、COMBOBOX
为了避免使用全局变量,可以用DialogBoxParam激活对话框。DialogBoxParam比DialogBoxParam多了一个32位的参数,可以传你需要的任意数据,一般传递一个结构体指针,这个参数传递到WM_INITDIALOGBOX消息的lParam。
对话框模板中,WS_TABSTOP标记表示按TAB时输入焦点在此停留,WS_GROUP标记表示与下一个WS_GROUP控件(不包括这个)之间的控件为一组,当用光标控制键时会在这输入焦点会在这一组切换。还可用GetNextDlgTabItem或GetNextDlgGroupItem获得下一个或前一个Tab或Group控件句柄。
MapDialogRect:把对话框的字符坐标转化成像素坐标。
自定义控件
首先在WinMain中注册窗口类并添加消息处理函数,再从工具箱添加一个自定义控件,在属性里填写刚刚注册的类名。
非模态对话框
使用CreateDialog创建,参数与DialogBox一样,但直接返回窗口句柄,一般句柄保存为全局变量。
非模态对话框的消息经由消息队列发到程序,所以非模态对话框要从消息队列中获取自己的消息,可以按下面方法修改消息循环while(GetMessage(&msg,NULL,0,0))
if(hDlgModeless==0 || IsDialogMessage(hDlgModeless,&msg)
TranslateMessage(&msg);
DispatchMessage(&msg);
}&IsDialogMessage把消息发给对话框,如果对话框处理则返回TRUE,不处理返回FALSE。
关闭非模态对话框用DestroyWindow而不是EndDialog。虽然非模态对话框默认有关闭按钮,但并不处理WM_CLOSE消息,用户必须添加处理过程:case WM_CLOSE:
DestroyWindow(hwnd);
hDlgModeless=NULL;
return TRUE;&DestroyWindow参数要写消息处理过程传递的窗口句柄。
可以直接用CreateDialog创建主窗口,但要自己写对话框模板并包含在.rc文件中,窗口类的cbWndExtra字段必须设为DLGWINDOWEXTRA,CreateDialog第三、四个参数为NULL,不能加对话框处理过程,所有消息处理在窗口类的窗口处理过程中。
通用对话框(Common Dialog Box)
要include头文件COMMDLG.h
GetOpenFileName(&ofn):ofn是OPENFILENAME结构体变量,创建一个打开文件对话框。
GetSaveFileName(&ofn):保存文件对话框。
ChooseFont(&cf):cf是CHOOSEFONT结构体变量,打开字体选择对话框。
FindText(&fr):fr是FINDREPLACE结构体变量,查找对话框。
ReplaceText(&fr):替换对话框。
RegisterWindowMessage(lpString):注册一个lpString指定的消息,返回消息ID。使用查找、替换对话框时,lpString为FINDMSGSTRING,在父窗口中注册,当点击查找、替换、关闭按钮时会给父窗口发送一个该函数注册的消息,lParam参数是FINDREPLACE结构体的指针。
ChooseColor(&cc):cc是CHOOSECOLOR结构体变量。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:61448次
积分:1000
积分:1000
排名:千里之外
原创:13篇
译文:25篇
评论:20条
(1)(1)(3)(5)(18)(4)(3)(4)1994人阅读
JavaScript(17)
dialogBox\css\dialogBox.css
.backgroundLayer_db{
z-index:9998;
border: 1px solid #A67901;
background: #EAEAEA;
.move_div{
width:100%;
background:url(../img/title_bg.jpg) repeat-x;
text-decoration:
display:inline-
line-height:25
.title_span{
line-height:25
display:inline-
.close_span{
width:100%;
height:100%;
background:url(../img/closeBox.gif) no-
background-position:
display:inline-
.content_div{
width:100%;
height:100%;
background: #
dialogBox\css\dialogBox.js
function DialogBox(args){
this.id = &0&;//层ID
this.title = &&;//层标题
this.width = 300;//层宽度
this.height = 200;//层高度
this.step = 10;
this.instance = &dialog&;//实例
this.content = &&;//层内容
if(args.id) this.id = args.
if(args.title) this.title = args.
if(args.width) this.width = args.
if(args.height) this.height = args.
if(args.instance) this.instance = args.
if(args.content) this.content = args.
if(!window.dialogBoxList){
window.dialogBoxList = [];
window.dialogBoxList[window.dialogBoxList.length] =
this.index = window.dialogBoxList.
this.show = function(){
var bgl = document.getElementById(&backgroundLayer_&+this.id);
if(bgl) document.body.removeChild(bgl);
//创建弹出背景层
bgl = document.createElement(&div&);
//给这个元素设置属性与样式
bgl.id = &backgroundLayer_&+this.
bgl.className = &backgroundLayer_db&;
bgl.style.width = this.width+&px&;
bgl.style.height = this.height+&px&;
bgl.style.left = &0px&;
bgl.style.top = &0px&;
document.body.appendChild(bgl);
var titleHTML = &&;
titleHTML += &&div id=\&move_div_&+this.id+&\& name=\&move_div\& class=\&move_div\&&&;
titleHTML += &&span id=\&title_span_&+this.id+&\& name=\&title_span\& class=\&title_span\& style=\&width:&+(this.width - 35)+&\&&&;
titleHTML += this.
titleHTML += &&/span&&;
titleHTML += &&a href=\&#\& onclick=\&&+this.instance+&.close();\& class=\&close_a\& title=\&关闭\&&&;
titleHTML += &&span id=\&close_span_&+this.id+&\& name=\&close_span\& class=\&close_span\&&&&/span&&;
titleHTML += &&/a&&;
titleHTML += &&/div&&;
titleHTML += &&div id=\&content_div_&+this.id+&\& name=\&content_div\& class=\&content_div\&&&;
if(this.content) titleHTML += this.
titleHTML += &&/div&&;
bgl.innerHTML = titleHTML;
this.resize();
bgl.style.height = &0px&;
bgl.style.top = (this.top + this.height )+ &px&;
this.moveTo();
this.close = function(){
var bgl = document.getElementById(&backgroundLayer_&+me.id);
document.body.removeChild(bgl);
this.moveTo = function(){
clearInterval(this.tempTimer);
this.bf = this.buffer(0, this.height,this.step);
var bgl = document.getElementById(&backgroundLayer_&+this.id);
this.tempTimer = setInterval(function() {//alert(me.bf[0]);
bgl.style.height = me.bf[0] + &px&;
bgl.style.top = me.top + me.index * me.height - me.index * me.bf[0] + &px&;
if(me.bf[1] == 0) {
clearInterval(me.tempTimer);
me.bf = me.buffer(me.bf[0],me.height,me.step);
this.buffer = function(a, b, c) {//缓冲计算
var cMath = Math[(a - b) & 0 ? &floor& : &ceil&];
c = c || 0.1;
return [a += cMath((b - a) / c), a - b];
this.top = 0;
//窗体改变大小时——遮罩背景层
this.resize = function(){
var bgl = document.getElementById(&backgroundLayer_&+me.id);
bgl.style.top = &0px&;
bgl.style.left = &0px&;
var pageSize = new PageSize();
bgl.style.left = (pageSize.clientWidth + pageSize.scrollLeft - me.width - 4) + &px&;
bgl.style.top = (pageSize.clientHeight + pageSize.scrollTop - (me.index * (me.height + 4))) + &px&;
this.top = pageSize.clientHeight + pageSize.scrollTop - (me.index * (me.height + 4));
this.onresize_fun = window.
//窗体改变大小时——重绘网格列表
this.onresize = function(){
window.onresize = function(){
if(me.onresize_fun){
me.onresize_fun();
if(me) me.resize();
this.onresize();//执行
function PageSize(){
this.pageWidth = 0 ;
this.pageHeight = 0 ;
this.clientWidth = 0;
this.clientHeight = 0;
//注意:scrollLeft、scrollTop必须在onscroll函数下才有值,直接打印出来是为0
this.scrollLeft = 0;//网页被卷去的左
this.scrollTop = 0;//网页被卷去的高
patMode == &BackCompat&) {
this.pageWidth = document.body.scrollW//body 对象
this.pageHeight = document.body.scrollH
this.clientWidth = document.body.clientW
this.clientHeight = document.body.clientH
this.scrollLeft = document.body.scrollL
this.scrollTop = document.body.scrollT
}else patMode == &CSS1Compat&){
this.pageWidth = document.documentElement.scrollW//html 对象
this.pageHeight = document.documentElement.scrollH
this.clientWidth = document.documentElement.clientW
this.clientHeight = document.documentElement.clientH
this.scrollLeft = document.documentElement.scrollLeft == 0 ? document.body.scrollLeft : document.documentElement.scrollL
this.scrollTop = document.documentElement.scrollTop == 0 ? document.body.scrollTop : document.documentElement.scrollT
this.pageWidth = this.pageWidth & this.clientWidth ? this.pageWidth : this.clientW
this.pageHeight = this.pageHeight & this.clientHeight ? this.pageHeight : this.clientH
dialogBox\img
closeBox.gif
还有一张背景上传不了。。
例子dialogBox.html
&meta http-equiv=&Content-Type& content=&text/ charset=utf-8&/&
&title&层&/title&
&link href=&css/dialogBox.css& type=&text/css& rel=&stylesheet&/&
&script src=&js/dialogBox.js& type=&text/javascript&&&/script&
&script type=&text/javascript&&
var dialog1 =new DialogBox({id:&1&,instance:&dialog1&,title:&提示&});
dialog1.content=&dialog1&;
dialog1.show();
var dialog2 =new DialogBox({id:&2&,instance:&dialog2&,title:&提示&});
dialog2.content=&dialog2&;
dialog2.show();
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:394296次
积分:2855
积分:2855
排名:第10110名
原创:36篇
转载:25篇
评论:26条
(1)(1)(1)(1)(2)(1)(1)(1)(1)(1)(1)(8)(1)(5)(6)(3)(3)(12)(10)(1)信息英语词汇第1247页 ...
dialog对话
dialogbox对话窗口
dialoging对话 ...
基于64个网页-
【转贴】天堂2FAQ(2) - 天堂2 - 线上游... ...
技能窗口 alt + k
对话窗口 alt + j
讨论区 alt + b ...
基于14个网页-
Display Preferences
3ds max 4完全使用手册|报价¥74.3 ...
Footstep Operations(脚步操作)展卷栏
Display Preferences对话窗口
Track Selection (轨迹选择)展卷栏 ...
基于6个网页-
Dialog Window
3、以弹出对话窗口(Dialog Window)的形式选择要保存(另存为)的文件
基于6个网页-
charscounter
window dialogue
Alert, Prompt, Confirm Windows
dialog box
&2,447,543篇论文数据,部分数据来源于
这将打开一个对话窗口,可在其中指定命名空间和端口名称。
This brings up a dialog window to specify the namespace and the port name.
这将打开一个对话窗口请求提供脚本的名称以及询问您希望如何编辑它。
This will open a dialog window, asking for the name of the script and how you wish to edit it.
但是,作者(或者可视化工具)根据原始语言中文本的长度定义了对话窗口的大小。
However, the author (or a visual tool) defines sizes for dialogue windows according to the size of the text in the original language.
$firstVoiceSent
- 来自原声例句
请问您想要如何调整此模块?
感谢您的反馈,我们会尽快进行适当修改!
请问您想要如何调整此模块?
感谢您的反馈,我们会尽快进行适当修改!}

我要回帖

更多关于 dialogboxparam 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信