Can anyone tell me how I can create a basic usable Windows application in C (I have a little idea about C++ also) ?
-
3I feel it's worth stating that if you're talking about developing a windowed application in C, then you're opening a whole world of hurt for yourself. If you're doing this because you know C and are wary of the learning curve involved in getting up to speed on C# or Java, then you're worrying about the wrong thing. You'll develop your app faster in C# including the C#/.Net/OOP learning curve than you will a useful windows app in C. I realise this advice may not apply to you, but feel it's better said than not.Binary Worrier– Binary Worrier2010-07-30 15:36:43 +00:00Commented Jul 30, 2010 at 15:36
-
1P.S. When Rocket Scientists & Brain Surgeons want a metaphor in place of "At least it's not Rocket Science/Brian Surgery" they say "At least it's not developing a Windows App in C".Binary Worrier– Binary Worrier2010-07-30 15:45:03 +00:00Commented Jul 30, 2010 at 15:45
-
see this link : stackoverflow.com/questions/3354692/windows-programing-in-c/…lsalamon– lsalamon2010-07-30 15:47:54 +00:00Commented Jul 30, 2010 at 15:47
-
@Ankit: It would be helpful if you gave more detail around what constitutes "usable" for you. Is the thrust of your question that you're looking to get into Windows programming in general, but ideally with C? Are you already a Windows programmer at a higher level looking to understand lower-level stuff? Etc.Ben Zotto– Ben Zotto2010-07-31 00:17:46 +00:00Commented Jul 31, 2010 at 0:17
-
@Binary Worrier I just want to move ahead from being able to just write pieces of code which are actually useless.I think I'll take your advice about this. I'll go for C#. I am choosing C# over Java as I think I'll find it easier to grasp having a understanding of C. Is that correct?Ankit– Ankit2010-07-31 14:32:00 +00:00Commented Jul 31, 2010 at 14:32
5 Answers
Get Petzold's Programming Windows book; it's a classic and covers Win32 development from its core C roots.
2 Comments
The most minimal windows C program is this :-
#include <windows.h>
#include "resource.h"
int CALLBACK WinMain(HINSTANCE hApp, HINSTANCE, LPSTR pszCmdLine, int nCmdShow)
{
return DialogBoxParam(hApp,MAKEINTRESOURCE(IDD_DIALOG1),NULL,NULL,NULL);
}
It assumes you have used the resource editor to create a dialog resource called IDD_DIALOG1. The dialog will display, and close if the Close button is clicked.
2 Comments
#include <windows.h> int main() { MessageBox(NULL, "Hidey Ho", "Message", MB_OK); return 0; } :-)#include <stdlib.h>
int main()
{
printf("Hello World!");
}
Will compile and run as a windows application. If you want to do something specific, then please let us know. There is nothing that makes Windows applications any different than any other applications.
4 Comments
Perhaps the video at this link will help. If not there's TONS of other resources available on MSDN that will get you started.
Other than that "How to write a Windows Program" is just to broad and large a topic to really address here.
Comments
Raymond Chen's scratch program is a minimally functional white box, and a good base to work through some of the other articles that he publishes.
You can compile this in Visual Studio. In VS2005, I created a new empty C++ project and added comctl32.lib to Configuration->Linker->Input->Additional Dependencies.