Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable a window with EnableWindow(), and gray it out?

In .NET, when you set the Control.Enabled property of a Form or a Control (such a a ListView) to false, it becomes grayed out, along with all its children:

I do not see this happen in Win32 (EnableWindow), at least not with ListViews.

How do I achieve this effect in Win32?

like image 889
user541686 Avatar asked Feb 21 '23 01:02

user541686


1 Answers

BOOL EnableWindow(HWND hWnd,
    BOOL bEnable
);

where hWnd is the handle to the control and bEnable is either TRUE or FALSE, TRUE enables the window and FALSE disables it.

Works fine for listviews.

It is worth nothing that in order to see the changes to its visual state, you'll need to force the window to be redrawn, e.g. by calling UpdateWindow.

like image 119
Gunner Avatar answered Feb 25 '23 00:02

Gunner