mfc

Why can't I directly send an HBIMAP from a CImage to clipboard?

浪尽此生 提交于 2020-01-25 04:25:06
问题 I'm working on a small widget, screen capture stuff on Windows. The core of this program is like the following (I found it on the Internet). First derive from CImage, then add a member function to do this: BOOL CScreenImage::CaptureRect(const CRect& rect) { // detach and destroy the old bitmap if any attached CImage::Destroy(); // create a screen and a compatible memory device context HDC hDCScreen = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL); HDC hDCMem = ::CreateCompatibleDC(hDCScreen); //

COMMAND AND UPDATE_COMMAND_UI handlers not called in MFC dll

烂漫一生 提交于 2020-01-25 00:45:31
问题 I have ON_COMMAND and ON_UPDATE_COMMAND_UI handlers for menu items in an MFC dll. But they are not invoked. The same code compiled as .exe has the handlers being invoked. What could be the reason for this? 回答1: ON_UPDATE_COMMAND_UI and ON_COMMAND handler are only called when the object that contains the handler is within the command routing. So the DLL itself isn't the problem but also this depends on how you created your DLL. For a standard DLL and without sharing the MFC as a DLL this will

How to disable auto document/view creation when MFC application first starts

扶醉桌前 提交于 2020-01-24 23:03:59
问题 I have a regular MFC application which uses Doc/View architecture. When the application starts it automatically creates a view of an empty document. I want to disable this automatic view on startup and show a view only when the user clicks on "New Document" from the File menu. Is there any way to do so? CMultiDocTemplate* template = new CMultiDocTemplate(IDR_DorlionTYPE, RUNTIME_CLASS(CDocument), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CView)); if (!CView) return

Modifying menu items

末鹿安然 提交于 2020-01-24 22:42:33
问题 I have a popup menu I would like to modify before it is being displayed. I can actually modify the string of a menu item fine. The problem is, that this renders it useless as nothing happens when the modified menu item is clicked on. CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while(pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); // modify string pPopup->ModifyMenu(1, MF_BYPOSITION | MF_STRING, NULL, oss.str().c

Unexplainable error “Please use the /MD switch for _AFXDLL builds”

别等时光非礼了梦想. 提交于 2020-01-24 21:13:29
问题 I use VisualStudio2010 and CMake 2.8.12.1. I created a CMakeLists.txt for a MFC project. MFC capability was done by following lines in the CMake file: add_definitions(-D_AFXDLL) #enables MFC set(CMAKE_MFC_FLAG 2) #use shared MFC library Furthermore the project will be build with MD as runtime library (default). But now I want my project to be build as MT (which also requires to specify static MFC library). So I replaced the lines above with: add_definitions(-D_AFXDLL) #enables MFC set(CMAKE

MFC 显示上标、下标文字

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-24 04:03:36
我们在实现应用中可能有时要使用下标操作,比如: CO 2 下面就是这样一个类: View Code 1 // CharStatic.h : header file 2 // 3 4 #pragma warning(disable : 4786) 5 #include < iostream > 6 using namespace std; 7 #include < map > 8 9 /////////////////////////////////////////////////////////////////////////// // 10 // CCharStatic window 11 class CCharStatic : public CStatic 12 { 13 // Construction 14 public : 15 CCharStatic(); 16 void AddSingleChar( int pos,UINT nFormat); 17 void SetFontSize(UINT fontSize); 18 // Attributes 19 public : 20 21 // Operations 22 public : 23 24 private : 25 map < int ,UINT > m_singleChar; // a map to store

Confused between logical coordinates and device coordinates in Windows API

感情迁移 提交于 2020-01-23 05:41:07
问题 I have been looking into a Visual Studio C++ Windows application project which used two functions SetWindowExt (...) and SetViewportExt (...) . I am confused about what these two functions do and why they are necessary. Searching about these functions, I came to the concept of logical coordinates and device coordinates. Can anyone please explain what is the importance of these two concepts? 回答1: Device coordinates are the simplest to understand. They are directly related to the device that

MFC显示系统时间

非 Y 不嫁゛ 提交于 2020-01-23 00:26:36
准备工作: 1、在视图中右击->类向导->消息->找到消息WM_TIMER,同事右侧会出现消息的响应函数OnTimer,双击OnTimer 一、标题栏显示系统时间 1、在BOOL XXXDlg::OnInitDialog()函数中添加定时器SetTimer(1,1000,NULL);//第一个参数是定时器ID,你随意定,但是如果不能喝其他定时器的ID重复,第二个参数是时间(ms)就是每隔多长时间执行一次,第三个参数一般为NULL,为NULL是表示使用OnTimer为响应函数,当然你也可以自己定义一个响应函数 2、在OnTimer中添加代码,获取系统时间。(例子在下面) CTime cTime = CTime::GetCurrentTime(); CString strTime; //字符串格式化时间 strTime = cTime.Format("现在是%Y年%m月%d日 %X"); SetWindowText(strTime); 二、在Edit编辑框中显示系统时间 1、从工具箱中拖拽一个Edit控件放在视图上 2、右击Edit控件选择添加变量(我的是m_strTimeTest),然后确定即可 三、一和二的示例如下: 1 BOOL CMFCTestDlg::OnInitDialog() 2 { 3 CDialogEx::OnInitDialog(); 4 5 SetTimer(0

【MFC国际化与多语言】03:SetThreadUILanguage函数导致程序不兼容winxp系统

为君一笑 提交于 2020-01-22 22:54:06
开发环境 系统:win10 x64 VS版本:VS2010 旗舰版 问题 MFC程序因为使用SetThreadUILanguage函数,导致程序界面异常。 解决方法 1、在InitInstance()例程中添加下列代码。 switch (m_nLanguageSel) { case CHINESE_SIMPLIFIED: m_wLanguageId = MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED); break; case ENGLISH_US: m_wLanguageId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); break; } if (GetWindowsType() == WINDOWS_XP) { SetThreadLocale(MAKELCID(m_wLanguageId, SORT_DEFAULT)); } else { SetThreadUILanguage(MAKELCID(m_wLanguageId, SORT_DEFAULT)); } 2、GetWindowType()函数 //□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□// //描述:获取操作系统类型 //参数: //□□□□□□□□□□□□□□□□□□□□□□□

error MSB3073: How do I fix this?

寵の児 提交于 2020-01-22 13:59:30
问题 3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "copy "C:\Users\jlee\Desktop\10_IPG2.7_4\InitialPowerGadget\Release\EnergyLib.dll" "C:\Users\jlee\Desktop\10_IPG2.7_4\InitialPowerGadget\Bins32\EnergyLib32.dll" 3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: copy "C:\Users\jlee\Desktop\10_IPG2.7_4\InitialPowerGadget\EnergyDriver\objfre_win7_x86\i386\EnergyDriver.sys" "C: