I finally got a chance to play around with this a bit. The problem with magnifying on the same form you're moving around is that you have to keep hiding the form so that you can see what is behind it. Maybe there is someway to tap into the buffer used to repaint the background and get your data from there. Anyway here is what I have that works pretty well.Now, when do you call the ZoomIn routine? You can subclass the form and call it whenever the form is movedVB Code:
Option Explicit Private srcDc As Long Private Declare Function StretchBlt Lib "gdi32" ( _ ByVal hdc As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long, _ ByVal hSrcDC As Long, _ ByVal xSrc As Long, _ ByVal ySrc As Long, _ ByVal nSrcWidth As Long, _ ByVal nSrcHeight As Long, _ ByVal dwRop As Long _ ) As Long Private Declare Function GetDC Lib "user32" ( _ ByVal hwnd As Long _ ) As Long Private Declare Function GetWindowRect Lib "user32" ( _ ByVal hwnd As Long, _ lpRect As RECT _ ) As Long Private Declare Function GetClientRect Lib "user32" ( _ ByVal hwnd As Long, _ lpRect As RECT _ ) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Sub Form_Load() Me.ScaleMode = vbPixels srcDc = GetDC(0&) Set FormSubClass = New clsSubClass FormSubClass.Enable Me.hwnd End Sub Sub ZoomIn(ZoomFactor As Long) Dim xWidth As Long, yHeight As Long Dim xLeft As Long, ytop As Long Dim nSrcWidth As Long, nSrcHeight As Long Dim xBorder As Long Dim yBorder As Long Dim wndRect As RECT Dim clientRect As RECT GetWindowRect Me.hwnd, wndRect GetClientRect Me.hwnd, clientRect 'need to hide form so we can see what is behind it Me.Visible = False DoEvents 'get size and location of form xBorder = Int((wndRect.Right - wndRect.Left - clientRect.Right) / 2) yBorder = wndRect.Bottom - wndRect.Top - clientRect.Bottom - xBorder xWidth = clientRect.Right yHeight = clientRect.Bottom nSrcWidth = Int(xWidth / ZoomFactor) nSrcHeight = Int(yHeight / ZoomFactor) xLeft = wndRect.Left + xBorder ytop = wndRect.Top + yBorder 'make the magnified picture StretchBlt Me.hdc, 0, 0, xWidth, yHeight, srcDc, xLeft, ytop, nSrcWidth, nSrcHeight, vbSrcCopy Me.Visible = True End SubThis causes a lot of flashing, so maybe you just want to call it once the form has completed movingVB Code:
Private Sub FormSubClass_WMArrival(hwnd As Long, uMsg As Long, _ wParam As Long, lParam As Long, lRetVal As Long) Select Case uMsg Case WM_MOVE ZoomIn 2 End Select End Sub




Reply With Quote