How to detect a CListCtrl selection change?

Also try: BEGIN_MESSAGE_MAP(cDlgRun, CDialog) ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2) END_MESSAGE_MAP() /* … */ void cDlgRun::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; if ((pNMListView->uChanged & LVIF_STATE) && (pNMListView->uNewState & LVIS_SELECTED)) { // do stuff… } }

Add my own compiler warning

In Visual Studio, #pragma message (“Warning goes here”) On a side note, if you want to suppress such warnings, find the compiler warning ID (for the deprecated warning, it’s C4996) and insert this line: #pragma warning( disable : 4996)

Dynamic allocation of class array with protected destructor

Rejecting an array-new with a protected destructor is correct, as per C++11, §5.3.4 ¶17: If the new-expression creates an object or an array of objects of class type, access and ambiguity control are done for the allocation function, the deallocation function (12.5), and the constructor (12.1). If the new expression creates an array of objects … Read more

How to use VC++ intrinsic functions w/o run-time library

I think I finally found a solution: First, in a header file, declare memset() with a pragma, like so: extern “C” void * __cdecl memset(void *, int, size_t); #pragma intrinsic(memset) That allows your code to call memset(). In most cases, the compiler will inline the intrinsic version. Second, in a separate implementation file, provide an … Read more

Does omitting the frame pointers really have a positive effect on performance and a negative effect on debug-ability?

Phoronix tested the performance downside of -O2 -fno-omit-frame-pointer with x86-64 GCC 12.1 on a Zen 3 laptop CPU for multiple open-source programs, as proposed for Fedora 37. Most of them had performance regressions, a few of them very serious, although the biggest ones are probably some kind of fluke or other interaction. Geometric mean slowdown of 14% … Read more

How do I use MultiByteToWideChar?

You must call MultiByteToWideChar twice: The first call to MultiByteToWideChar is used to find the buffer size you need for the wide string. Look at Microsoft’s documentation; it states: If the function succeeds and cchWideChar is 0, the return value is the required size, in characters, for the buffer indicated by lpWideCharStr. Thus, to make … Read more

Why is floor() so slow?

A couple of things make floor slower than a cast and prevent vectorization. The most important one: floor can modify the global state. If you pass a value that is too huge to be represented as an integer in float format, the errno variable gets set to EDOM. Special handling for NaNs is done as … Read more

In which situations is the C++ copy constructor called?

When an existing object is assigned an object of it own class B = A; Not necessarily. This kind of assignment is called copy-assignment, meaning the assignment operator of the class will be called to perform memberwise assignment of all the data members. The actual function is MyClass& operator=(MyClass const&) The copy-constructor is not invoked … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)