My hobby is embedded programming therefore I’m learning C , I was just wondering if C has library functions like windows forms,buttons etc(like in C#)?

Dani AI

Generated

: there is no ISO C equivalent of ".NET Windows Forms." Windows Forms is a .NET UI framework typically used from C# (and from C++/CLI, which is managed C++). That said, you can absolutely build native Windows GUIs in C. The usual routes are:

  • Win32 API + common controls: write a message loop (GetMessage/TranslateMessage/DispatchMessage), a window procedure (WndProc), and create controls like buttons with CreateWindowEx using the class name "BUTTON". This is verbose but gives full control and zero runtime dependencies.
  • Resource-based dialogs: define a dialog template in a .rc file and run it with DialogBoxParam/CreateDialogParam. This feels closer to "forms" because the layout is designed in a resource and you handle clicks in WM_COMMAND.

For your use case (firmware in C, occasional PC-side tool), you have three pragmatic options:

  • Stay in C: Win32 (above) on Windows; or a C toolkit like GTK for cross-platform. Expect more boilerplate, but you keep a single language.
  • Use a lightweight C immediate-mode GUI (e.g., a single-header C library) for quick internal tools; good for simple panels and graphs without designer tooling.
  • Accept a second language for the host UI: C# + WinForms/WPF will be far faster to build, and you can talk to the device over a virtual COM port (CDC) or HID while keeping all embedded code in C. Many teams do exactly this split.

Notes:

  • @Ancient Dragon is right that the Windows API is callable from C; @Surya’s 16-bit DOS examples (e.g., int86, <dos.h>) are legacy and not relevant on modern 32/64-bit Windows targets. Avoid those and stick to contemporary APIs and toolchains.

Recommended Answers

All 12 Replies

No. Windows Forms require c++, not C. If your embedded device is running some version of MS-Windows then you might be able to use pure win32 api functions. But if its running *nix then I don't know.

Hi there,

It's good to learn C. Basically C program can interact with hardware and you can do even more with it if you are pro in it. But C is a 16-bit DOS oriented programming language, it uses 16 bit address scheduling. It's neither possible to design a window form or button nor such library exists. Windows programming requires win32 api functions as Ancient Dragon narrated above. To design a window form or button you have to use VC++ or any 32-bit compiler that will make a 32-bit specific executable. However you may design them for your own interest using graphics environment on command line platform [16-bit/ console application] using graphics.h file and can create your own form using rectangle and ellipse fillstyle, outtextxy and many more features of graphics library. And you may add a mouse call in C using 33h interrupt in C remember to include DOS.H cause in86() is defined in dos.h file here is the code to show mouse in C:

initmouse()
{
// this function will initialize mouse
// you have to call this function before calling showmouseptr
// cause it need to know that rather environment is console or graphics. 
i.x.ax=0; // push 0 into ax register
int86(0x33,&i,&o); // call 8086 interrupt routine
return(o.x.ax); // return the output in output not needed in actual
}
void showmouseptr()
{
// this function will show mouse pointer
i.x.ax=1; // push 1 into ax register
int86(0x33,&i,&o);// call 8086 interrupt routine
}

Regards
Surya

Thank you both!

>>But C is a 16-bit DOS oriented programming language, it uses 16 bit address scheduling

You are totally wrong dude. The entire Windows api was written in C language. You are obviously only familar with Turbo C which does have the limitations you mentioned. But if you come into the 21st century and get a compiler that isn't 25 years old, and has been obsolete 10+ years ago, you would have found out that the statements you made about C language is totally wrong.

VC++ 2005/2008 and 2010 are all 32 bit compilers that will gladly compile either C programs or C++ programs. Programmers have been writing pure MS-Windows programs using win32 api functions in C language for decades.

@ Ancient Dragon

Yes you are right now a days we can compile our C code on any 32 bit C compatible compilers like VC++. And I was talking about it's history so the comment I made:

>>But C is a 16-bit DOS oriented programming language, it uses 16 bit address scheduling.

is wrong, I agree. But it is what I wanted to explain :

>>But C was initially developed as 16-bit console oriented programming language, it used to map 16 bit address scheduling.

This type you are wrong dude I didn't mentioned that it was working for DOS, I had said for console. Please look at the latest post.

I think I phrased the question poorly! Mainly I want to learn C to program “Microchips” but occasionally I’ll want to create a window application to interface with an embedded project(something like the logic tool interface on the PICkit2).
I don’t want to learn two different languages if possible( Finding C hard enough). So would I be able to create something resembling a windows form, with something resembling a button with C? How difficult would it be in C? Or would it easier to learn C++ and how big a jump is it from C to C++?

You said it was 16-bit console. Unix has never been a 16-bit operating systm.

: doing graphics on a microchip may not be possible due to lack of memory. Drawing a button in C language will be no different than doing the same thing in c++. Windows Forms is CLR/C++ language and requires the operating system to have the .NET framework installed. There is nothing inherent in standard c++ that will let you do any graphics, that will require other libraries whether you use C or C++.

You said it was 16-bit console. Unix has never been a 16-bit operating systm.

...

My rememberence was that *nix started on the DEC PDP-11 which was a 16-bit computer. After checking with wikipedia, the current version of the article indicates that the team started on the DEC PDP-7. PDP-7 wikipedia article indicates that the PDP-7 was a 18-bit computer. Then the team moved *nix to the PDP-11. The wikipedia PDP-11 article confirms that it was a 16-bit computer. My conclusion is that the statement "Unix has never been a 16-bit operating system." is not correct.

>>My conclusion is that the statement "Unix has never been a 16-bit operating system." is not correct.
And you may well be correct.

It's ok. I had left thinking of it with my last visit to this post.

@Phieninger, Nice case study dude..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.