vs2010: Gradient background in a windows application - c++

I am working on visual studios 2010 and c++. I am trying to change the background color of my basic windows app i want to put gradient colors to it like how skype and other programs do is it possible? As far as my guess is that i have to add gradient brush on the WNDCLASSEX.hbrBackground so far i could only find this
http://msdn.microsoft.com/en-us/library/windows/desktop/dd371488%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd799414%28v=vs.85%29.aspx
But i could not make it work as a whole background, i am just making guesses as i am completely lost and an example code or description on how to achieve this will be really helpful.

If you want to support versions prior to Vista, you needed to handle WM_ERASEBKGND message in your window proc and do the whole painting of the background yourself. Read about GDI or GDI+ at msdn on how to do it.

Related

Creating OpenGl Window with c++ in windows using 64 bit + Custom Window Shape (etc smooth corners not rectangular)

Im trying to make a software in c++ using OpenGl & C++ it must be 64 bit and be able to have custom window (frame/"handler") etc no normal windows rectangle around it... and use an opacity on etc corners... so get rounded corners on the window/frame.. Anyone know what libs and how to do this? I know OpenGl & C++ however im not sure how to get the window & 64 bit.. since i tried glut but it fails on the 64 bit version and also do not feature the custom framing that i want... Any advice appreciated (: (I want to not use any extra libs) so creating a opengl context myself and import the opengl32.dll and functions from "windows" rather then using libs like etc glut :3 )
Maybe you want to take a closer look to the winapi (MS Windows only).
The procedure of creating a window is pretty straight forward and "binding" OpenGL to it is not that difficult. There is even a nice tutorial from the khronos-group:
OpenGL Winapi Setup Tutorial
Thats the first step, creating round edges is another.
There are tons of approaches to achieve the desired effect, I assume you want to make your window frame as rounded in the default window 7 scheme.
Enabling Visual Styles
If that is not what you want, you can create a frame by yourself by opening a frameless window with winapi and draw your frame with OpenGL.

Visual Studio 2010 C++ console applications

I am new to C++ and I would like to know what the limitations are in graphics for a console application. For example---Could I create something as compicated as some of the
very colorful screensavers that have all kinds of splashes of color?? Could I draw lines
of changing color based on input strings??? I would appreciate any advice someone could
give me.
Thanks Doug
If you want to do some serious animation you'll pribably want hardware accelerated graphics (DirectX, OpenGL). If you just want simple images and animations a GUI app would do. As far as the console it's not really intended for more than text output but it can draw lines and change colors if you really want too.
However none of the three are limitations of C++ ... C++ as a language does not care about graphics that would be an OS limitation primarily and you'll find most of your drawing code however you go about it will be somewhat OS or hardware dependent unless you use a cross platform library with GUI or graphics support like QT, wxWidgets, OpenGL, etc.
As others have said, a console application is for text, not graphics! I don't know of any way (or reason) to do graphics in a console.
To do the kinds of things you are interested in (except maybe Windows screensavers) using Visual C++, I would recommend starting off with the SDL library. The Lazy Foo Productions website has an excellent series of game programming tutorials, and the first lesson gives you a step-by-step guide to build an app that displays stuff on the screen. It even has screenshots showing how to configure Visual Studio 2010, which is pretty important if you're new to this kind of thing.
SDL is free, cross-platform, and will let you (within your program's window):
draw pixels, lines, and rectangles in any color
draw text
draw images
make animations (by changing/redrawing the screen many times per second)
obtain keyboard input (including when keys are released)
It will also let you do 3D graphics with OpenGL, but that's another story.
You could, if you're very desperate- but certainly not platform-independently. From memory, the Windows API is quite good about letting you do a lot of crazy shit to it's console. However, it's probably better advised to get a genuine graphical API for this purpose, such as GDI, DirectX or OpenGL.
C++ does not have any standard facilities for drawing graphics in a console application. Any features (like changing the font color) will depend on your OS. I doubt you will find functions that do much more than changing the text color though. (For example, on Windows you would use system("color xx") to change the foreground and background color.)
Basically, if you want graphics you're going to have to abandon the console application and look for a graphics API.
Could I create something as compicated as some of the very colorful screensavers that have all kinds of splashes of color??
If by "splash" you mean "chunk of text", then yes. Otherwise no.
Could I draw lines of changing color based on input strings???
No, consoles are textual media.
If you want to try to do things to the console you need to use the Windows Console Functions. Standard C++ does not have any way to change console color.

Is is possible to make a shaped, alpha-blended dialog?

I'm making a non-rectangular dialog, modelled over an image from Photoshop (the image is the background of the dialog, and the user will see trough the transparent part of the image). I'ts like a dashboard-style window for a media-app with a few custom-drawn controls. Most of the background-image is either opaque or 100% transparent - but in between there is a thin area of partially transparent pixels, ment to blend the image smootly into the background. This works great for web-graphics, but I have not found a way to make this work for Windows windows. I'm using the Windows Template Library (WTL), msvc 2008 - and the app must run on Windows XP as well as Vista and Windows 7.
Currently, I'm simply using the opaque part of the background-image to create a GDI clipping-region, but this gives pretty rough edges.
Does anyone know about any API functions to accomplish this (part of WTL, or reachable from WTL)?
Perhaps you could use layered windows? I haven't tested these with WTL but you should be able to get the effect you want. To the best of my knowledge I don't think you can add controls to a layered window so you'll need to attach it to another (non-layered) window to use controls.
Not sure how this interoperates with WTL, but have a look at the AlphaBlend function. You'll need to select your partially transparent bitmap into a DC and copy that to your dialog's DC in your paint function.
This article shows how to use layered windows with WTL and the Gdi+ API which is available on all your target platforms.

Screen capture of MDI app with OpenGL graphics using MFC

In our MDI application - which is written in MFC - we have a function to save a screenshot of the MDI client area to file. We are currently doing a BitBlt from the screen into a bitmap, which is then saved. The problem is that some of the MDI child windows have their content rendered by OpenGL, and in the destination bitmap these areas show up as blank or garbled.
I have considered some alternatives:
- Extract the OpenGL content directly (using glReadPixels), and draw this to the relevant portions of the screen bitmap.
- Simulate an ALT+PrtScr, since doing this manually seems to get the content just fine. This will trash the clipboard content, though.
- Try working with the DWM. Appart from Vista and Win7, this also needs to work on Win2000 and XP, so this probably isn't the way to go.
Any input will be appreciated!
The best way to get a bitmap from an OpenGL window is to draw the content to a bitmap 'window'. See PFD_DRAW_TO_BITMAP for more information on how to do this.
If you want to go with the Alt+PrtScr way, you have to consider that many users have their own print screen tool installed which reacts on that very same hotkey. So you can't be sure that this hotkey will copy the content to the clipboard. It may just open the window of the installed print screen tool/utility.
Use the glReadPixels() approach. This question is asked quite often, here, on the gamedev.net forums and on other places, so google should show you code samples easily, but the glReadPixels() approach is the generally recommended approach.
Simulating keypresses is a recipe for disaster, I would stay away from that.

Displaying graphics on top of another full screen application; hardware overlay?

On Windows (Vista32), I want to display some simple graphics on top of a fullscreen flash window (an overlay of useful information while using the flash application). What's the fastest way to accomplish it?
I think I may be able to achieve it using DirectX with the DDSCAPS_OVERLAY flag but with the only example I've found I get an exception:
E_NOTIMPL
The function called is not supported at this time
on
m_direct_draw->CreateSurface(&ddsd, &m_overlay_surface, 0)
(full code here: http://nexe.gamedev.net/files/Overlay-2005-11-21.zip)
Something relevant to C/++ or Python would help me. I'm using the latest DirectX SDK.
Thank you
Just create a Layered Window and draw to it with an alpha channel - in WPF, this is as easy as setting the AllowsTransparency bit on the Window
While the transparent layered window is useful, it doesn't appear on top of the fullscreen flash with WS_EX_TOPMOST set.
Note sure how to reply to Paul sadly.
Overlaying on a 3D fullscreen application is very relevant but while it works and flash appears to load dx9, it doesn't show on flash.