PDA

View Full Version : Challenge to write a program



Twisted.alice
05-14-2003, 09:42 AM
I have been challenged to write a program in Borland turbc C++ 3.1.

i have been supplied with the .exe file and thats it

I have all the formulae that is needed for the logical side of the program... one drawback, it has to be all graphical!

i was wondering of anyone out there knows how to draw buttons (so that when u choose the relevent button they seem to depres), radio buttons/check boxes and drop down lists?

i would really appreciate the help on this guys!

if you would like the C++ 3.1 compiler email me and i will give you the link to download it

also if u wana see the .exe file you're welcome to ask me for it!

:) thanks in advance and i really apprecite your help, im not very good at C++, you could say a total beginner!

if anyone knows of any good links for graphical interface writing in C++ as well, please let me know!

Alice

Twisted.alice
05-14-2003, 10:19 AM
oh im sorry Salam, i didn't mention that i have looked lots of places for help

im not askin anyone to write the whole program for me but i am really stumped by this task i have been given.

i'm only askin for one little tiny piece of code, if u want to see the .exe file i can send it to you (althought u may need to download the complier to view it) u will see just how much work there it that i will have to do.

a little example code would be very very helpful so that i have some kind of starting point.

trust me, once i have some code i will be posting it asking for help, but how can i get any code when i don't know even how to draw a simple button in c++?

PJYelton
05-14-2003, 11:44 AM
Begin by telling us what you do know about C++. If you don't know how to program, then a small snippet of code isn't going to do you a lot of good. Likewise, if you have no experience with C++ then an advanced topic such as button creation will be far too difficult. I take it this is a windows program?

Twisted.alice
05-14-2003, 11:49 AM
no its in 3.1 its DOS i think.

ive done basic C++ coding, i'm not very great at it but i know enuf to get by, functions are fairly new to me, but im gettinthe hang of them.

so lets say i am intermediate? put it this way, im in my 1st year at uni doin a HND in Comp sys engineering, so im learning how to use c at the mo... just i've not been able to pick it up as well as some people have

that enuf info?cant think of what else to write!

Twisted.alice
05-14-2003, 12:07 PM
.EXE file (http://cd.bromley.ac.uk/emb/skychase.exe)

this is the .exe file

C++ complier (http://cd.bromley.ac.uk/emb/C++%20Jap.zip)

this is the c++ complier that i use... u might have to download it and install it before u can run the exe but im not sure. its about 3.3mg

if u have to download the complier u need to stick the .exe inthe bin or the bgi file before you run it.

maybe that will give u a better idea of what im looking for as u can see the scrolling box thingy working

cheers!

DougDbug
05-14-2003, 12:32 PM
if u want to see the .exe file i can send it to you (althought u may need to download the complier to view it) u will see just how much work there it that i will have to do.

The compiler won't let you "view" the code. De-compiling is a bit like un-scrambling an egg. You can get a de-compiler, but it won't reproduce the original source. It's almost always easier to start-over, than to try and decypher de-compiled code!

In your case, the exe file is a demonstration/example of what your program is supposed to do.


functions are fairly new to me Yep, you're a beginner... And graphics is an advanced topic.


buttons (so that when u choose the relevent button they seem to depres), radio buttons/check boxes and drop down lists?
This is windows / GUI stuff. It's going to take at least several months of study before you're ready to tackle windows programs. Windows programs are shockingly more complex than console programs! Here are some links to windows tutorials, etc.
WINDOWS (http://www.cprogramming.com/cgi-bin/cdir/Cdirectory.cgi?action=Category&CID=4)

FYI - ANSI/ISO standard (portable) C++ does not include any graphics. Graphical programs have to be written for a particular platform/compiler... although there are cross-platform tools.

Twisted.alice
05-14-2003, 12:39 PM
i dont think u understood what i meant about the .exe file.

the .exe file requires some of the files inthe compiler to run, and yes its an example of what the code needs to replicate. and trust me if i could view the source code i would not be askin for an example code for the drop down box from any of you guys.

lets see.. i have to do this by 2nd june.. i've already said im not a total beginner, but this is harder than what ive been doin

we have done some graphics stuff in C in Uni, drawing a button.. which i did from an example .cpp.. but i dont know quite how it worked.

and yes i know that the 3.1 dont have any graphics stuff, i know it has to all be drawn

take a look at the demo .exe and u will get what i mean, its hard to explain it when no one knows what the thing is meant to be like.

i just would like to know how to make one of the dropdown/scrolling list boxes, that way i can learn from seein the code manually and i can edit it and play about with it to my hearts content.

Twisted.alice
05-14-2003, 01:35 PM
actually i dont need to whole program calv but thanks for ur support! just the one little bit of the drop down box.. if u think u an write the whole thing then be my guest....but i dont expect anyone to write it all for me

if anyone has some USEFUL links, i.e some demo codes that would do the trick that i want then please let me know

also if anyone looks at the .exe file i would be glad if u can let me know what u think about it

i.e if u think it is codeable and tips u could give me about it

a decomplier would be nice, but i duno if it would help

Calv
05-14-2003, 01:46 PM
There is one thing,Alice.

Who challenged to write the whole program?I used Microsoft c++ only, As the borland compiler.... it would be quite a bit different from the Microsoft if i'm not wrong.

how come u r using Borland instead microsoft? Besides,
where u study? what r u majoring? Is it an exam for you or schoolwork? how long have u been in programming fields?

I try to help YOu!!!!!

The guys in the boards........ Try To help Alice as well! OK!!!

Twisted.alice
05-14-2003, 01:58 PM
im doin a HND in Computer System Engineering at Uni in London

Borland is what we use in Uni, i dont make the course up heehee, i personally dont like it too much.

yeah its part of my coursework, but the tutor cant help us as it will bummer up the grades and stuff and hes just no good at teaching it anyway!

if u want the borland complier theres a link on an earlier post so u can download it (3.3mg if i rem) its fairy simple to install and stuff.

i do have visual 6 c++ but its totally different from what we have to use. i did have visual studio.net or sumtin, 90 day evaluation thingy from microsoft, but dont ask where it is, it could be a coaster heehee

and thanks for tryinto help calv! :D

PJYelton
05-14-2003, 02:03 PM
Sorry, the .exe doesn't work, even when placed in the compilers bin file. It says bgi error, graphics not initialized.

Twisted.alice
05-14-2003, 02:05 PM
try stickin it in the bgi folder then, i wasnt too sure which one it needed, sorry

PJYelton
05-14-2003, 02:10 PM
No go. I get an error when trying to unzip the bgi folder from the original zip file. Looks like its corrupted or something. Sorry!

Twisted.alice
05-14-2003, 02:23 PM
why did u try to unzip the bgi file? theres a install file to run in the original zip file, it sets up the program for you. did u use that to set it up or just unzip everything instead?

PJYelton
05-14-2003, 02:35 PM
Tried both. I installed it but no bgi folder was created. So I went back to the zipped file and tried to unzip it myself and was given the error.

Twisted.alice
05-14-2003, 02:56 PM
ok... ive uploaded the decompressed Zip file to my server and also the ziped up file again...

you can find them here....

Compliers (http://cd.bromley.ac.uk/emb/C++/C++/)

note: if downloading the unzipped files, put them all into one file and then run the intall file, not the short cut one tho.

there are 41 files intotall to download in the unzipped file

oh, give it at least 30 mins from the time of this post before downloading them as i am uploading them as i post this! thanks!

confuted
05-14-2003, 03:33 PM
This sounds a bit advanced for you. You could check out the Win32 API, but chances are very poor that you will understand it.

we have done some graphics stuff in C in Uni, drawing a button.. which i did from an example .cpp.. but i dont know quite how it worked.

A good place to start would be figuring out how it worked. You can't master the advanced topics until you understand the basics.

Twisted.alice
05-14-2003, 03:43 PM
will no one give me the benifit of the doubt?!

is there no one out there that is gona just tell me what i want to know without tellin me its too advanced?!

all i would like is some example codes to play about with, and no one will give me any.

do u not think that i have looked up how to do them myself?! this is my last resort, i hate askin for help and its even more annoying when no one seems to wana help you

blackrat
the version of c++ i am using is not windows, it is a DOS complier, borlabd turbo c 3.1, so a would a win32 api help me?

the attached pic is a very basic image of what i would like. inmy final program there will be 4, so to use one you would need to press number 1-2 inc and then maybe arrow keys to select the information you want then the set the varible press a funtion key f1-f4 inc.

please someone help me out

PJYelton
05-14-2003, 03:57 PM
Nobody's withholding information from you. Since very few people program in dos anymore, I doubt that there is a whole lot of people here if any who could tell you how to create a dos button without doing a lot of research themselves. So considering this problem is quite likely compiler specific (a compiler probably nobody uses here) and involves advance dos programming (again something most people don't do here and if they have probably not lately) then I doubt you'll find anyone here who can help. Sorry!

The only advice I can give at the moment is to post your question in the DOS forum or find another place that is DOS specific and be patient and hope somebody who can help sees your question.

Twisted.alice
05-14-2003, 04:00 PM
so where would i find a dos forum then?

not my fault that my uni happens to teach us in dos is it?

the tutor is like, oh u know how to write a button so u should be able to do this easy, but wont show us an example script or anything, ive been looking for help for about 2 weeks now

the Wookie
05-14-2003, 04:02 PM
why don't you try asking him? or maybe he didnt mean a button, but something thats like a button?
im sure hed be more than happy to assist you..most teachers are willing to answer questions

Twisted.alice
05-14-2003, 04:04 PM
ive alreadt said that the tutor wont help hes not good at teaching anyway. he just gives us handouts and expects us to understan them

PJYelton
05-14-2003, 04:08 PM
Theres a dos forum here and you can search google for others.

Do you have a handout about buttons? Somewhere along the line buttons were taught in your class, they wouldn't expect you to know them otherwise. What about fellow classmates?

Twisted.alice
05-14-2003, 04:10 PM
no, we were not 'taught' them.

our tutors hand outs are just that.

he expects us to learn from them. i dont know how when we dont understand it in the first place

u think id be asking for help on here if other ppl in the class knew how to do it? none of us know

do u have a link for any good dos forums at all?

Hammer
05-14-2003, 04:39 PM
Moved to the DOS forum...

WaltP
05-14-2003, 07:36 PM
I just found this thread, I hope you're still around. You can easily draw buttons and things in DOS, use the graphics functions to draw lines, rectangles, cprintf to print to the screen, etc. I wrote a package in DOS that does create buttons (command, radio, etc) int Turob C/C++ ver 1.0 so ver 3 certainly can handle it.

BGI is the Borland Graphics Interface, a file with the extension .BGI that's used for the output to a certain type of display. The file was not downloaded with the EXE file -- ZIP the .BGI file and add a link to it like you did before.

To program buttons and things, look into the graphic commands:

// for getting into/outof graphics mode
registerbgidriver();
initgraph();
restorecrtmode();

// for drawing
setfillstyle();
fillpoly();
fillellipse();
line ();

// for labeling
setcolor();
settextstyle();
settextjustify();
outtextxy();

// for mouse control
HideMouseCursor();
ShowMouseCursor();

Hope this helps
Walt

WaltP
05-14-2003, 07:57 PM
By the way, here's a DOS version of MineSweeper I programmed
http://wpattinson.com/bombsrch.zip

Enjoy

Twisted.alice
05-15-2003, 05:08 AM
The BGI file in in the zip file, trust me its all there.

and, yeah it slightly helped with those commands - ie the comments... but i seen them used in some of the hand outs that are given to us.

that little program is quite good.

do u have the same complier that i use? 3.1? if so please take a look at the exe file and let me know if its possible to make the drop down box.

if someone would be able to just give me some example code it would be helpful.. dont worry if u think im not 'advance' enough to understand, i'll soon let you know if i dont understand it!

Carlos
05-15-2003, 05:40 AM
Sorry Twisted.alice, I didn't mean to offend you, but this is the totally wrong way to start programming, however, the best way to get dissapointed and/or frustrated...

You are newbie for C, and:
- want to reverse-engineer a given executable?
- try to create advanced graphics in DOS?

Hope this is *not* the way programming is taught in the UK :D

WaltP has given you some snippets where you'd start. Need more?

Why don't you try a quick search on google for e.g.
"Source code AND graphics AND DOS"?

I've got some projects with source included, but most of them are written in Assembly (even more advanced). Feel free to take a look at them (http://www.nexus.hu/n_kari/progsEng.htm).

Twisted.alice
05-15-2003, 06:39 AM
i am gettin very very offended actually

no they did not help all that much. and who said i am starting programming? i have been doing it since september... its not my fault that our teacher is a piece of mickey mouse brad pitt is it?!

i dont not see that what i am asking for is such a big deal

obviously no one is able to help me then? someone out there muat know what i want, what do i have to do to get what i need?!

did u miss the fact that ive already searched on google etc for help?!!?!

someone please come up with an answer to my problem.. i would have thought u would be proud to help me as it would give u all the chance to show off your programming skills..... which none of you seem to want to show tho.....

shall i take my question else where then as no one wants to help??

if the boot was on the other foot and i was in the position to help out any of you people on this forum i would be pleased to offer my assistance, obvouisly some people dont feel the same

mike

p.s. already done assembly code... did that in the first simester

PJYelton
05-15-2003, 09:16 AM
:rolleyes: Oh gawd... when will you understand that none of us without lots of research know how to write your button for you? Why in the world should anyone here go out of their way to research and relearn an outdated way of programming that very few people use anymore just so you can copy it and turn it in for homework? ESPECIALLY when all you do is insult us and treat us as though we are a bunch of jerks who take great pleasure in withholding information from newbies who are just asking questions?

We're sorry that you have a crappy teacher, but I'm beginning to think that if you treat him the way you treat us, then I'm sure he's done everything he can to help you and you probably just jumped all over him because he didn't write all your programs for you.

So for the last time, we don't know how to make your button. Lots of information has been given in this thread (especially the functions WaltP gave) that will lead you in the right direction. Play around with them, search the internet about them, whatever. But if you start to understand them then I guarantee you'll be able to write your program.

Carlos
05-15-2003, 09:36 AM
Amen!
:D

Twisted.alice
05-15-2003, 10:18 AM
PJYelton... i get the fact that you cant help me i got that ages ago, and thats not an insult to you ok.

this post got moved to the DOS programming forum so that maybe someone who is into DOS programming will be able to help me out.

and i do not STEAL any codes to use in assignments, thats just not right, its cheating yourself and i dont like cheats.

attached is one of two hand outs that we were given. they are just .cpp files that were printed out for us to copy. maybe then you'll get what i mean about our teacher. buttexmp.cpp is a banner and 3 buttons. decoptsc.cpp is a decimal to hex and oct convertor. (i'll put the other atachment in a diff post)

if someone could make head or tail of them, especially the button bits, coz ive tried believe me

and as for insults, im sorry, i could do worse :p , but you dont get how stressful this has all been. :(

im not askin anyone to to any research at all, i'm just askin if someone happens to know how to do what i'd like to know to do could u let me know.

and for the last time i have been searching on the internet... i've not stopped lookin actually since we was given the task :(

i really feel like breaking down in tears at the moment but i refuse to

Twisted.alice
05-15-2003, 10:19 AM
other attachment

Brighteyes
05-15-2003, 10:32 AM
>and who said i am starting programming? i have been doing it since september...
Less than a year is the same thing as 'just started' in my opinion.

>if someone could make head or tail of them, especially the button bits, coz ive tried believe me
I understood it. It simply draws a button and handles button features manually. Have you tried walking through this code in a debugger to see exactly how it does this?

>but you dont get how stressful this has all been
To be perfectly frank, we don't care how stressful your life is. We volunteer our knowledge and help, so we at least expect courtesy in return. If we aren't treated well, we withhold help and you get nothing but stony silence or flames.

PJYelton
05-15-2003, 10:56 AM
Ummm... that code you gave us is actually a hell of a lot better than what you would likely get from any of us. Its commented and very direct. Why can't you use his code to play around with? Anything anybody else who writes for you would just use the exact same code. You keep asking for people to give you code but you've had the code all the time. Like Brighteyes said, go through it line by line, changing things, seeing what happens, exactly what you've wanted all along except that its your tutors code and not ours.

Twisted.alice
05-15-2003, 10:59 AM
where would i get a debugger then? coz i tried takein out just the bits of code to draw a simple banner box and i cant get the fill bit right

that was a bit harsh bright eyes, surely everyone has stressful days at work or uni or just generally in their life? i'm sure there are times when u personaly feel so run down u cant think straight? :(

the comments are not very helpful to me tho. theres too much code to go throught it bit by bit and change each piece.

i tried to cut out just the button bits, and it jsut doesnt want to play at all.

WaltP
05-15-2003, 11:02 AM
I'm going to be honest with you, Twisted. If you have never been taught how to use the graphics your instructor wants you to use, and he gave no examples that you can type in and execute, he's not much of an instructor. If he DID give you examples, YOU need to type them in to understand what's happening, and change them to see how the parameters change what each function does.

As far as a drop-down box, I've seen them programmed, but I've never made one. I believe it requires defining windows on top of the current window so you can control the scrolling.

Now to draw a button,


1) define the upper left and lower right screen coordinates (x1,y1) & (x2,y2) of the button
2) load the coordinates into a polygram structure as defined by the fillpoly() function
3) Set the color to your button
4) call the fillpoly() function
5) Adding a 3d effect like I did on bombsearch reqires additional lines of different
colors be draw across the edges from
(x1,y1) to (x1,y2) in color 1
(x1,y2) to (x2,y2) in color 1
(x2,y2) to (x2,y1) in color 2
(x2,y1) to (x1,y1) in color 2
with the line() function. Switch the line colors to get the pressed effect.
6) write the caption on the button using
settextstyle()
settextjustify()
setcolor()
outtextxy()



That's the basic idea I used, and I did it after years of programming experience. I didn't do anything this complicated my first year. To be honest, my first year, graphics were barely invented :-)

HTH
Walt

Twisted.alice
05-15-2003, 11:42 AM
that helped quite a bit there WaltP, just not to sure on the
fillpolly(); function, im used to using drawbox();

as ive not used the fillpolly(); could u explain what it does please?

and ive attached the source code of some boxes i drew using ur idea with the diff lines on the bottom and right hand side to make it look more 3D, thought it looked pretty cool! (not got onto the depressing buttons yet, one step at a time!)

one problem at the mo... it seems to fill the whoooole screen grey(light grey i think) after my little splash screen thingy, but i dont know why its doin it!

(i know its called button instead of box,oops! got all excited when it worked gave it the wrong title!)

WaltP
05-15-2003, 11:56 AM
Originally posted by Twisted.alice
that helped quite a bit there WaltP, just not to sure on the
fillpolly(); function, im used to using drawbox();

as ive not used the fillpolly(); could u explain what it does please?
If draws and fills a polygon based on the parameters given as per step 2. You need to look it up and learn how to use it.

Twisted.alice
05-15-2003, 12:00 PM
I think i found a thing about it, kinda understand it, but it was used to draw a strange shape thing, so i think i'd be best to stick to the drawbox coz i think i understand that...

but i'm sure i'll need the poly functions if i wana draw a triangle

but as to why the screen 'background' goes gray after my splash screen function, i have no clue!