EnumChildWindows 如何得到子窗体句柄的集合? 求高人指点
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EnumChildWindows 如何得到子窗体句柄的集合? 求高人指点相关的知识,希望对你有一定的参考价值。
C# 代码实现
参考技术A BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)char sWindowName[128]=0;
char* sVMName = (char*)lParam;
::GetWindowText(hwnd,sWindowName,128);
if (strstr(sWindowName,sVMName)) //符合指定的名字
hwndFind = hwnd; //找到的指定的窗口句柄
return FALSE;
return TRUE;
本回答被提问者和网友采纳 参考技术B 源码啊亲,
子窗体父窗体方法互调
var childWindow = $("#editFrame")[0].contentWindow;//获取子窗体的window对象.
childWindow.subForm();
$("#editFrame")得到frame
[0].contentWindow//frame的子窗体,将JQUERY对象转化为DOM对象
subForm();//字窗体定义的方法
-----------------------------------------------------
子窗体调用父窗体的方法
function afterEdit(data) {
if (data == "ok") {
window.parent.afterEdit(data);
}
}
-------------------------------------
@model CZBK.ItcastOA.Model.RoleInfo @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>编辑角色信息</title> <script src="~/Scripts/jquery-1.7.1.min.js"></script> <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script> <script type="text/javascript"> function subForm() { $("#editForm").submit(); } function afterEdit(data) { if (data == "ok") { window.parent.afterEdit(data); } } </script> </head> <body> @using (Ajax.BeginForm("EditRoleInfo", "RoleInfo", new { }, new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterEdit" }, new {id="editForm"})) { @Html.ValidationSummary(true) <fieldset> <legend>RoleInfo</legend> @Html.HiddenFor(model => model.ID) <div class="editor-label"> @Html.LabelFor(model => model.RoleName, "角色名称") </div> <div class="editor-field"> @Html.EditorFor(model => model.RoleName) @Html.ValidationMessageFor(model => model.RoleName) </div> <div class="editor-label"> @Html.LabelFor(model => model.DelFlag) </div> <div class="editor-field"> @Html.EditorFor(model => model.DelFlag) @Html.ValidationMessageFor(model => model.DelFlag) </div> <div class="editor-label"> @Html.LabelFor(model => model.SubTime) </div> <div class="editor-field"> @Html.EditorFor(model => model.SubTime) @Html.ValidationMessageFor(model => model.SubTime) </div> <div class="editor-label"> @Html.LabelFor(model => model.Remark) </div> <div class="editor-field"> @Html.EditorFor(model => model.Remark) @Html.ValidationMessageFor(model => model.Remark) </div> <div class="editor-label"> @Html.LabelFor(model => model.ModifiedOn) </div> <div class="editor-field"> @Html.EditorFor(model => model.ModifiedOn) @Html.ValidationMessageFor(model => model.ModifiedOn) </div> <div class="editor-label"> @Html.LabelFor(model => model.Sort) </div> <div class="editor-field"> @Html.EditorFor(model => model.Sort) @Html.ValidationMessageFor(model => model.Sort) </div> </fieldset> } <div> @Html.ActionLink("Back to List", "Index") </div> </body> </html>
@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>角色管理</title> <link href="~/Content/themes/default/easyui.css" rel="stylesheet" /> <link href="~/Content/themes/icon.css" rel="stylesheet" /> <script src="~/Scripts/jquery-1.7.1.min.js"></script> <script src="~/Scripts/jquery.easyui.min.js"></script> <script src="~/Scripts/easyui-lang-zh_CN.js"></script> <script src="~/Scripts/datapattern.js"></script> <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script> <script type="text/javascript"> $(function () { loadData(); $("#addDiv").css("display", "none"); $("#editDiv").css("display", "none"); }); function loadData(pars) { $(\'#tt\').datagrid({ url: \'/RoleInfo/GetRoleInfo\', title: \'角色数据表格\', width: 700, height: 400, fitColumns: true, //列自适应 nowrap: false, idField: \'ID\',//主键列的列明 loadMsg: \'正在加载角色的信息...\', pagination: true,//是否有分页 singleSelect: false,//是否单行选择 pageSize: 5,//页大小,一页多少条数据 pageNumber: 1,//当前页,默认的 pageList: [5, 10, 15], queryParams: pars,//往后台传递参数 columns: [[//c.UserName, c.UserPass, c.Email, c.RegTime { field: \'ck\', checkbox: true, align: \'left\', width: 50 }, { field: \'ID\', title: \'编号\', width: 80 }, { field: \'RoleName\', title: \'角色名称\', width: 120 }, { field: \'Sort\', title: \'排序\', width: 120 }, { field: \'Remark\', title: \'备注\', width: 120 }, { field: \'SubTime\', title: \'时间\', width: 80, align: \'right\', formatter: function (value, row, index) { return (eval(value.replace(/\\/Date\\((\\d+)\\)\\//gi, "new Date($1)"))).pattern("yyyy-M-d"); } } ]], toolbar: [{ id: \'btnDelete\', text: \'删除\', iconCls: \'icon-remove\', handler: function () { deleteInfo(); } }, { id: \'btnAdd\', text: \'添加\', iconCls: \'icon-add\', handler: function () { addInfo(); } }, { id: \'btnEdit\', text: \'编辑\', iconCls: \'icon-edit\', handler: function () { eidtInfo(); } }], }); } //编辑用户信息 function eidtInfo() { var rows = $(\'#tt\').datagrid(\'getSelections\'); if (rows.length != 1) { //alert("请选择要修改的商品!"); $.messager.alert("提醒", "请选择要编辑的1条记录!", "error"); return; } // $.post("/UserInfo/GetUserInfoModel", { "id": rows[0].ID }, function (data) { //if (data.msg == "ok") { //$("#txtUName").val(data.serverData.UName); //$("#txtUPwd").val(data.serverData.UPwd); //$("#txtRemark").val(data.serverData.Remark); //$("#txtSort").val(data.serverData.Sort); //$("#txtSubTime").val(ChangeDateFormat(data.serverData.SubTime)); //$("#txtDelFlag").val(data.serverData.DelFlag); //$("#txtId").val(data.serverData.ID); $("#editFrame").attr("src", "/RoleInfo/ShowEditInfo/?id=" + rows[0].ID); $("#editDiv").css("display", "block"); $(\'#editDiv\').dialog({ title: "编辑角色信息", width: 300, height: 350, collapsible: true, resizable: true, modal: true, buttons: [{ text: \'确定\', iconCls: \'icon-ok\', handler: function () { //$("#editForm").submit();//提交表单 var childWindow = $("#editFrame")[0].contentWindow;//获取子窗体的window对象. childWindow.subForm(); } }, { text: \'取消\', handler: function () { $(\'#editDiv\').dialog(\'close\'); } }] }); } //修改完成以后调用该方法 function afterEdit(data) { if (data == "ok") { $(\'#editDiv\').dialog(\'close\'); $(\'#tt\').datagrid(\'reload\'); } else { $.messager.alert("提醒", "修改数据错误!!", "error"); } } //添加信息 function addInfo() { $("#addDiv").css("display", "block"); $(\'#addDiv\').dialog({ title: "添加角色信息", width: 300, height: 300, collapsible: true, resizable: true, modal: true, buttons: [{ text: \'确定\', iconCls: \'icon-ok\', handler: function () { $("#addForm").submit();//提交表单 } }, { text: \'取消\', handler: function () { $(\'#addDiv\'DEV控件 xtraTabbedMdiManager 如何将关闭子窗体改为收回主窗体内?