国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院

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

iczelion tut4

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

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文件打補丁

下一篇:iczelion tut6

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

圖片精選

国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院
国产一卡2卡3卡4卡网站免费| 国产美女高潮| 国产丝袜自拍| 自拍亚洲国产| 国产一区二区三区四区尤物| www.色五月| 懂色一区二区三区| 中文字幕av中文字幕| 91美女主播在线视频| 亚洲综合在线网| 国内外激情在线| 国产视频二区| 青青草视频在线免费观看| 超碰免费在线播放| 国产区视频在线| 永久免费av片在线观看全网站| 亚洲一区二区三区在线观看网站| 日本片在线看| 国产无遮挡又黄又爽免费软件| 在线一区观看| 成视频年人免费看黄网站| 中文字幕视频在线观看| 在线播放国产区| 国产美女极品在线| 99在线欧洲视频| 国产一级免费| 狠狠干在线视频| 精品176二区| 最新国产在线精品91尤物| 伊人狠狠av| 国产三级在线播放| 国产在线观看色| 在线观看的网站你懂的| 国产三级视频在线播放线观看| www.夜夜操| 国产精品国精产品一二| 国产在线精品一区二区不卡| 精品推荐国产麻豆剧传媒| 国产九色视频| 狠狠综合久久久综合| 日本欧美在线视频免费观看| 精品999视频| 精品国产一区二区三区不卡在线| 好看的中文字幕在线播放| 在线免费观看污| av福利在线播放| 夜夜操天天干| av在线日韩国产精品| 中文乱码字幕av网站| 精品推荐国产麻豆剧传媒| 最新av中文字幕| 国产视频三区| 国产aⅴ超薄肉色丝袜交足| 国产精品白浆视频免费观看| 国产精品剧情一区二区三区| 国产精品入口麻豆免费看| 国产视频你懂的| 精品推荐蜜桃传媒| 亚洲综合在线不卡| 日本国产在线| 日韩av成人| 18激情网站| 亚洲精品天堂在线观看| 玖玖在线视频| 中文字幕高清av| 91在线视频免费看| 午夜在线不卡| 国产一级二级在线| 国产福利小视频在线| www.三级.com| 国产亚洲依依| 欧美日韩**字幕一区| 中文字幕在线观看日本| 国产xxxx做受性欧美88| 快射av在线播放一区| 2019中文字幕在线电影免费| av在线免费观看网| 国产高清视频在线观看| 九九热在线观看| 在线观看中文字幕一区| 丁香花在线电影小说观看 | 天堂在线中文资源| 资源视频在线播放免费| 四虎成人免费| 国产a国产a国产a| 黄色片大全在线观看| 一级二级三级在线观看| 国产午夜电影| 国产精品亚洲色图| av三级在线观看| 国产95在线|亚洲| 国产偷倩在线播放| 亚洲免费国产| 在线视频xx| 999国产在线视频| 国产网站av| 最好看更新中文字幕| 国产原创精品视频| 日本成人a视频| jizz亚洲大全| 青青青手机在线视频观看| 在线国产福利网站| 中文字幕av高清| 97在线超碰| 99综合精品久久| 日韩精品免费一区二区| 日日夜夜中文字幕| 在线国产1区| 亚洲天堂影院在线观看| 亚洲欧美日韩成人网| 亚洲国产成人综合| 不卡av免费观看| 久热免费在线视频| 国产91大片| 国产亚洲依依| 国产叼嘿网站免费观看不用充会员| 中文字幕国产欧美| 精品日韩av| 四虎成人欧美精品在永久在线| 怡红院av在线| 日本h视频在线观看| 国产资源在线看| 最新亚洲精品国自产在线观看| 五月天天在线| 精品国产一区二区三区不卡在线| heisi视频网在线观看| 国内外激情在线| 国产成人亚洲综合小说区| av在线日韩国产精品| 国产理论电影在线| 精品国产99久久久久久| 免费观看一二区视频网站| 国产亚洲精品自在线观看| aaa大片在线观看| 欧美精品日韩少妇| 国产精品理人伦一区二区三区| av在线免费观看网| 国产免费黄网站| av大片在线播放| 中文字幕在线免费| 男女午夜视频在线观看| 国产成在线观看免费视频| 黄色网址在线免费播放| 影音先锋在线中文字幕| 国产精品视频一区二区图片| 开心丁香婷婷深爱五月| 一二三四区在线观看| 国产视频二区三区| 久久精品免视着国产成人| 精精国产xxxx视频在线中文版| 五月综合激情在线| 九九热在线视频观看| 国产成人精品久久一区二区小说 | 最近久乱中文字幕| 牛牛在线精品视频| 午夜在线视频| 亚洲综合在线网| 91精品大全| 国产高清在线观看| 国产区在线视频| 国产经典自拍视频在线观看| 国产尤物一区二区三区| 丝袜理论片在线观看| 在线视频观看亚洲| av亚洲男人天堂| 亚洲成人av在线影院| 精品一区二区三区在线观看l| 中文字幕国产视频| 国产亚洲精品久久久久久青梅 | 999精品网| 国产videos| 在线观看免费黄色| 97福利电影| 天堂网中文在线| 免费观看久久久久| 青青草观看免费视频在线| xxxxx中文字幕| 国内a∨免费播放| 91xxx在线观看| 国产二级c片l毛片| www.狠狠| 国产精品9区| 美女av在线播放| 国产精品秘入口| av首页在线| 最近久乱中文字幕| 亚洲成人在线播放| 成人午夜无人区一区二区| 国产精品久久久高清免费| 在线视频观看国产| 丁香婷婷在线| 在线播放www| 天天av综合网| 午夜影院免费| 国产精品久久久高清免费| 牛牛热在线视频| 中文字幕2019第三页| 久久99精品久久久久久野外| 91久久麻豆| 国产视频资源|