亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

iczelion tut6

2019-09-10 09:07:11
字體:
來源:轉載
供稿:網友

Theory:

Since normally there's only one keyboard in each PC, all running Windows programs must share it between them. Windows is responsible for sending the key strokes to the window which has the input focus.
Although there may be several windows on the screen, only one of them has the input focus. The window which has input focus is the only one which can receive key strokes. You can differentiate the window which has input focus from other windows by looking at the title bar. The title bar of the window which has input focus is highlighted.
Actually, there are two main types of keyboard messages, depending on your view of the keyboard. You can view a keyboard as a collection of keys. In this case, if you press a key, Windows sends a WM_KEYDOWN message to the window which has input focus, notifying that a key is pressed. When you release the key, Windows sends a WM_KEYUP message. You treat a key as a button. Another way to look at the keyboard is that it's a character input device. When you press "a" key, Windows sends a WM_CHAR message to the window which has input focus, telling it that the user sends "a" character to it. In fact, Windows sends WM_KEYDOWN and WM_KEYUP messages to the window which has input focus and those messages will be translated to WM_CHAR messages by TranslateMessage call. The window procedure may decide to process all three messages or only the messages it's interested in. Most of the time, you can ignore WM_KEYDOWN and WM_KEYUP since TranslateMessage function call in the message loop translate WM_KEYDOWN and WM_KEYUP messages to WM_CHAR messages. We will focus on WM_CHAR in this tutorial.
 

Example:

.386
.model flat,stdcall
option casemap:none

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD include masm32includewindows.inc
include masm32includeuser32.inc
include masm32includekernel32.inc
include masm32includegdi32.inc
includelib masm32libuser32.lib
includelib masm32libkernel32.lib
includelib masm32libgdi32.lib .data
ClassName db "SimpleWinClass",0
AppName  db "Our First Window",0
char WPARAM 20h/t/t/t ; the character the program receives from keyboard .data?
hInstance HINSTANCE ?
CommandLine LPSTR ? .code
start:
   invoke GetModuleHandle, NULL
   mov    hInstance,eax
   invoke GetCommandLine
   mov CommandLine,eax

   invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
   invoke ExitProcess,eax WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
   LOCAL wc:WNDCLASSEX
   LOCAL msg:MSG
   LOCAL hwnd:HWND
   mov   wc.cbSize,SIZEOF WNDCLASSEX
   mov   wc.style, CS_HREDRAW or CS_VREDRAW
   mov   wc.lpfnWndProc, OFFSET WndProc
   mov   wc.cbClsExtra,NULL
   mov   wc.cbWndExtra,NULL
   push  hInst
   pop   wc.hInstance
   mov   wc.hbrBackground,COLOR_WINDOW+1
   mov   wc.lpszMenuName,NULL
   mov   wc.lpszClassName,OFFSET ClassName
   invoke LoadIcon,NULL,IDI_APPLICATION
   mov   wc.hIcon,eax
   mov   wc.hIconSm,eax
   invoke LoadCursor,NULL,IDC_ARROW
   mov   wc.hCursor,eax
   invoke RegisterClassEx, addr wc
   invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,
/t   WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
/t   CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,
/t   hInst,NULL
   mov   hwnd,eax
   invoke ShowWindow, hwnd,SW_SHOWNORMAL
   invoke UpdateWindow, hwnd
   .WHILE TRUE
/t        invoke GetMessage, ADDR msg,NULL,0,0
/t        .BREAK .IF (!eax)
/t        invoke TranslateMessage, ADDR msg
/t        invoke DispatchMessage, ADDR msg
       .ENDW
   mov     eax,msg.wParam
   ret
WinMain endp WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
   LOCAL hdc:HDC
   LOCAL ps:PAINTSTRUCT    .IF uMsg==WM_DESTROY
       invoke PostQuitMessage,NULL
   .ELSEIF uMsg==WM_CHAR
       push wParam
       pop  char
       invoke InvalidateRect, hWnd,NULL,TRUE
   .ELSEIF uMsg==WM_PAINT
       invoke BeginPaint,hWnd, ADDR ps
       mov    hdc,eax
       invoke TextOut,hdc,0,0,ADDR char,1
       invoke EndPaint,hWnd, ADDR ps
   .ELSE
       invoke DefWindowProc,hWnd,uMsg,wParam,lParam
       ret
   .ENDIF
   xor    eax,eax
   ret
WndProc endp
end start
 

Analysis:


char WPARAM 20h/t/t/t ; the character the program receives from keyboard This is the variable that will store the character received from the keyboard. Since the character is sent in WPARAM of the window procedure, we define the variable as type WPARAM for simplicity. The initial value is 20h or the space since when our window refreshes its client area the first time, there is no character input. So we want to display space instead.    .ELSEIF uMsg==WM_CHAR
       push wParam
       pop  char
       invoke InvalidateRect, hWnd,NULL,TRUE This is added in the window procedure to handle the WM_CHAR message. It just puts the character into the variable named "char" and then calls InvalidateRect. InvalidateRect makes the specified rectangle in the client area invalid which forces Windows to send WM_PAINT message to the window procedure. Its syntax is as follows: InvalidateRect proto hWnd:HWND,
/t/t/t/t lpRect:DWORD,
/t/t/t/t bErase:DWORD lpRect is a pointer to the rectagle in the client area that we want to declare invalid. If this parameter is null, the entire client area will be marked as invalid.
bErase is a flag telling Windows if it needs to erase the background. If this flag is TRUE, then Windows will erase the backgroud of the invalid rectangle when BeginPaint is called. So the strategy we used here is that: we store all necessary information relating to painting the client area and generate WM_PAINT message to paint the client area. Of course, the codes in WM_PAINT section must know beforehand what's expected of them. This seems a roundabout way of doing things but it's the way of Windows.
Actually we can paint the client area during processing WM_CHAR message by calling GetDC and ReleaseDC pair. There is no problem there. But the fun begins when our window needs to repaint its client area. Since the codes that paint the character are in WM_CHAR section, the window procedure will not be able to repaint our character in the client area. So the bottom line is: put all necessary data and codes that do painting in WM_PAINT. You can send WM_PAINT message from anywhere in your code anytime you want to repaint the client area.        invoke TextOut,hdc,0,0,ADDR char,1 When InvalidateRect is called, it sends a WM_PAINT message back to the window procedure. So the codes in WM_PAINT section is called. It calls BeginPaint as usual to get the handle to device context and then call TextOut which draws our character in the client area at x=0, y=0. When you run the program and press any key, you will see that character echo in the upper left corner of the client window. And when the window is minimized and maximized again, the character is still there since all the codes and data essential to repaint are all gathered in WM_PAINT section.

 

上一篇:iczelion tut4

下一篇:小程序

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
欧美亚洲日本网站| 欧美成人免费全部观看天天性色| 亚洲精品理论电影| 国产精品91在线| 九九九热精品免费视频观看网站| 国产日韩精品在线播放| 2019中文字幕在线免费观看| 亚洲欧美国产一本综合首页| 亚洲精品av在线| 亚洲人成在线一二| 欧美激情videoshd| 久久久亚洲国产| 日韩精品视频在线观看网址| 久久精品国产久精国产思思| 国产一区二区三区免费视频| 国产日韩欧美91| 成人有码在线播放| 亚洲国语精品自产拍在线观看| 国产美女扒开尿口久久久| 日韩精品中文字幕久久臀| 国产精品一区二区电影| 欧美亚洲激情在线| 日韩激情片免费| 国产亚洲精品91在线| 国产精品高潮呻吟久久av野狼| 在线播放国产一区中文字幕剧情欧美| 久久精品电影网站| 中文字幕亚洲情99在线| 日韩网站免费观看高清| 亚洲国产精久久久久久| 久99九色视频在线观看| 欧美日韩第一页| 成人在线小视频| 国产精品香蕉国产| 色综合色综合久久综合频道88| 欧美电影免费观看网站| 日韩视频在线免费观看| 久久久久久久97| 伊人久久五月天| 国产精品免费久久久| 欧美在线观看一区二区三区| 午夜剧场成人观在线视频免费观看| xxxx欧美18另类的高清| 精品国内亚洲在观看18黄| 日韩电影中文字幕| 欲色天天网综合久久| 久久精品国产精品| 欧美国产在线电影| 久久精品国产成人精品| 中文字幕亚洲激情| 欧洲亚洲在线视频| 亚洲影院污污.| 91超碰caoporn97人人| 亚洲第一精品夜夜躁人人爽| 91精品在线观看视频| 国产精品欧美日韩久久| yw.139尤物在线精品视频| 中文字幕自拍vr一区二区三区| 久久成人人人人精品欧| 国模精品视频一区二区| 久久99久久99精品中文字幕| 最新国产精品亚洲| 日韩久久精品成人| 91中文字幕一区| 欧美日韩一区二区精品| 成人激情黄色网| 日韩av综合网| 久久久精品一区| 国产99久久久欧美黑人| 久久福利网址导航| 亚洲精品网站在线播放gif| 日本高清视频精品| 亚洲欧美国产高清va在线播| 亚洲片在线资源| 岛国av一区二区在线在线观看| 国产精品揄拍500视频| 欧美一区二粉嫩精品国产一线天| 91免费高清视频| 欧美性xxxx极品高清hd直播| 欧美性精品220| 欧美日韩中国免费专区在线看| 国产一区二区三区在线观看网站| 亚洲激情视频在线播放| 亚洲成人网在线观看| 久久夜精品va视频免费观看| 97在线看免费观看视频在线观看| www.国产精品一二区| 性欧美xxxx视频在线观看| 亚洲a中文字幕| 国产精品99久久久久久www| 日韩精品在线观| 日韩av免费在线播放| 国产精品日韩在线| 亚洲成avwww人| 亚洲精品在线不卡| 国产亚洲视频中文字幕视频| 在线成人一区二区| www.久久草.com| 国语自产在线不卡| 91精品国产综合久久久久久蜜臀| 日韩av手机在线| 色妞色视频一区二区三区四区| 中文字幕精品视频| 久久精品电影网| 91麻豆桃色免费看| 91亚洲精品一区| 欧美高清视频在线播放| 成人中文字幕在线观看| 夜色77av精品影院| 欧美性受xxxx白人性爽| 国模私拍视频一区| 国内精品久久影院| 超碰日本道色综合久久综合| 国产在线视频不卡| 亚洲国产成人久久综合一区| 国产mv免费观看入口亚洲| 久久久久久久一区二区| 欧美激情一级精品国产| 亚洲一区中文字幕在线观看| 97视频在线观看网址| 欧美插天视频在线播放| 日韩电影免费在线观看中文字幕| 欧美一区三区三区高中清蜜桃| 亚洲激情 国产| 亚洲第一精品夜夜躁人人爽| 国产精品自产拍在线观| 国产女人18毛片水18精品| 亚州成人av在线| 久久亚洲精品一区| 亚洲国产精品嫩草影院久久| 91精品国产乱码久久久久久蜜臀| 中文字幕在线精品| 精品国内产的精品视频在线观看| 国产精品日韩欧美综合| 久久久久这里只有精品| 久久亚洲精品小早川怜子66| 欧美性生活大片免费观看网址| 一区二区三区视频在线| 国产欧美日韩综合精品| 成人精品在线视频| 亚洲一区二区三区乱码aⅴ蜜桃女| 国产精品99久久久久久久久久久久| 久久中文久久字幕| 欧美插天视频在线播放| 亚洲视频日韩精品| 欧美成人午夜激情视频| xxxx性欧美| 午夜精品福利在线观看| 不卡毛片在线看| 亚洲在线视频福利| www.亚洲成人| 成人久久18免费网站图片| 欧美午夜xxx| 日韩av电影在线免费播放| 136fldh精品导航福利| 国产成人福利网站| 这里只有精品视频在线| 亚洲国语精品自产拍在线观看| 97热在线精品视频在线观看| 中文字幕亚洲综合久久筱田步美| 欧美日韩国产va另类| 国产欧美精品一区二区三区-老狼| 欧美一级视频一区二区| 操91在线视频|