How to find slide show window of Microsoft Power Point - c++

I have a simple c++ wIn32 program that allows you to paint over windows in Windows OS.
This program has a UI that lets a user to choose windows he wants to paint over.
The problem I'm facing is that if a user chooses a specific Microsoft PowerPoint window and than starts a slide show (by pressing 'F5' for example) than another new window is opened on full sceen and my program is unaware of it and does not paint over it.
I need to find out how may I identify this new window, assuming I can perform periodic polling on existing windows using EnumWindows method.
I have tryied using the methods GetAncestor & GetParent on the Slide Show window and on the PowerPoint window to see if they match but both of them return different HWND handle.
Moreover, a solution of identifying that a specific HWND handle is a PowerPoint Slide show window is not sufficient since if I have for example 2 instances of 2 different Power Point windows and the user has chosen to paint only over one of them, than I want to make sure that only if the chosen PowerPoint window is going to slide show window than I will paint over it. If the slide show window was started from the non-chosen PowerPoint window than I don't want to paint over it.

Related

How to keep the focus on the top window of 1st screen after clicking 2nd screen

we have one desktop(1st screen) to display the image and another touchscreen(2nd screen) for the control, we wrote a virtual keyboard(html&javascript) on touchscreen, ideally when we touch the keys on the touchscreen, we could input text in editbox(in an input dialog window) in the 1st desktop. Now the problem is the mouse is lost(originally it is in a input dialog in 1st desktop) when we touch the touchscreen, so we have to create a global window in C++ program, and manually copy each possible input dialog window to this global window when it is in use, also we need to set focus for each possible editbox in this input dialog window. please see this:
for each possible input dialog, we add
extern HWND activeInputWindow;
activeInputWindow=m_Edit_Name.m_hWnd;
also for each possible input box in this window we have to add
activeInputWindow=GetDlgItem(IDC_EDIT_TEST)->m_hWnd;
then the program always do this to get back the original window after clicking the touchscreen(2nd window)
extern HWND activeInputWindow;
if(IsWindow(activeInputWindow))
::SetFocus(activeInputWindow);
suppose we have 10 input window and 10 input boxes in each window,then I need to code 100 places! There must have some simple ways, windows osk.exe (virtual keyboard) have no problem for this but we have to use our own virtual keyboard.... I tried GetTopWindow() and GetForegroundWindow() but not working.. Many thanks for the help
This is trying to solve the problem using the wrong tools. What you really want is a window that receives input, but rejects activation. To achieve this, handle the WM_MOUSEACTIVATE message by returning MA_NOACTIVATE. This also works for touch input.
See How can I have a window that rejects activation but still receives pointer input? for all the ins and outs.
The problem is that your virtual keyboard is stealing the focus of the edit control. You'll need to prevent this.
Try to set the flag WS_EX_NOACTIVATE for a window's style or other approaches from this or this answers.

In C++ , how can I get the user to specify a point on the screen (X,Y) out of the app window?

I must find the coordinates of a point which is out of the application window.
I intend to have a button "Specify Point" and when the user clicks this button, their next mouseclick will be registered by the program as this desired point. The problem is I don't know how to implement this....Any ideas ?
You can call SetCapture to direct mouse clicks from anywhere on the desktop to your window. Call ReleaseCapture after the click to return to normal.
If the user clicks on another application you will receive the click but the other application will also be activated, which you probably don't want. To avoid this, an alternative approach is to overlay the entire desktop with an always-on-top very nearly fully transparent window (a fully transparent window won't get clicks). Transparent windows are known as layered windows; use the WS_EX_LAYERED extended style to create one.

Program that displays content on screen but no window

In windows: I would like to know if it is possible (and if so, how) to make a program in C++ that displays images/text on the screen directly, meaning no window; if you are still confused about what I am after some examples are: Rocketdock and Rainmeter.
you can do it certainly without using Qt or any other framework. Just Win32 API helps you do that and internally, every framework calls these API so there is no magic in any of these frameworks
First of all, understand that no image or text can be displayed without a window. Every program uses some kind of window to display text or image. You can verify it using the Spy++ that comes with windows SDK. click the cross-hair sign, click the image or text you think is displayed without any windows. The Spy++ will show you the window it is contained in.
Now how to display such image or text that seems like not contained in any window. Well you have to perform certain steps.
Create a window with no caption bar, resize border, control box, minimize, maximize or close buttons. Use the CreateWindowEx() and see the various windows style WS_EX_XXX, WS_XXX for the desired window style.
Once the window is there you need to cut the window. Much like a cookie cutter. for this you need to define an area. This area is called region and you can define it using many functions like CreateEllipticRgn(), CreatePolygonRgn(), CreateRectRgn(), CreateRoundRectRgn() etc. all these functions return a HRGN which is the handle to the region. Elliptical or rectangle regions are OK as starter.
Now the last part. You have to cut the window like that particular region. Use the SetWindowRgn() function which requires a handle to your window and a handle to that region (HRGN). This function will cut the window into your desired shape.
Now for the image or text. Draw the image or text inside the window. I assume you must have cut the window according to your image, You just need to give window a face. so just draw the image either on WM_ERRASE BACKGROUND or WM_PAINT messages
Use the SetWindowPos() to move the window to the location you wish to on screen. If you have used correct parameters in CreateWindowEx() then this step is not necessary
You can set any further styles of windows using SetWindowLong() function.
Congratulations, you have your image displayed without using any windows ;)

effective Overlapping of dialog windows in Visual C++ 6

Hello there I have issue with overlapping of child windows,I have created a software with menu driven interface( IDR_MAINFRAME - CFormView
etc) and upon clicking one of the menu items another child-window appears( Dialog based ) where I do the calculations as a normal
calculator.Now if I open any other entry say conversion of metrics which is also in menu entry then on overlapping with any other such
window the background windows gets horribly disfigured and if i move about the calculator or the metrics conversion calculator randomly
they get disfigured and its a mess.Also I have put up a bitmap image on the background.Upon moving the calculator the background image also
gets erased.
Please let me know about how to handle this issue.I have googled and found that handling of paint messages or WM_ERASEBKGND helps ..but I
have tried this piece of code which just doesn't help in OnEraseBkGnd();
BOOL COfficesoftDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CRect Rect;
GetClientRect(Rect);
//ClientToScreen(&Rect);
//this->ScreenToClient(&Rect);
this->InvalidateRect(Rect);
return CDialog::OnEraseBkgnd(pDC);
}
how can i achieve the smooth overlapping of different windows like a notepad overlapping a word document or even a calculator or even a VC6
IDE in my project.
Please explain it with an example .I am just a newbie and I need to understand in detail...thanks and regards
Override OnEraseBkgnd and return true so it stops erasing the background you're painting. Returning TRUE says that you've done the work. If you simply call the base class implementation, it's going to do this for you, and you'll lose the background until it gets a chance to paint.
You're not getting paint messages to the parent window for some reason. Make sure you're calling the modal in the correct manner. DoModal() works fine. Make sure you're not just creating the modal and showing it.
If your windows are children on the same dialog/window and they overlap or you have children on either dialog/window, make sure that you use clipchildren and clipsiblings (if children on a window overlap). Otherwise they'll get to paint in any order they choose artifacting all over the place.
Ensure that you're painting to memory and bitblting back to your dialog, otherwise you'll get a flashing effect.

How to select and highlight a window in another application?

I would like to send some keystrokes from a C++ program into another window.
For that reason I would like to have the user select the target window similar to how it is done in the Spy++ utility that comes with Visual Studio (drag a crosshair cursor over target window and have target window highlighted by a frame).
How is this dragging and selecting done in Windows? I am completely lost as to where I might start to look for a mechanism to implement this feature.
Here's how it's usually done:
Capture the mouse using SetCapture. This will cause all mouse messages to be routed toward your app's window.
Handle the WM_MOUSEMOVE message. In your handler code, grab the window underneath the mouse using WindowFromPoint. That will get you the HWND of the window the mouse is currently over.
Now that you've got the window, you need a device context (HDC). You can get one using GetWindowDC for the specified window.
Now you can draw into the DC using typical GDI functions.
There are some things you have to look out for - cleanly erasing the selection rectangle and so forth, but that's one way to do it.
You could also draw into a screen DC to do this, but in any case you'll need the window handle in order to get the window rect.
If you Google around Spy++ source code you'll see a few examples of this technique.
Formers answers are wrong.
Spy++ source code has been given on G. Groups for years (see mainly Win32 api ng news://194.177.96.26/comp.os.ms-windows.programmer.win32)