Monday, May 26, 2008

Where is my Print Screen Button ?? -.-'''


Yo... Long time no blog... haha..

Previously, i have mentioned that i faced problem with Apple Mouse's right click issues in Windows environment. Well, this time i faced another problem with the shortcut key in Apple keyboard... -.-

There is no Print Screen short cut key in Apple keyboard, instead, it have "F13", "F14", and "F15" button... haha.... -.-

Below are the codes, that i have researched and tested. It's quite useful to me when doing software Report with Print screen. Hope that these coding is useful to u too.. hehe....

<>
Public Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer

Public Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Integer) As Integer

Public Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Integer, ByVal hdc As Integer) As Integer

Public Const SRCCOPY As Integer = &HCC0020

Public Shared Sub CreateBitmap()
Dim gDest As Graphics
Dim hdcDest As IntPtr
Dim hdcSrc As Integer
Dim hWnd As Integer '= Control.Handle.ToInt32
Dim bmp As Bitmap

hWnd = Process.GetCurrentProcess.MainWindowHandle.ToInt32
bmp = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
gDest = gDest.FromImage(bmp)
hdcSrc = GetWindowDC(hWnd)
hdcDest = gDest.GetHdc
BitBlt(hdcDest.ToInt32, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, hdcSrc, 0, 0, SRCCOPY)
gDest.ReleaseHdc(hdcDest)
ReleaseDC(hWnd, hdcSrc)

Dim a As SaveFileDialog
Dim loc As String = ""
a = New SaveFileDialog
a.Filter = "Image .PNG file *.PNG"
a.ShowDialog()
loc = a.FileName()
bmp.Save(loc)
Shell("c:\windows\system32\mspaint " & loc, AppWinStyle.MaximizedFocus) 'Use msPaint to open the Print screen image.

End Sub

1 comment:

whisper said...

So lihai ne u.. hehehe

Next time can sell for Apple company.. wakaka!