滑鼠 5 滾輪

2021-06-08 06:50:26 字數 2998 閱讀 8558

這不是乙個噱頭,看**,雖然很長,但卻很經典,可以實現鍵盤,滾輪滑動滾動條。

下面是標頭檔案,是儲存的資料。

#define numlines ((int) (sizeof sysmetrics / sizeof sysmetrics [0]))

struct

sysmetrics =

;

**來了;

#include#include#include"char77.h"

lresult callback windowproc(

hwnd hwnd, // handle to window

uint umsg, // message identifier

wparam wparam, // first message parameter

lparam lparam // second message parameter

);int winapi winmain(

hinstance hinstance, // handle to current instance

hinstance hprevinstance, // handle to previous instance

lpstr lpcmdline, // command line

int ncmdshow // show state

) hwnd=createwindow(

text("this is title"), // window name

cw_usedefault, // horizontal position of window

cw_usedefault, // vertical position of window

cw_usedefault, // window width

cw_usedefault, // window height

null, // handle to parent or owner window

null, // menu handle or child identifier

null // window-creation data

); showwindow(hwnd,ncmdshow);

updatewindow(hwnd);

while(getmessage(&msg,null,0,0))

return msg.wparam;

}lresult callback windowproc(

hwnd hwnd, // handle to window

uint umsg, // message identifier

wparam wparam, // first message parameter

lparam lparam // second message parameter

) si.fmask=sif_pos;

setscrollinfo(hwnd,sb_vert,&si,true);

getscrollinfo(hwnd,sb_vert,&si);

if(si.npos!=ivertpos)

return 0;

case wm_hscroll:

si.cbsize=sizeof(si);

si.fmask=sif_all;

getscrollinfo(hwnd,sb_horz,&si);

ihorzpos=si.npos;

switch(loword(wparam))

si.fmask=sif_pos;

setscrollinfo(hwnd,sb_horz,&si,true);

getscrollinfo(hwnd,sb_horz,&si);

if(si.npos!=ihorzpos)

return 0;

case wm_keydown:

switch(wparam)

return 0;

case wm_mousewheel:

if(ideltaperline==0)

break;

iaccumdelta+=(short)hiword(wparam);

while(iaccumdelta>=ideltaperline)

while(iaccumdelta<=-ideltaperline)

return 0;

case wm_paint:

hdc=beginpaint(hwnd,&ps);

si.cbsize=sizeof(si);

si.fmask=sif_pos;

getscrollinfo(hwnd,sb_vert,&si);

ivertpos=si.npos;

getscrollinfo(hwnd,sb_horz,&si);

ihorzpos=si.npos;

ipaintbeg=max(0,ivertpos+ps.rcpaint.top/cychar);

ipaintend=min(numlines-1,ivertpos+ps.rcpaint.bottom/cychar);

for(i=ipaintbeg;i<=ipaintend;++i)

endpaint(hwnd,&ps);

return 0;

case wm_destroy:

postquitmessage(0);

return 0;

} return defwindowproc(hwnd,umsg,wparam,lparam);

}

效果圖,自己複製除錯吧。

滑鼠滾輪事件

新增事件 有相容性 註冊事件 if document.addeventlistener window.onmousewheel document.onmousewheel scrollfunc ie opera chrome detail與wheeldelta 判斷滾輪向上或向下在瀏覽器中也有相容性...

滑鼠滾輪事件

新增事件 有相容性 註冊事件 if document.addeventlistener window.onmousewheel document.onmousewheel scrollfunc ie opera chrome detail與wheeldelta 判斷滾輪向上或向下在瀏覽器中也有相容性...

滑鼠滾輪事件

滑鼠滾輪事件和鍵盤事件以及滑鼠左右鍵沒本質的區別。2 if document.addeventlistener window.onmousewheel document.onmousewheel scroll ie opera chrome safari 像上面這樣就可以給整個文件繫結滾輪事件。fu...