Can anyone tell me how I can开发者_JAVA技巧 create a basic usable Windows application in C (I have a little idea about C++ also) ?
Get Petzold's Programming Windows book; it's a classic and covers Win32 development from its core C roots.
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.
#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.
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.
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
.
精彩评论