Invisible main window - c++

I'm working on a DirectX GUI library, and the main class works by creating a main window, and then porting the input to all the GUI windows, which will handle the events. The problem is, the main window is a Win32 window (to handle messages), and needs to be invisible. Is there a way to create and invisible window and then be able to handle messages and draw things with DirectX?

In the WM_CREATE of your WindowProc, do:
ShowWindow( hwnd, SW_HIDE );

Related

Is it possible to create an MDI window to the dialog-based window instead of the frame window?

I know you can create an MDI window to Frame window but what about dialog-based window is it possible to create MDI window to it too or it is just exclusive for Frame window only?
or Is it possible to create an MDI client window then create an MDI child Frame window to dialog-based window?
Can it be done? Probably. Is it a good idea? Probably not.
The main issue is that both MDI and dialogs want to control focus and keyboard handling.
You definitely need to use CreateDialog and not DialogBox to create the main window because you need control of the message loop. TranslateMDISysAccel and IsDialogMessage can help you a little bit but you probably need some custom handling that determines if the active/focused window is a MDI child frame or a normal dialog control and prioritize messages for MDI or the dialog. The most difficult being tabbing out of the MDI child frame window and back into the dialog. The last one you could work around by adding a custom key like F6 to set the focus back to the dialog.
Raymond Chen did a blog post series about dialogs, some of them about how you can write your own dialog class and/or custom dlgproc handling.
Even with full control of the message loop and some control over the dialog, you might still end up having to subclass the dialog and/or the MDI client window to handle specific messages.

Get HWND for Direct3D init

I am pretty new into C++ and I am following tutorial "Getting started with Direct3D" from directxtutorial.com
I have used Niko Kauppi's Vulkan tutorials 'youtube link' to create window, but I am not using Vulkan here. Current project has win32 window and glfw window.
DXTutorial has this void function: void initD3D(HWND hWnd) {}
I'd like to know how to get the handle to the current window I am using ( either win32 or glfw ).
The win32 window is like this: http://pastebin.com/P54cX6gr
and glfw window is like this: http://pastebin.com/HD0Yxk2S
I ran out of links.
You can get the Windows window handle from a GLFW window with glfwGetWin32Window.
If you want to use WinAPI directly then, when you register the WindowProc for the window, the first parameter passed to it is the window handle. You can then use WM_CREATE event to handle the initialization.

Undock a child window from main application

let's say i have a big application with a few child windows inside of it. ( example )
Now, i am trying to undock one of those "inside windows" to a new serperated window, which i can move all over the place!
What i have done so far:
HWND oldHWND = SetParent(hwnd, NULL);
SendMessage(oldHWND, WM_SYSCOMMAND, SC_CLOSE, 0);
All this works very well, but i am not able to move the new window and i am not able to close it, because there is no window frame and no close button.
Do you have any suggestions for me?
Thank you very much!
Register a suitable window class for your undocked "floating" window with a frame/close button etc, and then make the undocked window a child of that.

Float GLUT window on top without titlebar on OSX

I'm creating a simple commandline applicatiation that starts a GLUT window.
I need that GLUT window to be always on top and remove the titlebar.
Basically GLUT does not provide anything for this so i'm looking into other options. On Windows i would do something like:
glutCreateWindow( "dpd" ); //create window with glut
HWND hwnd = FindWindow( "GLUT", "dpd" );
SetWindowPos( hwnd, HWND_TOPMOST, NULL, NULL, NULL, NULL, SWP_NOREPOSITION | SWP_NOSIZE ); //set the window always-on-top
But how can i do such a thing on OSX? (C++)
I already use some Carbon code to remove the menubar, but the titlebar is still visible:
SetSystemUIMode(kUIModeAllHidden,KWindowNoTitleBarAttribute);
i'm new to OSX development and out of ideas..
thanks
Ok, i found out that there is now way to make changes / ajustments to a glut window. So i finaly created a workaround: i start glut on one thread, on an other thread i created a fullscreen window with a transparent background and created a dynamic backgroundimage (png) with a viewport with just the size of the GLUT window without the titlebar. Sound kind a ugly but hey, it works, the client does get the result they want within budget :)
If you think there is a better solution for this without creating a manual openGL implementation please let me know!

Win32, C++: Creating a popup window without stealing focus

I am creating a program that displays a popup at certain times (just like some chat clients for example) on which the user can click. However, I do not want to take away the focus from the current application.
The way I'm doing it now is by using a HWND with WS_POPUPWINDOW and minimizing and then restoring the window. However, this steals the focus from the current application. Setting foreground or hiding and showing a window did not make it appear on the foreground. I would like to be able to keep using a HWND so I can use other elements in this window, but I have no idea how to give it foreground without stealing focus.
I use win32 and c++.
To show without activating:
ShowWindow(hwnd, SW_SHOWNOACTIVATE);
To raise without activating:
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
Unfortunately this is not working for me. The window is created with CreateWindowExA and is showed using ShowWindow(hwnd, SW_SHOWNOACTIVATE) however the keyboard focus is still stolen from the window which has the focus at the moment of the creation. (The window is created with layered and trasparent attributes by using SetWindowLong() and SetLayeredWindowAttributes() ).
PS: The window which has the focus is not parent of the new created window.
Solved: It worked when I removed the SetForegroundWindow call. This function cause the window passed as parameter to be activated.