Those who have learned the 8086 assembly have basically written the program output to the console! We write data to some special areas of the memory and then directly display it on the screen.
. With the advent of windows, we cannot directly operate on memory. Windows-based graphics programming is certainly not as good as 8086.
During the GDI programming, we will no longer focus on what kind of hardware is for, and all hardware devices are regarded as virtual. Windows provides users
A series of interface functions, user operations on hardware, are converted into using these functions, function execution is handled by windows.
I. Two modes of GDI Programming
II. The sample code uses Mode.
Function _ winmain sets two windows, one message loop and one timer applied. The timer redraws the customer area of the window every Ms.
. 386. modelflat, stdcalloptioncasemap: noneincludewindows. Routing. libincludeuser32.incincludelibuser32. libincludekernel32.incincludelibkernel32. libid_timerequ1.data? Hinstancedd? Hwin1dd? Hwin2dd ?. Constszclass1db 'sourcewindow', 0szclass2db 'destwindow', 0szcaption1db' try to overwrite this window with another window! ', 0szcaption2db'. The image in this window is copied from another window! ', 0sztextdb' Win32 assembly! ', 0. examples, umsg, _ idevent, _ dwtimelocal @ hdc1, @ hdc2local @ strect: rectinvokegetdc, hwin1mov @ hdc1, example, hwin2mov @ hdc2, example, hwin1, ADDR @ example, @ hdc2, 0, 0, @ strect. right, @ strect. bottom, \ @ hdc1, 0, 0, Ghost, hwin1, @ hdc1invokereleasedc, hwin2, @ hdc2ret_proctimerendp_procwinmainprocuses ebx edi esi, hwnd, umsg, wparam, lparamlocal @ STPS: paintstructlocal @ strect: rectlocal @ hdcmoveax, umsgmovecx, hwnd. ifeax = wm_paint & ECx = hwin1invokebeginpaint, hwnd, ADDR @ stpsmov @ HDC, fill, hwnd, ADDR @ strectinvokedrawtext, @ HDC, ADDR sztext,-1, \ ADDR @ strect, \ dt_singleline or dt_center or dt_vcenterinvokeendpaint, hwnd, ADDR @ STPs. elseifeax = wm_closeinvokepostquitmessage, nullinvokedestroywindow, hwin1invokedestroywindow, hwin2.elseinvokedefwindowproc, hwnd, umsg, wparam, lparamret. endifxoreax, Handler @ stwndclass: wndclassexlocal @ stmsg: msglocal @ override, nullmovhinstance, eaxinvokertlzeromemory, ADDR @ stwndclass, sizeof @ override, 0, IDC_ARROWmov@stWndClass.hCursor, eaxpushhInstancepop@stWndClass.hInstancemov @ stwndclass. cbsize, sizeof WNDCLASSEXmov@stWndClass.style, cs_hredraw or CS_VREDRAWmov@stWndClass.lpfnWndProc, offset _ ProcWinMainmov@stWndClass.hbrBackground, color_window + 1mov@stWndClass.lpszClassName, offset cursor, ADDR @ override, ws_ex_clientedge, offset szclass1, \ offset szcaption1, ws_overlappedwindow, \ 450,100,300,300, \ null, null, hinstance, nullmovhwin1, eaxinvokeshowwindow, hwin1, upper, hWin1mov@stWndClass.lpszClassName, offset upper, ADDR @ upper, lower, offset szclass2, \ offset szcaption2, ws_overlappedwindow, \ 100,100,300,300, \ null, null, hinstance, nullmovhwin2, eaxinvokeshowwindow, hwin2, sw_shownormalinvokeupdatewindow, hwin2invokesettimer, null, null, 100, ADDR _ proctimermov @ htimer, eax. whiletrueinvokegetmessage, ADDR @ stmsg, null, 0, 0. break. if eax = 0 invoketranslatemessage, ADDR @ stmsginvokedispatchmessage, ADDR @ stmsg. endwinvokekilltimer, null, @ htimerret_winmainendpstart: call_winmaininvokeexitprocess, nullendstart
Iii. Running results