[C] GUIs

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
User avatar
Wesley
Regular Member
Posts: 137
Joined: Sun 12 Oct, 2008 1:42 am
Location: Boise, Idaho
Contact:

[C] GUIs

Post by Wesley »

I'm going to be learning C (finally) next semester, so I started looking in an old book I had on my shelf about C. I couldn't find anything in it about GUI programming, and I can't seem to find any GUI examples on the web either.

Is it practical to create GUI programs in C?
ImageImage
ImageImage
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [C] GUIs

Post by benryves »

Wesley wrote:I'm going to be learning C (finally) next semester, so I started looking in an old book I had on my shelf about C. I couldn't find anything in it about GUI programming, and I can't seem to find any GUI examples on the web either.
If you're on Windows, MSDN has extensive documentation on Win32 GUI development.
Is it practical to create GUI programs in C?
Is it practical to do anything much in C these days? ;) Raw Win32 GUI programming is pretty horrible; it's several orders of magnitude easier to just use WinForms with C#.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Re: [C] GUIs

Post by tr1p1ea »

GUI's are overrated anyway! :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
Spencer
Extreme Poster
Posts: 346
Joined: Mon 17 Jan, 2005 8:56 am
Location: Indiana

Re: [C] GUIs

Post by Spencer »

If you want nice native controls and obsessively need UIs to behave exactly how you want them to, C is the way to go!

Here are some keywords to get you started:
CreateWindow
GetMessage
DispatchMessage
DefWindowProc
WM_PAINT
BeginPaint
SelectObject
GetStockObject
FillRect
DrawText
EndPaint

The first result in any search engine is always MSDN. The documentation is excellent. I recommend using the Visual Studio 2010 beta. It gives you real time feedback on your C code with error and warning badges in the gutter. The Windows SDK comes with hundreds of samples.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [C] GUIs

Post by benryves »

Spencer wrote:If you want nice native controls and obsessively need UIs to behave exactly how you want them to, C is the way to go!
Or WinForms+C#. ;) You get direct access to the control handle and can override WndProc if required, and P/Invoke can be used to call Win32 functions if you're feeling obsessive. (WinForms is a pretty thin wrapper around the Win32 API). The advantage is that if you just need to bung a few buttons on a form and call it a day you can, but you still have the option of dropping down a level if need be.
Spencer
Extreme Poster
Posts: 346
Joined: Mon 17 Jan, 2005 8:56 am
Location: Indiana

Re: [C] GUIs

Post by Spencer »

I admit WinForms and WPF are pretty nice, I use them for small projects. One problem I've noticed with WinForms is the controls don't smoothly fade to the hot color on mouse-over on Vista and 7. I have a feeling, for buttons at least, they simply use DrawThemeBackground to approximate the control. This is similar to how scrollbars in IE are different than normal scrollbars, since IE uses "window-less" controls.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Re: [C] GUIs

Post by King Harold »

I wouldn't call much about WPF nice - except perhaps some of the resulting graphics. On the other hand, WPF apps usually end up looking like a flash ad, and even when they don't the text rendering is broken by default (has been fixed very recently) and ignores your ClearType setting just for laughs (I am not laughing! ClearType is so horrible on CRT's that it causes your eyes to bleed!)
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [C] GUIs

Post by benryves »

King Harold wrote:I wouldn't call much about WPF nice - except perhaps some of the resulting graphics. On the other hand, WPF apps usually end up looking like a flash ad, and even when they don't the text rendering is broken by default (has been fixed very recently) and ignores your ClearType setting just for laughs (I am not laughing! ClearType is so horrible on CRT's that it causes your eyes to bleed!)
WPF is a nicely designed API and (when you can get your head around its "magic") very pleasant to develop in. However, I do agree with all of your gripes - the text rendering is atrocious, and the look and feel is "off" from native apps (this is due to it not using native rendering at all - everything is driven by theme files, so if you don't use Luna or Aero you end up with a Windows Classic look).

I've stuck with keeping WPF for the web (Silverlight) myself.
Post Reply