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.
Related
My application is a fullscreen window rendering a specified window or the desktop.
I would like to know if it's possible to fetch the window bitmap (like i'm already doing) but without the render of my window's application ?
There is the idea : dwm.giveBitmapWithoutRendering(HWND myApplicationHandler)
Working on Windows 7/8/8.1, QTCreator C++ MINGW
You can use the PrintWindow function with your own memory DC. The success of this method will depend on how the window and its child windows have implemented the WM_PRINT message.
This doesn't use DWM but rather gets the window to repaint itself. Since it's not repainting to the screen I hope it meets your requirements.
I have made an QML application using a frameless window and implemented actions like dragging and resizing by myself. But this way the application doesn't support native window manager features like windows aero snap or the Gnome window manager features. So I searched and found this where someone found a way to support them in a frameless window using the win32 API. But is there a way to use this with a QML application or another way to use the native window manager features?
I initialize the window from C++ with this code:
QQmlApplicationEngine engine(QUrl("qrc:/qml/main.qml"));
QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
window->setFlags(window->flags() | Qt::FramelessWindowHint);
if ( !window ) {
qWarning("Error: Your root item has to be a Window.");
return -1;
}
window->show();
EDIT: I would also like to use the native window manager drop shadow like in the example I have linked to, if possible.
EDIT:
I have a second problem: Following #Kuba Obers instructions I got it to work how it was intended to. But now I have the problem, that when I resize or move it Qt leaves an undrawn area with the size of the frame.
The winapi window handle is provided by window->winId():
HWND handle = window->winId();
You can pass this handle to native functions.
To filter the WM_NCCALCSIZE message, you need to implement a native event handler by subclassing QAbstractNativeEventFilter, and install an instance of it on the application by calling qApp->installNativeEventFilter(myFilter).
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 );
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!
What's a simple way to implement a c++ Win32 program to...
- display an 800x600x24 uncompressed bitmap image
- in a window without borders (the only thing visible is the image)
- that closes after ten seconds
- and doesn't use MFC
If you're targeting modern versions of Windows (Windows 2000) and above, you can use the UpdateLayeredWindow function to display any bitmap (including one with an alpha channel, if so desired).
I blogged a four-part series on how to write a C++ Win32 app that does this. If you need to wait for exactly ten seconds to close the splash screen (instead of until the main window is ready), you would need to use Dan Cristoloveanu's suggested technique of a timer that calls DestroyWindow.
Register a class for the splash window and create a window using these styles:
WS_POPUPWINDOW: will make sure your window has no caption/sysmenu
WS_EX_TOPMOST: will keep the splash screen on top of everything. Note that this is a bit intrusive. It might be better to just make the splash window a child of your main window. You may have to manipulate the z-order, though, to keep any other popup windows (if you create any) below the splash screen.
Use CreateDIBSection to load the bitmap. It should be easy, since BMP files are essentially dumps of DIB structures. Or do what Ken said and use LoadImage.
Handle the WM_PAINT or WM_ERASEBKGND message to draw the bitmap on the window.
On WM_CREATE set a timer of 10 seconds and when Windows sends the WM_TIMER message, have the window destroy itself.
The key point here is to use layered window.
You can start with a win32 wizard generated project and change CreateWindow call to CreateWindowEx and set WS_EX_LAYERED as extended window style and combination of WS_POPUP and WS_SYSMENU as window style. When you do that launch your application it will be invisible. Then you should use UpdateLayeredWindow to paint your image. You may also need AlphaBlend function if you want use PNG image with alpha layer.
Hope this helps!
You can:
Create a dialog in your resource file
Have it contain a Picture control
Set the picture control type to Bitmap
Create/import your bitmap in the resource file and set that bitmap ID to the picture control in your dialog
Create the window by using CreateDialogParam
Handle the WM_INITDIALOG in order to set a timer for 10 seconds (use SetTimer)
Handle WM_TIMER to catch your timer event and to destroy the window (use DestroyWindow)
Use LoadImage to load the bitmap
Use CreateWindowEx to create the window.
In the window proc capture the WM_PAINT. Use BitBlt to paint the bitmap.
It's a Win32 api FAQ
See professional Win32api forum
news://194.177.96.26/comp.os.ms-windows.programmer.win32
where it has been answered hundreds of times for 20 years..