Drawing text over/in a Process/Game - c++

I'm currently working on a C++ DLL project.
This DLL will be injected into a game.
All I'm looking to do for now is draw some text like "Active" or "Working" in the bottom right or left hand corner of the screen when in game.
Just to give me something visual to show that the DLL is working and active/injected.

I haven't done this myself and this is an amalgamation of resources. First of all, since you're targeting GTA San Andreas, you should know that it's running using DirectX 9. I'm not aware of any OpenGL rendering version, so correct me if I'm wrong. Now about how to 'inject' make a draw call to render an overlay, please look in here: Hooking DirectX EndScene from an injected DLL. So, basically you change DirectX function EndScene() with your custom function that draws the text you need and then calls the actual EndScene(). Let me know if you want to know more.
Helpful links:
Draw text in Direct3D 9
What is the most efficient way to draw text in DirectX 9?

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.

Windows 8 modern UI applications and DirectX... How to draw text?

I already have a Direct3d device at my beck and call...
I am working on a Windows 8 modern UI application (Metro if you will)
What's the general technique of getting text drawn to the screen?
Extra points: Can I do 3d stuff with it too? This is what originally got me here as I started to do some direct2d thing then I thought, but how can I do 3d with direct2d... second of all the d2d create text functions require a handle to a window hwnd and there is no such thing (or it has been abstracted away) in windows 8 metro apps.
Anyone got any good examples or demos I can take a look at?
You should look into DirectWrite.
Regarding your second question you can render your text to a texture and then when you render that texture on screen do 3d stuff with it.
Rendering text with DirectWrite and Direct2D it's relatively simple, however, if you want something higher level, you can look into Drawing Library for Windows Store Apps, which wraps raw DirectX calls into some more GDI like.

OpenGL Program with multiple windows

I'm looking for an efficient way to use two separate windows for one OpenGL program in C++. It is a drawing program and like Photoshop or Illustrator I would like to have a tool bar that is a separate window that can be moved around but does not get sent behind the composition window when the user starts to draw. Can this be done?

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.

How can I make my C++ ActiveX control print nicely in Excel?

I am trying to get my ActiveX control to print out nicely in Excel.
The control is written in C++. Originally I generated the control using the Visual Studio 2005 wizard. I have tested this with a simple wizard generated control to experiment with the OnDraw function and I discovered that even a control straight out of the wizard doesn't print well either. It appears to clip out a large portion of the control - which by default renders a black outline and some text in the centre.
The function IDataObject_GetData is called on my ActiveX control which in turn creates a metafile and renders to it.
Does anyone know how to get an ActiveX control to print out nicely? Alternatively links to useful information will be appreciated.
After much head scratching I figured out the solution to my problem.
The OnDraw function generated by the Visual Studio 2005 wizard sets up a clipping region by calling the function SelectClipRgn. It was this clipping setup that was causing ActiveX control to appear clipped when printed. Commenting out the code makes the ActiveX control print out perfectly. Commenting out the code doesn't appear to cause any other problems either - at least not in my case.
I can only assume that whatever coordinate system is used for clipping is not compatible with the coordinate system used when drawing to a metafile DC.
Here are some links to useful info that I found about printing ActiveX controls:
http://www.codeproject.com/KB/COM/officeatlprint.aspx
http://www.codeproject.com/KB/COM/WirgerPrintArticle.aspx
http://support.microsoft.com/kb/81497
http://support.microsoft.com/kb/84984