Sunday, July 12, 2009

How to create buttons in C language?

i have done an authentication program in turbo C ,wat i need,is a button like interface so that i can provide a user friendly way of accessing it.......





this button must be in such a form that my user will be able to run the C application at the backend.......!





also, suggest some links, so that i can just check out those codes





arun,

How to create buttons in C language?
This is for DOS, right?


I'm not sure what you mean by, 'run the C application at the backend.'


Anyway, you should take a look at the functions that are defined in conio.h. (Look on the Internet if your compiler doesn't have a help file which documents those functions.) You can use those functions to draw your text 'buttons' on the screen and to get user input without having the bothersome cursor on the screen.


If you want mouse input, you'll have to look around the internet for a mouse library written in C. (Usually, the mouse functions provided by a DOS mouse driver are accessed with Assembly language, so that's why you need to find a pre-made mouse library.)
Reply:case WM_CREATE:


CreateWindow("BUTTON", "Exit", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,


butL, butT + 3 * butH, butW, butH, hwnd, (HMENU)FINISH_GRAPH, MyInstance, NULL);


return 0;





case WM_COMMAND:


switch( LOWORD( wparam ) )


{


case FINISH_GRAPH:


CleanUpAndPostQuit();


break;


}


break;
Reply:C is not the ideal language for this . Try VC++ else contact a C graphic expert at websites like http://getafreelnacer.com/
Reply:Back at Rhode Island College Professor McDowell told us that C was not a language you could do much with. If you wanted to do anything with it you needed #include files and libraries. Stdio.h and stdlib.h for example, are useful for much of what we do. And the compiler generally links libc to help them link. When I first started using C if I wanted to use a math.h function (or the double type which is included there) I had to add -lm to the end of my compilation line. Nowadays, just about any compiler will link libm to your program without being told to.





I'm on Linux so I'm somewhat rusty but if you are programming for the console, or the command line then Borland has a neat library called conio. Just include conio.h in your library. Unix/Linux (it was written for Unix but ported to Linux) has something similar called curses or ncurses. For MS-Dos/Windows you can get something similar called pdcurses, or public-domain curses. It's not open source, it's free.





Programming boxes and buttons in Windows can be more complicated. As I remember it, at least check your include files for one called "Windows.h". If you have it then all you have to do is google for Windows Tutorials using Borland. If you don't you probably need another compiler. A free one is available at:


http://www.cs.virginia.edu/~lcc-win32/ which also has a tutorial included. Visual C++ of course is also good for it.





A solution for a front end for a C program can be a scripting language such as Tk/Tcl which is available as source code from here: http://www.tcl.tk/software/tcltk/downloa... . It's sometimes used in building prototypes for programs.





Anyhow, if you have the right libraries read the documentation and it should be straightforward. If you lack the right libraries you'd better do some more research. Standard C doesn't include buttons: you're asking about extensions.

plum

No comments:

Post a Comment