/***************************************************************************** * * Copyright (c) 1999, KL GROUP INC. All Rights Reserved. * http://www.klgroup.com * * This file is provided for demonstration and educational uses only. * Permission to use, copy, modify and distribute this file for * any purpose and without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies, and that the name of KL Group not be used in advertising * or publicity pertaining to this material without the specific, * prior written permission of an authorized representative of * KL Group. * * KL GROUP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. KL GROUP SHALL NOT BE LIABLE FOR ANY * DAMAGES SUFFERED BY USERS AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ #define STRICT #include #include #include #include "resource.h" HXRT2D hChart; HWND hwndChart; /* Main window callback */ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_COMMAND: /* handle commands */ switch(LOWORD(wParam)) { case IDM_EXIT: DestroyWindow(hwnd); break; case IDM_ABOUTDEMO: case IDMHELP: WinHelp(hwnd, "OLCH-DMO.HLP", HELP_CONTEXT, 41); break; case IDM_ABOUTOLECTRACHART: WinHelp(hwnd, "OLCH-DMO.HLP", HELP_CONTEXT, 19); break; default: break; } break; case WM_SIZE: SetWindowPos(hwndChart, HWND_TOP, 0, 0, LOWORD(lParam), HIWORD(lParam), SWP_NOMOVE | SWP_NOZORDER); break; case XRTN_PALETTECHANGED: SendMessage(hwndChart, WM_QUERYNEWPALETTE, 0, 0); break; case WM_QUERYNEWPALETTE: case WM_PALETTECHANGED: SendMessage(hwndChart, msg, wParam, lParam); 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 nCmdShow) { WNDCLASS wc; HWND hWnd; MSG msg; XrtDataHandle my_data; time_t tval; static struct tm ltime; HACCEL hAccel; if (!hPrevInstance) { wc.style = 0; wc.lpfnWndProc = (WNDPROC) MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon (hInstance, "olch2dicon"); wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hbrBackground = GetStockObject( WHITE_BRUSH); wc.lpszMenuName = "TimeMenu"; wc.lpszClassName = (LPSTR) "Main"; if (!RegisterClass (&wc)) return FALSE; } hAccel = LoadAccelerators(hInstance, "TimeAccelerators"); // Create main window hWnd = CreateWindow("Main", "Olectra Chart 2D - Simple Time Example", WS_OVERLAPPEDWINDOW, 0,0,520,340, NULL, NULL, hInstance, NULL); // Create chart hChart = XrtCreateWindow ("", 5,5,500,300,hWnd, hInstance); hwndChart = XrtGetWindow(hChart); // Get data my_data = XrtDataCreateFromFile("time.dat", NULL); /* Calculate basetime of Jan 1, 1992 */ ltime.tm_year = 92; ltime.tm_mday = 1; ltime.tm_isdst = -1; /* mktime figures out TZ effect */ tval = mktime(<ime); XrtSetValues(hChart, XRT_DATA, my_data, XRT_TIME_BASE, tval, XRT_TIME_UNIT, XRT_TMUNIT_MONTHS, XRT_XANNOTATION_METHOD, XRT_ANNO_TIME_LABELS, NULL); ShowWindow(hWnd, nCmdShow); while (GetMessage (&msg, NULL, 0, 0)) { if (!TranslateAccelerator(hWnd, hAccel, &msg)) { TranslateMessage (&msg); DispatchMessage (&msg); } } // remember to free allocated memory XrtDestroy(hChart); return (msg.wParam); }