wtl

Detect clicking inside listview and show context menu

有些话、适合烂在心里 提交于 2019-12-04 12:47:18
I have a listview created as a resource and loaded on a dialog window. I want to detect and show a context menu only when items within the listview have been clicked. MESSAGE_HANDLER(WM_CONTEXTMENU,OnContextMenu) LRESULT OnContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { int iSelected = -1; int iFocusGroup = -1; iSelected = SendMessage((HWND)wParam, LVM_GETNEXTITEM, -1,LVNI_SELECTED); iFocusGroup = ListView_GetFocusedGroup((HWND)wParam); if( iSelected != -1 && iFocusGroup == -1) { hPopupMenu = CreatePopupMenu(); Insert Menu(hPopupMenu, 0, MF_BYCOMMAND | MF_STRING | MF

Errors in Windows - DWORD (GetLastError) vs HRESULT vs LSTATUS

不羁的心 提交于 2019-12-02 20:47:23
I'm doing some programming in Win32 + WTL, and I'm confused with the available types of errors. In general, I want to check for an error, and feed it to AtlGetErrorDescription (which calls FormatMessage). My questions are: What's the difference between: DWORD , returned by GetLastError . HRESULT , returned by e.g. the CAtlFile wrapper, which uses HRESULT_FROM_WIN32 to convert from DWORD . LSTATUS , returned by e.g. RegCreateKeyEx . Which types of errors can I feed to FormatMessage ? Its signature indicates it accepts HRESULT , but there are lots of examples where the return value of

WTL multithreading, multiple interfaces & libraries

陌路散爱 提交于 2019-12-02 11:45:42
I have a Main Thread that displays an interface, within another thread created from the main thread before the Main interface is shown, I create tow other windows sequentially: I create the first window: CWarningDlg warnDlg; warnDlg.Create(NULL); warnDlg.ShowWindow(SW_SHOW); warnDlg.BringWindowToTop(); CMessageLoop _Loop ; if(_MyAppModule.AddMessageLoop(&_Loop)) { nRet = _Loop.Run(); _MyAppModule.RemoveMessageLoop(); } warnDlg.DestroyWindow(); if (nRet == SOME_VALUE) { doSomethingElse(); } Do something else has: CActionDlg actDlg; actDlg.Create(NULL); actDlg.ShowWindow(SW_SHOW); actDlg

Compiler Errors in atlwin.h

时光毁灭记忆、已成空白 提交于 2019-12-01 13:08:32
When including atlwin.h from the Microsoft ATL libraries in Visual Studio 2013 building will result in numerous complier errors about undefined elements. i.e. #include <atlwin.h> class MainWnd : public CWindowImpl<MainWnd> {}; "CWindowImpl: base class is not defined" error. or HMONITOR is not defined This does not occur when building using VS2010. How can I fix that? The problem is with the targeted version of windows in the stdafx.h file from MSDN Visual C++ no longer supports targeting Windows 95, Windows 98, Windows ME, or Windows NT. If your WINVER or _WIN32_WINNT macros are assigned to

Compiler Errors in atlwin.h

拟墨画扇 提交于 2019-12-01 11:21:38
问题 When including atlwin.h from the Microsoft ATL libraries in Visual Studio 2013 building will result in numerous complier errors about undefined elements. i.e. #include <atlwin.h> class MainWnd : public CWindowImpl<MainWnd> {}; "CWindowImpl: base class is not defined" error. or HMONITOR is not defined This does not occur when building using VS2010. How can I fix that? 回答1: The problem is with the targeted version of windows in the stdafx.h file from MSDN Visual C++ no longer supports targeting

STL,ATL,WTL的联系与区别

谁说我不能喝 提交于 2019-11-29 23:47:58
STL,ATL,WTL的联系与区别 STL 即 Standard Template Library STL(标准模板库)是惠普实验室开发的一系列软件的统称。它是由Alexander Stepanov、Meng Lee和David R Musser在惠普实验室工作时所开发出来的。现在虽说它主要出现在C++中,但在被引入C++之前该技术就已经存在了很长的一段时间。 STL的代码从广义上讲分为三类:algorithm(算法)、container(容器)和iterator(迭代器),几乎所有的代码都采用了模板类和模版函数的方式,这相比于传统的由函数和类组成的库来说提供了更好的代码重用机会。在C++标准中,STL被组织为下面的13个头文件:<algorithm>、<deque>、<functional>、<iterator>、<vector>、<list>、<map>、<memory>、<numeric>、<queue>、<set>、<stack>和<utility>。以下笔者就简单介绍一下STL各个部分的主要特点。 原文见:http://www.csdn.net/Develop/article/16%5C16310.shtm 从根本上说,STL是一些“容器”的集合,这些“容器”有list,vector,set,map等,STL也是算法和其他一些组件的集合。这里的“容器

Use CString in console app when using VS Express

两盒软妹~` 提交于 2019-11-29 16:23:46
I have a problem when trying to use CString. I have a console application written using VS2010Express. I have a piece of code I would like to use, but it uses CString. When I try to include the appropriate header atlstr.h (as far as I know) I get the famous error: Cannot open source file. After Goggling around for a while it seems that in general it should be possible, but the atlstr.h is not available to Express users. Questions: 1) Is that right ? 2) Can I avoid this problem somehow? Below is the code, (origin: http://www.cprogramming.com/tutorial/ado_c++_wrapper_classes.html ) If anyone has

flicker free tab control with WS_EX_COMPOSITED

不羁岁月 提交于 2019-11-29 16:04:16
I have a VS2008 C++ application for Windows XP SP3 developed using WTL 8.1. My application contains a tab control that flickers when the application border is resized. My window hierarchy looks like this: CFrameWindowImpl CMainFrm |-CSplitterWindow Splitter |-CTabView Configuration Tabs | |-CDialogImpl Configuration View 1 | |-CDialogImpl Configuration View 2 | |-CDialogImpl Configuration View 3 |-CDialogImpl Control View The solution I'm trying is to make the CFrameWindowImpl derived class use the WS_EX_COMPOSITED style and all windows beneath it use the WS_EX_TRANSPARENT style. Unfortunately

STL,ATL,WTL之间的联系和区别

旧街凉风 提交于 2019-11-28 23:15:07
STL即 Standard Template Library (标准模板库) STL是惠普实验室开发的一系列软件的统称。它是由Alexander Stepanov、Meng Lee和David R Musser在惠普实验室工作时所开发出来的。现在虽说它主要出现在C++中,但在被引入C++之前该技术就已经存在了很长的一段时间。 STL的代码从广义上讲分为三类: algorithm(算法)、container(容器)和iterator(迭代器), 几乎所有的代码都采用了模板类和模版函数的方式 ,这相比于传统的由函数和类组成的库来说提供了更好的代码重用机会。 从根本上说,STL是一些“容器”的集合,这些“容器”有list,vector,set,map等,STL也是算法和其他一些组件的集合。 这里的“容器”和算法的集合指的是世界上很多聪明人很多年的杰作。 STL的目的是标准化组件,这样你就不用重新开发它们了。你可以仅仅使用这些现成的组件。STL现在是C++的一部分,因此不用额外安装什麽。 它被内建在 你的编译器之内。因为STL的list是一个简单的容器,所以我打算从它开始介绍STL如何使用。如果你懂得了这个概念,其他的就都没有问题了。另外,list容器是相当简单的,我们会看到这一点。 这篇文章中我们将会看到如何定义和初始化一个list,计算它的元素的数量,从一个list里查找元素,删除元素