Two SDL Windows. How to know which was clicked in SDL_Event? - sdl

I have two different SDL windows simultaneously in one application. How do I know which of them was clicked when I get a mousebutton event?

You've got a data field named "windowID" into SDL_MouseButtonEvent, you can know which window catched that event with that. For more info : http://wiki.libsdl.org/SDL_MouseButtonEvent

Related

c++ Win32 Multiple windows doing same action

I have this problem. I want to open two same windows which behaviour is mirrored. So if I click on first window same action is executed on second window (mirrored behaviour). Is it possible? How can I do this? My application is in C++ and I use WinApi.
Thanks.
Well, you can comunicate between them using socket, shared memory or something like that... Another way is to send all windows messages you recieve from one window to another.

Win32 API, Get Child Windows for Game

I'm using this code to get the child windows of all open processes.
The code itself is working correctly, I get a 2 dimensional list of handles. Each index has a list of handles to the child windows of a specific process.
I'm trying to get a child window of a game. The game itself is inside window. It appears in the task manager and in my task bar. There is a button inside the game I press that opens a new window. The new window does not appear in the task manager but it does appear on the task bar.
The problem is the code in the link above will not return any child windows for the game even though a new window has opened and it can be seen in the task bar.
Any Ideas what I could be doing wrong?
Ok found the solution, should have used GetWindowText instead.

How to detect a Windows event in Qt?

I am trying to build an app to detect Windows events, in particular events related to multimedia (playing video, playing audio and images).
For instance, if Windows Media Player is opened, the related event should be detected.
There is no 'events' for that.
You can detect the lauches of media players (by winapi ::FindWindow) or image viewers.
I don't think it's possible to do this with QT's built in functions alone. You'll have to use the Windows API. Depending on what you actually want to do this can get quite complicated.
If you just want to check if a certain application has been started yet, you could use the FindWindow function. I'd suggest to use a qt timer to create signals that you can use to check if the Window has opened yet.
QTimer::singleShot(200, this, SLOT(checkForMediaPlayer()));
Just add this to your QObject along with the checkForMediaPlayer member function that'll do whatever you want once the MediaPlayer has been detected.

How do I link C++ (Visual Studio 2010) to an image-outputting event listener?

I am writing a very simple program in C++ that listens to keyboard input, but what I want to output is much more difficult than I expected. For every key I press, I want an image (specific to the key) to appear on the screen. For example, let's say if I press the "O" key, an image of Earth appears on my screen.
What's the best way to achieve this? Thanks!
This is possible with layered windows. I have created a Win32 project as a demo. You can find the code and explanations here.
Basically you have to:
handle the WM_CHAR message and load the appropriate image (from resources or from disk)
create a layered window and display the loaded image in that window
if you want to automatically close the window after an given interval after the last key was pressed you have to create a timer and in the timed procedure destroy the window
Check my link for a solution to your problem.

Qt and X11 fullscreen application , which blocks Window Manager simultaneously

i think i need to use a XEvent with QMainWindow together to make my application unable to close even by Window Manager , could any one provide an example ?
It's like a fullscreen video game , which blocks all keyboards , mouse buttons.
P.S: QWidget::grabKeyboard() && QWidget::grabMouse() doesn't work when i try to switch to other applications with key combinations like "ALT_TAB"
Thanks.
To completely block all inputs from other apps, you need to use XGrabServer and not XGrabKeyboard/XGrabPointer combination. Dunno whether Qt has an API for that but you can always call the Xlib function directly.
I however recommend against it. If the application is for some reason doesn't release the grab, you're stuck and need to escape to the console to kill it.
I think you can override closeEvent() of your main window and reject the event by using ignore() method as described here.