如何加入位图,并能够对它进行拖动 如何加入位图,并能够对它进行拖动,而且,需要在相应鼠标事件后,自动加入位图,如左键点击之后 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这不难吧。我这儿有一个CDib类,要不要。要,给我来个信息吧。 要,我的e_mail是[email protected]。有用一定给分。谢谢!! 应该不会很难吧!在相应的鼠标响应函数里GetDC来加载位图,不行么?试试看? 我用SDK写过,MFC也是类似的方式。载入的是1024*768图LRESULT CALLBACK WinProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam){ static HBITMAP hBit; PAINTSTRUCT ps; HDC hdc; static POINT oldPt,newPt,OriginPt; static BOOL flag=FALSE; HDC memdc; HINSTANCE hInstance; static int cxClient,cyClient; int cx,cy; static int mincx,mincy; switch(msg) { case WM_CREATE: hInstance=((LPCREATESTRUCT)lParam)->hInstance; hBit=LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_BACK)); return 0; case WM_SIZE: cxClient=LOWORD(lParam); cyClient=HIWORD(lParam); OriginPt.x=OriginPt.y=0; mincx=cxClient-1024; mincy=cyClient-768; return 0; case WM_LBUTTONDOWN: newPt.x=LOWORD(lParam); newPt.y=HIWORD(lParam); oldPt=newPt; flag=TRUE; return 0; case WM_LBUTTONUP: flag=FALSE; return 0; case WM_MOUSEMOVE: if(flag) { newPt.x=LOWORD(lParam); newPt.y=HIWORD(lParam); if(newPt.x !=oldPt.x || newPt.y != oldPt.y ) { hdc=GetDC(hwnd); cx=newPt.x-oldPt.x; cy=newPt.y-oldPt.y; OriginPt.x +=cx; OriginPt.y +=cy; if(OriginPt.x<=mincx) { cx=0; OriginPt.x=mincx; } if(OriginPt.x >=0) { cx=0; OriginPt.x=0; } if(OriginPt.y<=mincy) { cy=0; OriginPt.y=mincy; } if(OriginPt.y >=0 ) { cy=0; OriginPt.y=0; } ScrollDC(hdc,cx,cy,NULL,NULL,NULL,NULL); InvalidateRect(hwnd,NULL,FALSE); ReleaseDC(hwnd,hdc); oldPt=newPt; } } return 0; case WM_PAINT: hdc=BeginPaint(hwnd,&ps); if(hBit) { memdc=CreateCompatibleDC(hdc); SelectObject(memdc,hBit); BitBlt(hdc,0,0,1024,768,memdc,-OriginPt.x,-OriginPt.y,SRCCOPY); DeleteDC(memdc); } EndPaint(hwnd,&ps); return 0; case WM_DESTROY: DeleteObject(hBit); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,msg,wParam,lParam);} 两个对话框,怎么使他们不同时最小化 让窗口到屏幕边缘时,拖动无效 为解决编译出错问题而修改.dsp文件后,运行超慢 添加ODBC使用者类问题 如何实现QQ上的截屏功能? MFC中自定义消息问题 如何确定某点在某不规则区域中。 滚动条是实现了,但超出屏幕外的文字用滚动条显示不出来,如何办!! 跪求高手解答压缩语音的问题,多谢! 获取操作系统信息 一个函数返回一个指向结构体的指针,该怎么写这段代码,我是大菜鸟。。 关于用属性页和变量设置一问
LRESULT CALLBACK WinProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
static HBITMAP hBit;
PAINTSTRUCT ps;
HDC hdc;
static POINT oldPt,newPt,OriginPt;
static BOOL flag=FALSE;
HDC memdc;
HINSTANCE hInstance;
static int cxClient,cyClient;
int cx,cy;
static int mincx,mincy;
switch(msg)
{
case WM_CREATE:
hInstance=((LPCREATESTRUCT)lParam)->hInstance;
hBit=LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_BACK));
return 0;
case WM_SIZE:
cxClient=LOWORD(lParam);
cyClient=HIWORD(lParam);
OriginPt.x=OriginPt.y=0;
mincx=cxClient-1024;
mincy=cyClient-768;
return 0;
case WM_LBUTTONDOWN:
newPt.x=LOWORD(lParam);
newPt.y=HIWORD(lParam);
oldPt=newPt;
flag=TRUE;
return 0;
case WM_LBUTTONUP:
flag=FALSE;
return 0;
case WM_MOUSEMOVE:
if(flag)
{
newPt.x=LOWORD(lParam);
newPt.y=HIWORD(lParam);
if(newPt.x !=oldPt.x || newPt.y != oldPt.y )
{
hdc=GetDC(hwnd);
cx=newPt.x-oldPt.x;
cy=newPt.y-oldPt.y;
OriginPt.x +=cx;
OriginPt.y +=cy;
if(OriginPt.x<=mincx)
{
cx=0;
OriginPt.x=mincx;
}
if(OriginPt.x >=0)
{
cx=0;
OriginPt.x=0;
} if(OriginPt.y<=mincy)
{
cy=0;
OriginPt.y=mincy;
}
if(OriginPt.y >=0 )
{
cy=0;
OriginPt.y=0;
}
ScrollDC(hdc,cx,cy,NULL,NULL,NULL,NULL);
InvalidateRect(hwnd,NULL,FALSE);
ReleaseDC(hwnd,hdc);
oldPt=newPt;
}
}
return 0; case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
if(hBit)
{
memdc=CreateCompatibleDC(hdc);
SelectObject(memdc,hBit);
BitBlt(hdc,0,0,1024,768,memdc,-OriginPt.x,-OriginPt.y,SRCCOPY);
DeleteDC(memdc);
}
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
DeleteObject(hBit);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,msg,wParam,lParam);
}