0

I change extended window style from 0 to WS_EX_NOREDIRECTIONBITMAP by calling

SetWindowLong(wnd, GWL_EXSTYLE, WS_EX_NOREDIRECTIONBITMAP);

the return value is zero which means the function failed and GetLastError() returns 87 indicates "the parameter is incorrect".

any idea what's wrong with my code?

16
  • 1
    Looks like this style can only be set on CreateWindow
    – Ben
    Nov 13, 2016 at 16:57
  • 1
    SetWindowLong() can return 0 on success if the previous value was 0. You could probably juggle SetLastError()s to check for an explicit failure, but it's probably better to assume the function cannot fail...
    – andlabs
    Nov 13, 2016 at 17:08
  • 3
    Some style flags can only be specified in the CreateWindowEx() call. WS_EX_LAYERED is a good example. This one certainly fits the same bill. Doing it later requires entirely too much non-trivial internal reorganization, the redirect bitmap was already created and unspeakable DWM and DirectX stuff set up. It is a little sloppy that this isn't documented, they do chip away at limitations like this however. Do favor SetWindowLongPtr() btw. Nov 13, 2016 at 17:19
  • 1
    Yeah, sure. You'll have to do this when you create the window. Nov 13, 2016 at 17:27
  • 3
    @HansPassant There are no restrictions on setting WS_EX_LAYERED with SetWindowLongPtr, the docs for SetLayeredWindowAttributes even say that you can do it. Nov 13, 2016 at 20:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.