问题描述
假设有两个窗口,窗口1处于全屏状态,窗口2非显示,如何在保持窗口1全屏的情况下,取得窗口2的画面并保存为一张位图?我試過使用bitblt函數,但只能把屏幕上的控件拷貝過去,如果非屏幕上的控件就無法拷貝.以上均在vb6.0程序下.请教,谢谢
解决方案
解决方案二:
截取当前窗体的函数,我环境是vb.net2003,给你参考下吧PrivateDeclareFunctionCreateCompatibleDCLib"GDI32"(ByValhDCAsInteger)AsIntegerPrivateDeclareFunctionCreateCompatibleBitmapLib"GDI32"(ByValhDCAsInteger,ByValnWidthAsInteger,ByValnHeightAsInteger)AsIntegerPrivateDeclareFunctionSelectObjectLib"GDI32"(ByValhDCAsInteger,ByValhObjectAsInteger)AsIntegerPrivateDeclareFunctionBitBltLib"GDI32"(ByValsrchDCAsInteger,ByValsrcXAsInteger,ByValsrcYAsInteger,ByValsrcWAsInteger,ByValsrcHAsInteger,ByValdesthDCAsInteger,ByValdestXAsInteger,ByValdestYAsInteger,ByValopAsInteger)AsIntegerPrivateDeclareFunctionDeleteDCLib"GDI32"(ByValhDCAsInteger)AsIntegerPrivateDeclareFunctionDeleteObjectLib"GDI32"(ByValhObjAsInteger)AsIntegerDeclareFunctionGetDCLib"user32"Alias"GetDC"(ByValhwndAsInteger)AsIntegerConstSRCCOPYAsInteger=&HCC0020PublicSubpmjt()DimbmpAsBitmapDimhDC,hMDCAsIntegerDimhBMP,hBMPOldAsIntegerhDC=GetDC(0)hMDC=CreateCompatibleDC(hDC)hBMP=CreateCompatibleBitmap(hDC,Me.Width,Me.Height)hBMPOld=SelectObject(hMDC,hBMP)BitBlt(hMDC,0,0,Me.Width,Me.Height,hDC,Me.Left,Me.Top,SRCCOPY)hBMP=SelectObject(hMDC,hBMPOld)bmp=Image.FromHbitmap(NewIntPtr(hBMP))DeleteDC(hDC)DeleteDC(hMDC)DeleteObject(hBMP)DimofdAsNewSaveFileDialogofd.Filter="jpgfile|*.jpg|bmpfile|*.bmp"Ifofd.ShowDialog=DialogResult.OKThenbmp.Save(ofd.FileName)EndIfEndSub
解决方案三:
请问LS的GetDC是自定义的还是用Win32的API的那个。。。?
解决方案四:
DeclareFunctionGetDCLib"user32"Alias"GetDC"(ByValhwndAsInteger)AsInteger引用2楼Whnight的回复:
请问LS的GetDC是自定义的还是用Win32的API的那个。。。?
解决方案五:
你好,我的意思可能沒有講清楚,是這樣的:當一個Form的高度大於屏幕高度時,此時form上的控件比如textbox框由於超出屏幕顯示範圍,就不可見
解决方案六:
getdc(0)好像取得是當前屏幕的dc,我現在想去不可見部份的控件,存成圖片,謝謝!!