CWnd::SetRedraw(False) make mouse go throught window - c++

So I have a MFC application which flick when we do some action.
So I figured I would set SetRedraw(false) and set it to true at the end of the function.
The application doesn't refresh anymore but if I click on it while SetRedraw(false), my cursor is not catched by my application, it goes throught it and set focus on the application below.
Anyone has some kind of idea how I could fix that.

I ended up using CWnd::LockWindowUpdate instead after some research.
It freezes the update but doesn't act if the window was transparent.

Related

Minimize, Maximize button disappear without any reason

It's a dialog based MFC application. I didn't intentionally add any code about the Minimize, Maximize and Restore button. It can show those button at the first. But it just disappear after long time running. Or maybe sleep of the computer causes this?
I have no idea about this, do you have any clue?
Edited:
Thanks #xMRi's remind, I checked its style, seems still to be right.
Listed below few possible reason & resolution may impact you application look. More specifically, your device manager plays important role in application appearance. I would say its environment or certain unnecessary application(Virus)installation issue rather than your MFC application issue.
Full Fix: Minimize, Maximize and Close Buttons Disappear
At least I know a way to restore the disappared system buttons.
ModifyStyle(0, WS_MINIMIZEBOX);
GetSystemMenu(FALSE)->InsertMenu(-1, MF_BYPOSITION, SC_MINIMIZE, _T("Minimize"));
Press F11 for Windows 10, or right-click on the application which you can't see windows button then choose view finally uncheck the full screen

Why is my button firing twice?

I have a CButton as part of a CDialog screen. Everything works fine, but after I reinitialize a hardware device, when I click anywhere on the screen (even outside the dialog) the event for the CButton in question fires. I've run through the code in debugger mode, and the app literally thinks the button in question is being pressed. Thing is, its NOT being pressed. I've experimented with clearing the message pump, but that didn't seem to help. If you need code, let me know and I'll see what I can drum up without giving away how our app works. I get the feeling this is an edge case that others have run into and know how to solve without code.
Thanks in advance!

MFC Dialog disappearing while accessing application on Remote Desktop Connection

I am using MFC dialog of style 'Popup', it also contains Tab Control. But dialog is disappearing while accessing the application on Remote Desktop Connection. Actually it is there, when I hover on it accidentally I see a tab but when I move my cursor somewhere else, it gets disappeared again. I have tried changing Dialog properties, but nothing is helping. Any ideas on how to solve this issue?
Try to use : invalidate();
That should work.

C++ Win32 How to Create a "toggle" Pushbutton

I was originally thinking this would be extremely easy to do. Google searches returned results for everything but this.
I am trying to have a normal button that I can click, and it stays down, click again, and it rises back up.
I found one function that did what I wanted, but only worked if the button retained focus, click anywhere else and it rises again.
Button_SetState(GetDlgItem(hwnd, IDC_BTN_SLEEPCLICK), TRUE);
Is there any real way to do this? Or am I gonna need to do this kind of thing by hand?
Thanks.
Create a check box, then set the "push like" property for that check box to true.
You want a checkbox with BS_PUSHLIKE style. To toggle it programmatically, use Button_SetCheck
The "staying down" and "rising back up" are a matter of how you draw the button.
You could create your own button class by using the Paint and Redraw methods.

Programmatically navigating to the Windows Mobile home screen

We have an application that downloads some files in the background. Our application pops up when an Internet connection is made, and after prompting the user to accept the downloads, we'd like to switch back to the home screen while we do our stuff.
We can't work out how to do to this. We can emulate pressing "back" a few times, which sometimes works, but where you end up depends on what the user was doing when the Internet connection happened.
So, can someone provide pointers to how to do this?
Thanks.
Paul.
Can you try setting the today screen as the foreground window?
HWND hWnd = FindWindow(_T("DesktopExplorerWindow"), _T("Desktop"));
SetForegroundWindow(hWnd);
Why don't you simply hide your app?
Using a Notification shell object instead of popping up a full screen window might be a better alternative. Details here.