I think this is going to be an easy one for you guys :)
I am trying to get FPS displayed in the window title in my Directx application (written in C++). I do not really know how to do this as my app assigns title in this manner
any ideas how to do this (so that I can see the FPS when I minimise my app) ?
I think you can use SetWindowText() to accomplish this, e.g.:
HWND window = CreateWindow(windowClass.lpszClassName, title, WS_OVERLAPPEDWINDOW, x, y, width, height, GetDesktopWindow(),NULL,windowClass.hInstance,NULL);
... then later ...
SetWindowText(window, "XXXX FPS");
See:
http://msdn.microsoft.com/en-us/library/aa302340.aspx#win32map_windowfunctions
Related
I'd like to draw to the desktop wallpaper area with directX 9 in particular. Under the icons and text above the wallpaper.
Similar to Okozo or one of VLC's modes, or Dreamscene.
So there's a lot of similar questions to this but no working examples or tutorials.This A simmilar question but different approach seems pretty useful. A few years ago I was searching and found this site and code.
It's perfect aside from one big issue the icon text gets blocky even with alpha blending. I tried a few fixes but I wasn't able to find any helpful documentation maybe I just wasn't using the right words for searching, maybe it's proprietary. I think I fixed that with a call to invalidate the desktop area but I can't really tell as in the process I messed up the alpha values for the text so it doesn't properly draw the font color. So how do I alter the text for proper alpha blending?
Pouet's links are all dead
I know I should post a snippet but I can't pin down where the problem is as it's more an unexpected feature.
I've been searching for this code for too long.
I'd like to write a Dreamscene like app witch can render dynamic contents other than just video files, and this one may be the most hopful solution.
I compiled your code in VS2010 Win7x64 and found:
Desktop icon text become transparent just like Dreamscene do when the window is like:
0x00150138 "Program Manager" Progman
0x000605D6 "" SHELLDLL_DefView
0x000C05BA "FolderView" SysListView32
Desktop icon text become normal but not clear enough when the window is like:
0x000B007C "" WorkerW
0x000605D6 "" SHELLDLL_DefView
0x000C05BA "FolderView" SysListView32
0x000C05BA "FolderView" SysListView32
0x000511E2 "" WorkerW
0x00150138 "Program Manager" Progman
I tried this method Draw Behind Desktop Icons in Windows 8 to make the window status always be like the second condition; and tried to draw on WorkerW window above Progman window with D3D, but got nothing rendered out.
So far there's nothing helpful, dumping the bitmap used by memoryDC may help, which I'll try latter.
If you got any further approach, please let me know.
It has been long time since I last use English, Sorry for my mistake if any.
Update:Clear Icon Text got!
add this under d3ddev->BeginScene();
d3ddev->SetSamplerState(0,D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0,D3DSAMP_MAGFILTER, D3DTEXF_GAUSSIANQUAD);
and this:
HWND desktop = GetDesktopWindow();
HWND explorer = FindWindowEx(desktop, 0, _T("Progman"), _T("Program Manager"));
SendMessageTimeout(explorer, 0x052C, 0, 0, SMTO_NORMAL, 3000, NULL);
HWND defView = 0;
HWND worker = 0;
while(!defView) {
worker = FindWindowEx(desktop, worker, _T("WorkerW"), 0);
if(worker) {
defView = FindWindowEx(worker, 0, _T("SHELLDLL_DefView"), 0);
}
else break;
}
if (!worker){ /*DBG("First WorkerW failed");*/ return 0;}
worker = FindWindowEx(desktop, (HWND)worker, _T("WorkerW"), 0); //find the next WorkerW
if (!worker){ /*DBG("Created WorkerW not found");*/ return 0;}
Still drawing on the listView, but worker window must exist. This code runs with Aero Theme enabled only.
Is there a way to tell if a window is currently maximized in GLFW3? Not fullscreen, but maximized in windowed mode.
From https://www.glfw.org/docs/3.3/window_guide.html#window_maximize
int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED);
I've been looking through the GLFW3 docs (http://www.glfw.org/docs/latest/) and nothing has immediatly jumped out at me which is strange because you'd think it would be a window attribute but here are a few alternatives:
Keeping Track - This is the easiest method. You could just create a boolean variable to keep track of when the user maximizes (or minimizes) the window. You could then query this to determine which state the window is currently in.
Getting the Size - This is not entirely reliable because it changes depending on your monitor resolution but it is fairly simple to implement. Simply get the size of the window using the following code:
int width, height;
glfwGetWindowSize(window, &width, &height);
Then check to see if it matches the maximum window resolutions.
OS Specifics - If you are on Windows then it might be worth checking out the microsoft documentation on how to check for these attributes using the GLFW's window handle. The specific page to look at would be this: http://msdn.microsoft.com/en-gb/library/windows/desktop/ms633518(v=vs.85).aspx
If you create a window by using SDL_SetVideoMode(), you are returned a surface, not a window handle. Is there a way to get the SDL_Window handle? I know there is a SDL_GetWindowFromID function, but I'm also not sure how to get the ID, other than the SDL_GetWindowID function, which would require me to already have the window handle.
Any suggestions? Note that it is very important that I maintain cross platform portability, so I prefer to stick with built in SDL functionality if at all possible.
If it helps any, I'm trying to get and set the window position and window size, and those functions require a window handle.
Thanks!
EDIT: I should mention also that I am changing video modes at the user's request, so I cannot just use the default ID of 1, since this ID changes every time I call SDL_SetVideoMode().
I had the same problem with SDL-1.2.15 for windows ,but the problem solved by GetActiveWindow.
You can get SDL window handle like this :
...
screen = SDL_SetVideoMode(w, h, 0, flags);
...
HWND hnd= GetActiveWindow();
See this :
GetActiveWindow function
I had this exact problem - old SDL 1.2 only uses one window, so it keeps the handle to itself. Here's the method I found from reading the source code:
Include SDL_syswm.h then get the window handle using SDL_GetWMInfo
e.g. my code for getting the handle in Windows:
SDL_SysWMinfo wmInfo;
SDL_GetWMInfo(&wmInfo);
HWND window = wmInfo.window;
SDL_SetVideoMode returns a surface based on the video frame buffer, not on a window (just like SDL_GetVideoSurface). You seem to assume that all surfaces correspond to windows, but that is not the case.
Where should I be looking for resolution of DirectX (3D) device? getViewport seems to have Width and Height, yet as far as I know viewport is supposed to be an area, not 2D "canvas" with these attributes.
(I hope "resolution" applies to the device, not D3D directly. Please correct me if this part is wrong.)
Simple MSDN link will be good answer as well, however I already browsed it through and couldn't find it.
Edit: it seems like getDisplayMode will work for fullscreen apps that changes resolution since it returns the display adapter mode, yet I'd like to be able to get the size of d3d window too.
DirectX doesn't actually own a window. If you remember when you initialise the device, you give it a handle to a window. It takes this and displays to its viewports within this window.
So if your looking specifically for the window size then you'll want to get it at the OS level.
This question discusses how to deal with it.
Namely GetWindowRect/GetClientRect(HWND, LPRECT)
If for some reason you only have the d3d interface, you can use getcreationparameters to get the original hwnd and then you can use GetWindowRect or GetClientRect as suggested before.
D3DDEVICE_CREATION_PARAMETERS cparams;
RECT rect;
device->GetCreationParameters(&cparams);
GetWindowRect(cparams.hFocusWindow, &rect);
//rect.width
//rect.height
Perhaps this is what you need: IDirect3D9::GetAdapterDisplayMode Method
http://msdn.microsoft.com/en-us/library/bb174316%28v=VS.85%29.aspx
If you want the window size then call "GetClientRect" on the hWnd you are setting up with.
Stuck on a little fiddly problem. I'm creating a GUI in C++ using XP and VS C++ using the command CreateWindow().
My question is, how do I make the inside paintable region a perfect square. When passing in the size of the window to create, some of this is deducted for the menu bar at the top, border all around etc. Are there any real time variables I can pass in, e.g. to create a 500x500 window would be:
...500+BORDER,500+MENU_TOP+BORDER...
Thanks everyone
The way I usually do it is with AdjustWindowRect. I find it simpler than the other suggested methods (which should work just as well, it's your choice). Use it as such:
RECT rect = {0, 0, desiredWidth, desiredHeight};
AdjustWindowRect(&rect, windowStyle, hasMenu);
const int realWidth = rect.right - rect.left;
const int realHeight = rect.bottom - rect.top;
And pass realWidth & realHeight to CreateWindow.
The function will, as its name suggests, adjust the window according to your window style and menu use, so that the client region matches your desired size.
you can find all the relevant size (windows framewidth, menubar height, etc) here: GetSystemMetrics(). Using these values you should be able to create a perfect square window
You can get all the UI metrics from the GetSystemMetrics() API call.
For example, the menu will be SM_CXMENU and SM_CYMENU.