⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colorpickupdlg.cpp

📁 是一个较好的缩放工具
💻 CPP
📖 第 1 页 / 共 2 页
字号:
*       
* Effect: 
*       Does nothing. Keeps the <esc> key from exiting the application
****************************************************************************/

void CColorPickupDlg::OnCancel() 
{
}

/****************************************************************************
*                          CColorPickupDlg::OnClose
* Result: void
*       
* Effect: 
*       Calls the OnOK handler to actually close the application
****************************************************************************/

void CColorPickupDlg::OnClose() 
{
        CDialog::OnOK();
}

/****************************************************************************
*                           CColorPickupDlg::OnSize
* Inputs:
*       UINT nType: Type of resize
*       int cx: New width
*       int cy: New height
* Result: void
*       
* Effect: 
*       Resizes the image box (but only if it exists)
****************************************************************************/

void CColorPickupDlg::OnSize(UINT nType, int cx, int cy) 
   {
    CDialog::OnSize(nType, cx, cy);

    if(c_Image.GetSafeHwnd() != NULL)
       { /* resize it */
        ResizeImage();
       } /* resize it */
}

/****************************************************************************
*                        CColorPickupDlg::ResizeImage
* Result: void
*       
* Effect: 
*       Resizes the window. The image is resized. Note that to preserve
*       the aspect ratio, the size is changed isotropically, relying on the
*       implicit clipping of a child window
****************************************************************************/

void CColorPickupDlg::ResizeImage()
    {
     CRect client;
     GetClientRect(&client);
     CRect r;
     c_Image.GetWindowRect(&r);
     ScreenToClient(&r);
     int n = max(client.Width(), client.Height() - r.top);
     c_Image.SetWindowPos(NULL,
                          0, 0,  // not used
                          n,
                          n,
                          SWP_NOMOVE | SWP_NOZORDER);
     c_Image.RecomputeImage();
    } // CColorPickupDlg::ResizeImage

/****************************************************************************
*                          CColorPickupDlg::OnPoint
* Inputs:
*       WPARAM: (WPARAM)MAKELONG(x,y): screen coordinates
*       LPARAM: (LPARAM)(COLORREF)
* Result: LRESULT
*       Logically void, 0, always
* Effect: 
*       Puts the color info in the display.
****************************************************************************/

LRESULT CColorPickupDlg::OnPoint(WPARAM wParam, LPARAM lParam)
    {
     CPoint pt;
     pt.x = (int)(short)LOWORD(wParam);
     pt.y = (int)(short)HIWORD(wParam);
     COLORREF color = (COLORREF)lParam;
     CString s;
     s.Format(_T("RGB(%d, %d, %d)"), GetRValue(color), GetGValue(color), GetBValue(color));
     c_RGB.SetWindowText(s);
     c_R.SetColor(RGB(GetRValue(color), 0, 0));
     c_G.SetColor(RGB(0, GetGValue(color), 0));
     c_B.SetColor(RGB(0, 0, GetBValue(color)));
     return 0;
    } // CColorPickupDlg::OnPoint

/****************************************************************************
*                        CColorPickupDlg::OnChangeSize
* Result: void
*       
* Effect: 
*       Handles the initial, or subsequent, changes in the size of the
*       capture box.
****************************************************************************/

void CColorPickupDlg::OnChangeSize() 
   {
    if(!initialized)
        return;
    int n = LOWORD(c_SpinSize.GetPos());
    c_Image.SetSize(n);
   }

/****************************************************************************
*                                   Nudgers
* Result: void
*       
* Effect: 
*       Calls the AdjustPos method to change the position where the
*       bitmap is being retrieved.
****************************************************************************/

void CColorPickupDlg::OnDown() 
   {
    c_Image.AdjustPos(0, 1);
   }

void CColorPickupDlg::OnLeft() 
   {
    c_Image.AdjustPos(-1, 0);
   }

void CColorPickupDlg::OnRight() 
   {
    c_Image.AdjustPos(1, 0);
   }

void CColorPickupDlg::OnUp() 
   {
    c_Image.AdjustPos(0, -1);
   }

void CColorPickupDlg::OnDownleft() 
   {
    c_Image.AdjustPos(-1, 1);
   }

void CColorPickupDlg::OnDownright() 
   {
    c_Image.AdjustPos(1, 1);
   }

void CColorPickupDlg::OnUpleft() 
   {
    c_Image.AdjustPos(-1, -1);
   }

void CColorPickupDlg::OnUpright() 
   {
    c_Image.AdjustPos(1, -1);
   }

/****************************************************************************
*                           CColorPickupDlg::OnShow
* Result: void
*       
* Effect: 
*       Invokes the "Show" of the image control, which pops up a little
*       window to show where the selection is.
****************************************************************************/

void CColorPickupDlg::OnShow() 
   {
    c_Image.Show();
   }

/****************************************************************************
*                           CColorPickupDlg::OnCopy
* Result: void
*       
* Effect: 
*       Makes a copy of the current selection on the clipboard
****************************************************************************/

void CColorPickupDlg::OnCopy() 
   {
    c_Image.Copy();
   }

/****************************************************************************
*                      CColorPickupDlg::OnGetMinMaxInfo
* Inputs:
*       MINMAXINFO * lpMMI:
* Result: void
*       
* Effect: 
*       Limits the size so that the buttons at the top are not obscured duirng
*       a resize.
****************************************************************************/

void CColorPickupDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
   {
    // Limits the size to the frame
    if(c_Frame.GetSafeHwnd() != NULL)
       { /* has frame */
        CRect r;
        c_Frame.GetWindowRect(&r);
        ScreenToClient(&r);
        CalcWindowRect(&r);
        lpMMI->ptMinTrackSize.x = r.Width();
        lpMMI->ptMinTrackSize.y = r.Height();
       } /* has frame */        
    else
       CDialog::OnGetMinMaxInfo(lpMMI);
}

/****************************************************************************
*                          CColorPickupDlg::OnPicker
* Inputs:
*       WPARAM: TRUE to indicate pickup, FALSE to indicate drop
*       LPARAM: (LPARAM)MAKELONG(x,y) [ignored if WPARAM is FALSE]
* Result: LRESULT
*       Logically void, 0, always
* Effect: 
*       Handles the pickup and putdown of the picker tool.
* Notes:
*       When the picker tool is grabbed, the image is blanked to simulate
*       it having been picked up and now being dragged.
*       When the picker tool is released, its image is put back.
****************************************************************************/

LRESULT CColorPickupDlg::OnPicker(WPARAM wParam, LPARAM lParam)
    {
     if(wParam)
        { /* pickup */
         c_Picker.SetIcon(NULL);
         c_Image.StartPick(CPoint((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)));
        } /* pickup */
     else
        { /* drop */
         c_Picker.SetIcon(picker);
        } /* drop */
     return 0;
    } // CColorPickupDlg::OnPicker

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -