第四讲:鼠标_第1页
第四讲:鼠标_第2页
第四讲:鼠标_第3页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、第四讲:鼠标只要鼠标跨越窗口,或者在某窗口中按下鼠标按钮,那么窗口过程函数就会收到鼠标消息,而不管该窗口是否为活动窗口和是否拥有输入焦点窗口。鼠标消息:1. lParam是相对于客户区左上角的坐标,其中X坐标:LOWORD(IParam)Y坐标:HIWORD(lParam)2. wParam是Shift键和Ctrl键或鼠标按钮的状态,若wParam&MK_SHIFT0wParam&MK_CONTROL0wParam&MK_LBUTTON0wParam&MK_MBUTTON0wParam&MK_RBUTTON0表示在产生相应的鼠标消息时,也按下了Shift键和Ctrl键或鼠标按钮。WM_LBUT

2、TONDOWNWM_MBUTTONDOWNWM_RBUTTONDOWNWM_LBUTTONUPWM_RBUTTONUPWM_MBUTTONUPWM_LBUTTONDBLCLKWM_MBUTTONDBLCLKWM_RBUTTONDBLCLKWM_MOUSEMOVE鼠标双击消息如果希望窗口过程函数能接受鼠标双击消息,那么在注册窗口类时,窗口风格应为:wndclass.style=CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;重点:鼠标消息:WM_LBUTTONDOWNWM_MBUTTONDOWNWM_RBUTTONDOWNWM_LBUTTONUPWM_RBUTTONUPWM_M

3、BUTTONUPWM_LBUTTONDBLCLKWM_MBUTTONDBLCLKWM_RBUTTONDBLCLKWM_MOUSEMOVE子窗口风格:WS_CHILDWINDOW|WS_VISIBLE取程序实例句柄:(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE)函数MoveWindow(hwndChildxy,x*cxBIock,y*cyBlock,cxBIock,cyBlock,TRUE);移动窗口和改变窗口大小尺寸,产生WM_SIZE消息。存取预留在窗口额外字节的函数:SetWindowLong(hwnd,0,0);GetWindowLong(hwn

4、d,0,0);设置窗口捕获鼠标函数:SetCapture(hwnd)旦窗口hwnd被设置了捕获鼠标,不管鼠标光标是否在窗口hwnd的边界之内,窗口hwnd都接受鼠标输入。释放窗口捕获鼠标函数:ReleaseCapture();WM_MOUSEMOVE消息:每当鼠标移动时,窗口接收WM_MOUSEMOVE消息,系统此时自动把鼠标光标形状切换到在窗口类中定义的鼠标光标形状,如wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);/*CONNECT.C-Connect-the-DotsMouseDemoProgram(c)CharlesPetzold,1998*/#

5、include#defineMAXPOINTS1000LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);intWINAPIWinMain(HINSTANCEhlnstanee,HINSTANCEhPrevInstanee,PSTRszCmdLine,intiCmdShow)staticTCHARszAppName=TEXT(Connect);HWNDhwnd;MSGmsg;WNDCLASSwndclass;wndclass.stylewndclass.hCursor=CS_HREDRAW|CS_VREDRAW;=WndProc;=0;=0;=hln

6、stanee;=LoadIcon(NULL,IDI_APPLICATION);=LoadCursor(NULL,IDC_ARROW);wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);wndclass.lpszMenuName=NULL;wndclass.lpszClassName=szAppName;if(!RegisterClass(&wndclass)MessageBox(NULL,TEXT(ProgramrequiresWindowsNT!),szAppName,MB_ICONERROR);return0;hwnd=C

7、reateWindow(szAppName,TEXT(Connect-the-PointsMouseDemo),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstanee,NULL);ShowWindow(hwnd,iCmdShow);UpdateWindow(hwnd);while(GetMessage(&msg,NULL,0,0)TranslateMessage(&msg);DispatchMessage(&msg);returnmsg.wParam;wPar

8、am,LRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMLPARAMIParam)staticPOINTptMAXPOINTS;staticintiCount;HDChdc;inti,j;PAINTSTRUCTps;switch(message)caseWM_LBUTTONDOWN:iCount=0;InvalidateRect(hwnd,NULL,TRUE);return0;caseWM_MOUSEMOVE:if(wParam&MK_LBUTTON&iCount1000)ptiCount.x=LOWORD(IParam);ptiCount+.

9、y=HIWORD(IParam);hdc=GetDC(hwnd);/SetPixel(hdc,LOWORD(IParam),HIWORD(IParam),0);SetPixel(hdc,LOWORD(lParam),HIWORD(lParam),RGB(255,0,0);ReleaseDC(hwnd,hdc);return0;caseWM_LBUTTONUP:InvalidateRect(hwnd,NULL,FALSE);return0;caseWM_PAINT:hdc=BeginPaint(hwnd,&ps);SetCursor(LoadCursor(NULL,IDC_WAIT);ShowC

10、ursor(TRUE);for(i=0;iiCount-1;i+)for(j=i+1;jiCount;j+)MoveToEx(hdc,pti.x,pti.y,NULL);LineTo(hdc,ptj.x,ptj.y);ShowCursor(FALSE);SetCursor(LoadCursor(NULL,IDC_ARROW);EndPaint(hwnd,&ps);return0;caseWM_DESTROY:PostQuitMessage(0);return0;returnDefWindowProc(hwnd,message,wParam,lParam);/*CHECKER1.C-MouseH

11、it-TestDemoProgramNo.1(c)CharlesPetzold,1998*/#include#defineDIVISIONS5LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);intWINAPIWinMain(HINSTANCEhlnstanee,HINSTANCEhPrevInstanee,PSTRszCmdLine,intiCmdShow)staticTCHARszAppName=TEXT(Checkerl);HWNDhwnd;MSGmsg;WNDCLASSwndclass;wndclass.stylewndclass.1pfn

12、WndProcwndclass.cbCIsExtra=CS_HREDRAW|CS_VREDRAW;=WndProc;=0;=0;=hlnstanee;=LoadIcon(NULL,IDI_APPLICATION);=LoadCursor(NULL,IDC_ARROW);wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);wndclass.lpszMenuName=NULL;wndclass.lpszClassName=szAppName;if(!RegisterClass(&wndclass)MessageBox(NULL,TE

13、XT(ProgramrequiresWindowsNT!),szAppName,MB_ICONERROR);return0;hwnd=CreateWindow(szAppName,TEXT(CheckerlMouseHit-TestDemo),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstanee,NULL);ShowWindow(hwnd,iCmdShow);UpdateWindow(hwnd);while(GetMessage(&msg,NULL,0,0)

14、TranslateMessage(&msg);DispatchMessage(&msg);returnmsg.wParam;wParam,LRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMLPARAMIParam)staticBOOLfStateDIVISIONSDIVISIONS;staticintcxBlock,cyBlock;HDChdc;intx,y;PAINTSTRUCTps;RECTrect;switch(message)caseWM_SIZE:cxBlock=LOWORD(IParam)/DIVISIONS;cyBlock=HIW

15、ORD(IParam)/DIVISIONS;return0;caseWM_LBUTTONDOWN:x=LOWORD(lParam)/cxBlock;y=HIWORD(lParam)/cyBlock;if(xDIVISIONS&yDIVISIONS)fStatexyA=1;rect.left=x*cxBlock;rect.top=y*cyBlock;rect.right=(x+1)*cxBlock;rect.bottom=(y+1)*cyBlock;InvalidateRect(hwnd,&rect,FALSE);elseMessageBeep(0);return0;caseWM_PAINT:h

16、dc=BeginPaint(hwnd,&ps);for(x=0;xDIVISIONS;x+)for(y=0;yDIVISIONS;y+)Rectangle(hdc,x*cxBIock,y*cyBlock,(x+1)*cxBlock,(y+1)*cyBlock);if(fState凶y)MoveToEx(hdc,x*cxBlock,y*cyBlock,NULL);LineTo(hdc,(x+1)*cxBlock,(y+1)*cyBlock);MoveToEx(hdc,x*cxBlock,(y+1)*cyBlock,NULL);LineTo(hdc,(x+1)*cxBlock,y*cyBlock)

17、;EndPaint(hwnd,&ps);return0;caseWM_DESTROY:PostQuitMessage(0);return0;returnDefWindowProc(hwnd,message,wParam,lParam);/*CHECKER3.C-MouseHit-TestDemoProgramNo.3(c)CharlesPetzold,1998*/#include#defineDIVISIONS5LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);LRESULTCALLBACKChildWndProc(HWND,UINT,WPARAM

18、,LPARAM);TCHARszChildClass=TEXT(Checker3_Child);intWINAPIWinMain(HINSTANCEhlnstanee,HINSTANCEhPrevInstanee,PSTRszCmdLine,intiCmdShow)staticTCHARszAppName=TEXT(Checker3);HWNDhwnd;MSGMSGmsg;WNDCLASSwndclass;wndclass.stylewndclass.lpfnWndProcwndclass.cbCIsExtra=CS_HREDRAW|CS_VREDRAW;=WndProc;=0;=0;=hln

19、stanee;=Loadlcon(NULL,IDI_APPLICATION);=LoadCursor(NULL,IDC_ARROW);wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);wndclass.lpszMenuName=NULL;wndclass.lpszClassName=szAppName;if(!RegisterClass(&wndclass)MessageBox(NULL,TEXT(ProgramrequiresWindowsNT!),szAppName,MB_ICONERROR);return0;wndcla

20、ss.lpfnWndProc=ChildWndProc;wndclass.cbWndExtra=sizeof(long);wndclass.hIcon=NULL;wndclass.lpszClassName=szChildClass;RegisterClass(&wndclass);hwnd=CreateWindow(szAppName,TEXT(Checker3MouseHit-TestDemo),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstanee,NU

21、LL);ShowWindow(hwnd,iCmdShow);UpdateWindow(hwnd);while(GetMessage(&msg,NULL,0,0)TranslateMessage(&msg);DispatchMessage(&msg);returnmsg.wParam;LRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMLPARAMIParam)staticHWNDhwndChildDIVISIONSDIVISIONS;intcxBIock,cyBIock,x,y;switch(message)caseWM_CREATE:for(x

22、=0;xDIVISIONS;x+)for(y=0;yDIVISIONS;y+)hwndChildxy=CreateWindow(szChildCIass,NULL,WS_CHILDWINDOW|WS_VISIBLE,0,0,0,0,hwnd,(HMENU)(y8|x),(HINSTANCE)GetWindowLongGWL_HINSTANCE),NULL);return0;caseWM_SIZE:cxBIock=LOWORD(IParam)/DIVISIONS;cyBIock=HIWORD(IParam)/DIVISIONS;for(x=0;xDIVISIONS;x+)for(y=0;yDIV

23、ISIONS;y+)MoveWindow(hwndChildxy,x*cxBIock,y*cyBIock,cxBIock,cyBIock,TRUE);return0;caseWM_LBUTTONDOWN:MessageBeep(0);return0;caseWM_DESTROY:PostQuitMessage(0);return0;returnDefWindowProc(hwnd,message,wParam,IParam);wParam,(hwnd,LRESULTCALLBACKChildWndProc(HWNDhwnd,UINTmessage,WPARAMwParam,LPARAMIPar

24、am)HDChdc;PAINTSTRUCTps;RECTrect;switch(message)/on/offflag/on/offflagcaseWM_CREATE:SetWindowLong(hwnd,0,0);return0;caseWM_LBUTTONDOWN:SetWindowLong(hwnd,0,1AGetWindowLong(hwnd,0);InvalidateRect(hwnd,NULL,FALSE);return0;caseWM_PAINT:hdc=BeginPaint(hwnd,&ps);GetClientRect(hwnd,&rect);Rectangle(hdc,0,

25、0,rect.right,rect.bottom);if(GetWindowLong(hwnd,0)MoveToEx(hdc,0,0,NULL);LineTo(hdc,rect.right,rect.bottom);MoveToEx(hdc,0,rect.bottom,NULL);LineTo(hdc,rect.right,0);EndPaint(hwnd,&ps);return0;returnDefWindowProc(hwnd,message,wParam,lParam);相关函数SetPixelTheSetPixelfunctionsetsthepixelatthespecifiedco

26、ordinatestothespecifiedcolor.COLORREFSetPixel(/handletoDCHDChdc,intXintY,COLORREFcrColorintXintY,COLORREFcrColor/x-coordinateofpixel/y-coordinateofpixel/pixelcolor);ParametershdcinHandletothedevicecontext.inSpecifiesthex-coordinate,inlogicalunits,ofthepointtobeset.inSpecifiesthey-coordinate,inlogica

27、lunits,ofthepointtobeset.crColorinSpecifiesthecolortobeusedtopaintthepoint.TocreateaCOLORREFcolorvalue,usetheRGBmacro.ReturnValuesIfthefunctionsucceeds,thereturnvalueistheRGBvaluethatthefunctionsetsthepixelto.ThisvaluemaydifferfromthecolorspecifiedbycrColor;thatoccurswhenanexactmatchforthespecifiedc

28、olorcannotbefound.Ifthefunctionfails,thereturnvalueis1.SetCursorTheSetCursorfunctionsetsthecursorshape.HCURSORSetCursor(HCURSORhCursor/handletocursor);ParametershCursorinHandletothecursor.ThecursormusthavebeencreatedbytheCreateCursorfunctionorloadedbytheLoadCursororLoadImagefunction.Ifthisparameteri

29、sNULL,thecursorisremovedfromthescreen.ReturnValuesThereturnvalueisthehandletothepreviouscursor,iftherewasone.Iftherewasnopreviouscursor,thereturnvalueisNULL.LoadCursorTheLoadCursorfunctionloadsthespecifiedcursorresourcefromtheexecutable(.EXE)fileassociatedwithanapplicationinstanee.HCURSORLoadCursor(

30、HINSTANCEhlnstanee,/handletoapplicationinstaneeLPCTSTRlpCursorName/nameorresourceidentifier);LoadCursor(NULL,IDC_WAIT)IDC_ARROW,IDC_CROSS,IDC_WAITMoveToExTheMoveToExfunctionupdatesthecurrentpositiontothespecifiedpointandoptionallyreturnsthepreviousposition.BOOLMoveToEx(HDChdc,/handletodevicecontexti

31、ntX,/x-coordinateofnewcurrentpositionintY,/y-coordinateofnewcurrentpositionLPPOINTlpPoint/oldcurrentposition);ParametershdcinHandletoadevicecontext.XinSpecifiesthex-coordinateofthenewposition,inlogicalunits.YinSpecifiesthey-coordinateofthenewposition,inlogicalunits.lpPointoutPointertoaPOINTstructure

32、thatreceivesthepreviouscurrentposition.IfthisparameterisaNULLpointer,thepreviouspositionisnotreturned.ReturnValuesIfthefunctionsucceeds,thereturnvalueisnonzero.Ifthefunctionfails,thereturnvalueiszero.LineToTheLineTofunctiondrawsalinefromthecurrentpositionupto,butnotincluding,thespecifiedpoint.BOOLLi

33、neTo(HDChdc,/devicecontexthandleintnXEnd/x-coordinateofendingpointintnYEnd/y-coordinateofendingpoint);ParametershdcinHandletoadevicecontext.nXEndinSpecifiesthex-coordinateofthelinesendingpoint,nYEndinSpecifiesthey-coordinateofthelinesendingpoint.ReturnValuesIfthefunctionsucceeds,thereturnvalueisnonz

34、ero.Ifthefunctionfails,thereturnvalueiszero.RectangleBOOLRectangle(HDChdc,intnLeftRect,intnTopRect,intnRightRect:BOOLRectangle(TheRectanglefunctiondrawsarectangle.Therectangleisoutlinedbyusingthecurrentpenandfilledbyusingthecurrentbrush./handletoDC/x-coordofupper-leftcornerofrectangle/y-coordofupper

35、-leftcornerofrectangle/x-coordoflower-rightcornerofrectangle);ParametershdcinHandletothedevicecontext.nLeftRectinSpecifiesthelogicalx-coordinateoftheupper-leftcorneroftherectangle.nTopRectinSpecifiesthelogicaly-coordinateoftheupper-leftcorneroftherectangle.nRightRectinSpecifiesthelogicalx-coordinate

36、ofthelower-rightcorneroftherectangle.nBottomRectinSpecifiesthelogicaly-coordinateofthelower-rightcorneroftherectangle.CreateSolidBrushTheCreateSolidBrushfunctioncreatesalogicalbrushthathasthespecifiedsolidcolor.HBRUSHCreateSolidBrush(COLORREFcrColor/brushcolorvalue);ParameterscrColorinSpecifiestheco

37、lorofthebrush.TocreateaCOLORREFcolorvalue,usetheRGBmacro.CreatePenTheCreatePenfunctioncreatesalogicalpenthathasthespecifiedstyle,width,andcolor.Thepencansubsequentlybeselectedintoadevicecontextandusedtodrawlinesandcurves.HPENCreatePen(intfnPenStyle,/penstyleintnWidth,/penwidthCOLORREFcrColor/pencolo

38、r);ParametersfnPenStyleinSpecifiesthepenstyle.Itcanbeanyoneofthefollowingvalues.ValueMeaningPS_SOLIDThepenissolid.PS_DASHThepenisdashed.Thisstyleisvalidonlywhenthepenwidthisoneorlessindeviceunits.PS_DOTThepenisdotted.Thisstyleisvalidonlywhenthepenwidthisoneorlessindeviceunits.PS_DASHDOTThepenhasalte

39、rnatingdashesanddots.Thisstyleisvalidonlywhenthepenwidthisoneorlessindeviceunits.PS_DASHDOTDOTThepenhasalternatingdashesanddoubledots.Thisstyleisvalidonlywhenthepenwidthisoneorlessindeviceunits.PS_NULLThepenisinvisible.PS_INSIDEFRAMEThepenissolid.WhenthispenisusedinanyGDIdrawingfunctionthattakesabou

40、ndingrectangle,thedimensionsofthefigureareshrunksothatitfitsentirelyintheboundingrectangle,takingintoaccountthewidthofthepen.Thisappliesonlytogeometricpens.nWidthinSpecifiesthewidthofthepen,inlogicalunits.IfnWidthiszero,thepenisasinglepixelwide,regardlessofthecurrenttransformation.CreatePenreturnsap

41、enwiththespecifiedwidthbitwiththePS_SOLIDstyleifyouspecifyawidthgreaterthanoneforthefollowingstyles:PS_DASH,PS_DOT,PS_DASHDOT,PS_DASHDOTDOT.crColorinSpecifiesacolorreferenceforthepencolor.TogenerateaCOLORREFstructure,usetheRGBmacro.ReturnValuesIfthefunctionsucceeds,thereturnvalueisahandlethatidentif

42、iesalogicalpen.Ifthefunctionfails,thereturnvalueisNULL.GetLastErrorWindowsNT/2000:Togetextendederrorinformation,callRemarksAfteranapplicationcreatesalogicalpen,itcanselectthatpenintoadevicecontextbycallingtheSelectObjectfunction.Afterapenisselectedintoadevicecontext,itcanbeusedtodrawlinesandcurves.I

43、fthevaluespecifiedbythenWidthparameteriszero,alinedrawnwiththecreatedpenalwaysisasinglepixelwideregardlessofthecurrenttransformation.IfthevaluespecifiedbynWidthisgreaterthan1,thefnPenStyleparametermustbePS_NULL,PS_SOLID,orPS_INSIDEFRAME.IfthevaluespecifiedbynWidthisgreaterthan1andfnPenStyleisPS_INSI

44、DEFRAMEhelineassociatedwiththepenisdrawninsidetheframeofallprimitivesexceptpolygonsandpolylines.IfthevaluespecifiedbynWidthisgreaterthan1,fnPenStyleisPS_INSIDEFRAM同ndthecolorspecifiedbythecrColorparameterdoesnotmatchoneoftheentriesinthelogicalpalette,thesystemdrawslinesbyusingaditheredcolor.Dithered

45、colorsarenotavailablewithsolidpens.WhenyounoIongerneedthepen,calltheDeleteObjectfunctiontodeleteit.ShowCursorTheShowCShowCursor(BOOLbShow/cursorvisibility);ParametersbShowinSpecifieswhethertheinternaldisplaycounteristobeincrementedordecremented.IfbShowisTRUE,

46、thedisplaycountisincrementedbyone.IfbShowisFALSE,thedisplaycountisdecrementedbyone.ReturnValuesThereturnvaluespecifiesthenewdisplaycounter.RemarksThisfunctionsetsaninternaldisplaycounterthatdetermineswhetherthecursorshouldbedisplayed.Thecursorisdisplayedonlyifthedisplaycountisgreaterthanorequalto0.I

47、famouseisinstalled,theinitialdisplaycountis0.Ifnomouseisinstalled,thedisplaycountis-1.GetCursorPosTheGetCursorPosfunctionretrievesthecursorsposition,inscreencoordinates.BOOLGetCursorPos(LPPOINTlpPoint/cursorposition);ParameterslpPointoutPointertoaPOINTstructurethatreceivesthescreencoordinatesofthecu

48、rsor.ScreenToClientTheScreenToClientfunctionconvertsthescreencoordinatesofaspecifiedpointonthescreentoclientcoordinates.BOOLScreenToClient(HWNDhWnd/handletowindowLPPOINTlpPoint/screencoordinates);ParametershWndinHandletothewindowwhoseclientareawillbeusedfortheconversion.lpPointinPointertoaPOINTstruc

49、turethatspecifiesthescreencoordinatestobeconverted.ReturnValuesIfthefunctionsucceeds,thereturnvalueisnonzero.Ifthefunctionfails,thereturnvalueiszero.WindowsNT/2000:Togetextendederrorinformation,callGetLastErrorRemarksThefunctionusesthewindowidentifiedbythehWncparameterandthescreencoordinatesgivenint

50、hePOINTstructuretocomputeclientcoordinates.Itthenreplacesthescreencoordinateswiththeclientcoordinates.Thenewcoordinatesarerelativetotheupper-leftcornerofthespecifiedwindowsclientarea.TheScreenToClientfunctionassumesthespecifiedpointisinscreencoordinates.Allcoordinatesareindeviceunits.ClientToScreenT

51、heClientToScreenfunctionconvertstheclient-areacoordinatesofaspecifiedpointtoscreencoordinates.BOOLClientToScreen(HWNDhWnd/handletowindowLPPOINTlpPoint/screencoordinates);ParametershWndinHandletothewindowwhoseclientareaisusedfortheconversion.lpPointin/outPointertoaPOINTstructurethatcontainstheclientc

52、oordinatestobeconverted.Thenewscreencoordinatesarecopiedintothisstructureifthefunctionsucceeds.ReturnValuesIfthefunctionsucceeds,thereturnvalueisnonzero.Ifthefunctionfails,thereturnvalueiszero.WindowsNT/2000:Togetextendederrorinformation,callGetLastErrorRemarksTheClientToScreenfunctionreplacesthecli

53、ent-areacoordinatesinthePOINTstructurewiththescreencoordinates.Thescreencoordinatesarerelativetotheupper-leftcornerofthescreen.Note,ascreen-coordinatepointthatisabovethewindowsclientareahasanegativey-coordinate.Similarly,ascreencoordinatetotheleftofaclientareahasanegativex-coordinate.Allcoordinatesa

54、redevicecoordinates.RequirementsSetCursorPosTheSetCursorPosfunctionmovesthecursortothespecifiedscreencoordinates.BOOLSetCursorPos(intX,/horizontalpositionintY/verticalposition);ParametersXinSpecifiesthenewx-coordinateofthecursor,inscreencoordinates.YinSpecifiesthenewy-coordinateofthecursor,inscreenc

55、oordinates.GetWindowLongTheGetWindowLongfunctionretrievesinformationaboutthespecifiedwindow.Thefunctionalsoretrievesthe32-bit(long)valueatthespecifiedoffsetintotheextrawindowmemory.Ifyouareretrievingapointerorahandle,thisfunctionhasbeensupersededbytheGetWindowLongPtrfunction.(Pointersandhandlesare32

56、bitson32-bitWindowsand64bitson64-bitWindows.)Towritecodethatiscompatiblewithboth32-bitand64-bitversionsofWindows,useGetWindowLongPtr.LONGGetWindowLong(HWNDhWnd/handletowindowintnlndex/offsetofvaluetoretrieve);ParametershWndinHandletothewindowand,indirectly,theclasstowhichthewindowbelongs.nlndexinSpecifiesthezero-basedoffsettothevaluetoberetrieved.Validvaluesareintherangezerothroughthenumberofbyteso

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论