Code:
#include <windows.h>
#include <string.h>
//#include <direct.h>
#define MAXPATH 256
#define MAXREAD 8192
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
//LRESULT CALLBACK ListProc (HWND, UINT, WPARAM, LPARAM) ;
WNDPROC fnOldList ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static char szAppName[] = "Head" ;
HWND hwnd ;
MSG msg ;
WNDCLASSEX wndclass ;
HDC hdc ;
// int i ;
TEXTMETRIC tm ;
wndclass.cbSize = sizeof (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) (COLOR_BTNFACE + 1) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION) ;
RegisterClassEx (&wndclass) ;
hdc = GetDC (NULL) ;
GetTextMetrics (hdc, &tm) ;
ReleaseDC (NULL, hdc) ;
hwnd = CreateWindow (szAppName, "listbox",
WS_CAPTION | WS_CLIPCHILDREN | WS_SYSMENU | WS_VISIBLE | LBS_STANDARD,
tm.tmAveCharWidth, tm.tmHeight * 3,
tm.tmAveCharWidth * 90 + GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 25,
NULL, NULL, hInstance, NULL) ;
/* hwnd = CreateWindow (szAppName, "File Head",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
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) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
switch (iMsg)
{
case WM_CREATE :
/* hdc = GetDC (hwnd) ;
// SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)) ;
GetTextMetrics (hdc, &tm) ;
ReleaseDC (hwnd, hdc) ;
SendMessage (hwnd, LB_ADDSTRING, 0, (LPARAM) "a msg") ;
/*
hwndList = CreateWindow ("listbox", NULL,
WS_CHILDWINDOW | WS_VISIBLE | LBS_STANDARD,
tm.tmAveCharWidth, tm.tmHeight * 3,
tm.tmAveCharWidth * 13 +
GetSystemMetrics (SM_CXVSCROLL),
tm.tmHeight * 10,
hwnd, (HMENU) 1,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE),
NULL) ;
*/
return 0 ;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}