在某些情况下我们需要防止用户单击窗口的标题栏中的关闭按钮关闭 MFC 应用程序。可以删除窗口的WS_SYSMENU 样式, 但是,这样最大化最小化和还原按钮也被删除,并且无法添加。 这是Windows的设计依据。 可以通过禁用关闭按钮来模拟没有关闭按钮的窗口。 在 WM_CREATE 消息处理程序中禁用关闭按钮。使用下面的代码: CMenu *pSysMenu = GetSystemMenu(FALSE); ASSERT(pSysMenu != NULL); VERIFY(pSysMenu->RemoveMenu(SC_CLOSE, MF_BYCOMMAND)); 这样删除之后关闭按钮变为灰色,用户无法点击。但是使用Alt+F4仍然可以关闭程序。要将此功能也禁用需要重载CDialog的OnSysCommand方法。代码如下: void MyDlg::OnSysCommand( UINT nID, LPARAM lParam ) { if ( ( nID & 0xFFF0 ) == IDM_ABOUTBOX ) { CAboutDlg dlgAbout; //if you have an about dialog dlgAbout.DoModal(); } //add the following code else if
Read more
Tag: Windows
MFC程序使用系统风格界面
Posted onVC6默认编译出来的程序在XP下Luma风格下运行也是Windows的经典界面, 有损界面的美观与统一. VC2008默认设置下如果不是使用的unicode也是如此. 本文给出使VC6和VC2008可以编译出使用系统界面风格的解决方案. 1. 使VC6编译出使用系统风格的程序 步骤如下: 1) 创建一个.manifest文件的资源. 在res/文件夹下创建一个跟以程序名加.manifest的文件, 如果程序为test.exe, 则创建test.exe.manifest 文件可由此下载: https://www.systutorials.com/t/g/programming/resultcollector.manifest/ 注意要使用utf-8编码保存。 2) 将新定义的资源加入到.rc2文件中, 类型设为24. 打开res/文件夹下的.rc2文件, 在其中加入如下定义: 1 24 MOVEABLE PURE “res/test.exe.manifest” 其中的文件地址按1)步中修改的设置即可. 之后编译即可, 为了使程序界面可能充分利用系统的界面特性, 可以将界面字体设置为TrueType类型的, 利用Windows XP等系统的屏幕字体平滑特性. 2. 使VC2008编译出使用系统风格的程序 在VC2008下就比较简单了, 如果程序字符集使用unicode则默认就是使用系统界面风格的, 如果选择其它的类型, 则编辑下stdafx.h即可. 最后面部分找到这么一段: #ifdef _UNICODE #if defined _M_IX86 #pragma comment(linker,”/manifestdependency:”type=’win32′ name=’Microsoft.Windows.Common-Controls’ version=’6.0.0.0′ processorArchitecture=’x86′ publicKeyToken=’6595b64144ccf1df’ language=’*'””) #elif defined _M_IA64 #pragma comment(linker,”/manifestdependency:”type=’win32′
Read more
Java Calling Native Functions in .DLL on Windows
Posted onHow to call a function in .dll from Java on Windows is introduced in this post with an example. Platforms used: OS: Microsoft Windows XP [5.1.2600] C to .dll compiler: MS Visual Studio 2008 JDK: java -version java version “1.6.0_05” Java(TM) SE Runtime Environment (build 1.6.0_05-b13) Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
Read more
Emacs Tips and Howtos
Posted onWith Emacs, I feel happy. I love the rich functions of Emacs, such as compiling, quickly jumping to the lines with compilation error and debugging with gdb, and more. I ever wrote small tips posts about Emacs before. But it is a good idea to put them together and keep adding new ones. Here comes
Read more
Viewing XPS Files in Linux
Posted onXPS files is a format from MS on Windows. Evince can view some XPS files, but fails to view some. To view XPS files generated on Windows on a Linux system, we can use mupdf. It works very well. I like it much especially in the situation that Evince fails to open the XPS file.
Read more
How to Install MS Office 2007 on Linux using Wine
Posted onAs a Linux user, I must keep a copy of Windows. One reason is that I should edit MS Office files, such as .doc, .ppt, .xls and .xml (office 2003 xml format) required by, created by or for other using Windows. Wine worked for me with Office 2003 ever but has this or that problem.
Read more
How to SSH to Linux Hosts for Beginners
Posted onThis is a simple tutorial for beginners to SSH to a Linux host. This is quite easy with the easy-to-use software freely available but the beginners need a tutorials to start with. Hence, I write this tutorial about how to ssh to a Linux host. This tutorial is for users on Windows. 1. Download a
Read more
How to Get System Uptime on Linux and Windows OSes
Posted onHow to find out Linux and Windows uptime is introduced in this post. Linux uptime Linux uptime can be easily found out by the uptime command: $ uptime 22:19:29 up 10 days, 22:26, 5 users, load average: 0.00, 0.00, 0.00 The system is up for 10 days, 22 hours and 26 minutes. uptime gives a
Read more
Open Source and Portable SSH, SCP, SFTP and VNC Clients for Windows to Remote Control Linux
Posted onssh, scp, sftp and vnc are frequently used tools (both servers and clients) on Linux. We may want to remote control a Linux box from Windows such as when we make demostration in a meeting while our work are done on the Linux box. There are lots open source SSH, SCP, SFTP and VNC clients for
Read more
Linux Cluster Solutions
Posted onSolutions to Linux cluster construction and management such as unified account management, NFS home directory, network configurations are summarised in this post. The post is keeping updating while new solutions is added to this site. ===Account and storage management=== [[unified-linux-login-and-home-directory-using-openldap-and-nfsautomount|Unified Linux Login and Home Directory Using OpenLDAP and NFS/automount]] [[backup-linux-home-directory-using-rsync|Backup Linux Home Directory Using rsync]]
Read more
How to Create Fedora Live USB Media
Posted onHow to create a Fedora live USB media is introduced in this post. We can boot to Fedora operating system environment through a live USB system in the USB flash media on a USB-bootable computer without writing the computer’s hard disk. We can also install Fedora operating system from the live system environment. Remember to
Read more
Speeding Up Firefox in Linux
Posted onFirefox can be much faster on Linux! Let’s speed up Firefox on Linux system. Part 1 and 2 only config firefox, so it can also be used on other platform such as Windows. 1. Pipe-lining network connection Most of us use a broad band width network, then why not pip line the connection from Firefox?
Read more
Setting Up Linux Network Gateway Using iptables and route
Posted onSharing the networking is important and setting up a gateway is a good solution to it. Building up the gateway on a Linux box is easy, cost efficient and reliable. With a Linux box, you can share the internet connection or the only cable connected to the network. The Linux box network configuration The Linux
Read more
How to Set Up Socks Proxy Using SSH Tunnel
Posted onWe can set up a socks proxy on top of a SSH tunnel. Besides the common proxy functions, such as web browsing, the proxy on top of SSH tunnel also ensures the security between the browser and the proxy server (the SSH server). In this post, we introduce and explain how to set up a
Read more
How to Flush DNS Cache of Linux and Windows Client
Posted onWe may need to flush DNS cache of our client when the site’s DNS has been changed. Flush DNS cache of Linux with NetworkManager/dnsmasq You may simply restart NetworkManager by sudo systemctl restart NetworkManager Flush DNS Cache on (Old) Linux with nscd 1) Use su – to get root privilege or sudo with the following
Read more
Vim Removing “^M” Returns from Files
Posted onWhen editing some files fro Windows in vim, there are some ugly “^M” returns. Here is a method to remove and replace these “^M”s (please note that you should not copy/past to use the follows): :1,$s/{Ctrl+V}{Ctrl+M}//{Enter} {Ctrl+V} means keyboard operation that is push ‘ctrl’ and ‘v’ together. {Enter} is push ‘enter’. : means that it
Read more
Creating and Running Virtual Machine Using VMware Player and qemu-img
Posted on基于VMware Player, qemu-img创建和运行虚拟机 Linux系统上的免费个人虚拟机方案. 1. 创建虚拟硬盘映象文件: qemu-img create -f vmdk WindowsXPPro.vmdk 10G 2. 创建.vmx虚拟机配置文件: 这是一文本文件. WindowsXPPro.vmx内容: config.version = “8” virtualHW.version = “3” ide0:0.present = “TRUE” ide0:0.filename = “WindowsXPPro.vmdk” memsize = “256” MemAllowAutoScaleDown = “FALSE” ide1:0.present = “TRUE” ide1:0.fileName = “auto detect” ide1:0.deviceType = “cdrom-raw” ide1:0.autodetect = “TRUE” floppy0.present = “FALSE” ethernet0.present = “TRUE” usb.present =
Read more