What is the difference between GTK and Win32 Native API in C? - c

I'm a beginner in C programming. I read about some tutorials and forums about creating GUI application in C. I encountered some terms like GTK, Win32 native API. They say that GTK is one of the library to use in creating GUI application. I also tried the code that create a simple window using Win32 API. What are the difference between them?
Thanks.

GTK is multi-platform tool kit for creating graphical user interfaces(GUI).
In short they provide a framework which you can use as an library for developing your UI applications.
Win32 API is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. These are restricted only for windows platform.
The language rules for c/c++ are governed by ISO standards which define what functionality every standard c/c++ implementation has to provide.Note that both of above provide some functionality that is over and above what the standard libraries provide.Basically, they provide you boiler plate framework for easy usage instead of reinventing wheels for your project.

Win32 is the "native" API for Microsoft Windows. You can only run it on Microsoft Windows.
GTK+ is also a GUI library. You can run it on multiple different platforms.
Qt and SDL are other multi-platform libraries. Like GTK+, the same GUI can be recompiled to run on multiple different platforms: Windows, Linux, MacOS, etc etc.

Gtk+ = cross-platform and very powerfull. more simple than win32. more tools you will have.
win32 = just in windows. standard windows GUI framework.
and DUDE! Gtk+ in windows is a pain in the ass. but for any othe supported platforms I reccomend Gtk+ for a widget toolkit.

Related

How to develop GTK+ programs on windows?

There isn't a windows binary release, so when it says that they are cross-OS, they mean you can write source to compile on windows, but you have to develop in linux/osx? But then what if you want to make calls to win32api within the app, and want to test as you go along?
They mean you can develop under Windows and you do not have to compile the libraries for yourself.
Binaries for GTK+ and its dependencies can be found here.
Cross OS means that the same API is available across all supported platforms.
Direct calls to the win32 API can be made normally in a GTK+ application.

How to use Winrt API's in c for creating libraries?

I have an existing C libraries which uses Win32 API but it is not supported in windows 8 metro store apps.
I tried calling WinRT API but failed so is there any way ican use WinRT apis in C.
Since the question although very general seems to be specifically about SHGetSpecialFolderPath() on WinRT I'll address this:
As you found out WinRT (Metro) apps run in a sandboxed environment which only supports a limited subset of the win32 api.
SHGetSpecialFolderPath is officially deprecated on MSDN and its functionality is not available to WinRT applications. The closest equivalent would be the ApplicationData class. Unfortunately calling it from C is complicated. I would recommend writing a C++ helper which your library could call into.

how to write a c program that runs on a mobile phone?

i wanna write a C program that runs on a mobile phone. Just for learning purpose. i think it's possible. but i dont know where to start with and the libraries that are available for it.
i have also planned to write a game that runs on a mobile phone.
help me to do it. thanks in advance.
I do not know a mobile platform where its SDK are reccomending using pure C anymore. Last that I knew of was the old Palm platform.
But you can write C/C++ with QT as GUI library for Maemo, MeeGo and possibly other Nokia devices. QT are object oriented, so its not procedural as you want.
I know of 1 platform where pure C is possible. That's the windows mobile version <6.5 using win32 api. But this is not a thing I personally recommend doing since C#.NET makes it easier to develop applications for that platform. I also think that pure C combined with XML/CSS using the WebOS PDK is possible but I might be wrong here.
If you have a wish to write for mobile devices using your knowledge in C then i would rather recommend to use languages like C++ and Objective-C where you also can write C and use C libraries.
A list of mobile devices and the programming languages used to develop applications for them:
Symbian - C/C++
iOS - Objective-C
Android - Java
Windows Mobile - C/C++/.NET
WebOS - C/C++
How about MoSync. It's OS-independent SDK. MoSync applications are written in the C and C++ programming languages.
Programming is almost same. Try downloading one of the SDKs and review the documents for any of the platforms you want.
1) iPhone
2) Android
3) Bada (This is Samsung's latest platform)
SDK comes with cross compilers , simulators and IDE to assist you.
Will add more to this.
Java-to-C compiler may work in J2ME case. You can try Clue: http://cluecc.sourceforge.net/

Is there any crossplatform GUI library for C language? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Cross Platform C library for GUI Apps?
Is there any crossplatform GUI library for C language? (I mean at least win mac lin) If there is any XML-like GUI editing model, any GUI editing crossplatform visual programms it'l be grate!)
Take a look at the IUP Toolkit. It is written largely in C, and is also easily bound to Lua.
I use Gtk a lot it is consistent and nice to use. It was formerly used as a common platform for Gimp but became widely used and is the base toolkit for the Gnome desktop under Linux.
The GUI editor I use is Glade under Linux. The code generated can be recompiled without change under Windows. GLib is an underlying library that abstracts files, network, provides basic types and collections. As long as you use Glib, you are mostly OS independent.
I forgot to mention that glade stores the user interface in XML and generates code out of it. On the glade page I saw there is a windows version there but I cannot tell much about its behaviour. Under Linux it's fairly OK to use and quite stable.
Tk is a GUI library written in C. It comes with a scripting language named Tcl. These can be embedded in your C program. They are very mature and relatively lightweight. You can call the GUI toolkit from C, though it's much easier to do your GUI in Tcl and import it into your C program.
Applications written in Tcl, Tk and C are highly portable, and easy to distribute. The language is BSD style, which is a lot more liberal than GNU licenses.
On the Mac and Windows, Tk uses native widgets whenever possible, making your apps look right for each of those platforms.
GTK is a cross-platform GUI for C (not C++, though there are wrappers for it and many languages).

How to make window application in ANSI C?

Until now I've been only writing console applications but I need to write a simple window application for a school assignment.
Could somebody point me to a good tutorial how to create windows and other ordinary windows elements such as buttons, 2d graphs etc in ANSI C? is there some good library I should use?
I tried googling but there are no tutorial websites devoted to C.
If you can, I would also appreciate some example code.
Thank you.
By the way, I use Dec C++.
GTK is a good library to use, but may provide non-native looks under Windows. It looks great under GNU/Linux, especially using GNOME.
It is implemented in just C (Using the GObject Type System, part of the GLib library), so it will work great for your needs. There is also a RAD tool called Glade.
There's nothing in the ANSI C standard about windows. If you want to make a windowed application, you'll have to use platform-specific libraries (e.g. Win32, Cocoa, or X11), or some sort of cross-platform library that encapsulates that (e.g. SDL, wxWidgets, or many more).
Common places to start are Charles Petzold's Programming Windows and theForger's Win32 API Programming Tutorial.
However in most cases C is no longer the preferred language for Windows development. Object oriented technology is far better suited to GUI development, and with the introduction of MFC, C++ became the preferred language, and later with .Net, C# and C++/CLI.
The Win32 API can be hard work, much of MFC is little better than a Win32 API wrapper, the .Net framework however was designed from the ground up, and is less encumbered by the legacy of the Win32 API monster, and working with it tends to result in far greater productivity.
Either way, Dev-C++ is not a great tool for GUI development.
http://support.microsoft.com/kb/829488 which also talks how to create
Windows application: Creates a simple
Microsoft Windows-based application.
The application files include a
ProjectName.cpp file that contains a
_tWinMain function. You can use this type of application to perform
graphical user interface (GUI) based
programming.
As for tutorials... use MSDN. Win32 API is C. You don't need "Win32 ANSI C tutorial" - you need Win32 tutorial (for example http://www.winprog.org/tutorial/start.html, http://www.functionx.com/win32/Lesson01.htm) - unless, of course, you don't know ANSI C but then you just look for ANSI C tutorial. These subjects are independent.
There are lots of good libraries—too many for there to be an obvious choice without starting a religious war. I recommend that for your first library you learn something that will work on Windows, Linux, or OSX. Here are two good choices, not necessarily the best, but widely used and personal favorites:
Tcl/Tk. You write most of your application in the Tcl scripting language, but you can easily integrate your own ANSI C code into Tcl, which was designed from the beginning with such integration in mind. The Tk toolkit is very easy to learn, and you can write many simple GUIs in pure Tcl when you are getting started. Interactive, easy, and very well supported.
If you want to write everything in ANSI C, I don't know of any really simple choices, but I've been fairly happy with wxwidgets. All these tools have a pretty steep learning curve, however.
There are not many plain C GUI libraries as the strengths of the language lie elsewhere. Perhaps you should think about using a language with C bindings so you can still do the number crunching in C, but use something less painful for GUI development?
If you really want to stick to C, you can either use the OS' native API or the only current cross-platform C GUI lib I'm aware of: GTK+. If you don't really need a GUI but just graphical output, I'd go with SDL.
I suggest you download Microsoft Visual Studio 2008 Express Edition and use C#.Net.
As has been said, I suggest you use Winforms and switch to a .Net environment. It's 2009, and I think there are more suitable solutions to GUI's :P
Edit: Nvm, didn't see it was a school assignment.
However, here is a C++ guide on the Win32 API: http://www.relisoft.com/win32/index.htm

Resources