#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (hinstance hinstance, hinstance hprevinstance, PSTR szcmdline, int icmdshow)
{
Static TCHAR szappname[] = TEXT ("Hellowin");
HWND hwnd;
MSG msg;
Wndclass Wndclass;
Wndclass.style = Cs_hredraw | Cs_vredraw;
Wndclass.lpfnwndproc = WndProc;
Wndclass.cbclsextra = 0;
Wndclass.cbwndextra = 0;
Wndclass.hinstance = hinstance;
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))
{
MessageBox (NULL, TEXT ("This program requires Windows nt!"), Szappname, Mb_iconerror);
return 0;
}
hwnd = CreateWindow (Szappname, TEXT ("The Hello Program"), Ws_overlappedwindow, Cw_usedefault, Cw_usedefault, Cw_ Usedefault, cw_usedefault, NULL, NULL, HINSTANCE, NULL);
ShowWindow (hwnd, icmdshow);
UpdateWindow (HWND);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&MSG);
DispatchMessage (&MSG);
}
System ("pause");
return msg.wparam;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
HDC hdc;
Paintstruct PS;
Rect rect;
Switch (message)
{
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 98"),-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);
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Hellowin Program---HELLOWIN.C