Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Some C questions

Status
Not open for further replies.

aibelectronics

New Member
I've often wondered how:

1) to make menus and dialog boxes using C
2) to make games/ multimedia in c/c++? how does one control pre-drawn images by some line of code?
3) mouse programming in c, without the problem of platform dependency..

I'll appreciate a tip or two, or guidance to some text available on the net.
 
DirectX is great for 3-D figure manipulation, mouse input and video input. Plenty of samples in the SDK. It will take a lot of reading.
 
Reading

If you use Borland C++ Builder (my preferred) or Visual C++ that will allow you to visually place windows and dialog boxes and deal with all the settings in a GUI environment (I think Borland is much MUCh better at this than Visual C++). To do it by text if hard and will take lots and lots of reading :(

You tend to use libraries that other people have made already instead of coding everything from scratch (Microsoft Windows MFC will allow you to do this, very complicated and lots of reading. I have a 3 inch book just listing the function and summarizing what they do, impossible to learn anything from it). That is a daunting task. Again, lots of reading.

That's why I moved away from user interface programming to embedded ;)
 
Last edited:
aibelectronics said:
I've often wondered how:

1) to make menus and dialog boxes using C
What you need is a toolkit to do all the work. Sure accessing the Windows toolkit sounds ok in theory but it is a pain to code for
Personally I would suggest one of the cross-platform toolkits. Since you say C I would have to recomend GTK it is an extreamly easy toolkit to code for and I code with it daily on windows (be it in python but not much different).
GTK comes with a program called GLADE which means you can drop buttons onto a "canvas" and assign "call-back" names. Once happy you can then have GLADE auto-generate your C-code with callback functions already in place - then all you need to do is add your custom code

GTK also has plenty of examples

aibelectronics said:
2) to make games/ multimedia in c/c++? how does one control pre-drawn images by some line of code?
its all via vectors. Say you want picture to rotate you would define the plane and then just get the code to rotate abt an axis.

Sure DirectX sounds good in theory but it is equally "querky" to work with and it will only work for Windows (and then only certain versions depending on what version you use and dont forget licencing fee's if you really start doing something).
OpenGL is a fantastic API for 3D (doesn't do sound you would need SDL) and is very easy to use and it will work on MAC/Linux/Unix/PS3/Nintendo/... as well. SDL is a bit querky but you have to ask yourself it is worth learning - it is getting better



aibelectronics said:
3) mouse programming in c, without the problem of platform dependency..
How most things seem to have settled out is POSIX (Linux,Mac,Unix...) and there are very standard calls for getting access to IO inputs. And then there is the non-POSIX (ie windows). What I have had to do in the past is have a #DEFINE and a IF DEF statement near the begining to load the relevant header file.

Saying that there is alot of work to kinda "bolt" on a POSIX like interface to windows so a code will just compile and run - to some extent
 
As Styx said GTK: GTK is the only real answer I am aware of.

If you are using Windows and like C, Borland C++ is the best answer.

I use PowerBASIC for Windows GUI (tight code, you can draw dialogs and it
drops in the callbacks, APIs are so easy). If anything else at the PC (personal computer) level, GTK.

On the cellphones, there are a lot of items. Java for most, Palm has a number of good compilers..

More info than you asked about, but you mentioned cross platforms. If at the PC level, GTK. When you hit the PDA/phones, it is a little of everything..
 
Windows has a nice little function for message boxes..

int MessageBox(HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box);
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top