Hello, can you help me with this problem:
I'm extending the TListView to enable notifying me about the column resize. I've found the code written in Delphi, but I needed to use it in C++, so I decided to rewrite this code to C++. But first problem occurs when I overload this function:
virtual void __fastcall CreateWnd(void);
In Delphi, this code was required to enable functionality of column resize notification:

procedure TListViewEx.CreateWnd;
  wnd: HWND;
  wnd := GetWindow(handle, GW_CHILD);
  SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd, GWL_STYLE) and not HDS_FULLDRAG);

I have rewritten Delphi code to this:

virtual void __fastcall CreateWnd(void)
    HWND wnd = GetWindow(Handle, GW_CHILD);
    SetWindowLongA(wnd, GWL_STYLE, GetWindowLong(wnd, GWL_STYLE) & !HDS_FULLDRAG);

The problem comes with calling to this function. GetWindow(Handle, GW_CHILD) returns NULL. Why?

From msdn [link]

The retrieved handle identifies the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved handle is NULL. The function examines only child windows of the specified window. It does not examine descendant windows.

If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the specified window, the return value is NULL. To get extended error information, call GetLastError.

Try to find out more about the problem using the GetLastError function.

Hope this helps.

Try to find out more about the problem using the GetLastError function.

Hope this helps.

I have already tried it. GetLastError returns 0, and I don't understand if the same example works in Delphi, why it doesn't work in C++, I know I'm missing something or I did some mistake...

This article has been dead for over six months. Start a new discussion instead.