Desktop preview

Viper87
04-09-2006, 10:13 AM
Hi,

I want to translate thic code to VB NET 2005 EE from VB 6.0:


Option Explicit

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Private Const SRCCOPY = &HCC0020

Private Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = 3
End Sub

Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
Dim scr_hwnd As Long
Dim dc_hwnd As Long
Dim pt1 As POINTAPI
Static pt2 As POINTAPI

GetCursorPos pt1

If pt1.x = pt2.x And pt1.y = pt2.y Then
Exit Sub
Else
pt2.x = pt1.x
pt2.y = pt1.y
End If

scr_hwnd = GetDesktopWindow
dc_hwnd = GetDC(scr_hwnd)

Me.Cls

BitBlt Me.hDC, 0, 0, Me.ScaleWidth, Me.ScaleHeight, dc_hwnd, pt1.x - Me.ScaleWidth / 2, pt1.y - Me.ScaleHeight / 2, SRCCOPY
End Sub


Could you help me? I want to send this preview to remote computer in LAN, but I don't know how I can do it... (I never code client-server application) Could you prompt me any sugestions?

lebb
04-10-2006, 12:38 AM
Honestly, I'd recommend just writing it from scratch. There's no reason to use legacy GDI functions in a VB.NET app when the .NET framework provides you with built-in GDI+ functionality.

Beyond that, what are you trying to accomplish, specifically? Would it not make more sense to use an existing product such as VNC for remote screen captures, rather than reinventing the wheel?

Viper87
04-10-2006, 01:31 AM
I want to train coding client-server apps. I want to show only desktop PREVIEW. Could you give me an example of built-in VB.NET GDI+ function?

Can I use wincosk ocx to make connection between computers?

lebb
04-10-2006, 01:36 AM
Could you give me an example of built-in VB.NET GDI+ function?
Take a look at the System.Drawing namespace in MSDN.

Can I use wincosk ocx to make connection between computers?
I sure wouldn't recommend it for .NET. Have a look at Sockets instead (System.Net.Sockets namespace).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum