#include "c_WinApp.h" #include "Resource.h" /* ------------------------------------------------------------------------------------------------------------------ */ /* */ #define MAIN_WINDOW_CLASSNAME "Resource.Main" static HANDLE hResource; static HBITMAP hTheBitmap; static int ScrollWidth; static int MaxLines = 21; static int Start = 0; static int TextHeight=0; static int PageSize = 3; static int nPosition = 0; static BOOL bDrawBitmaps = TRUE; /* ------------------------------------------------------------------------------------------------------------------ */ /* */ static void NotYetAvailable(HWND hwnd) { MessageBox(hwnd, "Not Yet Available!", "Under Construction", MB_OK); } /* ------------------------------------------------------------------------------------------------------------------ */ /* */ BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { return TRUE; } case WM_COMMAND: { if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } } return FALSE; } c_WinGUI_EventHandlerDef(WM_CREATE, Main_Create) { TEXTMETRIC TextMetric; hTheBitmap = LoadBitmap(WinApp.hInstance, "Bitmap"); if (!hTheBitmap) { MessageBox(hwnd, "No Bitmap", "Fatal Error", MB_OK); return FALSE; } hResource = LoadResource(WinApp.hInstance, FindResource(WinApp.hInstance, "Brahma", "CUSTOM")); HDC PaintDC = GetDC(hwnd); GetTextMetrics(PaintDC, &TextMetric); ReleaseDC(hwnd, PaintDC); TextHeight = TextMetric.tmHeight + TextMetric.tmExternalLeading; SetScrollRange(hwnd, SB_VERT, 0, -1, FALSE); return TRUE; } c_WinGUI_EventHandlerDef(WM_DESTROY, Main_Destroy) { FreeResource(hResource); DeleteBitmap(hTheBitmap); PostQuitMessage(0); } c_WinGUI_EventHandlerDef(WM_COMMAND, Main_Command) { switch (id) { case CM_ABOUT: { FARPROC AboutBox = MakeProcInstance((FARPROC)AboutDlgProc, WinApp.hInstance); DialogBox(WinApp.hInstance, "About", hwnd, (DLGPROC)AboutBox); FreeProcInstance(AboutBox); break; } case CM_BITMAP: { bDrawBitmaps = TRUE; SetScrollRange(hwnd, SB_VERT, 0, -1, FALSE); InvalidateRect(hwnd, NULL, TRUE); break; } case CM_BRAHMIN: { Start = 32; MaxLines = 22; SetScrollRange(hwnd, SB_VERT, 0, MaxLines-1, FALSE); InvalidateRect(hwnd, NULL, TRUE); bDrawBitmaps = FALSE; break; } case CM_WOODNOTES: { Start = 0; MaxLines = 32; SetScrollRange(hwnd, SB_VERT, 0, MaxLines-1, FALSE); InvalidateRect(hwnd, NULL, TRUE); bDrawBitmaps = FALSE; break; } case CM_SEASHORE: { Start = 64; MaxLines = 37; SetScrollRange(hwnd, SB_VERT, 0, MaxLines-1, FALSE); InvalidateRect(hwnd, NULL, TRUE); bDrawBitmaps = FALSE; break; } } } c_WinGUI_EventHandlerDef(WM_PAINT, Main_Paint) { PAINTSTRUCT PaintStruct; int NumImages = 15; char s[101]; int Y = 0; HDC PaintDC = BeginPaint(hwnd, &PaintStruct); SetBkMode(PaintDC, TRANSPARENT); if (bDrawBitmaps) { HDC BitmapDC = CreateCompatibleDC(PaintDC); HBITMAP oldBitmap = SelectBitmap(BitmapDC, hTheBitmap); for (int i=0; i0) { nPosition -= 1; SrcMove = TextHeight; } break; } case SB_LINEDOWN: { if (nPosition < MaxLines) { nPosition +=1; SrcMove = -TextHeight; } break; } case SB_PAGEUP: { if ((nPosition - PageSize) > 0) { for (i=0; i