Re: Using GDI+ w/Visual C++
Quote:
Originally Posted by mjgroves
Hello,
New to posting on these forums, so hopefully I will explain clearly what im trying to accomplish (if this is in the wrong forum please move... my apologies).
Welcome to Codeguru :wave:
Quote:
Originally Posted by mjgroves
1. Is it possible (using windows forms c++) to make a small "picturebox" type of control and draw whatever you want separate from the rest of the controls on the form?
You'll need to derive your own class from CStatic and implement OnPaint (WM_PAINT handler).
Search these articles for more detailed information and examples.
Quote:
Originally Posted by mjgroves
2. I didnt notice any built in functions or documentation on how to add textboxes at the end of a random line that you draw.
What exactly do you want to achieve? Do you want to dislay some static text at the end of a line or should the user be able to edit that text?
Re: Using GDI+ w/Visual C++
To draw your own thing, You might also add a button to the Dialog, make it ownerDraw and overwrite parents DrawItem().
to use GDIplus in C++, you should add something like that to your stdafx:
Code:
// use GDI+ (Platform SDK needed) //
/////////////////////////////////////////
#define ULONG_PTR ULONG //
#include <Gdiplus.h> //
using namespace Gdiplus; //
#pragma comment(lib, "gdiplus.lib") //
/////////////////////////////////////////
... and make sure that the include + lib files from platform SDK are in your visual studio's include pathes (menu: Tools->Options -> tab: directories)
furthermore, somewhere in your app before using gdiplus (e.G. in your MyApp::InitInstance() ) you must call something like:
Code:
Status s;
GdiplusStartupInput gdiplusStartupInput( NULL, FALSE, FALSE );
GdiplusStartupOutput gdiplusStartupOutput;
s = GdiplusStartup( &g_gdiplus_token, &gdiplusStartupInput, &gdiplusStartupOutput );
BOOL g_gdiplus_initialized = ( s==Ok );
Re: Using GDI+ w/Visual C++
Quote:
Originally Posted by Marc G
Welcome to Codeguru :wave:
You'll need to derive your own class from CStatic and implement OnPaint (WM_PAINT handler).
Search
these articles for more detailed information and examples.
What exactly do you want to achieve? Do you want to dislay some
static text at the end of a line or should the user be able to edit that text?
Thanks for the warm welcome guys. Yes, I want to be able just to draw static text at the end of a line I draw (showing line information like length and x,y coordinates). Im guessing as long as you have your endpoint you can offset the textbox relatively close to it. The only thing is that I cant have text overlapping and im unsure how to check for this.
I decided to code in C# rather than C++ (kinda limited on the visual side, but C# is wonderful). Thanks to both of you guys, Im able to draw basic shapes and lines onto my panel control of the windows form. Things are picking up :)
If you have any ideas that pop out about the 'text' problem I have, I would be happy to hear it!