/*[]=====================================================================[]*/ /*[] LeadTools Run Time Library - Version 14 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2004 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ #include "ImgPF.h" static L_BOOL PrspctvDlg_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT uCodeNotify); static L_BOOL PrspctvDlg_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam); static L_VOID PrspctvDlg_OnTimer (HWND hWnd, L_INT nID); static L_VOID PrspctvDlg_OnPaint (HWND hWnd); static L_VOID L_ApplyFilter (HWND hWnd); static L_VOID Preview_OnDown (HWND hWnd, L_BOOL bDoubleClick, L_INT nX, L_INT nY, L_UINT uKeyFlags); static L_VOID Preview_OnMove (HWND hWnd, L_INT nX, L_INT nY, L_UINT uKeyFlags); static L_VOID Preview_OnUp (HWND hWnd, L_INT nX, L_INT nY, L_UINT uKeyFlags); L_HANDLE hDoubleBufferHandle; HDC hMemDC; L_INT nXBound, nYBound; L_INT nPreviewType; L_VOID ApplyPreviewFilter(HWND hWnd) { LPPERSDLGDATA pPerspectiveDlgData = (LPPERSDLGDATA) GetWindowLong(hGlobalWnd,GWL_USERDATA); L_INT nRet; STATUSCALLBACK pStatus; if (!nPreviewType) { L_FreeBitmap(&pPerspectiveDlgData->LeadThumbBitmap); L_CopyBitmap(&pPerspectiveDlgData->LeadThumbBitmap, &pPerspectiveDlgData->LeadThumpCopy, sizeof(BITMAPHANDLE)); pStatus = L_GetStatusCallBack(NULL); L_SetStatusCallBack(NULL, NULL, NULL, NULL); nRet = L_PerspectiveBitmap(&pPerspectiveDlgData->LeadThumbBitmap, pPerspectiveDlgData->ptPreview, GetSysColor(COLOR_3DFACE), PERSPECTIVE_COLOR); L_SetStatusCallBack(pStatus, NULL, NULL, NULL); } InvalidateRect(hWnd, NULL, FALSE); } L_VOID DrawHandler(HDC hMemDC, LPPOINT ptPreview, LPPERSDLGDATA pPerspectiveDlgData, HWND hWnd) { HPEN hPen, hOldPen; L_INT nI; L_INT nX, nY; RECT rcRect; L_UINT uRop2; GetClientRect(hWnd, &rcRect); uRop2 = SetROP2(hMemDC, R2_NOT); hPen = CreatePen(1, 1, RGB(255, 255, 255)); hOldPen = SelectPen(hMemDC, hPen); SelectBrush(hMemDC, GetStockBrush(NULL_BRUSH)); for (nI = 0; nI < 4; nI++) { nX = ptPreview[nI].x + nXBound; nY = ptPreview[nI].y + nYBound; MoveToEx(hMemDC, nX, nY - 6, NULL); LineTo(hMemDC, nX, nY + 7); MoveToEx(hMemDC, nX - 6, nY, NULL); LineTo(hMemDC, nX + 7, nY); MoveToEx(hMemDC, nX - 6, nY - 6, NULL); Ellipse(hMemDC, nX - 6, nY - 6, nX + 7, nY + 7); } if (nPreviewType) { L_INT nArray[4] = {0, 1, 3, 2}; nX = ptPreview[0].x + nXBound; nY = ptPreview[0].y + nYBound; MoveToEx(hMemDC, nX, nY, NULL); for (nI = 1; nI < 4; nI++) { nX = ptPreview[nArray[nI]].x + nXBound; nY = ptPreview[nArray[nI]].y + nYBound; LineTo(hMemDC, nX, nY); } nX = ptPreview[0].x + nXBound; nY = ptPreview[0].y + nYBound; LineTo(hMemDC, nX, nY); } SetROP2(hMemDC, uRop2); SelectBrush(hMemDC, GetStockBrush(WHITE_BRUSH)); SelectPen(hMemDC, hOldPen); DeletePen(hPen); } static L_VOID Preview_OnDown(HWND hWnd, L_BOOL bDoubleClick, L_INT nX, L_INT nY, L_UINT uKeyFlags) { LPPERSDLGDATA pPerspectiveDlgData = (LPPERSDLGDATA) GetWindowLong(hGlobalWnd, GWL_USERDATA); RECT rcRect; L_INT nNearest, nI; if (pPerspectiveDlgData->bIsPressed) return; GetClientRect(hWnd, &rcRect); SetCapture(hWnd); nNearest = 1000; for (nI = 0; nI < 4; nI++) { L_INT nHypot = (L_INT)_hypot(abs(nX - pPerspectiveDlgData->ptPreview[nI].x), abs(nY - pPerspectiveDlgData->ptPreview[nI].y)); if (nHypot < nNearest) { nNearest = nHypot; pPerspectiveDlgData->nActivePoint = nI; } } /* if (nX < (RECTWIDTH(&rcRect) / 2) + (RECTWIDTH(&rcRect) - pPerspectiveDlgData->LeadThumpCopy.Width + 1) / 2) { if (nY < (RECTHEIGHT(&rcRect) / 2) + (RECTHEIGHT(&rcRect) - pPerspectiveDlgData->LeadThumpCopy.Height + 1) / 2) pPerspectiveDlgData->nActivePoint = 0; else pPerspectiveDlgData->nActivePoint = 2; } else { if (nY < (RECTHEIGHT(&rcRect) / 2) + (RECTHEIGHT(&rcRect) - pPerspectiveDlgData->LeadThumpCopy.Height + 1) / 2) pPerspectiveDlgData->nActivePoint = 1; else pPerspectiveDlgData->nActivePoint = 3; } */ pPerspectiveDlgData->bIsPressed = TRUE; Preview_OnMove(hWnd, nX, nY, uKeyFlags); } static L_VOID Preview_OnMove(HWND hWnd, L_INT nX, L_INT nY, L_UINT uKeyFlags) { LPPERSDLGDATA pPerspectiveDlgData = (LPPERSDLGDATA) GetWindowLong(hGlobalWnd,GWL_USERDATA); RECT rcRect; if (!pPerspectiveDlgData->bIsPressed) return; GetClientRect(hWnd, &rcRect); pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x = max(0, min(RECTWIDTH(&rcRect) - (2 * nXBound), nX - nXBound)); pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y = max(0, min(RECTHEIGHT(&rcRect) - (2 * nYBound), nY - nYBound)); switch(pPerspectiveDlgData->nActivePoint) { case 0: pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x = min(pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x, RECTWIDTH(&rcRect) / 2 - nXBound); pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y = min(pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y, RECTHEIGHT(&rcRect) / 2 - nYBound); break; case 1: pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x = max(pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x, RECTWIDTH(&rcRect) / 2 - nXBound); pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y = min(pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y, RECTHEIGHT(&rcRect) / 2 - nYBound); break; case 2: pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x = min(pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x, RECTWIDTH(&rcRect) / 2 - nXBound); pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y = max(pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y, RECTHEIGHT(&rcRect) / 2 - nYBound); break; case 3: pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x = max(pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x, RECTWIDTH(&rcRect) / 2 - nXBound); pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y = max(pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y, RECTHEIGHT(&rcRect) / 2 - nYBound); break; } pPerspectiveDlgData->ptPerspective[pPerspectiveDlgData->nActivePoint].x = (pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x * pPerspectiveDlgData->LeadBitmap.Width) / pPerspectiveDlgData->LeadThumbBitmap.Width; pPerspectiveDlgData->ptPerspective[pPerspectiveDlgData->nActivePoint].y = (pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y * pPerspectiveDlgData->LeadBitmap.Height) / pPerspectiveDlgData->LeadThumbBitmap.Height; SetDlgItemInt(hGlobalWnd, pPerspectiveDlgData->nActivePoint * 2 + pPerspectiveDlgData->nEdtBaseID, pPerspectiveDlgData->ptPerspective[pPerspectiveDlgData->nActivePoint].x, TRUE); SetDlgItemInt(hGlobalWnd, pPerspectiveDlgData->nActivePoint * 2 + pPerspectiveDlgData->nEdtBaseID + 1, pPerspectiveDlgData->ptPerspective[pPerspectiveDlgData->nActivePoint].y, TRUE); ApplyPreviewFilter(hWnd); } static L_VOID Preview_OnUp(HWND hWnd, L_INT nX, L_INT nY, L_UINT uKeyFlags) { LPPERSDLGDATA pPerspectiveDlgData = (LPPERSDLGDATA) GetWindowLong(hGlobalWnd,GWL_USERDATA); if (!pPerspectiveDlgData->bIsPressed) return; pPerspectiveDlgData->bIsPressed = FALSE; ReleaseCapture(); pPerspectiveDlgData->ptPerspective[pPerspectiveDlgData->nActivePoint].x = (pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].x * pPerspectiveDlgData->LeadBitmap.Width) / pPerspectiveDlgData->LeadThumbBitmap.Width; pPerspectiveDlgData->ptPerspective[pPerspectiveDlgData->nActivePoint].y = (pPerspectiveDlgData->ptPreview[pPerspectiveDlgData->nActivePoint].y * pPerspectiveDlgData->LeadBitmap.Height) / pPerspectiveDlgData->LeadThumbBitmap.Height; SetDlgItemInt(hGlobalWnd, pPerspectiveDlgData->nActivePoint * 2 + pPerspectiveDlgData->nEdtBaseID, pPerspectiveDlgData->ptPerspective[pPerspectiveDlgData->nActivePoint].x, TRUE); SetDlgItemInt(hGlobalWnd, pPerspectiveDlgData->nActivePoint * 2 + pPerspectiveDlgData->nEdtBaseID + 1, pPerspectiveDlgData->ptPerspective[pPerspectiveDlgData->nActivePoint].y, TRUE); L_ApplyFilter(hGlobalWnd); } L_BOOL CALLBACK PreviewProc (HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { switch(uMessage) { case WM_PAINT: { RECT rcRect; HDC hDC; PAINTSTRUCT ps; HPALETTE hPalette, hSavedPalette; RECT rcImage; LPPERSDLGDATA pPerspectiveDlgData = (LPPERSDLGDATA) GetWindowLong(hGlobalWnd,GWL_USERDATA); hDC = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rcImage); hMemDC = L_DoubleBufferBegin(hDoubleBufferHandle, hDC, RECTWIDTH(&rcImage), RECTHEIGHT(&rcImage)); FillRect(hMemDC, &rcImage, (HBRUSH) COLOR_WINDOW); if (!nPreviewType) { hPalette = L_CreatePaintPalette(hMemDC, &pPerspectiveDlgData->LeadThumbBitmap); hSavedPalette = SelectPalette(hMemDC, hPalette, TRUE); RealizePalette(hMemDC); FitImageToWindow(rcImage, &pPerspectiveDlgData->LeadThumbBitmap, &rcRect); L_PaintDC(hMemDC, &pPerspectiveDlgData->LeadThumbBitmap, NULL, NULL, &rcRect, NULL, SRCCOPY); hPalette = SelectPalette(hMemDC, hSavedPalette, TRUE); DeletePalette(hPalette); } DrawHandler(hMemDC, pPerspectiveDlgData->ptPreview, pPerspectiveDlgData, hWnd); L_DoubleBufferEnd(hDoubleBufferHandle, hDC); EndPaint(hWnd, &ps); } break; HANDLE_MSG(hWnd, WM_LBUTTONUP, Preview_OnUp); HANDLE_MSG(hWnd, WM_LBUTTONDOWN, Preview_OnDown); HANDLE_MSG(hWnd, WM_MOUSEMOVE, Preview_OnMove); } return DefWindowProc(hWnd, uMessage, wParam, lParam); } L_BOOL CALLBACK PerspectiveDlgProc (HWND hWnd, L_UINT uMessage, WPARAM wParam, LPARAM lParam) { switch(uMessage) { HANDLE_MSG (hWnd, WM_COMMAND, PrspctvDlg_OnCommand); HANDLE_MSG (hWnd, WM_INITDIALOG, PrspctvDlg_OnInitDialog); HANDLE_MSG (hWnd, WM_TIMER, PrspctvDlg_OnTimer); HANDLE_MSG (hWnd, WM_PAINT, PrspctvDlg_OnPaint); case WM_USER_UPDATEVIEW: StatusProc.ProgressValue = 100; L_ApplyFilter(hWnd); break; } return FALSE; } static L_VOID PrspctvDlg_OnTimer (HWND hWnd, L_INT nID) { Dialog_Timer(nID); } static L_BOOL PrspctvDlg_OnInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam) { LPPERSDLGDATA pPersDlgData; HWND hWndParent; pCHILDDATA pData; L_INT nSlider; RECT rcRgn; RECT rcRectSource, rcRectDest; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); pPersDlgData = (LPPERSDLGDATA)lParam; hGlobalWnd = hWnd; SetWindowLong(hWnd,GWL_USERDATA,(LONG)pPersDlgData); GetClientRect(GetDlgItem(hWnd, IDC_PRES_IMG_TXT), &rcRectSource); FitImageToWindow(rcRectSource, &pData->LeadBitmap, &rcRectDest); L_GetBitmapRgnBounds(&pData->LeadBitmap, NULL, &rcRgn); L_CopyBitmapRect(&pPersDlgData->LeadThumbBitmap, &pData->LeadBitmap, sizeof(BITMAPHANDLE), rcRgn.left, rcRgn.top, RECTWIDTH(&rcRgn), RECTHEIGHT(&rcRgn)); L_SizeBitmap(&pPersDlgData->LeadThumbBitmap, (rcRectDest.right - rcRectDest.left) * 1, (rcRectDest.bottom - rcRectDest.top) * 1, SIZE_BICUBIC); L_CopyBitmap(&pPersDlgData->LeadThumpCopy, &pPersDlgData->LeadThumbBitmap, sizeof(BITMAPHANDLE)); nXBound = (RECTWIDTH(&rcRectSource) - pPersDlgData->LeadThumpCopy.Width + 1) / 2; nYBound = (RECTHEIGHT(&rcRectSource) - pPersDlgData->LeadThumpCopy.Height + 1) / 2;; //MEMDISK...// MemorizeAndCopyBitmap (hWndParent, &pPersDlgData->LeadBitmap); StatusProc.bProgress = TRUE; StatusProc.bInvalidate = FALSE; StatusProc.bEnd = FALSE; StatusProc.DlgWnd = hWnd; StatusProc.ProgressValue = 100; StatusProc.ProgWnd = GetDlgItem(hWnd, IDC_PRES_PROG); Progress_SetRange(StatusProc.ProgWnd, 0, 100); Progress_SetPos(StatusProc.ProgWnd, 0); pPersDlgData->nEditNum = 4; pPersDlgData->nEdtBaseID = IDC_PRES_PT1X; pPersDlgData->uFlags = PERSPECTIVE_COLOR; pPersDlgData->ptPerspective[0].x = 0; pPersDlgData->ptPreview[0].x = 0; pPersDlgData->ptPerspective[0].y = 0; pPersDlgData->ptPreview[0].y = 0; pPersDlgData->ptPerspective[1].x = (rcRgn.right - rcRgn.left); pPersDlgData->ptPreview[1].x =pPersDlgData->LeadThumbBitmap.Width; pPersDlgData->ptPerspective[1].y = 0; pPersDlgData->ptPreview[1].y = 0; pPersDlgData->ptPerspective[2].x = 0; pPersDlgData->ptPreview[2].x = 0; pPersDlgData->ptPerspective[2].y = (rcRgn.bottom - rcRgn.top); pPersDlgData->ptPreview[2].y = pPersDlgData->LeadThumbBitmap.Height; pPersDlgData->ptPerspective[3].x = (rcRgn.right - rcRgn.left); pPersDlgData->ptPreview[3].x = pPersDlgData->LeadThumbBitmap.Width; pPersDlgData->ptPerspective[3].y = (rcRgn.bottom - rcRgn.top); pPersDlgData->ptPreview[3].y = pPersDlgData->LeadThumbBitmap.Height; pPersDlgData->crColor = RGB(0, 0, 0); nPreviewType = 0; for (nSlider = 0; nSlider < pPersDlgData->nEditNum; nSlider++) { SetDlgItemInt(hWnd, pPersDlgData->nEdtBaseID + (nSlider << 1), pPersDlgData->ptPerspective[nSlider].x, FALSE); SetNumericEditBox(GetDlgItem(hWnd, pPersDlgData->nEdtBaseID + (nSlider << 1)), 0, rcRgn.right - rcRgn.left, 1, 0, 0); EnableWindow(GetDlgItem(hWnd, pPersDlgData->nEdtBaseID + (nSlider << 1)), FALSE); SetDlgItemInt(hWnd, pPersDlgData->nEdtBaseID + (nSlider << 1) + 1, pPersDlgData->ptPerspective[nSlider].y, FALSE); SetNumericEditBox(GetDlgItem(hWnd, pPersDlgData->nEdtBaseID + (nSlider << 1) + 1), 0, rcRgn.bottom - rcRgn.top, 1, 0, 0); EnableWindow(GetDlgItem(hWnd, pPersDlgData->nEdtBaseID + (nSlider << 1) + 1),FALSE); } ComboBox_AddString(GetDlgItem(hWnd, IDC_PRES_BKG_COM), TEXT("Color")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PRES_BKG_COM), TEXT("Same Image")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_PRES_BKG_COM), 0); ComboBox_AddString(GetDlgItem(hWnd, IDC_PRES_PRV_COM), TEXT("Image")); ComboBox_AddString(GetDlgItem(hWnd, IDC_PRES_PRV_COM), TEXT("Outline")); ComboBox_SetCurSel(GetDlgItem(hWnd, IDC_PRES_PRV_COM), 0); pPersDlgData->WndProc = (WNDPROC)GetWindowLong(GetDlgItem(hWnd, IDC_PRES_IMG_TXT), GWL_WNDPROC); L_DoubleBufferCreateHandle(&hDoubleBufferHandle); L_DoubleBufferEnable(hDoubleBufferHandle, TRUE); SetWindowLong(GetDlgItem(hWnd, IDC_PRES_IMG_TXT), GWL_WNDPROC, (LONG)PreviewProc); pData->uTimerID = SetTimer(hWnd, 1, 100, NULL); ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); InvalidateRect(hWnd, NULL, FALSE); L_ApplyFilter(hWnd); return TRUE; } static L_VOID PrspctvDlg_OnPaint (HWND hWnd) { HDC hDC; PAINTSTRUCT ps; RECT rcImage; HBRUSH hBrush; LPPERSDLGDATA pPerspectiveDlgData = (LPPERSDLGDATA) GetWindowLong(hWnd,GWL_USERDATA); hBrush = CreateSolidBrush(pPerspectiveDlgData->crColor); GetClientRect(GetDlgItem(hWnd, IDC_PRES_CLR_TXT), &rcImage); hDC = BeginPaint(GetDlgItem(hWnd, IDC_PRES_CLR_TXT), &ps); FillRect(hDC, &rcImage, (pPerspectiveDlgData->uFlags == PERSPECTIVE_IMAGE) ? (HBRUSH) COLOR_WINDOW : hBrush); EndPaint(GetDlgItem(hWnd, IDC_PRES_CLR_TXT), &ps); DeleteBrush(hBrush); } static L_BOOL PrspctvDlg_OnCommand (HWND hWnd, L_INT nID, HWND hWndCtl, L_UINT uCodeNotify) { LPPERSDLGDATA pPersDlgData; HWND hWndParent; pCHILDDATA pData; L_INT nValue, nIndex; hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); pPersDlgData = (LPPERSDLGDATA) GetWindowLong(hWnd, GWL_USERDATA); if (nID >= pPersDlgData->nEdtBaseID && nID < pPersDlgData->nEdtBaseID + (pPersDlgData->nEditNum * 2)) { if(uCodeNotify == EN_CHANGE) { nValue = GetDlgItemInt(hWnd, nID, NULL, TRUE); nIndex = nID - pPersDlgData->nEdtBaseID; switch (nIndex) { case 0: case 2: case 4: case 6: if(pPersDlgData->ptPerspective[nIndex >> 1].x == nValue) return TRUE; pPersDlgData->ptPerspective[nIndex >> 1].x = nValue; pPersDlgData->ptPreview[nIndex >> 1].x = nValue * pPersDlgData->LeadThumbBitmap.Width / pPersDlgData->LeadBitmap.Width; ApplyPreviewFilter(GetDlgItem(hWnd, IDC_PRES_IMG_TXT)); break; case 1: case 3: case 5: case 7: if(pPersDlgData->ptPerspective[nIndex >> 1].y == nValue) return TRUE; pPersDlgData->ptPerspective[nIndex >> 1].y = nValue; pPersDlgData->ptPreview[nIndex >> 1].y = nValue * pPersDlgData->LeadThumbBitmap.Height / pPersDlgData->LeadBitmap.Height; ApplyPreviewFilter(GetDlgItem(hWnd, IDC_PRES_IMG_TXT)); break; } L_ApplyFilter(hWnd); } } switch (nID) { case IDC_PRES_PRV_COM: if (uCodeNotify == CBN_SELCHANGE) { L_INT nSlider; if (nPreviewType == ComboBox_GetCurSel(hWndCtl)) return FALSE; nPreviewType = ComboBox_GetCurSel(hWndCtl); InvalidateRect(hWndCtl, NULL, FALSE); ApplyPreviewFilter(GetDlgItem(hWnd, IDC_PRES_IMG_TXT)); for (nSlider = 0; nSlider < pPersDlgData->nEditNum; nSlider++) { EnableWindow(GetDlgItem(hWnd, pPersDlgData->nEdtBaseID + (nSlider << 1)), nPreviewType); EnableWindow(GetDlgItem(hWnd, pPersDlgData->nEdtBaseID + (nSlider << 1) + 1),nPreviewType); } InvalidateRect(GetDlgItem(hWnd, IDC_PRES_IMG_TXT), NULL, FALSE); } break; case IDC_PRES_BKG_COM: if (uCodeNotify == CBN_SELCHANGE) { if (nIndex == ComboBox_GetCurSel(hWndCtl)) return FALSE; nIndex = ComboBox_GetCurSel(hWndCtl); EnableWindow(GetDlgItem(hWnd, IDC_PRES_CLR_BTN), nIndex ? FALSE : TRUE); EnableWindow(GetDlgItem(hWnd, IDC_PRES_CLR_TXT), nIndex ? FALSE : TRUE); pPersDlgData->uFlags = nIndex ? PERSPECTIVE_IMAGE : PERSPECTIVE_COLOR; InvalidateRect(hWnd, NULL, FALSE); L_ApplyFilter(hWnd); } break; case IDC_PRES_CLR_BTN: { COLORREF crColor = pPersDlgData->crColor; pPersDlgData->crColor = ShowColorDialog(hWnd, crColor); if (pPersDlgData->crColor != crColor) { InvalidateRect(hWnd, NULL, FALSE); L_ApplyFilter (hWnd); } } break; case IDCANCEL: L_FreeBitmap(&pPersDlgData->LeadThumbBitmap); L_FreeBitmap(&pPersDlgData->LeadThumpCopy); L_DoubleBufferDestroyHandle(hDoubleBufferHandle); StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE ; StatusProc.ProgressValue = 100; SetWindowLong(GetDlgItem(hWnd, IDC_PRES_IMG_TXT), GWL_WNDPROC, (LONG)pPersDlgData->WndProc); EndDialog(hWnd, FALSE); break; case IDOK: L_FreeBitmap(&pPersDlgData->LeadThumbBitmap); L_FreeBitmap(&pPersDlgData->LeadThumpCopy); L_DoubleBufferDestroyHandle(hDoubleBufferHandle); ShowStatusWindow(FALSE); StatusProc.bStillWork = TRUE; StatusProc.bInvalidate = TRUE; StatusProc.bEnd = TRUE; SetWindowLong(GetDlgItem(hWnd, IDC_PRES_IMG_TXT), GWL_WNDPROC, (LONG)pPersDlgData->WndProc); EndDialog(hWnd, TRUE); break; } return TRUE; } L_VOID L_ApplyFilter(HWND hWnd) { pCHILDDATA pData; L_INT nRet = 0; HWND hWndParent; LPPERSDLGDATA pPersDlgData; if ( 100 != StatusProc.ProgressValue ) { StatusProc.bKillProgress = TRUE ; return ; } pPersDlgData = (LPPERSDLGDATA) GetWindowLong(hWnd,GWL_USERDATA); hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage); pData = LOCKCHILDDATA (hWndParent); FreeMemorizedBitmap (hWndParent); //MEMDISK// L_CopyBitmap(&pData->LeadBitmap, &pPersDlgData->LeadBitmap, sizeof(BITMAPHANDLE)); nRet = L_PerspectiveBitmap(&pData->LeadBitmap, pPersDlgData->ptPerspective, pPersDlgData->crColor, pPersDlgData->uFlags); if(nRet == SUCCESS) { InvalidateRect(hWndParent, NULL, FALSE); StatusProc.ProgressValue = 100; Progress_SetPos(StatusProc.ProgWnd , 0); if(StatusProc.bEnd) { StatusProc.bProgress = FALSE; StatusProc.bKillProgress = TRUE ; } } }