/*
Hellowin. C displays "Hello, Windows XP! "In client area
*/
# Include <windows. h>
Lresult callback wndproc (hwnd, uint, wparam, lparam );
Int winapi winmain (hinstance, hinstance hprevinstance,
Pstr szcmdline, int icmdshow)
{
Static tchar szappname [] = text ("hellowin ");
/*
Typedef handle hwnd;
Typedef pvoid handle;
Typedef void * pvoid;
*/
Hwnd;
/*
Typedef struct tagmsg {
Hwnd;
Uint message;
Wparam;
Lparam;
DWORD time;
Point pt;
} MSG;
*/
MSG;
/*
Typedef struct _ wndclass {
Uint style;
Wndproc lpfnwndproc;
Int cbclsextra;
Int cbwndextra;
Handle hinstance;
Hicon;
Hcursor;
Hbrush hbrbackground;
Lpctstr lpszmenuname;
Lpctstr lpszclassname;
} Wndclass;
Window struct
*/
Wndclass; // use wndclass (wndclassex) to define a window object
Wndclass. Style = cs_hredraw | cs_vredraw ;//
Wndclass. lpfnwndproc = wndproc;
Wndclass. cbclsextra = 0;
Wndclass. cbwndextra = 0;
Wndclass. hinstance = 0;
Wndclass. hicon = loadicon (null, idi_application );
Wndclass. hcursor = loadcursor (null, idc_arrow );
Wndclass. hbrbackground = (hbrush) getstockobject (white_brush );
Wndclass. lpszmenuname = NULL;
Wndclass. lpszclassname = szappname;
If (! Registerclass (& wndclass) // registration window
{
MessageBox (null, text ("this program requires Windows NT! "), Szappname, mb_iconerror );
Return 0;
}
// Create a window
Hwnd = createwindow (szappname, // window class name
Text ("the hello program"), // window caption
Ws_overlappedwindow, // window style
Cw_usedefault, // initial X position
Cw_usedefault, // initial y position
Cw_usedefault, // initial X size
Cw_usedefault, // initial y size
Null, // parent window handle
Null, // Window menu handle
Hinstance, // program instance handle
Null); // creation Parameters
// Set the detailed display status of the window
Showwindow (hwnd, icmdshow );
// Refresh and display the window
Updatewindow (hwnd );
While (getmessage (& MSG, null, 0, 0 ))
{
Translatemessage (& MSG );
Dispatchmessage (& MSG );
}
Return msg. wparam;
}
/* # Define callback _ stdcall;
Typedef long_ptr lresult;
# If defined (_ win64)
Typedef _ int64 long_ptr;
# Else
Typedef long long_ptr;
# Endif
*/
Lresult callback wndproc (hwnd, uint message, wparam, lparam)
{
HDC;
Paintstruct pS;
Rect;
Switch (Message) // Message Processing Switch
{
Case wm_create:
Playsound (text ("hellowin.wav"), null, snd_filename | snd_async );
Return 0;
Case wm_paint:
HDC = beginpaint (hwnd, & PS );
Getclientrect (hwnd, & rect );
Drawtext (HDC, text ("Hello, Windows XP! "),-1, & rect,
Dt_singleline | dt_center | dt_vcenter );
Endpaint (hwnd, & PS );
Return 0;
Case wm_destroy:
Postquitmessage (0 );
Return 0;
}
Return defwindowproc (hwnd, message, wparam, lparam); // call the default Processing Method
}
Unsolved problem: unable to understand callback, check the msdn display # define callback _ stdcall; I do not understand it !!!