Advertisement

Windows & C++ Problems

Started by September 10, 2000 10:24 AM
4 comments, last by Alphathree 24 years, 4 months ago
Two problems I''m having: #1# I can''t seem to find any decent information on the internet about this so forgive me if I come off like an idiot. I''m used to working with scripts embedded in webpages and such or Java which runs on a VM. Now that I''m learning C++, I''m wondering, how do I interact with the Windows environment? I''m not trying to do anything fancy, but creating a normal window rather than a dos-box when I run my C++ program would be a great start. Then, how do I create those standard windows menus (eg. say I wanted a "File" menu with "New Game" and "Exit" options) How do I create other GUI objects that are built into windows. Eg. scroll bars, check-boxes, etc. This stuff was fairly easy in Java as much of it was built into the java.awt and java.applet classses. You just created an instance and added it: Checkbox box = new Checkbox(); add(box); . . . Any help in this area appreciated. #2# So far my C++ programs have been all-text. Why? Because the tutorials on graphics on confusing the heck out of me. In Java I could say: public void paint(Graphics g){ g.drawLine(...) } In C++, it looks like I have to write 200 lines of code to put a pixel on the screen. If that''s true, I''m willing to learn. But surely there must be a simply way to draw some basic shapes? If someone could show me how to specify screen resolution, color depth and then specify the (x,y) coords for ONE pixel as well as color for that pixel, that''d be great. I don''t mind writing Circle() and Rectangle() algorithms if that''s what C++ programmers usually do for basic 2D graphics. Lets put it this way, I''m trying to get a little box move across the screen, not build the next 1st person shooter. Thanks in advance, -Alphathree
Oh yeah, I had one more thing on my mind.

If I have, for example, a microsoft access database (*.mdb) and I wanted to use SQL from a C++ program to read and modify it, how would I go about doing that? I''m familiar with SQL, I just want to know how to incorporate it into C++.

The only way I''ve interacted with an MSAccess DB is from active server pages via Visual Basic and SQL...

eg.

Set conn = Server.CreateObject("ADODB.Connection")

cmd = "DRIVER={Microsoft Access Driver(*.mdb)};"
cmd = cmd & "DBQ=" & Server.MapPath ("some_database.mdb")

Set record_set = conn.Execute("SELECT * FROM some_table ... ;")

rem ... etc

I want to do this in C++

- Alphathree
Advertisement
Right now you''re making a console application and you need to make a Win32 Application to make windows and stuff like that. I don''t have time to find any sites but just do a search for win32 programming and you could find some stuff, or if you would like to get a book, I highly recommend Charles Petzold''s Programming WIndows 5th edition. Checkboxes are things called child windows and they''re explained in the book mentioned. Learn to make a window first, then learn that.

And as for graphics, like I said, learn to make a window and go from there, graphics are also explained in Programming Windows. I can''t really explain to you how to do it without you having some basic win32 knowledge.

I think there''s a tut on gamedev about makign a simple window or something, not sure though. I hope this helps.
Ok.... you''re in for it now...
my 2 intergalatic credits
my first thought : no offense, but you''ve been coddled. Badly
1) I would suggest that if you have been comfortable with the VB / Java type of windowing, and that you are not interested in learning lots of Win32 code (ex: the 1 line of Java roughly equates to about 20-30 lines of c++), you get BCB. This is because it has lots of built in stuff like scroll bars etc, it''s like VB in design, i.e. properties, forms etc, BUT it has the power of C++. If later you want to do pure Win32 code, it allows you.
2) Code to deal with databases is HARD. very. lots of disgusting code to implement. That''s why most games implement their own database . Again, BCB to the rescue. It has components to interface with data base code, setup everything up for 0 lines of code. Ex: drop down a TDatabase, double click, select all, ok... there we go, all the fields are setup right and everything.
3) Graphics. I would say that you should jump directly to 2d DirectDraw graphics. Here, its BCB to the rescue again, you can get components that implement the deep down interface with DD, and you can begin to use them straight away, saving you lots of time.
* SHAMELESS PROMO*
of course you could use BCBDX lib, IF you wanted to use BCB, it has all the lower level / generic game components: DirectDraw / Direct3D, DirectSound, DirectInput, loading sprites (pictures), loading sounds, managing all you resources, etc.
(www.geocities.com/bcbdirectx)

If you don''t want to splash out on BCB, you''re going to have learn alot of code, just to get a window up, then a lot more, to get DD up, then a bit more the draw your pixels, then alot more to learn how to load pictures... etc.
But it''s all on the web. All you have to do is search. BUT it will take a lot of time: about 100-150 lines for basic window, another 300-400 for DirectDraw, 10 for the pixels, 50-100 for 1 sprite format (BMP).

Hope that doesn''t discourage you too much.
quote: Original post by Alphathree
(snip)
#2#

So far my C++ programs have been all-text. Why? Because the tutorials on graphics on confusing the heck out of me.
(snip)
In C++, it looks like I have to write 200 lines of code to put a pixel on the screen. If that''s true, I''m willing to learn. But surely there must be a simply way to draw some basic shapes? If someone could show me how to specify screen resolution, color depth and then specify the (x,y) coords for ONE pixel as well as color for that pixel, that''d be great. I don''t mind writing Circle() and Rectangle() algorithms if that''s what C++ programmers usually do for basic 2D graphics.

Lets put it this way, I''m trying to get a little box move across the screen, not build the next 1st person shooter.
(snip)


One question, what C/C++ compiler are you currently using?

Dave "Dak Lozar" Loeser

Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
Borland C++

This topic is closed to new replies.

Advertisement