如何在设计时更改MFC 中控件的Z顺序- 即我不能使用SetWindowPos或在运行时执行此操作 - 我希望在设计器中看到更改的z顺序(即使我必须求助于 -编辑.rc代码).
我有一个MFC对话框,我正在添加控件.如果控件的边缘之间有重叠,我想将一个带到另一个的前面.在Windows窗体或WPF等我可以带到前面,发送到后面,前进,后退.我在MFC中找不到这些选项,也无法判断它如何确定前面的内容,因为刚刚添加的控件通常位于之前的控件之后.如何操作MFC中的Z顺序?即使我必须直接操作.rc文件代码(即在设计器周围运行).
在WPF DocumentViewer中显示XPS文件并关闭DocumentViewer实例后,XPS文件被锁定,我无法删除它.我需要释放XPS文件上的锁,以便我可以删除它,编写另一个具有相同名称的文件,并可选择在新的DocumentViewer实例中显示新的XPS文件.我需要在同一个应用程序实例中执行此操作 - 无需关闭应用程序(这是打印预览方案).
换句话说,如何在不在"File.Delete(tempXpsFile);"处抛出异常的情况下运行以下代码?声明?
var tempXpsFile = @"c:\path\to\Temporary.xps";
var previewWindow = new Window();
var docViewer = new DocumentViewer();
previewWindow.Content = docViewer;
GenerateXpsFile(tempXpsFile);
var xpsDocument = new XpsDocument(tempXpsFile);
previewWindow.ShowDialog();
File.Delete(tempXpsFile); //this will throw an exception due to a file lock on tempXpsFile
GenerateXpsFile(tempXpsFile); //assume this generates a different file
//otherwise the scenario doesn't make sense as we could just skip the above delete
//and this statement and re-use the same file
previewWindow = new Window();
docViewer = new DocumentViewer();
previewWindow.Content …Run Code Online (Sandbox Code Playgroud) 我想构建一个MSI,它在安装过程中将自己与包含的文件/组件一起部署到TargetDir.
所以MyApp.msi在其文件表中包含MyApp.exe和MyAppBootstrapperEmpty.exe(没有资源).
用户启动MyAppBootstrapperPackaged.exe(包含MyApp.msi作为资源,从某处获取,或通过电子邮件或其他方式获得).MyAppBootStrapperPackaged.exe将MyApp.msi提取到临时文件夹并通过msiexec.exe执行.
在msiexec.exe进程完成后,我想要MyApp.msi,MyBootstrapperEmpty.exe(和%ProgramFiles%\ MyApp文件夹中的和MyApp.exe,以便MyApp.exe在运行时可以确保访问MyApp.msi(用于创建以下内容)提到包装内容).
MyAppBootstrapper*.exe可以尝试将MyApp.msi复制到%ProgramFiles%\ MyApp文件夹,但需要提升才能执行此操作,并且不允许通过Windows Installer卸载过程(从"添加/删除程序"或其他方式)删除它,应该保留.
显然(我认为这很明显 - 我错了吗?)我不能将MSI作为文件包含在我的Media/CAB(鸡蛋和鸡蛋场景)中,所以我认为必须在安装之前通过自定义操作完成进程,将原始MSI添加到MSI DB的Media/CAB以及动态文件表中的相应条目.可以这样做,如果是这样的话怎么办?
想一想内容分发模型,其中内容文件只能与App一起分发.内容由最终用户在运行时通过App生成,并打包成可分发的EXE,其中包括App和内容.
MyApp的安装程序必须保持MSI,但可以由Bootstrapper EXE执行.安装的MyApp.exe必须能够访问MyApp.msi和EXE将在运行时由应用程序从基础(空)MyAppBootstrapper.exe(也由MSI安装)和由内容创建的内容"组装".最终用户.EXE的资源MSI必须与用于安装运行时打包的App的资源相同.
WIX不与MyApp一起安装.
在运行/打包时不存在网络依赖性(即不能通过Web服务进行打包 - 必须在本地完成).
我熟悉(和使用)自定义操作(托管和非托管,通过DTF等).
我无法编写自定义urllib.FancyURLopener,它在构造函数中初始化用户和passwd值.我可以使用空构造函数和后续调用setpasswd来使其正常工作.当我尝试在构造函数中设置用户和密码时,我会发现有关缺少属性"tempcache"的奇怪错误.我是否遗漏了一些关于init的 Python语法/用法?
我希望能够在构造函数中指定我的用户和passwd,如下所示:
opener = MyRouterOpener("", "secretPassword")
page = opener.open("http://192.168.1.1/Status_Router.asp")
#do something with the page
Run Code Online (Sandbox Code Playgroud)
尝试这种方式失败:
import urllib
class MyRouterOpener(urllib.FancyURLopener):
def __init__(self, user, passwd):
self.setpasswd(user, passwd)
def setpasswd(self, user, passwd):
self.__user = user
self.__passwd = passwd
def prompt_user_passwd(self, host, realm):
return self.__user, self.__passwd
opener = MyRouterOpener("", "secretPassword")
statusPage = opener.open("http://192.168.1.1/Status_Router.asp")
Run Code Online (Sandbox Code Playgroud)
输出:
Traceback (most recent call last):
File "W:\Desktop\DynDns.enom.bad.py", line 15, in <module>
statusPage = opener.open("http://192.168.1.1/Status_Router.asp")
File "C:\Users\pengt\Python26\lib\urllib.py", line 179, in open
if self.tempcache and fullurl in self.tempcache:
AttributeError: RouterOpener …Run Code Online (Sandbox Code Playgroud)