| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 728 人关注过本帖
标题:屏幕截取的一段代码,后面的不会写了,请大家指点
取消只看楼主 加入收藏
yaoguai2005
Rank: 1
等 级:新手上路
帖 子:168
专家分:0
注 册:2005-9-11
收藏
 问题点数:0 回复次数:2 
屏幕截取的一段代码,后面的不会写了,请大家指点
case WM_CREATE:
{
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
HWND hDesktopWnd = GetDesktopWindow();
HDC hDesktopDC = GetDC(hDesktopWnd);
HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC,
nScreenWidth, nScreenHeight);
SelectObject(hCaptureDC,hCaptureBitmap);
BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,hDesktopDC,0,0,SRCCOPY)
}
//到了这里,我就不知道咋写了,我觉得就该把屏幕抓到我的窗口里面去了,
可是事实还是没有成功,请大家指点一下,后面还要加什么语句呢
谢谢了~~~~~~~~~~~~~~~~~
搜索更多相关主题的帖子: 屏幕 nScreenWidth hDesktopDC hCaptureDC 代码 
2006-04-18 22:06
yaoguai2005
Rank: 1
等 级:新手上路
帖 子:168
专家分:0
注 册:2005-9-11
收藏
得分:0 

老大,我还是搞不定啊,是不是还要设个位图BITMAP结构啊,
能不能再给指点一下把

#include <windows.h>
#define ID_TIMER 1

LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

char szClassName[ ] = "WindowsApp";

int WINAPI
WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)

{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;

wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);

wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;

wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

if (!RegisterClassEx (&wincl))
return 0;

hwnd = CreateWindowEx (
0,
szClassName,
"Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
544,
375,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);

ShowWindow (hwnd, nFunsterStil);

while (GetMessage (&messages, NULL, 0, 0))
{

TranslateMessage(&messages);

DispatchMessage(&messages);
}

return messages.wParam;
}

LRESULT CALLBACK
WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ int nScreenWidth;
int nScreenHeight;
HWND hDesktopWnd;
HDC hDesktopDC;
HDC hCaptureDC;
HBITMAP hCaptureBitmap;
HGDIOBJ oldobj;
HDC hdc;
PAINTSTRUCT ps;
switch (message)
{
case WM_CREATE:
SetTimer(hwnd, ID_TIMER, 1000, NULL);
return 0;
case WM_TIMER:
// case WM_CREATE:
{
nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
hDesktopWnd = GetDesktopWindow();
hDesktopDC = GetDC(hDesktopWnd);
hCaptureDC = CreateCompatibleDC(hDesktopDC);
hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC,
nScreenWidth, nScreenHeight);
oldobj=SelectObject(hCaptureDC,hCaptureBitmap);
InvalidateRect(hwnd,NULL,FALSE);
BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,hDesktopDC,0,0,SRCCOPY);
InvalidateRect(hwnd,NULL,FALSE);
break;
}
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);

BitBlt(hdc,0,0,ps.rcPaint.right-ps.rcPaint.left,ps.rcPaint.bottom-ps.rcPaint.top,hCaptureDC,0,0,SRCCOPY);
EndPaint(hwnd, &ps);
break;
}

case WM_DESTROY:
SelectObject(hCaptureDC,oldobj);
DeleteDC(hCaptureDC);

PostQuitMessage (0);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
}


2006-04-19 10:38
yaoguai2005
Rank: 1
等 级:新手上路
帖 子:168
专家分:0
注 册:2005-9-11
收藏
得分:0 

真是没说的了,老大,
太感谢你了,
为了这个,我研究了3本书,10天时间,
还下载了好多程序
可没有一个有你这样直接有效的,
我得在下面好好的领会才行
感动啊


2006-04-19 11:11
快速回复:屏幕截取的一段代码,后面的不会写了,请大家指点
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023221 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved