📄 microwindows_architecture.html
字号:
CreateWindowEx Createan instance of a window of a certain class<br> DestroyWindow Destroy awindow instance</p><p>The WM_CREATE message is just after window creation, before returning fromCreateWindowEx. The WM_DESTROY message is sent just before destroying a window withDestroyWindow. </p><p>When a window is registered, extra bytes can be allocated to the window structure whencreated. The GetWindowLong, GetWindowWord, SetWindowLong and SetWindowWordmanipulate these bytes. In addition, a fixed number of extra bytes per window classcan be allocated on registration and retrieved via the GetClassLong function.</p><h3> 3.3 Window showing,hiding and moving</h3><p>The ShowWindow function allows windows to be made visible or hidden. In addition,this can be specified during the creation of the window, through CreateWindowEx. MoveWindow is called to change a window's position or size. A WM_MOVE message issent if the window's position changes, and WM_SIZE is sent on size changes.</p><h3> 3.4 Window painting</h3><p>The Microwindows system determines when a window needs to be initially painted orrepainted as the result of other window movement, and a WM_PAINT message is sent to theassociated window procedure. At this point, it's up the the application to use thegraphics primitives available to paint the window, described below. Microwindowskeeps track of a windows' "update" region, and sends WM_PAINT whenever theregion is non-empty. For speed reasons, the WM_PAINT message is only sent when thereare no other messages in the application's queue. This allows the application torepaint in one, rather than possibly many, steps. To force a repaint rather thanwaiting, the UpdateWindow function can be called. The InvalidateRect functionspecifies a rectangle to add to the update region, causing a subsequent WM_PAINT.</p><p>The window title is automatically painted and is set with the SetWindowText function,and retrieved with the GetWindowText function.</p><h3> 3.4.1 Client and screencoordinates</h3><p>Every window is drawn on the screen using the device global screen coordinate systemfor absolute reference to any pixel on the screen. The Microwindows API allowsapplications programmers to be concerned with only the relative coordinates from the upperleft portion of their window, not including the title bar and 3d effects. Thiscoordinate system is called "client coordinates." As will be explainedbelow, the Microwindows programmer has the option of getting a device context in eitherscreen or client coordinates. If device coordinates are specified, then thecoordinate system is device-based and includes the title area and 3d areas of thewindow. Otherwise, the drawable region is clipped to just that area that isreserved by the system for the application's drawing. The GetClientRect andGetWindowRect functions return client or screen coordinates for the passed window. ClientToScreen and ScreenToClient can be called to translate between window coordinatesystems.</p><h3> 3.4.2 Device contexts</h3><p>An applications programmer must obtain a "device context" before calling anygraphics drawing API functions. As explained above, this specifies to the systemwhich window and what coordinate system are desired, so that these don't have to be passedto every graphics function. In addition, various other attributes like foregroundand background color are also set in a device context, so that these parameters don't haveto be specified for every graphics operation. The device context selects theappropriate clipping region based on the window specified and the coordinate system. When a device context is obtained, various graphics values are set to default values.</p><p>To obtain a client device context, call GetDC. To obtain a screen device context,required when drawing onto title bars and the like, call GetWindowDC. In addition,fancy clipping operations and child/sibling window clipping can be specified if GetDCEx iscalled. When finished drawing, the ReleaseDC function must be called to deallocatethe DC.</p><p>On receipt of the WM_PAINT message, two special calls, BeginPaint and EndPaint arecalled, that serve as replacements to the GetDC/ReleaseDC functions. These functionsessentially allocate a DC but also validate the update region so that no subsequentWM_PAINT messages are generated. BeginPaint also combines the update region and theclipping region so that user output will only occur where previously invalidated.</p><h3> 3.4.3 Graphics drawingAPI</h3><p>There are many graphics drawing API's in the Microwindows API. Following is alist, most of these match up to the engine GdXXX functions discussed in section 2.</p><p> SetTextColor Set the foreground text color in a DC<br> SetBkColor Set the background color in a DC<br> GetSysColor Get the system color defined for the current look and feel scheme<br> SetBkMode Set the use background flag in a DC<br> SetROP2 Set the drawing mode (XOR, SET, etc) for drawing<br> SetPixel Draw a pixel in the current fg color<br> MoveToEx Prepare to draw a line<br> LineTo Draw a line from the last location to this one in the current fg color<br> Rectangle Draw a rectangle in the current pen color<br> FillRect Fill a rectangle with the current brush color<br> TextOut Draw text in the current fg/bg color<br> ExtTextOut Draw text in the current fg/bg color<br> DrawText Draw text or compute text height and width sizes<br> DrawDIB Draw a color bitmap<br> SelectObject Select a pen, brush or font to use in a DC<br> GetStockObject Get a predefined standard pen, brush or font<br> CreatePen Create a pen of a certain color<br> CreateSolidBrush Create a brush of a certain color<br> CreateCompatibleBitmap Create an offscreen area to draw onto<br> DeleteObject Delete a pen, brush or bitmap<br> CreateCompatibleDC Create anoffscreen DC<br> DeleteDC Delete an offscreen DC<br> BitBlit Copy from one bitmap in a DC to another<br> GetSystemPaletteEntries Get the currently in-usesystem palette entries<br> </p><h3> 3.5 Utility functions</h3><p>A number of routines are provided for various purposes, described below. Inaddition, Microwindows currently exports some helper routines, named WndXXX, that areuseful but subject to change. These are detailed following:</p><p> WndSetDesktopWallpaper Set the desktop background image<br> WndSetCursor Set the cursor for a window<br> WndRaiseWindow Raise a window's z-order<br> WndLowerWindow Lower a window's z-order<br> WndGetTopWindow Return the topmost window's handle<br> WndRegisterFdInput Register to send a message when file descriptor has read data available<br> WndUnregisterFdInput Unregister file descriptor for read data messages</p><p> GetTickCount Return # milliseconds elapsed since startup<br> Sleep Delay processing for specified milliseconds</p><h3> 3.5.1 Setting windowfocus</h3><p>The SetFocus routine is used to pass keyboard focus from one window to another. Keystrokes are always sent to the window with focus. The WM_SETFOCUS andWM_KILLFOCUS messages are sent to windows just receiving and losing focus. TheGetActiveWindow routines returns the first non-child ancestor of the focus window, whichis the window that is currently highlighted. The GetDesktopWindow routine returnsthe window handle of the desktop window.</p><h3> 3.5.2 Mouse capture</h3><p>Normally, Microwindows sends WM_MOUSEMOVE messages to the window the mouse is currently
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -