Show tips for scrollbell applications when you

xiaoxiao2021-03-06  53

When dynamically opening a bitmap file to the specified DC, the image size is often encountered with the problem of the specified area, and in the case where the bitmap file is not distorted, the best way is to use the scroll bar to perform the display processing of the specified area. The fourth middle situation occurs depending on the size of the bitmap, namely: the image length and width are less than the length width of the specified area. The code for processing is as follows:

CWnd * hwnd = GetDlgItem (IDC_WIN); hDesDC = hwnd-> GetDC () -> m_hDC; hSrcDC = CreateCompatibleDC (hDesDC); hBitmap = (HBITMAP) LoadImage (AfxGetInstanceHandle (), dlg.GetPathName (), IMAGE_BITMAP, 0,0 , LR_LOADFROMFILE | LR_CREATEDIBSECTION); GetObject (hBitmap, sizeof BITMAP, & bm); SelectObject (hSrcDC, hBitmap); hwnd-> GetClientRect (& rect); bm.bmHeight, SRCCOPY); if (bm.bmWidth> rect.right) { IF (bm.bmheight> Rect.bottom) {rate = bm.bmHeight-Rect.bottom; restw = bm.bmwidth-reference.right;} else {rest = bm.bmwidth-reference.right; rest = 0;}}} Else {if (bm.bmheight> Rect.bottom) {rate = bm.bmHeight-Rest.bottom; restw = 0;} else {restw = 0; resth = 0;}} m_scrollbar2.setscrollRange (0, restw); m_scrollbar1 .SetscrollRange (0, RESTH);

Then in the corresponding onhscroll (uint nsbcode, uint npos, cscrollbar * pscrollbar)

And ONVScroll (uint nsbcode, uint npos, cscrollbar * pscrollbar)

Join

Switch (nsbcode) {copy sb_lineright: {if (POS2

{

POS2 = 5;

m_scrollbar2.setscrollpos (POS2);

Bitblt (HDesDC, 0, 0, Rect.right, Rect.Bottom, HSRCDC,

0 POS2, 0 POS1, SRCCOPY);

}

ELSE IF (POS2! = restw) // Distance from 5

{

m_scrollbar2.setscrollpos (RESTW-POS2 5);

Bitblt (HDesDC, 0, 0, Rect.right, Rect.Bottom, HSRCDC,

0 POS2, 0 POS1, SRCCOPY);

POS2 = restw;}} Break; Case SB_LINELEFT: {IF (POS2> 0) {POS2- = 5; m_scrollbar2.setscrollpos (SB_horz, Pos2); Bitblt (HDesDC, 0, 0, Rect.right, Rect.Bottom, HSRCDC , 0 POS2, 0 POS1, SRCCOPY);} else if (POS2! = 0) {m_scrollbar2.setscrollpos (RESTW-POS2-5); Bitblt (HDESDC, 0, 0, Rect.right, Rect.Bottom, HSRCDC , 0 POS2, 0 POS1, SRCCopy; POS2 = 0;}} Break; Case Sb_thumbTrack: {POS2 = NPOS; M_ScrollBar2.setscrollpos (POS2); Bitblt (HDESDC, 0, 0, Rect.right, Rect.Bottom , HSRCDC, 0 POS2, 0 POS1, SRCCOPY;} Break;} cdialog :: Onhscroll (NSBCode, Npos, Pscrollbar); The other direction scroll bar can imitate the above code to fill in

In addition, the refresh of the image can also assist in the message trigger mechanism, or the designated area, which can be retrieved, so that the delicate transition effect can be obtained.

The code is written very rough, mainly I hope everyone will take some tips to discuss, I hope everyone will make progress together. I hope that many teachers will advise.

转载请注明原文地址:https://www.9cbs.com/read-117445.html

New Post(0)