第四講:鼠標_第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

提交評論