How to achieve scalableshrink dialog

zhaozj2021-02-17  51

How to achieve scalable / shrink dialog

In the software interface design, concise, and efficient is always the goal of pursuit. The scalable / shrinkage dialog can effectively utilize screen space resources. After the expansion can provide more setting options, then save screen space resources, exempt from some secondary options to operate interference. The following describes the principles and details. The icon is a gathering and lanter, an example, the design dialog box is complete (after the expansion) size, when the dialog is initialized, we only show a part, which is the result. Only the functionality of only a part of the dialog interface can be implemented by a function setWindowPOS. The following is its prototype: Bool setWindowPos (                                                                                                                           int Y, // vertical positionint cx, // widthint cy, // heightUINT uFlags // window-positioning flags); cx window is newly set width. CY is the height of the window reset. Let's call it: Invoke SetWindowPos, HWND, NULL, 0, 0, EBX, EAX, SWP_NOZORDER OR SWP_NOMOVE where EBX and EAX are new windows widths and heights. After the initialization dialog size, we must also respond to the button message to expand / collate the dialog box in the program. So we write the code of the setting window size into a function, you can call when you need it.

The specific implementation code is as follows: example. 386.Model flat, stdcalloption casemap: none; ******************************************* *********************************************************** ***** Include C: /masm32/include/windows.incinclude c: /masm32/include/user32.include c: /masm32/include/kernel32.inc includelib c: /masm32/lib/user32.libincludeLib C: / Masm32 / lib / kernel32.lib; ************************************************************* *************************************************************** DLGPROC PROTO: DWORD ,: DWORD,: DWORD,: DWORDSHWND PROTO: DWORD; ************************************************* *********************************************************** * .DATADLGNAME DB "DLG_MAIN", 0stRBTNS DB "Show & >>", 0stRBTNH DB "& << Hide", 0 .data? Hinstance Hinstance? HBTNEXPAND DD? Rectful RECT ; dialog Box Expanded Size RectHalf Rect ; The location of the "Show / Hide" button after the dialog box is the location bshwnd bool?; Whether to expand the window. Constid_Static EQU -1IDI_MAIN EQU 900IDC_BTN_EXPAND EQU 2001; ****** *********************************************************** ******************************. CODESTART:   cinvoke getmodulehandle, null                                                                                                 Nstance, EAX -                                                           *********************************************************** ******** DlgProc proc hWnd: HWND, uMsg: UINT, wParam: wPARAM, lParam: lPARAM .IF uMsg == WM_CLOSEinvoke EndDialog, hWnd, NULL                                                                                                                              in GetWindowRect, Hwnd, Addr Rectful1                                                                                                                              

HBTNEXPANDOWRECT, HBTNEXPAND, ADDR RectSH; Push RectFull.Left; RectFull.Left; RectHalf assignment value   Push Rectfull.top             pop recstshlf.bottom    pop recth recthalf.bottom -                                                                                                                              ^ ^ , False; the window is closed when the window is displayed.                                                                                                     中mov eax, wParamand eax, 0ffffh.IF eax == IDC_BTN_EXPANDinvoke SHWnd, hWnd                                                          retDlgProc endp; expand / collapse window Functions ************************************** ***************************************** ShWnd Proc HWnd: hwnd                                                                       Bshwnd; Expand window                                                                                                                                            ^ ^ ^ ^ ^ Push RectFull.Lux Rect, Push RectFull.Right # Rect.RightpuP Rect.Right  Push R Ectfull.top  pop rect.bottom   push recstfull.bottom   pop rectfull.bottom   pop rectfull.bottom   pop rect.bottom   pop rect.bottom   pop rect.bottom   pop rect.bottom  pop rect.bottom  pop rect.bottom                                                            invoke SetWindowText, hBtnExpand, addr strBtnS; set the button text to "show & >>" mov bSHWnd, TRUEpush rectHalf.left Pop recthalf.Right                                                                                                                                 ^ Pop rect.bottom   push rect.bottom                                                       Width of the window   Sub EAX, Rect.Lep, EBX, EAX                                                                  Invoke SetWindowPos, HWND, NULL, 0, 0, EBX, EAX, SWP_NOZORDER OR SWP_NOMOVE; Reset Window Size                                          

Acquisition window size invoke GetDlgItem, hWnd, IDC_BTN_EXPAND; obtain "Show / Hide" button handler mov hBtnExpand, eax; handle => hBtnExpandinvoke GetWindowRect, hBtnExpand, addr rectSH; obtain "Show / Hide" button push rectFull.left size; to rectHalf assignment push rectFull.toppush rectFull.rightpush rectSH.bottompop rectHalf.bottompop rectHalf.rightpop rectHalf.toppop rectHalf.leftadd rectHalf.bottom, 12 first obtains the position size of the entire dialog box, stored in rectFull structure inside. Then get the location of the "display >>" button, saved in RectSh. Then calculate the collapsed size RectHalf. The position of the lower boundary of the dialog is calculated from the position of the button, and the distance is 12 pixels, which is determined according to the actual observation effect. MOV BSHWND, FALSE; The window is closed when the window is displayed. Invoke shwnd, hwnd; calls "Expand / Grid" subunies HSHWND indicates that the current is unfold (true) or a false. When the dialog is displayed for the first time we set it to the gathering state, then call the function shwnd to perform the expansion / gathering. The implementation code of the function is as follows: shwnd proc hwnd: hwnd                                                                                                            & << Hide "                                  pupping RectFull.Right Push RectFull.top Rect.Top Rect.top Rect.Top :push RectFull.                                                                                                       Pop Recthalf.top Recthalf.Top Rect.Top  pupp rect.top                                                                                                                                    Pop Rect.Bottom                                                                    mov EBX EAX, Rect.Bottom; Sub eax, rect.top, eBx, EAX, SWP_NOZORDER OR SWP_NOMOVE; reset window size RetshWnd ENDP Judgment is an expansion or a gathering window, set different buttons text and window size. When the window is to be expanded, the full size Rectfull of the window is assigned to the REC.

When you are gathered, you assign the gathered size RectHalf to REC. Finally, the SetWindOS function is called to set the size of the window according to the value of the RECT. .ELSEIF uMsg == WM_COMMANDmov eax, wParamand eax, 0ffffh.IF eax == IDC_BTN_EXPANDinvoke SHWnd, hWnd.ENDIF In response to the button message, call the SHWND function to expand / get together. CopyRight (C) 2001-2002 a piece of three cents

转载请注明原文地址:https://www.9cbs.com/read-30570.html

New Post(0)