Click here to Skip to main content
15,923,006 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralError when creating MFC wizard app with MS VisualC++ .NET Pin
rsasalm_3-Jul-02 5:17
rsasalm_3-Jul-02 5:17 
QuestionCan we use VC6 to program .NET ? Pin
Prem Kumar1-Jul-02 20:31
Prem Kumar1-Jul-02 20:31 
AnswerRe: Can we use VC6 to program .NET ? Pin
Nemanja Trifunovic3-Jul-02 6:15
Nemanja Trifunovic3-Jul-02 6:15 
AnswerRe: Can we use VC6 to program .NET ? Pin
Nish Nishant3-Jul-02 8:03
sitebuilderNish Nishant3-Jul-02 8:03 
Generalscreen shot of process Pin
SimonS1-Jul-02 2:12
SimonS1-Jul-02 2:12 
GeneralRe: screen shot of process Pin
Richard Deeming2-Jul-02 0:03
mveRichard Deeming2-Jul-02 0:03 
GeneralRe: screen shot of process Pin
SimonS5-Jul-02 10:18
SimonS5-Jul-02 10:18 
GeneralRe: screen shot of process Pin
Richard Deeming7-Jul-02 23:13
mveRichard Deeming7-Jul-02 23:13 
Part of the problem with the original code was that it relies on bringing the window to the top, which doesn't always work on W2K/XP. I got it working in VB.Net on XP by modifying the code to use the PrintWindow API:
#Region "API"
    Private Declare Function GetDesktopWindow Lib "user32" () As IntPtr
    Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As IntPtr, ByRef rect As Rectangle) As Boolean
    Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As IntPtr, ByVal hDC As IntPtr, ByVal nFlags As Integer) As Integer
#End Region

Private Shared Function ImageFromWindow(ByVal hWnd As IntPtr) As Image
    If IntPtr.Equals(hWnd, IntPtr.Zero) Then Return Nothing

    Dim myImage As Image
    Try
        Dim rc As Rectangle
        GetWindowRect(hWnd, rc)
        Dim lW As Integer = rc.Width
        Dim lH As Integer = rc.Height
        If lW = 0 OrElse lH = 0 Then Return Nothing

        myImage = New Bitmap(lW, lH)
        Dim grImg As Graphics
        Try
            grImg = Graphics.FromImage(myImage)
            Dim iDC As IntPtr
            Try
                iDC = grImg.GetHdc()
                PrintWindow(hWnd, iDC, 0)
            Finally
                grImg.ReleaseHdc(iDC)
            End Try
        Catch
            myImage.Dispose()
            myImage = Nothing
        Finally
            grImg.Dispose()
            grImg = Nothing
        End Try
    Finally

    End Try
    Return myImage
End Function

Public Shared ReadOnly Property DesktopAsBitmap() As Image
    Get
        Return ImageFromWindow(GetDesktopWindow())
    End Get
End Property
Public ReadOnly Property WindowAsBitmap() As Image
    Get
        Return ImageFromWindow(hWnd)
    End Get
End Property

It should be fairly easy to convert back to C#.

Also, Nish has an article on a similar topic for C++: http://www.codeproject.com/managedcpp/ijwscrcap.asp#xx174639xx
GeneralRe: screen shot of process Pin
SimonS8-Jul-02 0:12
SimonS8-Jul-02 0:12 
GeneralFloatable docking windows Pin
Oyvind Bratland30-Jun-02 22:01
Oyvind Bratland30-Jun-02 22:01 
GeneralRe: Floatable docking windows Pin
SimonS1-Jul-02 2:18
SimonS1-Jul-02 2:18 
GeneralRe: Floatable docking windows Pin
Oyvind Bratland1-Jul-02 21:44
Oyvind Bratland1-Jul-02 21:44 
GeneralFTP Client Pin
30-Jun-02 17:52
suss30-Jun-02 17:52 
GeneralRe: FTP Client Pin
Oyvind Bratland1-Jul-02 22:41
Oyvind Bratland1-Jul-02 22:41 
QuestionAccessing Web Services through proxy with authentication ? Pin
Peter Hayward30-Jun-02 17:34
Peter Hayward30-Jun-02 17:34 
QuestionWhat happened to Visual Interdev Pin
Jan R Hansen30-Jun-02 11:21
Jan R Hansen30-Jun-02 11:21 
AnswerRe: What happened to Visual Interdev Pin
Andrew Connell1-Jul-02 2:17
Andrew Connell1-Jul-02 2:17 
GeneralWhere is Security... Pin
Venet29-Jun-02 4:08
Venet29-Jun-02 4:08 
GeneralRe: Where is Security... Pin
Venet29-Jun-02 5:28
Venet29-Jun-02 5:28 
GeneralRe: Where is Security... Pin
SimonS1-Jul-02 2:02
SimonS1-Jul-02 2:02 
General.NET, Java webservice hotswop Pin
SimonS27-Jun-02 0:41
SimonS27-Jun-02 0:41 
GeneralPalm Programming With .NET Pin
tho26-Jun-02 17:22
tho26-Jun-02 17:22 
GeneralRe: Palm Programming With .NET Pin
Andrew Connell16-Jul-02 4:40
Andrew Connell16-Jul-02 4:40 
GeneralRe: Palm Programming With .NET Pin
Jamie Nordmeyer20-Aug-02 18:44
Jamie Nordmeyer20-Aug-02 18:44 
QuestionWould this be possible? Pin
Brian Olej25-Jun-02 15:34
Brian Olej25-Jun-02 15:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.