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

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

iczelion tut4

2019-09-10 09:07:10
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

Tutorial 4: Painting with Text

Theory:

Text in Windows is a type of GUI object.  Each character is composed of numerous pixels (dots) that are lumped together into a distinct pattern. That's why it's called "painting" instead of "writing". Normally, you paint text in your own client area (actually, you can paint outside client area but that's another story).  Putting text on screen in Windows is drastically different from DOS. In DOS, you can think of the screen in 80x25 dimension. But in Windows, the screen are shared by several programs. Some rules must be enforced to avoid programs writing over each other's screen. Windows ensures this by limiting painting area of each window to its own client area only. The size of client area of a window is also not constant. The user can change the size anytime. So you must determine the dimensions of your own client area dynamically.
Before you can paint something on the client area, you must ask for permission from Windows. That's right, you don't have absolute control of the screen as you were in DOS anymore.  You must ask Windows for permission to paint your own client area. Windows will determine the size of your client area, font, colors and other GDI attributes and sends a handle to device context back to your program. You can then use the device context as a passport to painting on your client area.
What is a device context? It's just a data structure maintained internally by Windows. A device context is associated with a particular device, such as a printer or video display. For a video display, a device context is usually associated with a particular window on the display.
Some of the values in the device context are graphic attributes such as colors, font etc. These are default values which you can change at will. They exist to help reduce the load from having to specify these attributes in every GDI function calls.
You can think of a device context as a default environment prepared for you by Windows. You can override some default settings later if you so wish.
When a program need to paint, it must obtain a handle to a device context. Normally, there are several ways to accomplish this.
  • call BeginPaint in response to WM_PAINT message.
    call GetDC in response to other messages.
    call CreateDC to create your own device context
One thing you must remember, after you're through with the device context handle, you must release it during the processing of a single message. Don't obtain the handle in response to one message and release it in response to another.
Windows posts WM_PAINT messages to a window to notify that it's now time to repaint its client area. Windows does not save the content of client area of a window.  Instead, when a situation occurs that warrants a repaint of client area (such as when a window was covered by another and is just uncovered), Windows puts WM_PAINT message in that window's message queue. It's the responsibility of that window to repaint its own client area. You must gather all information about how to repaint your client area in the WM_PAINT section of your window procedure, so the window procudure can repaint the client area when WM_PAINT message arrives.
Another concept you must come to terms with is the invalid rectangle. Windows defines an invalid rectangle as the smallest rectangular area in the client area that needs to be repainted. When Windows detects an invalid rectangle in the client area of a window , it posts WM_PAINT message to that window. In response to WM_PAINT message, the window can obtain a paintstruct structure which contains, among others, the coordinate of the invalid rectangle. You call BeginPaint in response to WM_PAINT message to validate the invalid rectangle. If you don't process WM_PAINT message, at the very least you must call DefWindowProc or ValidateRect to validate the invalid rectangle else Windows will repeatedly send you WM_PAINT message.
Below are the steps you should perform in response to a WM_PAINT message:
  • Get a handle to device context with BeginPaint.
    Paint the client area.
    Release the handle to device context with EndPaint
Note that you don't have to explicitly validate the invalid rectangle. It's automatically done by the BeginPaint call. Between BeginPaint-Endpaint pair, you can call any GDI functions to paint your client area. Nearly all of them require the handle to device context as a parameter.

Content:

We will write a program that displays a text string "Win32 assembly is great and easy!" in the center of the client area.
.386
.model flat,stdcall
option casemap:none

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD include masm32includewindows.inc
include masm32includeuser32.inc
includelib masm32libuser32.lib
include masm32includekernel32.inc
includelib masm32libkernel32.lib .DATA
ClassName db "SimpleWinClass",0
AppName  db "Our First Window",0
OurText  db "Win32 assembly is great and easy!",0 .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
   LOCAL rect:RECT
   .IF uMsg==WM_DESTROY
       invoke PostQuitMessage,NULL
   .ELSEIF uMsg==WM_PAINT
       invoke BeginPaint,hWnd, ADDR ps
       mov    hdc,eax
       invoke GetClientRect,hWnd, ADDR rect
       invoke DrawText, hdc,ADDR OurText,-1, ADDR rect,
/t        DT_SINGLELINE or DT_CENTER or DT_VCENTER
       invoke EndPaint,hWnd, ADDR ps
   .ELSE
       invoke DefWindowProc,hWnd,uMsg,wParam,lParam
       ret
   .ENDIF
   xor   eax, eax
   ret
WndProc endp
end start

Analysis:

The majority of the code is the same as the example in tutorial 3. I'll explain only the important changes.    LOCAL hdc:HDC
   LOCAL ps:PAINTSTRUCT
   LOCAL rect:RECT These are local variables that are used by GDI functions in our WM_PAINT section. hdc is used to store the handle to device context returned from BeginPaint call. ps is a PAINTSTRUCT structure. Normally you don't use the values in ps. It's passed to BeginPaint function and Windows fills it with appropriate values. You then pass ps to EndPaint function when you finish painting the client area. rect is a RECT structure defined as follows:
RECT Struct
   left/t   LONG ?
   top/t   LONG ?
   right        LONG ?
   bottom    LONG ?
RECT ends
Left and top are the coordinates of the upper left corner of a rectangle Right and bottom are the coordinates of the lower right corner. One thing to remember: The origin of the x-y axes is at the upper left corner of the client area. So the point y=10 is BELOW the point y=0.        invoke BeginPaint,hWnd, ADDR ps
       mov    hdc,eax
       invoke GetClientRect,hWnd, ADDR rect
       invoke DrawText, hdc,ADDR OurText,-1, ADDR rect,
/t        DT_SINGLELINE or DT_CENTER or DT_VCENTER
       invoke EndPaint,hWnd, ADDR ps In response to WM_PAINT message, you call BeginPaint with handle to the window you want to paint and an uninitialized PAINTSTRUCT structure as parameters. After successful call, eax contains the handle to device context. Next you call GetClientRect to retrieve the dimension of the client area. The dimension is returned in rect variable which you pass to DrawText as one of its parameters. DrawText's syntax is: DrawText proto hdc:HDC, lpString:DWORD, nCount:DWORD, lpRect:DWORD, uFormat:DWORD DrawText is a high-level text output API function. It handles some gory details such as word wrap, centering etc. so you could concentrate on the string you want to paint. Its low-level brother, TextOut, will be examined in the next tutorial. DrawText formats a text string to fit within the bounds of a rectangle. It uses the currently selected font,color and background (in the device context) to draw the text.Lines are wrapped to fit within the bounds of the rectangle. It returns the height of the output text in device units, in our case, pixels. Let's see its parameters:
  • hdc  handle to device context
    lpString  The pointer to the string you want to draw in the rectangle. The string must be null-terminated else you would have to specify its length in the next parameter, nCount.
    nCount  The number of characters to output. If the string is null-terminated, nCount must be -1. Otherwise nCount must contain the number of characters in the string you want to draw.
    lpRect  The pointer to the rectangle (a structure of type RECT) you want to draw the string in. Note that this rectangle is also a clipping rectangle, that is, you could not draw the string outside this rectangle.
    uFormat The value that specifies how the string is displayed in the rectangle. We use three values combined by "or" operator:
    • DT_SINGLELINE  specifies a single line of text
    • DT_CENTER  centers the text horizontally.
    • DT_VCENTER centers the text vertically. Must be used with DT_SINGLELINE.
After you finish painting the client area, you must call EndPaint function to release the handle to device context.
That's it. We can summarize the salient points here:
  • You call BeginPaint-EndPaint pair in response to WM_PAINT message.
  • Do anything you like with the client area between the calls to BeginPaint and EndPaint.
  • If you want to repaint your client area in response to other messages, you have two choices:
    • Use GetDC-ReleaseDC pair and do your painting between these calls
    • Call InvalidateRect or UpdateWindow  to invalidate the entire client area, forcing Windows to put WM_PAINT message in the message queue of your window and do your painting in WM_PAINT section
上一篇:給PE文件打補(bǔ)丁

下一篇:iczelion tut6

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

亚洲电影免费观看高清完整版在线观看| yellow中文字幕久久| 亚洲成人手机在线观看| 日本欧美韩国一区三区| 麻豆精品密在线观看| 黄色大片在线播放| 一区二区三区四区av| 一色道久久88加勒比一| 亚洲欧美日韩国产中文| 亚洲国产天堂| 国产成人在线免费观看| 亚洲成人在线视频播放| 日本一区二区三区精品视频| 亚洲国产精品t66y| 色777狠狠综合秋免鲁丝| 亚洲一区二区免费视频软件合集| 四虎成年永久免费网站| 国产精品123区| 狠狠色伊人亚洲综合网站色| 国产黄a三级三级三级| 久久亚洲无码视频| 日韩视频一区二区三区在线播放免费观看| 亚洲无码精品在线播放| 伊人国产精品视频| 91丨九色丨国产| 精品奇米国产一区二区三区| 国产精品88888| 九九精品久久| 国产精品免费丝袜| 波多野结衣作品集| av在线视屏| 视频国产精品| 日韩欧美手机在线| 1024精品视频| 国产日韩欧美一区二区三区四区| 欧美精品一区男女天堂| 91网页在线观看| 乱中年女人av三区中文字幕| 色欧美乱欧美15图片| 国产视频一区二区在线观看| 国卡一卡二卡三免费网站| 中文 欧美 日韩| 日本成人午夜影院| 激情视频免费在线| 国产成人无码av在线播放dvd| 欧美色xxxx| 热久久这里只有精品| 一本大道香蕉久久| 日韩小视频在线| 在线一区日本视频| 成人久久视频在线观看| 精品视频在线观看| 欧美性猛交99久久久久99| 青草在线视频在线观看| 毛片在线免费视频| 日日爱夜夜操| 日韩一区二区三区精品| 精品盗摄女厕tp美女嘘嘘| 欧美一级视频在线| 国产精久久久久久| 欧美日韩视频在线一区二区观看视频| 欧美性jizz18性欧美| 一区二区三区黄色| 国产成人精品免费视频| 午夜视频在线观看一区二区| 亚洲成av人片一区二区三区| 羞羞视频在线观看一区二区| 美女一区二区三区视频| 欧美激情综合五月色丁香| 精品日本一区二区三区| 国产成人亚洲综合91精品| 日韩.com| 四虎精品一区二区免费| 欧美性片在线观看| 黄色av一级片| 国产极品在线观看| 国产精品人成电影在线观看| 久久视频免费在线| 欧美艾v福利视频在线观看| 欧美精品成人| 大尺度做爰床戏呻吟舒畅| 乱子伦一区二区三区| 国产在线不卡一区二区三区| 巨人精品**| 亚洲欧洲成视频免费观看| 精品视频全国免费看| 国产一区二区三区四区老人| 女人让男人操自己视频在线观看| 久久久久久久久久久久久久国产| 午夜精品一区二| 欧美亚洲日本网站| 国产精品狼人色视频一区| 国产精品777777| av在线免费播放网址| 欧美日韩免费不卡视频一区二区三区| 中文字幕黄色av| 北条麻妃在线一区二区| 波多野结衣精品在线| 国产绿帽一区二区三区| 91精品国产综合久久久久久豆腐| 成人免费影院| 亚洲高清免费一级二级三级| 国产精品99一区二区三区| 影音先锋中文资源站| 国内在线免费视频| 欧美精品国产精品日韩精品| 777一区二区| 麻豆久久久av免费| 日韩精品电影一区亚洲| 在线免费看毛片| av日韩中文| 久久精品视频7| 日韩大片免费观看| 99热这里只有精品免费| 91成人福利在线观看| 欧美hdxxxxx| 日韩欧美亚洲在线| 国产精品白丝久久av网站| 麻豆传媒视频在线| 中文字幕免费高清电视剧网站在线观看| 黄色网址免费在线观看| aiai久久| 亚洲乱色熟女一区二区三区| 北条麻妃在线一区二区免费播放| 久久激情五月丁香伊人| 欧美一级片在线视频| 黄色成年人视频在线观看| 一区二区三区| 911美女片黄在线观看游戏| 欧美性受极品xxxx喷水| 成人av资源网址| tube国产麻豆| 538国产精品一区二区免费视频| 99re亚洲国产精品| 一本岛在免费一二三区| 国产精品久久久久久久久影视| 在线观看美女av| 日本男人操女人| 十大免费污污软件| 色婷婷在线播放| 视频一区二区精品| 黄色的电影在线-骚虎影院-骚虎视频| 青青草原在线免费观看视频| 欧美aaaaa成人免费观看视频| 伊人久久久久久久久久久久久久| 精品福利视频一区二区三区| 日本国产精品| 国产美女福利视频| 亚洲精品视频大全| 精品国产一区二| 国产精品成人69xxx免费视频| 久久人人爽人人片| 国产97在线亚洲| 日本乱人伦一区| 日韩三级av在线播放| 成人黄色大片在线免费观看| 精品精品国产国产自在线| 亚洲一区在线直播| 五月婷六月丁香| 亚洲欧洲精品一区二区| 麻豆短视频在线观看| 国产精品福利电影一区二区三区四区| 免费网站永久免费观看| 久久国产精品免费一区二区三区| 国产97在线|亚洲| 亚洲无人区一区| 国产在线激情视频| 草莓视频丝瓜在线观看丝瓜18| 色大师av一区二区三区| 国产日本精品| 91久久国产综合久久| 亚洲精品白浆高清久久久久久| 国产精品视频入口| 亚洲欧美区自拍先锋| 99国产揄拍国产精品| 欧美区一区二| 亚洲男同性恋视频| 国产精品视频一区二区三区经| 波多野结衣av一区二区全免费观看| 欧美一区二区三区男人的天堂| 桥本有菜亚洲精品av在线| 亚洲国产成人精品无码区99| 国产一区二区三区不卡在线观看| 波多野结衣一区二区| 欧美在线免费观看视频| 国产精品区一区二区三| 久久久久久国产精品mv| 日本国产在线视频| 久草视频福利在线| 粉嫩av一区二区三区| 久久国产色av| 丰满人妻一区二区| 正义之心1992免费观看全集完整版| 全部免费的黄色毛片| 欧美专区日韩| 国产免费www| 黄色在线网站噜噜噜| 最近2019中文字幕在线高清| 熟年交尾五十路视频在线播放| 久久婷婷一区二区| 可骚可骚的黄视频网站| 波多野结衣视频一区二区| 国产麻豆天美果冻无码视频| 欧美黄片一区二区三区| 欧美啪啪精品| 欧洲vodafone精品| 日韩国产欧美在线观看| 91嫩草|国产丨精品入口| 国产亚洲一级| av网站无病毒在线| 日本 片 成人 在线| 国产一区二区三区天码| 影音先锋中文在线播放| 日韩精品一区二区三区中文精品| 亚洲男人在线天堂| 欧美一级做一级爱a做片性| 天天综合在线视频| 国产日韩v精品一区二区| 色噜噜狠狠狠综合曰曰曰| 精品少妇久久久| 青青草成人av| 91精品福利视频| 成a人片在线观看www视频| 国产精品视频一区二区三区,| 欧美午夜在线| free性欧洲69| 视色视频在线观看| caoporn视频在线观看| 成人xxxx| 欧美色就是色| 国产精品入口免费| 中文字幕在线影视资源| 国产真实老熟女无套内射| 国产又爽又黄视频| 2021中文字幕在线| 99久久久无码国产精品免费蜜柚| 免费在线看污| 亚洲第一页综合| 亚洲黄色www| 亚洲视频在线观看三级| 99久久国产热无码精品免费| 欧美亚洲丝袜传媒另类| 美女精品在线观看| 日韩在线麻豆| 人妻少妇偷人精品久久久任期| 中文字幕日韩精品有码视频| 一区二区三区四区欧美| 久久av红桃一区二区小说| 久久偷看各类wc女厕嘘嘘偷窃| 中文字幕不卡三区视频| 婷婷色中文字幕| 乱小说欧美综合| 日本少妇高潮喷水视频| 97超碰成人在线| 91精品国产一区二区在线观看| 日韩一区二区三区免费| 成人精品一区二区| 97视频在线免费播放| 欧美中文字幕一区二区| zzijzzij亚洲日本成熟少妇| 久久99精品国产99久久| 青青草在线视频免费观看| 中文字幕在线不卡国产视频| 国产精品久久久久久久久久久久午夜片| 伊人成人222| 成人自拍网站| 国产精品无码专区av免费播放| 久久久久久久久久影视| 亚洲欧美一区二区精品久久久| japanese中文字幕| 巨大黑人video| 黄色录像二级片| 麻豆国产精品视频| 亚洲大胆精品| 亚洲国产精品人人做人人爽| 深夜福利91大全| 自慰无码一区二区三区| 免看一级a毛片一片成人不卡| 欧美黑人性受xxxx精品| 国产嫩草在线视频| 91动漫免费网站| 国产精品主播在线观看| 成人国产在线| 91免费公开视频| 国产黑丝一区二区| 蜜桃导航-精品导航| 免费国产h视频在线观看86| 亚洲熟女一区二区三区| 在线观看天堂av| 国产精品网址在线| 精品久久久久久久久久久久久久久久久久| 亚洲三级 欧美三级| 欧美四级电影网| 成人一区二区三区仙踪林| 国产精品一区一区三区| 欧美国产激情一区二区三区蜜月| 亚洲一区在线日韩在线深爱| 亚洲欧美自拍偷拍| 欧美天堂在线视频| 青青草原国产在线| 大片网站久久| 波多野一区二区| 亚洲欧美一区二区三区在线观看| 粉嫩aⅴ一区二区三区四区| 欧美交受高潮1| 欧美与黑人午夜性猛交久久久| 亚洲欧美国产精品久久久久久久| 国产91麻豆视频| 日韩中文字幕电影| 男生和女生一起差差差视频| 国产精品免费视频网站| 日韩有码中文字幕在线| 久久蜜桃av一区精品变态类天堂| 午夜美女久久久久爽久久| 中国一级特黄毛片| 精品综合久久88少妇激情| 久草精品在线播放| 亚洲二区在线观看| 久久久人成影片一区二区三区在哪下载| 蜜桃av噜噜一区二区三| 久久99精品久久久久| 亚洲精品国产一区二区在线| 亚洲日本香蕉视频| 欧美交换配乱吟粗大25p| 日韩综合另类| 91成人精品| 99久久综合狠狠综合久久止| 98视频精品全部国产|