Click here to Skip to main content
15,887,135 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Question1073479673(c0040007) Pin
Krishna Kamal7-Nov-14 18:44
professionalKrishna Kamal7-Nov-14 18:44 
AnswerRe: 1073479673(c0040007) Pin
Richard MacCutchan7-Nov-14 22:05
mveRichard MacCutchan7-Nov-14 22:05 
GeneralRe: 1073479673(c0040007) Pin
Krishna Kamal10-Nov-14 22:17
professionalKrishna Kamal10-Nov-14 22:17 
GeneralRe: 1073479673(c0040007) Pin
Richard MacCutchan10-Nov-14 23:11
mveRichard MacCutchan10-Nov-14 23:11 
QuestionChecking listview Items against a lable text Pin
Pete_1237-Nov-14 10:41
Pete_1237-Nov-14 10:41 
NewsRe: Checking listview Items against a lable text Pin
Mycroft Holmes7-Nov-14 13:10
professionalMycroft Holmes7-Nov-14 13:10 
QuestionVBScript / HTA - Drop Down Menu in form Pin
Malbordio5-Nov-14 13:41
Malbordio5-Nov-14 13:41 
QuestionCapturing a Picturebox in Windows 8 Pin
gwittlock31-Oct-14 17:34
gwittlock31-Oct-14 17:34 
I have the following code which works on windows 7 but when I run my app on windows 8 I just get a black box. I am using VB6
and have seen several capture submissions here but they all do the same thing (or at least the several I have tried.

Here is my code
VB
Public Function CaptureWindow(ByVal hWndSrc As Long, ByVal Client As Boolean, ByVal LeftSrc As Long, ByVal TopSrc As Long, ByVal WidthSrc As Long, ByVal HeightSrc As Long) As Picture
  
    Dim hDCMemory As Long
    Dim hBmp As Long
    Dim hBmpPrev As Long
    Dim hDCSrc As Long
    Dim hPal As Long
    Dim hPalPrev As Long
    Dim RasterCapsScrn As Long
    Dim HasPaletteScrn As Long
    Dim PaletteSizeScrn As Long
    Dim LogPal As LOGPALETTE
  
    On Error Resume Next
  
    If Client Then
        hDCSrc = GetDC(hWndSrc)
    Else
        hDCSrc = GetWindowDC(hWndSrc)
    End If
    hDCMemory = CreateCompatibleDC(hDCSrc)
    hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
    hBmpPrev = SelectObject(hDCMemory, hBmp)
    RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS)
    HasPaletteScrn = RasterCapsScrn And RC_PALETTE
    PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE)
    If HasPaletteScrn And (PaletteSizeScrn = 256) Then
        LogPal.palVersion = &H300
        LogPal.palNumEntries = 256
        GetSystemPaletteEntries hDCSrc, 0, 256, LogPal.palPalEntry(0)
        hPal = CreatePalette(LogPal)
        hPalPrev = SelectPalette(hDCMemory, hPal, 0)
        RealizePalette hDCMemory
    End If
    BitBlt hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy
    hBmp = SelectObject(hDCMemory, hBmpPrev)
    If HasPaletteScrn And (PaletteSizeScrn = 256) Then
        hPal = SelectPalette(hDCMemory, hPalPrev, 0)
    End If
    DeleteDC hDCMemory
    ReleaseDC hWndSrc, hDCSrc
    Set CaptureWindow = CreateBitmapPicture(hBmp, hPal)
   
End Function

Any help in changing or making it work on windows 7 & 8 is much appreciated
SuggestionRe: Capturing a Picturebox in Windows 8 Pin
Richard MacCutchan31-Oct-14 22:20
mveRichard MacCutchan31-Oct-14 22:20 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
gwittlock31-Oct-14 23:55
gwittlock31-Oct-14 23:55 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
Richard MacCutchan31-Oct-14 23:58
mveRichard MacCutchan31-Oct-14 23:58 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
gwittlock1-Nov-14 0:03
gwittlock1-Nov-14 0:03 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
Richard MacCutchan1-Nov-14 0:11
mveRichard MacCutchan1-Nov-14 0:11 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
gwittlock1-Nov-14 0:22
gwittlock1-Nov-14 0:22 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
Richard MacCutchan1-Nov-14 5:15
mveRichard MacCutchan1-Nov-14 5:15 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
i006-Nov-14 13:08
i006-Nov-14 13:08 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
Richard MacCutchan6-Nov-14 22:04
mveRichard MacCutchan6-Nov-14 22:04 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
Mycroft Holmes1-Nov-14 0:12
professionalMycroft Holmes1-Nov-14 0:12 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
gwittlock1-Nov-14 0:20
gwittlock1-Nov-14 0:20 
AnswerRe: Capturing a Picturebox in Windows 8 Pin
Dave Kreskowiak1-Nov-14 4:01
mveDave Kreskowiak1-Nov-14 4:01 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
gwittlock1-Nov-14 19:49
gwittlock1-Nov-14 19:49 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
Richard MacCutchan1-Nov-14 22:07
mveRichard MacCutchan1-Nov-14 22:07 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
gwittlock1-Nov-14 22:23
gwittlock1-Nov-14 22:23 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
Richard MacCutchan1-Nov-14 22:32
mveRichard MacCutchan1-Nov-14 22:32 
GeneralRe: Capturing a Picturebox in Windows 8 Pin
Mycroft Holmes1-Nov-14 23:45
professionalMycroft Holmes1-Nov-14 23:45 

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.