Sign in to follow this  
Dustman

Question about GDI graphics???????

Recommended Posts

The compiler you're using shouldn't matter.

The majority of GDI functions are included from "Wingdi.h", that header itself is included from "Windows.h" which you'll need for basic things such as opening a window.


If you have neither then you need to obtain the Windows Platform SDK which contains all those headers and other stuff (I'm sure Borland C++ ships with a version of the PSDK though - so it might be a setup issue)

Share this post


Link to post
Share on other sites
here's a simple line drawing example. you will start at 0, 0 (uppser left corner) by default and draw a line to 100, 100.


#include <windows.h>

LRESULT CALLBACK LineProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(Msg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
LineTo(hdc, 100, 100);
EndPaint(hWnd, &ps);
break;
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
MSG msg;
WNDCLASS wc = {0};
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpfnWndProc = LineProc;
wc.lpszClassName = "Simple Line";

RegisterClass(&wc);
CreateWindow(wc.lpszClassName, "A simple line", WS_OVERLAPPEDWINDOW|WS_VISIBLE, 0, 0, 640, 480,
NULL, NULL, NULL, NULL);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}



hope that helps.

Share this post


Link to post
Share on other sites
It had an error. " Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\C0X32.OBJ"
what the crap does that mean?

Share this post


Link to post
Share on other sites
It means you're not compling it correctly.

Google for some tutorials on writing win32 applications with borland. They should mention how to set up the project so that you don't get that error.

Share this post


Link to post
Share on other sites
yeah, i think you need to set your target to Win32. they don't need main() to run. if using the commandline compiler, it's a flag you set. i forget which one, (maybe -w ???), look at Borlands site. they have some information about it.

EDIT: dammit. gotta be quicker.

Share this post


Link to post
Share on other sites
Ive already set it up, i did it step by step on some site, and ive already compiled like hundreds of programs, but none of then have graphics!!!!!

Share this post


Link to post
Share on other sites
Firstly, calm down. A single exclamation mark or question mark is enough, you do not need seven.

Secondly, this has become a compiler/buildconfig issue, and does not belong in GP&T. Moving to For Beginners.

Share this post


Link to post
Share on other sites
oh and im using the FREE BORLAND 5.5 COMPILER AND ITS A COMAND LINE COMPILER!!!!!!!!!!!!! and i saw a little thing on it about that there a graphics window and a text window, and there like a command like closegraph or something? because it said that this free compiler can only use gdi graphics. so im looking for somone to tell me BUT SO FAR NO ONE IS!!! ive been looking for tutorials for like a month but i havent found any that my compiler can compile!!!!!!! SOMEONE please help!!!!!!!!!!

Share this post


Link to post
Share on other sites
All-Caps is interpreted as shouting and is considered rude. Use bold or italics for emphasis.

Now, as for your problem: If you don't figure this one out yourself, you might as well give up on programming. Source code is only half the equation; you have to instruct the compiler and linker how to build your application appropriately. In this case, it's a difference between a Win32 Console Application and a full-fledged Windows Application.

Share this post


Link to post
Share on other sites
Hey man that was mean. Saying I should give up. Its called learning, DUH, and I'm sorry about all those caps. I also have one more question, when I compile on my comand line compiler, I use 'bcc32' is that right for Borland 5.5? Thanks.

Share this post


Link to post
Share on other sites
Hey man thanks for telling me to use -tW! it works finnaly my dreams have come true! And to that guy that said i should just give up, I hate you! YAY i can draw a line!

Share this post


Link to post
Share on other sites
ok, Dustman. Oluseyi was pointing out your rudeness and unwillingness to use www.newbsthatcan'tusegoogle.com <--click on this btw. my guess is you need to learn how to do some graphics prior to delving into GDI. for that i recommend this site <--click on this btw. and by all means look up some reference on message boards and proper ways to not appear like a jerk on them. we are only trying to help, and it leaves a bad taste in our mouths when someone acts in this manner.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dustman
And to that guy that said i should just give up, I hate you!

Quote:
Original post by Dustman
And could someone post some explaining thing...


You need to think of your life.

You are rude on us. You are shouting, you hate (some of) us. You are shouthing you want help. You can't search for anything yourself. You're not even trying to search for informations yourself. You know only how to shout "help!".

What if we took our offence and didn't help you anymore?

Oxyd

Share this post


Link to post
Share on other sites
Yea, we give help to people out of our own free will, no one pays us or anything.This place is for sharing and giving, not demanding, but rather requesting.


We dont hate each other,so if you hate one of us, we might not like you for that.

Btw, welcome to the net life, earn respect , you can never buy it or demand it.
-------------------------------------------------------------------------------------------


if you want GDI stuff check out this tutorial

Share this post


Link to post
Share on other sites
And when someone actually does post links and such for you, ignoring the post to ask for people to give you links and such is extremely rude. It may have been a little less than obvious, but I still provided links to both MSDN and WinProg. The latter is a great site for learning about Windows programming, which you have to learn if you want to use GDI...

Quote:
Original Post by Dustman
Hey man that was mean. Saying I should give up. Its called learning, DUH...


Yes, it is called learning. But guess what? Learning is a two way process. If you don't want to put forward any effort, then why should we?

If you can't read the documentation that came with your compiler or at least find something out there to tell you how to use it properly, then get a different compiler. Bloodshed Dev-C++ is an IDE including the MinGW compiler and it will hold your hand quite through setting up a project and so long as you choose the right selection, you shouldn't have a problem compiling things with it.

-Auron

Share this post


Link to post
Share on other sites
I've been searching for graphic tutorials for like 3 months, without finding anything. I put forth much effort. And I already said im sorry for being so loud(caps) and you keep on bugging me about it. Believe me if i could figger it out on my own i would, but i cant so im asking you guys for help, and i was just mad because i could'nt find anything on google. But thank you guys for your help, and im not a noob at c++ im just a noob at graphics. I'm sorry for talking so mean like.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this