An application message pop-up window implementation method and device, electronic equipment and storage medium
By customizing and extending the form area and data display properties of the application message pop-up, and using an adaptive algorithm to ensure that the message content automatically wraps in the appropriate position, the problems of inconsistent form display and inability to customize button content in the existing technology are solved, thus improving ease of use.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING NAURA MICROELECTRONICS EQUIP CO LTD
- Filing Date
- 2023-02-28
- Publication Date
- 2026-04-17
AI Technical Summary
In existing technologies, the form area and data display properties of application message pop-ups cannot be customized or extended, which causes inconvenience and trouble in practical applications. In particular, the button content cannot be customized in multilingual environments, and the message content is displayed inconsistently in the form.
By defining a form as the carrier of message pop-ups, setting the first type of attributes for the areas and the second type of attributes for the data within the areas, the customization and expansion of each area and the data within the areas can be realized. An adaptive algorithm is used to ensure that the message content automatically wraps at the appropriate position, avoiding the truncation of English words.
It enables customization and expansion of the attributes of each area within the form and the data within each area, ensuring that the message content automatically wraps at the appropriate position and that the form's width and height are in proportion. This solves the problems of inconsistent form display and the inability to customize button content in existing technologies, thus improving ease of use.
Smart Images

Figure CN116301855B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of semiconductor technology, and in particular to a method, apparatus, electronic device, and storage medium for implementing application message pop-ups. Background Technology
[0002] EDA (Equipment Data Acquisition) standards are a set of SEMI standards designed to facilitate and improve data acquisition applications and communication between equipment in semiconductor integrated circuit factories. Currently, semiconductor integrated circuit factories use EDA standards to collect specific data from equipment, and then analyze the data to determine how to better improve productivity, quality, and reduce costs.
[0003] EDA products often require providing users with relevant message prompts or error alerts, necessitating the use of message pop-up controls. Typically, the MessageBox, a built-in feature of the .NET Framework, is used directly, as it can meet basic usage requirements such as displaying specific messages and executing corresponding logic based on user clicks on different form buttons. Summary of the Invention
[0004] The present invention aims to solve the technical problems of the inconvenience of application message pop-ups in the prior art.
[0005] To address the aforementioned problems, a first aspect of the present invention proposes a method for implementing an application message pop-up, comprising the following steps: defining a window as a message pop-up carrier, the window including at least one area; in response to a first type of parameter, setting a first type of attribute for at least one area; in response to a second type of parameter, setting a second type of attribute for data in at least one area; displaying the window according to the first type of attribute and the second type of attribute; wherein the first type of parameter includes the area display mode characteristics of at least one area, and the second type of parameter includes the data display mode characteristics of data in at least one area.
[0006] Furthermore, when the at least one area is a message area, the first type of attribute includes the width and height attributes of the message area, and the second type of attribute includes the message display attribute of the message area; the step of displaying the window according to the first type of attribute and the second type of attribute includes: calculating the expected width and expected height of the area required to display the message; using the calculated expected width as a reference, automatically wrapping the part of the message that exceeds the expected width; displaying the automatically wrapped message in the message area; and adjusting the size of the window and / or at least one area other than the message area according to the actual size of the message area.
[0007] Furthermore, the calculation of the expected width and expected height of the area required to display the message includes: using a message control in the message area, setting cells with width and height in pixels within the message area, such that each cell corresponds to one text character, with no gaps between cells; setting a preset aspect ratio for the message area, representing the ratio of the number of cells per row to the number of rows in the message area; displaying the original message in the message control, and converting the width and height of the message control from pixels to cells, thereby obtaining the number of cells xCell and the number of rows yCell in each row of the message control; assigning xCell as the initial value to the expected width, and yCell as the initial value to the expected height; calculating the ratio of the expected width to the expected height after assigning the initial values, and determining: if it is less than or equal to the preset aspect ratio, then outputting the expected width and expected height; if it is greater than the preset aspect ratio, then performing line wrapping calculations on the expected width and expected height repeatedly until the condition of being less than or equal to the preset aspect ratio is met, then outputting the current expected width and expected height.
[0008] Furthermore, the step of cyclically performing line break calculations on the expected width and expected height until the condition of being less than or equal to the preset aspect ratio is met, and then outputting the current expected width and expected height, includes: a) increasing the expected height by 1 to reassign the expected height; b) dividing xCell by the reassigned expected height and reassigning the result to the expected width; c) determining the ratio of the reassigned expected width to the reassigned expected height. If it is less than or equal to the preset aspect ratio, the reassigned expected width and reassigned expected height are output; if it is greater than the preset aspect ratio, step ac is repeated.
[0009] Furthermore, the step of automatically wrapping the portion of the displayed message that exceeds the expected width, based on the calculated expected width, includes: calculating the maximum number of bytes that each line of the message area can accommodate based on the calculated expected width; extracting several message lines according to the carriage return and line feed characters in the original displayed message; and performing formatting processing on each message line to automatically wrap the portion that exceeds the expected width.
[0010] Furthermore, the formatting process of automatically wrapping the portion exceeding the expected width for each message line includes: A. Extracting a first truncation string from the starting character position of the current message line using a first truncation method; B. Accumulating the number of bytes in each first truncation string to obtain the total number of bytes; C. Determining if the total number of bytes is less than the maximum number of bytes, repeating steps A and C; otherwise, proceeding to step D; D. Subtracting the number of bytes in the current first truncation string from the total number of bytes and reassigning the result to the total number of bytes; E. Extracting a second truncation string from the current first truncation string using a second truncation method; F. Accumulating the number of bytes in each second truncation string based on the reassigned total number of bytes to obtain the continued accumulation of the total number of bytes; G. Determining if the continued accumulation of the total number of bytes is less than the maximum number of bytes, repeating step E and G; otherwise, proceeding to step H; H. Adding a newline character after the current second truncation string and using the next character position after the newline as the new starting character position, repeating step A and H until the current message line is processed.
[0011] Furthermore, the first truncation method is to truncate using spaces, and the second truncation method is to truncate using punctuation marks.
[0012] Furthermore, it also includes: if the current first or second truncated string is determined to be a string generated by abnormal input, then the string is truncated at the position where the maximum number of bytes is reached within the abnormal string and a newline character is added, and the position of the next character after the newline and the remaining characters of the abnormal string is taken as the new starting character position.
[0013] Furthermore, when the at least one area is a button area, the first type of attribute includes the width and height attributes of the button area, and the second type of attribute includes the button name display attribute of the button area.
[0014] A second aspect of the present invention provides an apparatus for implementing an application message pop-up, comprising: a configuration module for defining a window as a message pop-up carrier, the window including at least one area; a processing and setting module for setting a first type of attribute of at least one area in response to a first type of parameter; and setting a second type of attribute of data in at least one area in response to a second type of parameter; and a display module for displaying the window according to the first type of attribute and the second type of attribute; wherein the first type of parameter includes a display mode feature of at least one area, and the second type of parameter includes a display mode feature of data in at least one area.
[0015] A third aspect of the present invention provides an electronic device comprising a processor and a memory connected to the processor, the memory being used to store computer program data, and the processor being used to execute the computer program data to implement the above-described implementation method of the present invention.
[0016] A fourth aspect of the present invention provides a computer-readable storage medium storing computer program data, which, when executed by a processor, is used to implement the above-described implementation method of the present invention.
[0017] Based on the application message pop-up implementation method, apparatus, electronic device and storage medium provided by the present invention, it is possible to customize and extend at least one attribute of each area and data within the window, which greatly improves the ease of use.
[0018] This invention also employs a self-designed adaptive message algorithm to ensure that the message window's aspect ratio remains consistent regardless of the input message content, and that the message content automatically wraps at appropriate positions without truncating complete English words. Furthermore, this invention solves the problem in existing technologies where the display content, button style, and button click response messages of message pop-up buttons cannot be customized or expanded. Attached Figure Description
[0019] Figure 1 This is a flowchart illustrating the method for implementing application message pop-ups according to the present invention.
[0020] Figure 2 This is a diagram illustrating how existing technologies can truncate English words by arbitrarily specifying the window width in built-in message pop-ups.
[0021] Figure 3 This is an illustration of a technology where the content displayed on built-in buttons cannot be customized.
[0022] Figure 4 This is a schematic diagram of the window area division according to an embodiment of the present invention;
[0023] Figure 5 This is a flowchart illustrating the process of estimating the size of the area required to display a message, according to an embodiment of the present invention.
[0024] Figure 6 This is a flowchart illustrating the process of reformatting and displaying messages to adaptively wrap text, according to an embodiment of the present invention.
[0025] Figure 7 This is a schematic diagram illustrating the effect of English message display anti-truncation adaptive line wrapping and button display of custom content in an embodiment of the present invention; Detailed Implementation
[0026] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0027] Furthermore, the terms "first" and "second" are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, "a plurality of" means two or more, unless otherwise specifically defined.
[0028] Any process or method description, whether in a flowchart or otherwise described herein, can be understood to represent a module, segment, or portion of code that includes one or more executable instructions for implementing a specific logical function or process. The scope of the preferred embodiments of the present invention includes additional implementations where the functions may be performed in an order different from that shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the involved functions, which should be understood by those skilled in the art to which the embodiments of the present invention pertain.
[0029] The message pop-up windows that are directly used by default in EDA products (such as the MessageBox pop-up window provided by.Net Framework) can meet the basic usage requirements to a certain extent. For example, the specific message display required by the system, form adaptation, control of the overall size and shape of the form, and different form button click feedback to the calling end to provide different results for the program to execute corresponding logic according to user clicks, etc. However, for at least one area included in the form (such as the message area, button area, icon area, etc.), many of its attributes (such as type, style, width, height, position, quantity, corresponding response message, etc.) are fixed default settings, and there is a problem of not supporting customization and extension, which causes many inconveniences and troubles in practical applications.
[0030] In addition, for many attributes of the data within the area (such as data display content, font, font size, etc.), there are also problems of being fixed and default settings, which cannot meet the actual application production requirements. For example, when EDA needs to use an all-English interface display, developers also need to write English messages to meet the English display of the title and message content of the EDA product. However, the buttons in the existing message forms are restricted by the operating system language environment, and the content displayed on the buttons cannot be customized. For example
[0031] The MessageBoxButtons.OK type button can only be displayed as "OK" in Chinese; as Figure 3 shown, the corresponding type of button can only display the default specified language and content. In addition, the style of the button and the corresponding response message are defined by the enumeration type built into MessageBox and cannot be customized and extended.
[0032] In this invention, the window serves as the carrier of the message pop-up, and it includes at least one area, such as: a title area, an icon area, a message area, a button area, etc. (see also...) Figure 4 In addition, each of the at least one area typically contains data within that area. For example, for a message area, the message text (or message text data) displayed therein is the data within that message area; similarly, for a button area, the button name text displayed therein is the data within that button area.
[0033] In this invention, at least one area is given a first type of attribute, and the data in the at least one area is given a second type of attribute. Here, the first type of attribute characterizes the specific display method of the area when it is displayed in the form, such as the area's type, style, width, height, position, and quantity. The second type of attribute characterizes the specific display method of the data in the area, such as the data display content, font, and font size.
[0034] In this invention, the setting of the first type and the second type of attributes can be implemented based on the first type of parameters and the second type of parameters, respectively. Specifically, the first type of attributes of the at least one area can be set in response to the first type of parameters; and the second type of attributes of the data in the at least one area can be set in response to the second type of parameters. Here, the first type of parameters include, for example, the width parameter (hereinafter "expected width") and the height parameter (hereinafter "expected height") of the message area. The second type of parameters include, for example, the message content parameter (hereinafter "message"), the font parameter (hereinafter "Microsoft YaHei"), and the font size parameter (hereinafter "8pt") of the data in the message area.
[0035] When determining the specific attribute values of the first and second types of attributes, they can be set in response to the first and second types of parameters, respectively. For example, the first type of attributes of the message area includes width and height (also referred to as the actual width and actual height of the message area). The setting of this width and height can be achieved in response to the first type of parameters. Specifically, the first type of parameters can be obtained, for example, by calculating the width and height parameters of the message area (for an example of this calculation process, please see the description in the embodiments below). These width and height parameters are equivalent to the first type of parameters, so the width (or width attribute) and height (or height attribute) of the message area both belong to the first type of attributes and can be set in response to the width and height parameters (first type of parameters). In specific settings, the calculated expected width (i.e., a width parameter) and expected height (i.e., a height parameter) can be used directly (e.g., if the calculated expected width and estimated height are 10 and 5 respectively, then the width and height of the message area are set to 10 and 5 respectively). Alternatively, an indirect setting method can be used. For example, in response to the expected width and height, the actual width and height of the message area can be set to be greater than the expected width and height to a certain extent, thereby leaving a certain blank space (or margin) between the width and height boundaries of the message area and the messages displayed inside. The actual width and height can be obtained by scaling up the expected width and height by a fixed ratio (for example, if the calculated expected width and estimated height are 10 and 5 respectively, and the fixed scaling ratio is 1.2, then the width and height of the message area are set to 12 (10*1.2) and 6 (5*1.2) respectively) or by adding a predetermined margin (for example, if the calculated expected width and estimated height are 10 and 5 respectively, and the fixed width margin is 2 and the fixed height margin is 1, then the width and height of the message area are 12 (10+2) and 6 (5+1) respectively).
[0036] The following examples further illustrate the correspondence between the first and second types of parameters and the first and second types of attributes. For instance, MessageBoxButtons.OK, a parameter used as a method call in the button area, corresponds to the first type of parameter and is used to set the type of the button area; where "OK" indicates the specific type of the button, it corresponds to "Type" in the first type of attribute; the situation is similar for other first type parameters and attributes. Second type attributes include data display content, font, and / or font size. For example, buttonNames, a parameter used as a method call in the button area, corresponds to the second type of parameter and is used to set the display content within the button area; the specific button name (such as text) defined in buttonNames represents the specific display content of the button, it corresponds to "Data Display Content" in the second type of attribute. Similarly, message, a parameter used as a method call in the message area, corresponds to the second type of parameter and is used to set the display content within the message area; the specific message content (such as text) defined in message represents the specific display content of the message area, it corresponds to "Data Display Content" in the second type of attribute; the situation is similar for other second type parameters and attributes.
[0037] like Figure 1 As shown, this invention proposes a method for implementing an application message pop-up, including the following steps:
[0038] S101. Define the form as a message pop-up carrier. The form includes at least one area.
[0039] In this field, the most commonly known form of a window is the Windows Form, which includes folder forms, application forms, application message pop-ups, etc. The areas contained within a form typically include a title bar, icon bar, message bar, and button bar.
[0040] S102. In response to the first type of parameter, set at least one first type of attribute of a region; in response to the second type of parameter, set at least one second type of attribute of data in a region;
[0041] S103. Display the form according to the first type of attribute and the second type of attribute.
[0042] The first type of parameters includes the display mode characteristics of the at least one area, and the second type of parameters includes the data display mode characteristics of the data in the at least one area. Examples of the first type of attributes include the width and height of the message area and the width and height of the button area. Examples of the second type of attributes include message display attributes in the message area (such as message display content, font, and font size) and button name display attributes in the button area (such as the data display content, font, and font size of the button name).
[0043] The method for implementing application message pop-ups provided by the present invention enables the customization and expansion of at least one attribute of each area and data within the window, overcoming the problem that in the prior art, many attributes of the areas contained in the window can only use fixed default settings, causing many inconveniences and troubles in practical applications.
[0044] As an embodiment of the present invention, this embodiment uses Winform under the .NET Framework platform as an example for preferred illustration in order to facilitate a specific and detailed explanation of the present invention. However, this should not be construed as a limitation of the present invention. The present invention can also be applied to the implementation of application message pop-ups under other platform architectures.
[0045] Figure 4 This is a schematic diagram of the window area division according to an embodiment of the present invention; Figure 5 This is a flowchart illustrating the process of estimating the size of the area required to display a message, according to an embodiment of the present invention. Figure 6 This is a flowchart illustrating the process of reformatting a message to adaptively wrap text, according to an embodiment of the present invention.
[0046] like Figure 4 As shown, the Winform form MSGBox is defined as the message popup container. This form is divided into four areas: title area, icon area, message area, and button area.
[0047] In this embodiment, the first type of parameters corresponding to the message area may include the expected width and expected height of the message area, and the second type of parameters corresponding to the message area may include the message display mode characteristics of the message area.
[0048] To achieve adaptive message area size, you first need to estimate an area (mainly referring to the width, i.e., the expected width) that can accommodate all displayed messages. Then, use this width as a reference to automatically wrap the original message. Finally, adjust the size of the entire window and / or other areas according to the reformatted message area size.
[0049] Step 1: Calculate the expected width and height of the area required to display the message.
[0050] In this embodiment, the message area uses a message control (e.g., the built-in Label control), and the default font is "Microsoft YaHei, 8pt". Each English character in this font occupies 6*14 pixels, and each Chinese character occupies 11*14 pixels.
[0051] Based on this, the concept of a cell is abstracted and defined. Each cell is equivalent to a unit cell, and there are no gaps between cells (i.e., no pixel spacing). The width and height are represented in pixels. In this embodiment, each cell occupies 12*14 pixels, and the preset aspect ratio is set to 5:1 (this ratio is an example in this embodiment and can be adjusted in actual applications), that is, the ratio of the number of cells in each row of the message area to the number of rows is 5:1.
[0052] like Figure 5 As shown, the original message is first displayed directly in the Label. At this time, the actual pixel size of the Label control may have exceeded the default original size of the form.
[0053] Then, the width and height of the Label control are converted from pixels to cells. That is, the actual number of rows of cells in the current Label control is represented as yCell, and the number of cells in each row is represented as xCell.
[0054] Let the expected width be represented as realCellX and the expected height as realCellY, and initialize them with the following values: realCellX = xCell, realCellY = yCell.
[0055] Then, it is determined that if realCellX:realCellY <= 5:1, the expected width and height of the area required to display the message are output for the current realCellX and realCellY.
[0056] If realCellX:realCellY > 5:1, perform line breaks on realCellX and realCellY repeatedly until the condition realCellX:realCellY <= 5:1 is met. See also Figure 5 Specifically, it includes:
[0057] a. realCellY plus 1 (i.e. realCellY=realCellY+1);
[0058] b. realCellX=xCell / realCellY;
[0059] c. If the current realCellX:realCellY > 5:1, then execute from a again until realCellX:realCellY <= 5:1 is satisfied, and output the expected width and height of the current realCellX and realCellY as the area size required to display the message.
[0060] Step 2: Using the calculated realCellX (estimated width) as a reference, reformat the displayed message, automatically wrapping any portion exceeding realCellX so that it can be displayed within the width limit of realCellX. Even better, this further satisfies the requirement that English words at the automatic wrapping positions are not truncated.
[0061] like Figure 6 As shown, considering the possibility that a message may contain both English and Chinese characters, bytes are used as the unit to measure the number of characters that each line of the message area can hold. This embodiment uses the case of English and Chinese characters as an example for illustration. One English character occupies 1 byte, and one Chinese character occupies 2 bytes. Including Chinese and English punctuation marks, the maximum number of bytes that each line can hold is maxByteCount = realCellX * 2.
[0062] See Figure 6 The message is split into several original message lines (messageRow = message.split('\r\n')) based on the carriage return and line feed characters in the original message. Each messageRow is then formatted with automatic line breaks, specifically including:
[0063] A. Starting from the beginning character position of the current message line messageRow, extract the first truncation string longWord (which may contain punctuation marks or have a length exceeding maxByteCount) using the first truncation method (preferred in this embodiment and illustrated using character space truncation). (i.e., longWord = messageRow.split(''))
[0064] B. Calculate and sum the number of bytes for each longWord to obtain the total number of bytes, totalByteCount;
[0065] C. If totalByteCount is less than maxByteCount, repeat steps AC; otherwise, go to step D.
[0066] D. Subtract the current number of bytes of longWord from totalByteCount to reassign totalByteCount (i.e., totalByteCount -= longWord.bytes);
[0067] E. Extract the second substring singleWord from the longWord (i.e., the current longWord) that exceeds maxByteCount using the second truncation method (preferred in this embodiment and illustrated using punctuation marks as an example);
[0068] F. Based on the reassigned totalByteCount, continue to accumulate the number of bytes for each singleWord starting from the current longWord position; (i.e., totalByteCount += singleWord.bytes)
[0069] G. If totalByteCount is less than maxByteCount, repeat step EG; otherwise, go to step H.
[0070] H. Add a newline character (i.e., singleWord + "\r\n") after the current singleWord, and take the next character position after the newline as the new starting character position. Repeat step AH until the current message line is processed.
[0071] Step 3: Re-display the reformatted message in the Label, and adjust the form size (the size of the entire message box) and / or the size of other areas within the form (such as the width of the button area) according to the current actual size of the message area. At this point, the message form's adaptive design is complete.
[0072] Further illustratively, the actual size (actual width and actual height) of the aforementioned message area can be set in response to and directly using the calculated expected width and height (i.e., setting the first type of attribute of the message area - width and height). Alternatively, in response to the expected width and height, the actual width and height of the message area can be set to be slightly larger than the expected width and height, thus leaving a certain blank space (or margin) between the width and height boundaries of the message area and the displayed messages within it. The actual width and height can be derived by scaling up by a fixed ratio or increasing a predetermined margin based on the expected width and height.
[0073] Furthermore, throughout the second step described above, the case of English sentences can be more preferably considered. This means considering not only normal input (normal word length, default rules such as spaces between punctuation and words) but also cases of abnormal input (e.g., excessively long input without breaks, or other irregular cases). Here, excessively long strings generated by abnormal input can be disregarded as English words, thus the requirement of "words not being truncated" no longer applies. As an example, the following approach can be used:
[0074] If the current longWord or the current singleWord is determined to be a string generated by abnormal input, then the string is truncated at the position of maxByteCount and a newline character is added. The position of the next character after the newline and the remaining characters of the abnormal string is taken as the new starting character position.
[0075] Based on the application message pop-up implementation method provided by this invention, a self-designed message adaptive algorithm can be used to ensure that the width and height ratio of the message window is coordinated under any input message content, the message content automatically wraps at appropriate positions, and complete English words are not truncated. For example, in an existing device modeling application, when a user needs to delete a state machine type node defined in the SEMI E120 protocol on the device model, due to the internal logic of the device model, it is necessary to ask the user whether they are sure about deleting, and thus display the following query text: Are you sure to delete node "State Machine"? "State Machine" is referenced by other nodes in the Model. And reference nodes are out of range of "State Machine" and its subnodes!
[0076] When using the built-in message pop-up, no adaptive algorithm is used to display messages. The entire message is displayed on a single line, causing the window width to be much larger than its height, resulting in a disproportionate display. Furthermore, if the message content is longer, it may not display completely on the screen. Alternatively, arbitrarily specifying a fixed window width and having the message wrap at that width may truncate English words, causing issues such as… Figure 2 The display effect shown.
[0077] After processing using the method provided by this invention, the following can be obtained: Figure 7 The image shows the effect of adaptive line wrapping for truncation-free English messages. Furthermore, this invention can expand the message area display font and size, allowing for the configuration of more font and size attributes, thereby further enriching the user experience.
[0078] Furthermore, the window in this invention may also include a button area (such as...). Figure 4As shown, button controls are used in the button area. The present invention provides a display method Show(), which includes input parameters such as a title caption, a message content message, button types buttons, button display names buttonNames, and a display icon icon. When an application executes a specific operation of a user and needs to prompt the user or ask the user how to operate next, the method Show() will be called, and corresponding parameters will be passed according to the actual situation. For example, when a form is created, the method Show() is called correspondingly. The message display form will display the caption in the title area, the message in the message area, the icon icon in the icon area, generate buttons of the corresponding type in the button area, and display the button names defined in buttonNames on the buttons in sequence. And according to the type of the parameter buttons, the number and type of buttons can be dynamically generated, and a click event and a return message type are bound to each button.
[0079] The present invention can be used directly by calling the provided method, and it is similar to the usage method of the existing MessageBox provided by.Net Framework, which is convenient for upgrading and replacing old systems. For example, for a message pop-up window with a title of "Hello!", a displayed message content of "Hello", and including a button with the displayed text "OK" (the buttons in the existing built-in message pop-up window can only be fixed to display as Chinese "OK" due to the operating system language environment limitation):
[0080] The usage method of the existing built-in MessageBox call method is: MessageBox.Show("Hello!","Hello",MessageBoxButtons.OK,MessageBoxIcon.Information);
[0081] The present invention uses the Winform form MSGBox as the carrier of the message pop-up window and reconstructs it into NMessageBox. The usage method of its call method is: NMessageBox.Show("Hello!","Hello",MessageBoxButtons.OK,new string[]{"OK"},MessageBoxIcon.Information);
[0082] As can be seen, compared to the original MessageBox, the NMessageBox class only needs to add a string[] type parameter to display the button as "OK", thus realizing the customization of the button's displayed content. Furthermore, this invention can also expand the button's style by replacing the existing message popup button enumeration type (MessageBoxButtons) with a custom enumeration type, and / or expand the button's response message by replacing the existing dialog structure enumeration type (DialogResult) with a custom enumeration type. Therefore, this invention solves the problem that the displayed content of message popup buttons cannot be customized in the prior art, and the problem that the style of message popup buttons and button click response messages cannot be customized and expanded in the prior art, greatly improving the ease of use.
[0083] This invention also proposes an apparatus for implementing application message pop-ups, which can apply the message pop-up implementation method described above. The apparatus includes:
[0084] The configuration module is used to define a form as a message pop-up carrier, wherein the form includes at least one area;
[0085] The processing and setting module is used to set a first type of attribute of the at least one area in response to a first type of parameter; and to set a second type of attribute of the data in the at least one area in response to a second type of parameter; the display module is used to display a form according to the first type of attribute and the second type of attribute; wherein, the first type of parameter includes the area display mode characteristics of the at least one area; and the second type of parameter includes the data display mode characteristics of the data in the at least one area.
[0086] The present invention also provides an electronic device, which includes a processor and a memory connected to the processor. The memory is used to store computer program data, and the processor is used to execute the computer program data to implement the above-described implementation method of the present invention.
[0087] The application message pop-up implementation method provided by this invention can be applied to electronic devices, including mobile phones, tablets, desktop computers, laptops, handheld computers, ultra-mobile personal computers (UMPCs), netbooks, as well as cellular phones, personal digital assistants (PDAs), artificial intelligence (AI) devices, and other electronic devices with image storage capabilities. This invention does not impose any special limitations on the specific form of the electronic device.
[0088] The present invention also provides a computer-readable storage medium storing computer program data, which, when executed by a processor, is used to implement any of the above-described implementation methods of the present invention.
[0089] The application message pop-up implementation method provided by this invention, if implemented as a software functional unit and sold or used as an independent product, can be stored in an executable computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a computer software product. This computer software product is stored in a computer-readable storage medium and includes several instructions to cause a processor of an electronic device (such as the CPU of a desktop computer, the SOC of a mobile phone, etc.) to execute all or part of the steps of the methods described in the embodiments of this invention. The computer-readable storage medium can be a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or any other medium capable of storing computer program data.
[0090] The application message pop-up implementation method, device, electronic device and storage medium provided by the present invention have excellent versatility and can theoretically be applied to all products developed based on WinForm.
[0091] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0092] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for implementing an application message pop-up, characterized in that, Includes the following steps: Define the form as a message pop-up carrier, and the form includes at least one area; In response to the first type of parameter, set the first type of attribute of the at least one zone; In response to the second type of parameter, set the second type of attribute of the data in the at least one zone; Display the form based on the first type of attribute and the second type of attribute; The first type of parameters includes the display mode characteristics of the at least one area, and the second type of parameters includes the data display mode characteristics of the data in the at least one area; When the at least one area is a message area, the first type of attribute includes the width and height attributes of the message area, and the second type of attribute includes the message display attributes of the message area; displaying the window according to the first type of attribute and the second type of attribute includes: calculating the expected width and expected height of the area required to display the message; using the calculated expected width as a reference, automatically wrapping the portion of the displayed message that exceeds the expected width; displaying the automatically wrapped displayed message in the message area; adjusting the size of the window and / or at least one area other than the message area in the at least one area according to the actual size of the message area; The calculation of the expected width and expected height of the area required to display the message includes: setting a preset aspect ratio of the message area, which represents the ratio of the number of cells in each row to the number of rows in the message area; displaying the original message in a message control; and determining the expected width and expected height that satisfy the preset aspect ratio based on the message control. The step of displaying the original display message in the message control and determining the expected width and expected height that satisfy the preset aspect ratio based on the message control includes: The message area uses a message control, and cells with width and height expressed in pixels are set within the message area, with no gaps between the cells. The original display message is displayed in the message control, and the width and height of the message control are converted from pixels to cells, thereby obtaining the number of cells xCell and the number of rows yCell for each row of the display message in the message control. The xCell is assigned as the initial value to the expected width, and the yCell is assigned as the initial value to the expected height. The ratio of the expected width to the expected height after assigning the initial values is calculated, and it is determined that: if it is less than or equal to the preset aspect ratio, the expected width and the expected height are output; if it is greater than the preset aspect ratio, the expected width and the expected height are cyclically calculated for line breaks until the condition of being less than or equal to the preset aspect ratio is met, and then the current expected width and the expected height are output.
2. The method for implementing an application message pop-up window according to claim 1, characterized in that, The step of cyclically performing line break calculations on the expected width and expected height until the condition of being less than or equal to the preset aspect ratio is met, and then outputting the current expected width and expected height, includes: a. Increment the estimated height by 1 to reassign the estimated height; b. Divide xCell by the reassigned expected height, and reassign the result to the expected width; c. Determine the ratio of the reassigned expected width to the reassigned expected height. If it is less than or equal to the preset aspect ratio, output the reassigned expected width and the reassigned expected height. If it is greater than the preset aspect ratio, repeat step ac.
3. The method for implementing an application message pop-up window according to claim 1, characterized in that, The step of automatically wrapping the portion of the displayed message that exceeds the calculated expected width, based on the calculated expected width, includes: Based on the calculated expected width, calculate the maximum number of bytes that each line of the message area can hold; Extract several message lines based on the carriage return and line feed characters in the original displayed message; For each of the message lines, a formatting process is performed to automatically wrap any portion that exceeds the expected width.
4. The method for implementing an application message pop-up window according to claim 3, characterized in that, The step of performing formatting processing on each of the message lines, automatically wrapping any portion exceeding the expected width, includes: A. Extract the first truncated string from the starting character position of the current message line using the first truncating method; B. Summing up the number of bytes in each of the first extracted strings gives the total number of bytes; C. If the total number of bytes is less than the maximum number of bytes, repeat steps AC; otherwise, proceed to step D. D. Subtract the number of bytes in the first extracted string from the total number of bytes, and reassign the result to the total number of bytes; E. Extract a second substring from the current first substring using the second substring extraction method; F. Based on the total number of bytes after reassignment, add the number of bytes of each of the second truncated strings to obtain the total number of bytes to be accumulated; G. If the total number of bytes to be accumulated is less than the maximum number of bytes, then repeat step EG; otherwise, proceed to step H. H. Add a newline character after the current second truncated string, and take the next character position after the newline as the new starting character position. Repeat step AH until the current message line is processed.
5. The method for implementing an application message pop-up window according to claim 4, characterized in that, The first truncation method is to truncate using spaces, and the second truncation method is to truncate using punctuation marks.
6. The method for implementing an application message pop-up window according to claim 4, characterized in that, Also includes: If it is determined that the current first truncated string or the current second truncated string is a string generated by abnormal input, then the string is truncated at the position where the maximum number of bytes is reached and a newline character is added. The position of the next character after the newline and the remaining characters of the abnormal string is taken as the new starting character position.
7. The method for implementing an application message pop-up window according to any one of claims 1-6, characterized in that, When the at least one area is a button area, the first type of attribute includes the width and height attributes of the button area, and the second type of attribute includes the button name display attribute of the button area.
8. A device for implementing an application message pop-up, characterized in that, include: The configuration module is used to define a form as a message pop-up carrier, wherein the form includes at least one area; A processing and setting module is used to set the first type of attribute of the at least one area in response to the first type of parameter; In response to the second type of parameter, set the second type of attribute of the data in the at least one zone; The display module is used to display the form according to the first type of attribute and the second type of attribute; The first type of parameters includes the display mode characteristics of the at least one area, and the second type of parameters includes the data display mode characteristics of the data in the at least one area; When the at least one area is a message area, the first type of attribute includes the width and height attributes of the message area, and the second type of attribute includes the message display attributes of the message area; the display module is further configured to calculate the expected width and expected height of the area required to display the message; based on the calculated expected width, automatically wrap the portion of the displayed message that exceeds the expected width; display the automatically wrapped displayed message in the message area; and adjust the size of the window and / or at least one area other than the message area according to the actual size of the message area; The display module is further configured to set a preset aspect ratio of the message area, representing the ratio of the number of cells in each row to the number of rows in the message area; display the original display message in a message control; and determine the expected width and the expected height that satisfy the preset aspect ratio based on the message control. The display module is further configured to enable the message area to use a message control, set cells with width and height expressed in pixels within the message area, and ensure no gaps between the cells; display the original display message in the message control, and convert the width and height of the message control from pixels to cells, thereby obtaining the number of cells xCell and the number of rows yCell for each row of the display message in the message control; assign xCell as the initial value to the expected width, and yCell as the initial value to the expected height; calculate the ratio of the expected width to the expected height after assigning the initial values, and determine: if it is less than or equal to the preset aspect ratio, output the expected width and the expected height; if it is greater than the preset aspect ratio, perform line wrapping calculations on the expected width and the expected height repeatedly until the condition of being less than or equal to the preset aspect ratio is met, and then output the current expected width and the expected height.
9. An electronic device, characterized in that, The electronic device includes a processor and a memory connected to the processor, the memory being used to store computer program data, and the processor being used to execute the computer program data to implement the implementation method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program data, which, when executed by a processor, is used to implement the implementation method according to any one of claims 1-7.
Citation Information
Patent Citations
Method and system for enabling character size to adapt to display of languages of various countries
CN106095374A