/**************/ /* gdi3dev.c */ /***************************************************************************** PROGRAM: gdi3dev.c Windows: Win 3.1 PURPOSE: Tapahtuman käsittely yksinkertaiselle 3D-piirrolle. Editor: Vesa Lappalainen 11.11.1994 PROJECT: *****************************************************************************/ #include #include "tabhand.h" #include "3d\gdi3dev.h" void G3DrawAxis(HDC hDC, NPG3POINT p1, NPG3POINT p2, LPCSTR szAnnot) { POINT p; G3MoveTo(p1); G3LineTo(p2); G3G3ToViewport(p2, &p, 1); TextOut(hDC, p.x, p.y, szAnnot, lstrlen(szAnnot)); } static WNDPROC lpfnOldG3WndProc; //////////////////////////////////////////////////////////////////////////// // Window procedure for G3 screen window. Note that the previous window // procedure in the chain is called if the message is not handled here. //////////////////////////////////////////////////////////////////////////// static pMy3DDraw My3DDraw; int G3InitMy3DDraw(pMy3DDraw NewMy3DDraw) { My3DDraw = NewMy3DDraw; return 0; } long CALLBACK _export G3WndProc(HWND hWnd, UINT msg, WPARAM wParam,LPARAM lParam) { HDC hDC; PAINTSTRUCT ps; RECT rect; HRGN hRgn; switch (msg) { case WM_PAINT: hDC = BeginPaint(hWnd, &ps); GetClipBox(hDC,&rect); EndPaint(hWnd, &ps); hDC = G3GetDC(hWnd); hRgn = CreateRectRgnIndirect(&rect); SelectClipRgn(hDC, hRgn); if ( My3DDraw ) My3DDraw(hDC); G3ReleaseDC(hWnd, hDC); return 0L; } // switch return CallWindowProc(lpfnOldG3WndProc, hWnd, msg, wParam, lParam); } static EVENT WM_create(tMSGParam *msg) { Init3DWndClass(GetWindowInstance(msg->hWnd)); return CONTINUE_TABLE; } static EVENT WM_size(tMSGParam *msg) { static HWND hGraph = NULL; HINSTANCE hInst = GetWindowInstance(msg->hWnd); RECT rect; FARPROC lpfnG3WndProc; int iSize; if (hGraph == NULL) { GetClientRect(msg->hWnd, &rect); iSize = min(rect.bottom, rect.right); hGraph = CreateWindow("g3wnd", NULL, WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER | WS_CAPTION, 0, 0, iSize, iSize, msg->hWnd, NULL, hInst, NULL); if (hGraph) { lpfnG3WndProc = MakeProcInstance( (FARPROC) G3WndProc, hInst); lpfnOldG3WndProc = (WNDPROC) GetWindowLong(hGraph, GWL_WNDPROC); SetWindowLong(hGraph, GWL_WNDPROC, (LONG) lpfnG3WndProc); return 0; } MessageBeep(-1); SendMessage(msg->hWnd, WM_CLOSE, 0, 0); return 0; } #if 0 GetClientRect(msg->hWnd, &rect); iSize = min(rect.bottom, rect.right); MoveWindow(hGraph,0,0,iSize,iSize,TRUE); #endif return CONTINUE_TABLE; } /****************************************************************************/ /* Viestien käsittelytaulukko */ /****************************************************************************/ tMSGEntry G3MsgTblGDI3D[] = { { WM_CREATE , DoC , DoC , WM_create }, /*a*/ { WM_SIZE , DoC , DoC , WM_size }, /*a*/ { 0 } }; /****************************************************************************/