Well, it's not hard to create a windows program with C.
Basically, what happens is the following:
1) You create an instance of a window class.
//or create your own class.The term class is always used even
//though the standard window class is a structure.
2) You register the instance of that class.
3) You create a window using the window class that you declared
4) You show the window
5) Now you enter a loop.
// This loop will get messages from the window and send it to
// a function known as a windows procedure. In the function,
// The proper course of action takes place depending on message
// Normal messages would be like, when click a button.
Here's an example :
Code:
#include "resource.h"
// Global Variables:
HINSTANCE hInst;
TCHAR szWindowClass[MAX_LOADSTRING];
// Foward declarations of functions included in this code module:
ATOM MyRegisterClassHINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex; //This is the instance
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style= CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra= 0;
wcex.cbWndExtra= 0;
wcex.hInstance= hInstance;
wcex.hIcon= LoadIcon(hInstance, (LPCTSTR)I_WIND2);
wcex.hCursor= LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName=NULL;
wcex.lpszClassName= szWindowClass;
wcex.hIconSm= NULL;
return RegisterClassEx(&wcex); //Registering it
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in global variable
//Create the window
hWnd = CreateWindow(szWindowClass, szTitle,
WS_OVERLAPPEDWINDOW,
0,0,100,100,
NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
//Show the window
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,
message, wParam, lParam);
}
return 0;
}