1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#include <windows.h>
#include <fstream>
using namespace std;
char *mem = (char *) malloc ((80*2)*25);
LPLOGFONT to_save;
BOOL CALLBACK SaveFont (LPLOGFONT lplf, LPNEWTEXTMETRIC lpntm, DWORD FontType, LPVOID aFontCount)
{
to_save = lplf;
return false;
}
LRESULT CALLBACK WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
int cur_line = 0, cur_pos = 0;
char *out = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab";
switch (msg)
{
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);
EnumFontFamilies (hdc, "Fixedsys", (FONTENUMPROC) SaveFont, 0);
to_save->lfHeight = 12;
to_save->lfWidth = 8;
SelectObject (hdc, (HGDIOBJ) CreateFontIndirect (to_save));
SetBkColor (hdc, RGB(0,0,0));
SetTextColor (hdc, RGB(200,200,200));
TextOut (hdc, 0, 0, out, 80);
EndPaint (hwnd, &ps);
UpdateWindow (hwnd);
break;
case WM_CLOSE:
DestroyWindow (hwnd);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
HWND window;
MSG Msg;
WNDCLASSEX wc;
MessageBox (NULL, mem, "Memory Contents:", MB_OK);
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = CreateSolidBrush (RGB (0,0,0));
wc.lpszMenuName = NULL;
wc.lpszClassName = "WindowClass";
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx (&wc))
return -1;
window = CreateWindow ("WindowClass",
"Hello all",
WS_OVERLAPPEDWINDOW,
10,
10,
80*8,
25*12,
NULL,
NULL,
hInstance,
NULL);
if (!window)
return -1;
ShowWindow (window, SW_SHOW);
UpdateWindow (window);
while (GetMessage (&Msg, NULL, 0, 0) > 0)
{
TranslateMessage (&Msg);
DispatchMessage (&Msg);
}
return 0;
}
|