It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm not sure if this is something that is possible. But basically the gist of what I need is that a bunch of stuff in my Win32 program is drawn to hWnd through a device context during WM_PAINT. Then through a separate function, I have more stuff drawn to hWnd through the SAME DC. Unfortunately since I use the same DC, the stuff drawn during WM_PAINT is still held in the DC, and is therefore subsequently copied again through my function.
What I need to do is clear the contents of my device context at the end of WM_PAINT or the beginning of my function so that the stuff isn't copied twice.
Why cant you do the entire drawing in WM_PAINT handler ?in the second drawing how do you draw?may be using GetDC to get the device context and draw, right?
The problem is that when you draw outside the WM_PAINT handler, it get erased when the window need to repaint, and the WM_PAINT drawing trump your GetDC based painting, unless you use a bitmat to keep the current context's content
Do all of your drawing to an off-screen bitmap whenever you need to while outside of WM_PAINT, then simple copy the current bitmap to the HWND inside of WM_PAINT.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am now trying to create a screen capture program. Last week I have tried the GetFrontBufferData method and it succeed. However, its performance is terrible and can only catch the desktop images. It means that when I start to run a full screen game, the GetFrontBufferData Method will get nothing. But what I want is to catch the full screen game not the desktop images.
In the GetFrontBufferData solution, I created a device and let the HWND parameter be NULL. I wonder if I can get the handle of the toplevel window (mean, the handle of full screen game), and pass it to the CreateDevice method, I can catch its screen shot.
Actually I have tried several screen capture method based on DX9. I have studied the questions Fastest method of screen capturing and tried the GetRenderTarget() method in conjunction with GetRenderTargetData(). The problem is I can only get the Render data rendered by the program itself. And the same with GetBackBuffer().
So the problem comes to, can I get a specific window image (like some running full screen game) if I can get the Handle of the toplevel window? I have checked the EnumWindow method described in Win32 - Get Main Wnd Handle of application. This code seems to get windows which only created by the program it self according to my test. However I need to get some windows created by the other programs.
So, that is my question. In a word, I want to know two things: 1, Is my approach that get handles of other windows then pass it to the CreateDevice and get its screen shot right? 2, If it is right, how to get the handles; if it is wrong, what is the rigth way to capture the full screen games?
That's not right, the window handle passed to CreateDevice has nothing to do with screen capture, it is the window that alert Direct3D when the app go background. since you want to capture the screen data stream from another app, so the window handle here cannot help you.
Since performance is critical, and GetFrontBufferData was time-consuming, so the only way I think suit for your need is Hooking Direct3D, interrupt the call to Present, and get the data from backbuffer, then you can do what you want, this is just an idea, I am not familiar with hooking and I never hooking Direc3D before.
Here is something about the two window handle used in CreateDevice(from DirectX SDK document)
When you create a Direct3D device, you supply two different window
parameters: a focus window (hFocusWindow) and a device window (the
hDeviceWindow in D3DPRESENT_PARAMETERS). The purpose of each window
is: The focus window alerts Direct3D when an application switches from
foreground mode to background mode (via Alt-Tab, a mouse click, or
some other method). A single focus window is shared by each device
created by an application. The device window determines the location
and size of the back buffer on screen. This is used by Direct3D when
the back buffer contents are copied to the front buffer during
Present.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I need to develop a Maya Viewport Extension in C++ with(MFC),also need to control view style(such as top view, left view etc.).Can I use Maya SDK to archive this and how to make it?Thanks.
I'm not perfectly sure what you mean by "Viewport Extension".
I guess you're trying to write a Maya Plug-In that features your own type of viewport, which is commonly called "Model View".
MCF does not have anything to do with this.
You use Maya MEL/Python commands to create Maya windows, panels and other UI-elements.
(if there is a hack to make Maya work with windows you've created yourself, I don't know it).
You can develop custom viewports in Maya by creating two classes:
A viewport or model view, and a "model editor command".
Model View
One is your viewport class, let's call it "MyViewport".
It has to inherit "MPx3dModelView".
Normally you will associate a camera with the viewport. This let's you control from where you see the scene. You can have multiple cameras connected to your viewport (multi-pass display, for example stereo 3D), or none at all (but then you must set all rendering parameters by yourself, which can be tedious).
The (callback) functions you inherit from that class allow you to set up the details for your viewport.
See the Maya documentation on MPx3dModelView to see how to use it.
http://download.autodesk.com/us/maya/2010help/API/class_m_px3d_model_view.html
Model Editor Command
The other class you'll need is a viewport command.
That is the thing that get's called when someone tries to create your viewport.
It has to inherit "MPxModelEditorCommand".
It's most important feature is that it can create an instance of your Model Editor class.
See the Maya documentation on MPxModelEditorCommand on how to use it:
http://download.autodesk.com/us/maya/2011help/API/class_m_px_model_editor_command.html
Registering the viewport command with the Maya plug-in
In order to be able to create your viewport, you must register your Model Editor Command with the plugin.
In your initializePlugin function (the one you export with the plugin)
MStatus initializePlugin( MObject obj )
{
MFnPlugin plugin( obj, PLUGIN_COMPANY, "1.0", "Any");
plugin.registerModelEditorCommand(MyModelViewCmd::commandName, MyModelViewCmd::creator, MyModelViewCmd::createModelView);
}
Writing a script that creates your viewport
Finally, you use MEL or Python scripting in Maya to create your user interface.
In the most simple set-up, you simply create a window and then call your model editor command to create you custom viewport in this window.
window MyWindow;
paneLayout MyWindowPane;
MyModelView MyModelView1;
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Say for example that I wanted to draw a red square (or multiple red squares) in the middle of the screen and still be able to see everything not covered by the square, a little bit like a splash screen.
I want to implement this in windows but I don't know the best way to draw on top of the screen. These are my ideas so far:
I initially attempted to draw directly onto the desktop by obtaining a Device Context for it.
Make the rectangle/s a separate window as they would be very easy to move around and I wouldn't have to worry about transparency.
Create a transparent window that covers the entire screen and stays on top. Draw the rectangle/s on the client area of the screen
I think that the best of the 3 ideas is the last one, but any opinions on my ideas, or new ideas would be much appreciated :)
Creating transparent window, then drawing in it, in my experience it is messy.
Why don't you just take a screenshot from the back ground set it as the back ground for you snake game. When ever they click somewhere/die you just close your game.
You could catch the last click and resubmit it after closing the game.
That is how I would do, but of course that just an opinion.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have to make the background (of desktop) blur when i open my app.how do i do this please help me out with hints or links..
Take a screenshot.
Apply some blurring to the screenshot bitmap (e.g. Gaussian).
Display a fullscreen window with processed screenshot as content.
Show your window on top of the fullscreen window.
The details depend on the OS and the technology you are working with.
If dimming instead of blurring is OK, you can just show a black fullscreen rectangle with alpha less than one (as suggested in the answer by Seçkin).
Though I must add that as a user I would resent an application doing that to me. Unless it's a nuclear missile launch control application (or something with similarly drastic consequences of a user mistake), I'll just uninstall it.
If I were you, I would create a semi-transparent rectangle which spans entire screen to achieve this effect. It is similar to see behind blurry glasses: World is not blurred, just glasses make it perceived blurry.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to change background button when mouse move or mouse leave or click on button. I write my app in MFC.
Please help with demo/sample.
How to track mouse movements? See here
How to change the bitmaps of the MFC buttons? See here