I have a MFC dialog with a graphic displayed that is updated via OnPaint(). The dialog continues to exist but it is hidden with ShowWindow(SW_HIDE) then later open again with ShowWindow(SW_SHOW) but there is a moment when the old contents are shown before OnPaint() updates the new graphic. I got around it by first ShowWindow(SW_MINIMIZE) followed by ShowWindow(SW_SHOWNORMAL) but why? How can I just ensure when the window is shown it calls OnPaint() before it puts back the old device context graphic?
TIA!!
Related
There is a Managed C++ application. Some of its C++ (MFC) views host a WinForm's version of CefSharp. It shows everything OK.
But, there is annoying bug: when Cefsharp's window where hidden by another window, and then that window are closed, then CefSharp's window becomes completely blank. If try to resize this window or move it then CefSharp engine re-draw html content and everything is OK. But if we do nothing it stays blank forever. Is it possible somehow to force CefSharp to re-draw content on Activate or so event?
I tried to google, bot not successed ...
When I click on a non-reactive area of a win32 window in the foreground (for example, a blank space on a menu bar) and drag the mouse off, background windows do not receive mouse events. Buttons don't got into hover state, the cursor doesn't change, etc. The mouse is "captured" by the foreground window, although it doesn't receive messages either unless the mouse is over it. This state persists until I release the mouse button. Why is this, and how can I get out of this state programmatically without releasing the mouse button?
Researching this issue, I thought at first it was related to the concept of mouse capture, but it appears it is not. GetCapture() returns NULL during this state, whatever it is.
Clarification Edit: This is easy to see in the simplest of applications. Create a new Win32 project in Visual Studio with the default project template, which makes an empty window. Run it, and click and hold the blank inside of the window. Drag the mouse outside the window, and note that no buttons in background windows light up or otherwise respond to mouse-over events. Even if I stick ReleaseCapture() in the WndProc so that it fires after every message, the result is the same. It really seems like this has nothing to do with mouse capture in the Get/SetCapture sense.
I open an open file dialog using GetOpenFileName function. I'm making a handler function that will center the dialog window inside the owner window. I center the dialog on CDN_INITDONE notification.
Currently, it seems that Windows remembers last dialog position for desktop apps and overrides my dialog coordinates. How to reset that last remembered position so that I can check centering will work for my users?
I thought about running a test using a different user or virtual machine but this isn't very convenient. Unfortunately, searching in the registry for myexecutable.exe returns nothing.
I'm running Windows 8.
I'm about a year late, but I just had to deal with this issue. What worked for me was supplying an OFNHookProc to GetOpenFileName(), then subclassing the parent of the HWND passed to the OFNHookProc.
After subclassing, I handle WM_WINDOWPOSCHANGED, and if the coordinates aren't where I think they should be, I do a SetWindowPos(), undo the subclass and return 0.
Edit: I should say that other methods, such as WM_INITDIALOG in the hook proc or CDN_INITDONE did not work for me whatsoever.
I created a PopUp which is draggable across the screen, like a photoshop palette independent of the main window.
However, I would like the main window to react when I drag this PopUp over it, i.e. receive the mouse events from the drag.
The problem seems to be that since the PopUp is a Window itself, it consumes the dragging mouse events, and the main window never gets them.
I tried making the main windows the owner of the PopUp, however it still doesn't get them.
Is there any way to get around this ? Thanks
I've uploaded a VS2010 project at the below location. This test app should be run once you have a full screen application running. As soon as its running, you have 2 seconds to click back on your fullscreen application. It creates 2 modeless dialog boxes using the full screen application (which should be the last window to have focus) as the owner of the dialog boxes. One dialog is displayed, hidden, the second dialog is displayed, hidden and then the first dialog is displayed again in a cycle. What I find is that when the first dialog box is displayed for the second time, the taskbar pops up. I've spent 4 painful days trying to understand whats going on here and I am desperate for some help.
I received some help which suggested that when I call DestroyWindow to hide the dialogs, Windows would put focus "somewhere" - and in my case the taskbar. Previously when I asked this question I wasn't using the full screen application as the Owner of my windows. I would have thought that the focus should go back to the owner window? I have also tried calling SetFocus() and SetForegroundWindow() on the full screen application prior to calling DestroyWindow on my dialog - but the seems to cause the taskbar to appear everytime and I don't want that at all.
Please help!
Sample VS2010 Project