Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I try to create Window for video by using following syntax:

hwnd=CreateWindow("Video Window", "Video window", 
                    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        CW_USEDEFAULT, CW_USEDEFAULT, rect.right-rect.left,rect.bottom-rect.top,        NULL, NULL, hInstance, NULL);

All works as expected but the issue is that the window always on top. It means that I see this window even if I switch to other application.

From Window directive program I found additional style: WS_EX_TOPMOST

enter image description here

How can I remove It programmatically or do I need override it somehow?

I tried SetWindowPos:

SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

or to use instead CreateWindow at CreateWindowEx:

hwnd=CreateWindowEx(WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_WINDOWEDGE,
                    "Video Window","Video Window",
                    WS_OVERLAPPEDWINDOW  | WS_VISIBLE ,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    rect.right-rect.left,
                    rect.bottom-rect.top,
                    NULL,
                    NULL,
                    hInstance,
                    NULL);

but still get flag WS_EX_TOPMOST

Thanks,

share|improve this question
    
Clearly the window you are looking at is not the window that you created. Not unusual if you play back video with some kind of library. Why it would create a topmost window is unguessable. – Hans Passant Jan 18 '14 at 13:58

1 Answer 1

up vote 2 down vote accepted

One way of going about it is to query the window for it's current extended-style, before clearing the bits that correspond to WS_EX_TOPMOST and setting the new extended style.

Something like this:

long dwExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
dwExStyle &= ~WS_EX_TOPMOST;
SetWindowLong(hwnd, GWL_EXSTYLE, dwExStyle);
share|improve this answer
    
The documentation for the WS_EX_TOPMOST Extended Window Style implies that it should be added/removed using SetWindowPos. – IInspectable Nov 27 '14 at 12:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.