GLFW loadding status on the taskbar - c++

I need to make progres bar on taskbar using GLFW ( C++ ) , something like that:
There is a simular question about java: How to make a windows 7 loading bar on the taskbar, but I need it in C++
I was alredy looking for answer in GLFW's documentation, but I could not find any.
Is it possible using GLFW, and how can I do this? Let me know, if I can also make it work in linux or macOS.
If required, I might use native HWND window handler in Windows, but I was not able to find solution for native handler too.

On windows you will need to use ITaskbarList3 interface. SetProgressState and SetProgressValue method in particular.

Related

QT How to embed an application into QT widget

In our project we have three independent applications, and we have to develop a QT control application that controls these three applications. The main window will be seperated to three sub windows - each one display another one application.
I thought to use QX11EmbedWidget and QX11EmbedContainer widgets, but two problems with that:
The QX11Embed* is based on X11 protocol and I dont know if it's supported on non-x11 systems like Windows OS.
Since QT 5 these classes are not existing, and the QT documentation doesn't mention why.
So that I dont know whether to use it or not - I'll be happy to get an answers.
In addition, I see that the QT 5.1 contains QWidget::createWindowContainer(); function that in some posts it looks like this should be the replacement to the X11Embed. Can anyone please explian me more how can I use this function to create a QT widget that will run another application (a Calculator for example) inside its?
I have searched a lot in Google, and didn't find answers to my Qs.
Can anyone please help me? Am I on the right way?
Thanks!
If all three independent applications are written with Qt, and you have their source, you should be able to unify them just through the parenting of GUI objects in Qt.
http://qt-project.org/doc/qt-4.8/objecttrees.html
http://qt-project.org/doc/qt-4.8/widgets-and-layouts.html
http://qt-project.org/doc/qt-4.8/mainwindows-mdi.html
If you don't have access to them in that way, what you are talking about is like 3rd party window management. It is kind of like writing a shell, like Windows Explorer, that manipulates the state and the size of other window applications.
Use a program like Spy++ or AutoIt Spy for Windows and the similar ones for other OS's, and learn the identifying markings of your windows you want to control, like the class, the window title, etc. Or you can launch the exe yourself in a QProcess::startDetached() sort of thing.
http://qt-project.org/doc/qt-5.1/qtcore/qprocess.html#startDetached
Then using the OS dependent calls control the windows. The Qt library doesn't have this stuff built in for third party windows, only for ones under the QApplication that you launched. There are a lot of examples of doing things like this by AutoHotKey, or AHK. It is a scripting language that is made for automating a lot of things in the windows environment, and there is port for Mac as well (though I haven't tried the mac port myself).
So in the end you are looking at finding your window probably with a call like this:
#include <windows.h>
HWND hwnd_1 = ::FindWindow("Window_Class", "Window Name");
LONG retVal = GetWindowLongA(hwnd_1, GWL_STYLE); // to query the state of the window
Then manipulate the position and state of the window like so:
::MoveWindow(hwnd_1, x, y, width, height, TRUE);
::ShowWindow(hwnd_1, SW_SHOWMAXIMIZED);
You can even draw widgets on top of the windows you are controlling if you set your window flags correctly for the windows you are manipulating.
transparent QLabel with a pixmap
Cannot get QSystemTrayIcon to work correctly with activation reason
Some gotchas that come up in Windows when doing all of this, is finding out the quirks of the Windows UI when they set the Display scaling different from what you expect, and if you want to play nice with the Task bar, and handling all the modal windows of your programs you are manipulating.
So overall, it is do-able. Qt will make a nice interface for performing these commands, but in the end you are looking at a lot of work and debugging to get it in a beautiful, reliable, window manager.
Hope that helps.
I never tried it myself, but from the docs in Qt 5.1 I would try QWindow::fromId(WId id), which gives you a QWindow, which should be embeddable with createWindowContainer:
QWindow * QWindow::fromWinId(WId id) [static] Creates a local
representation of a window created by another process or by using
native libraries below Qt.
Given the handle id to a native window, this method creates a QWindow
object which can be used to represent the window when invoking methods
like setParent() and setTransientParent(). This can be used, on
platforms which support it, to embed a window inside a container or to
make a window stick on top of a window created by another process.
But no guarantee. :-)

SDL1.2, Window in another window

I'm using Ubuntu 12.04 here and developing an SDL1.2 app in c++. What I would like to achieve is that the user could open like a "Preferences" window or something from the "Main" window (both window should have a titlebar etc). I'd also like to have this program be able to run cross-platform, and SDL2 is not an option, either.
Is this achievable in any way? What I could think of so far is writing another SDL program that will be called from inside the 'main' program, but that would include some system() calls, and anyways, it's not the best solution IMO.
SDL only supports a single window. If you upgrade to SDL2, it supports multiple windows, though you can't put one window inside of another window.
If you want this functionality without upgrading, you'll have to render the window-in-a-window yourself.

Terminal to open a popup window in C++

My c++ application needs to display a message via a popup window or an alternative. My application is running on Ubuntu 12.04 version. Can I program the application to open a Ubuntu type popup window? If possible, how?
Do I need to use gnome window or something like that?
The simplest way to display a popup from a program that doesn't otherwise use a GUI, is probably just execute a command-line tool that does the work:
to display a notification with no buttons, you can use notify-send
system("/usr/bin/notify-send MessageSubject \"message body here\"");
if you want buttons so the user can give a response, you could use the (much uglier) xmessage
system("/usr/bin/xmessage")
(see each tool's manpage for all their options)
The alternative is really to use a full GUI framework (probably gtk+), and that's not typically a small change.
For example, you can use libnotify directly (giving you the same basic capabilities as notify-send, but more control), but this also depends on glib. So, now you've added two external dependencies when you could just have run system.
In order to display the popup or any kind of window, you will have to reference either gtk+ or qt libraries in your application/program. gtk+ is advisable, since the ubuntu unity desktop is also based on gtk+ - this way your program will have lesser overhead and more performance gain while running on ubuntu. You can either use the default C library (libgtk2.0) or the gtkmm (libgtkmm) for C++.
You can get more information on how to refer these libraries, initialize gtk_main in your main() function, etc. at this place: http://www.gtk.org/documentation.php

wxWidgets create an app that lives on the desktop?

Is it possible, using wxWidgets and C++, to create an application that will show on the desktop? What I mean, is that it would only display on the desktop, like Geektools, Rainmeter, etc.
Not out of the box.
You could try to get the HWND of the Desktop and create your own control in wxWidgets by deriving a class from wxControl or wxWindow and do the Drawing yourself. It is not that hard to do it :). You could even use wxHTMLWindow or wxWebConnect (3rdParty, based on Webkit) for that.
See GetDesktopWindow() for that:
http://msdn.microsoft.com/en-us/library/ms633504(VS.85).aspx
Assuming you are on Windows. You have to check for your WindowManagers Documentation on Linux yourself though. If you are using KDE, I would suggest to use QT directly or the KDE API. Same for Gnome.
It would be easier to use the corresponding os/windowmanager api for that though.
Hope that helps.

C++ on Windows: Using DirectInput without a window?

Short version:
How do I initialize and use DirectInput if I have no access to the HWND/HINSTANCE?
Background information:
I am currently using SFML for most parts of my program, amongst others for window creation. Works like a charm. But I'm not fully satisfied with SFML's input system (e.g. I want XInput for XBox 360 gamepads) and want to write my own.
I've already written the XInput part, but for other gamepads/joysticks/... I also need DirectInput. Since SFML hides the Windows-related code from the user (and rightly so) I don't have access to the hwnd or hinstance. How can I use DirectInput without it? Maybe catching input all the time, not only when the window is active? (I could then filter it based on the Window's (de)activated event.)
Thanks,
Mr. Wonko
Finding the window back isn't too hard, use EnumThreadWindows() and GetCurrentThreadId().
Note that DirectInput doesn't need a window handle anywhere. It just needs the instance handle in DirectInput8Create(). GetModuleHandle(NULL) is good for an SFML app.
To get HINSTANCE you can call: GetModuleHandle(NULL)