mirror of
https://github.com/VincentWei/minigui-docs.git
synced 2025-10-20 04:55:01 +08:00
fix bad format
This commit is contained in:
@@ -26,7 +26,7 @@ Selected, Copy and Paste, etc.
|
||||
|
||||
Except the differences described above, the styles, messages and notification
|
||||
codes of the three types of edit box control classes are general similar, with
|
||||
only a little differences. Figure 1 shows the running effect of the three types
|
||||
only a little differences. Fig 22.1 shows the running effect of the three types
|
||||
of edit boxes.
|
||||
|
||||
|
||||
@@ -201,230 +201,277 @@ operations of edit box control, such as copy:
|
||||
- `CTRL+X`: Cut text of edit box to clipboard
|
||||
|
||||
`EM_COPYTOCB` message is used to copy the currently selected text of an edit
|
||||
box control to the clipboard, as `CTRL+C` operation:
|
||||
box control to the clipboard, as <CTRL+C> operation:
|
||||
|
||||
```cpp
|
||||
SendMessage (hwndEdit, EM_COPYTOCB, 0, 0);
|
||||
```
|
||||
|
||||
`EM_CUTTOCB` message is used to cut the currently selected text of an edit box
|
||||
control to the clipboard, as `CTRL+X` operation:
|
||||
|
||||
`CODE{"cpp"}`%
|
||||
`SendMessage` (hwndEdit, `EM_CUTTOCB`, 0, 0);
|
||||
```
|
||||
|
||||
EM_INSERTCBTEXT message is used to copy the text on the clipboard to an edit box, as `CTRL+V` operation:
|
||||
control to the clipboard, as <CTRL+X> operation:
|
||||
|
||||
```cpp
|
||||
`SendMessage` (hwndEdit, `EM_INSERTCBTEXT`, 0, 0);
|
||||
SendMessage (hwndEdit, EM_CUTTOCB, 0, 0);
|
||||
```
|
||||
|
||||
### 22.2.4 Setting/Getting Properties of Line Height and Others
|
||||
`EM_INSERTCBTEXT` message is used to copy the text on the clipboard to an edit
|
||||
box, as <CTRL+V> operation:
|
||||
|
||||
```cpp
|
||||
SendMessage (hwndEdit, EM_INSERTCBTEXT, 0, 0);
|
||||
```
|
||||
|
||||
### Setting/Getting Properties of Line Height and Others
|
||||
|
||||
Row height here represents the height of single line in wrapped display style.
|
||||
|
||||
EM_GETLINEHEIGHT message is used to get the row height of an edit box:
|
||||
`EM_GETLINEHEIGHT` message is used to get the row height of an edit box:
|
||||
|
||||
```cpp
|
||||
int `line_height;`
|
||||
`line_height` = `SendMessage` (hwndEdit, `EM_GETLINEHEIGHT`, 0, 0);
|
||||
int line_height;
|
||||
line_height = SendMessage (hwndEdit, EM_GETLINEHEIGHT, 0, 0);
|
||||
```
|
||||
|
||||
EM_SETLINEHEIGHT message is used to set the row height, If success, return old line height value, otherwise return –1:
|
||||
`EM_SETLINEHEIGHT` message is used to set the row height, If success, return
|
||||
old line height value, otherwise return –1:
|
||||
|
||||
```cpp
|
||||
int `line_height;`
|
||||
`SendMessage` (hwndEdit, `EM_SETLINEHEIGHT`, `line_height,` 0);
|
||||
int line_height;
|
||||
SendMessage (hwndEdit, EM_SETLINEHEIGHT, line_height, 0);
|
||||
```
|
||||
|
||||
***
|
||||
It should be noted that it is preferred to use EM_SETLINEHEIGHT message before setting text of an edit box, because reset row height will redraw the whole content of the edit box.
|
||||
It should be noted that it is preferred to use `EM_SETLINEHEIGHT` message
|
||||
before setting text of an edit box, because reset row height will redraw the
|
||||
whole content of the edit box.
|
||||
***
|
||||
|
||||
EM_GETLINECOUNT message is used to get the number of rows:
|
||||
`EM_GETLINECOUNT` message is used to get the number of rows:
|
||||
|
||||
```cpp
|
||||
int `line_count;`
|
||||
`line_count` = `SendMessage` (hwndEdit, `EM_GETLINECOUNT`, 0, 0);
|
||||
int line_count;
|
||||
line_count = SendMessage (hwndEdit, EM_GETLINECOUNT, 0, 0);
|
||||
```
|
||||
|
||||
Row herein represents a single line in wrapped display style.
|
||||
|
||||
### 22.2.5 Setting Limit of Text
|
||||
### Setting Limit of Text
|
||||
|
||||
Sending EM_LIMITTEXT to an edit box can set the text upper limit in bytes of an edit box:
|
||||
Sending `EM_LIMITTEXT` to an edit box can set the text upper limit in bytes of
|
||||
an edit box:
|
||||
|
||||
```cpp
|
||||
`SendMessage` (hwndEdit, `EM_LIMITTEXT`, 10, 0L);
|
||||
SendMessage (hwndEdit, EM_LIMITTEXT, 10, 0L);
|
||||
```
|
||||
|
||||
The message above will make that only 10 bytes of characters can be input to the edit box.
|
||||
The message above will make that only 10 bytes of characters can be input to
|
||||
the edit box.
|
||||
|
||||
### 22.2.6 Setting or Canceling Read-only Status
|
||||
### Setting or Canceling Read-only Status
|
||||
|
||||
Using EM_SETREADONLY message and passing TRUE for wParam, the edit box will be set in read-only status, and passing FALSE for wParam will make the edit box be set in normal editable status.
|
||||
Using `EM_SETREADONLY` message and passing `TRUE` for `wParam`, the edit box
|
||||
will be set in read-only status, and passing `FALSE` for `wParam` will make the
|
||||
edit box be set in normal editable status.
|
||||
|
||||
### 22.2.7 Setting/Getting Password Character
|
||||
### Setting/Getting Password Character
|
||||
|
||||
By default, MiniGUI uses asterisks (*) to display the characters input in a password edit box. However, we can use the EM_SETPASSWORDCHAR message to change the password character:
|
||||
By default, MiniGUI uses asterisks (*) to display the characters input in a
|
||||
password edit box. However, we can use the `EM_SETPASSWORDCHAR` message to
|
||||
change the password character:
|
||||
|
||||
```cpp
|
||||
`SendMessage` (hwndEdit, `EM_SETPASSWORDCHAR`, ‘%’, 0L);
|
||||
SendMessage (hwndEdit, EM_SETPASSWORDCHAR, ‘%’, 0L);
|
||||
```
|
||||
|
||||
The message above will change the password character to be ‘%’.
|
||||
|
||||
Using EM_GETPASSWORDCHAR message would get the current password character.
|
||||
Using `EM_GETPASSWORDCHAR` message would get the current password character.
|
||||
|
||||
***
|
||||
[Prompt] Password character only can be set ASCII code which can be displayed.
|
||||
***
|
||||
|
||||
Note that TEXTEDIT control does not carry out EM_SETPASSWORDCHAR and EM_GETPASSWORDCHAR messages.
|
||||
Note that `TEXTEDIT` control does not carry out `EM_SETPASSWORDCHAR` and
|
||||
`EM_GETPASSWORDCHAR` messages.
|
||||
|
||||
### 22.2.8 Setting Title and Tip Text
|
||||
### Setting Title and Tip Text
|
||||
|
||||
When SLEDIT has ES_TIP styles, you can set tip text of the edit box using EM_SETTIPTEXT message, and get tip text of edit box using EM_GETTIPTEXT message.
|
||||
When `SLEDIT` has `ES_TIP` styles, you can set tip text of the edit box using
|
||||
`EM_SETTIPTEXT` message, and get tip text of edit box using `EM_GETTIPTEXT`
|
||||
message.
|
||||
|
||||
```cpp
|
||||
int len;
|
||||
char *tip_text;
|
||||
`SendMessage` (hwndEdit, `EM_SETTIPTEXT`, len, (LPARAM)tip_text);
|
||||
SendMessage (hwndEdit, EM_SETTIPTEXT, len, (LPARAM)tip_text);
|
||||
```
|
||||
|
||||
Here lParam parameter specifies tip text string, wParam parameter specifies the length of the string; if tip_text is ended with ’\0’, wParam can be set to -1, if wParam is 0, tip_text can be NULL. EM_GETTIPTEXT message will return the current tip text string:
|
||||
Here `lParam` parameter specifies tip text string, `wParam` parameter specifies
|
||||
the length of the string; if `tip_text` is ended with ’\0’, `wParam` can be set
|
||||
to -1, if `wParam` is 0, `tip_text` can be `NULL`. `EM_GETTIPTEXT` message will
|
||||
return the current tip text string:
|
||||
|
||||
```cpp
|
||||
int len;
|
||||
char `tip_text[len+1];`
|
||||
`SendMessage` (hwndEdit, `EM_GETTIPTEXT`, len, (LPARAM)tip_text);
|
||||
char tip_text[len+1];
|
||||
SendMessage (hwndEdit, EM_GETTIPTEXT, len, (LPARAM)tip_text);
|
||||
```
|
||||
|
||||
Here lParam specifies the buffer to store the tip text string; wParam specifies the length of the string that can be stored in buffer (not including ’\0’).
|
||||
Here `lParam` specifies the buffer to store the tip text string; `wParam`
|
||||
specifies the length of the string that can be stored in buffer (not including
|
||||
’\0’).
|
||||
|
||||
When TEXTEDIT control has ES_TITLE style, you can use EM_SETTITLETEXT message to set the title text of the edit box, and use EM_GETTITLETEXT message to get title text of edit box:
|
||||
When `TEXTEDIT` control has `ES_TITLE` style, you can use `EM_SETTITLETEXT`
|
||||
message to set the title text of the edit box, and use `EM_GETTITLETEXT`
|
||||
message to get title text of edit box:
|
||||
|
||||
|
||||
```cpp
|
||||
int len;
|
||||
char *title_text;
|
||||
`SendMessage` (hwndEdit, `EM_SETTITLETEXT`, len, (LPARAM)title_text);
|
||||
SendMessage (hwndEdit, EM_SETTITLETEXT, len, (LPARAM)title_text);
|
||||
```
|
||||
|
||||
Here lParam parameter specifies title text string, wParam parameter specifies the length of the string; if tip_text is ended with ’\0’, wParam can be set as -1, if wParam is 0, tip_text can be NULL. EM_GETTIPTEXT message will return current title text string.
|
||||
Here `lParam` parameter specifies title text string, `wParam` parameter
|
||||
specifies the length of the string; if `tip_text` is ended with ’\0’, `wParam`
|
||||
can be set as -1, if `wParam` is 0, `tip_text` can be `NULL`. `EM_GETTIPTEXT`
|
||||
message will return current title text string.
|
||||
|
||||
```cpp
|
||||
int len;
|
||||
char `title_text[len+1];`
|
||||
`SendMessage` (hwndEdit, `EM_GETTITLETEXT`, len, (LPARAM)title_text);
|
||||
char title_text[len+1];
|
||||
SendMessage (hwndEdit, EM_GETTITLETEXT, len, (LPARAM)title_text);
|
||||
```
|
||||
|
||||
Here lParam parameter specifies the buffer to store the title text string; wParam parameter specifies the length of string that can be stored in the buffer (not including ’\0’).
|
||||
Here `lParam` parameter specifies the buffer to store the title text string;
|
||||
`wParam` parameter specifies the length of string that can be stored in the
|
||||
buffer (not including ’\0’).
|
||||
|
||||
### 22.2.9 Setting End of Line Symbol
|
||||
### Setting End of Line Symbol
|
||||
|
||||
In normal situation, TEXTEDIT edit box will not display linefeed symbol. If using EM_SETLFDISPCHAR message sets the display symbol for linefeeds, then edit box will display linefeed as the set display symbol.
|
||||
In normal situation, `TEXTEDIT` edit box will not display linefeed symbol. If
|
||||
using `EM_SETLFDISPCHAR` message sets the display symbol for linefeeds, then
|
||||
edit box will display linefeed as the set display symbol.
|
||||
|
||||
```cpp
|
||||
char `disp_char;`
|
||||
`SendMessage` (hwndEdit, `EM_SETLFDISPCHAR`, 0, `disp_char);`
|
||||
char disp_char;
|
||||
SendMessage (hwndEdit, EM_SETLFDISPCHAR, 0, disp_char);
|
||||
```
|
||||
|
||||
Here lParam parameter is the display symbol to be set for linefeed.
|
||||
Here `lParam` parameter is the display symbol to be set for linefeed.
|
||||
|
||||
For example, if you want to display linefeed with “*”, you can set as follows:
|
||||
For example, if you want to display linefeed with “*”, you can set as follows:
|
||||
|
||||
```cpp
|
||||
`SendMessage` (hwndEdit, `EM_SETLFDISPCHAR`, 0, ‘*’);
|
||||
SendMessage (hwndEdit, EM_SETLFDISPCHAR, 0, ‘*’);
|
||||
```
|
||||
|
||||
### 22.2.10 Setting End of Line
|
||||
### Setting End of Line
|
||||
|
||||
In default situation, linefeed symbol of TEXTEDIT edit box is ’\n’. You can use EM_SETLINESEP message to change the line feed used by edit box.
|
||||
In default situation, linefeed symbol of `TEXTEDIT` edit box is ’\n’. You can
|
||||
use `EM_SETLINESEP` message to change the line feed used by edit box.
|
||||
|
||||
```cpp
|
||||
char `sep_char;`
|
||||
`SendMessage` (hwndEdit, `EM_SETLINESEP`, 0, `sep_char);`
|
||||
char sep_char;
|
||||
SendMessage (hwndEdit, EM_SETLINESEP, 0, sep_char);
|
||||
```
|
||||
|
||||
Here lParam parameter is the linefeed symbol to be set.
|
||||
Here `lParam` parameter is the linefeed symbol to be set.
|
||||
|
||||
For example, if you want to indicate the line is end with TAB character, you can set as follows:
|
||||
For example, if you want to indicate the line is end with `TAB` character, you
|
||||
can set as follows:
|
||||
|
||||
```cpp
|
||||
`SendMessage` (hwndEdit, `EM_SETLINESEP`, 0, ‘\t’);
|
||||
SendMessage (hwndEdit, EM_SETLINESEP, 0, ‘\t’);
|
||||
```
|
||||
|
||||
### 22.2.11 Getting Paragraphs Information
|
||||
### Getting Paragraphs Information
|
||||
|
||||
EM_GETNUMOFPARAGRAPHS message is used to get the number of paragraphs.
|
||||
`EM_GETNUMOFPARAGRAPHS` message is used to get the number of paragraphs.
|
||||
|
||||
```cpp
|
||||
int num;
|
||||
num = `SendMessage` (hwnd, `EM_GETNUMOFPARAGRAPHS`, 0, 0);
|
||||
num = SendMessage (hwnd, EM_GETNUMOFPARAGRAPHS, 0, 0);
|
||||
```
|
||||
|
||||
EM_GETPARAGRAPHLENGTH message is used to get the length of a specified paragraph。If success, return the length of a specified paragraph, otherwise return –1.
|
||||
`EM_GETPARAGRAPHLENGTH` message is used to get the length of a specified
|
||||
paragraph。If success, return the length of a specified paragraph, otherwise
|
||||
return –1.
|
||||
|
||||
```cpp
|
||||
int len;
|
||||
len = `SendMessage` (hwnd, `EM_GETPARAGRAPHLENGTH`, idx, 0);
|
||||
len = SendMessage (hwnd, EM_GETPARAGRAPHLENGTH, idx, 0);
|
||||
```
|
||||
|
||||
Here, wParam argument specifies the paragraph index.
|
||||
Here, `wParam` argument specifies the paragraph index.
|
||||
|
||||
EM_GETPARAGRAPHTEXT message is used to get the text of a specified paragraph. To show correct characters, it might adjust the number of characters can be copied appropriately.
|
||||
`EM_GETPARAGRAPHTEXT` message is used to get the text of a specified paragraph.
|
||||
To show correct characters, it might adjust the number of characters can be
|
||||
copied appropriately.
|
||||
|
||||
|
||||
```cpp
|
||||
`TEXTPOSINFO` info;
|
||||
TEXTPOSINFO info;
|
||||
unsigned char buff [32];
|
||||
|
||||
|
||||
info.start_pos = 5;
|
||||
info.copy_len = 10;
|
||||
info.buff = buff;
|
||||
info.paragraph_index = -1;
|
||||
|
||||
`SendMessage` (hwnd, `EM_GETPARAGRAPHTEXT`, &info, 0);
|
||||
SendMessage (hwnd, EM_GETPARAGRAPHTEXT, &info, 0);
|
||||
```
|
||||
|
||||
Here, info is a structure of TEXTPOSINFO type, and specifies the related information for the copied text, as follows:
|
||||
Here, info is a structure of `TEXTPOSINFO` type, and specifies the related
|
||||
information for the copied text, as follows:
|
||||
|
||||
```cpp
|
||||
typedef struct _TEXTPOSINFO {
|
||||
/*The index of paragraph, if value is -1,
|
||||
*it will take effect on the whole text.*/
|
||||
int `paragraph_index;`
|
||||
/*The beginning byte position can be copied to the buffer.*/
|
||||
int `start_pos;`
|
||||
/*The maximal number of bytes can be copied to the buffer.*/
|
||||
int `copy_len;`
|
||||
/*The pointer to a buffer receives the text.
|
||||
*Please make sure buffer size is more than the value of `copy_len.*/`
|
||||
char *buff;
|
||||
/*The index of paragraph, if value is -1,
|
||||
*it will take effect on the whole text.*/
|
||||
int paragraph_index;
|
||||
/*The beginning byte position can be copied to the buffer.*/
|
||||
int start_pos;
|
||||
/*The maximal number of bytes can be copied to the buffer.*/
|
||||
int copy_len;
|
||||
/*The pointer to a buffer receives the text.
|
||||
*Please make sure buffer size is more than the value of copy_len.*/
|
||||
char *buff;
|
||||
}TEXTPOSINFO;
|
||||
```
|
||||
|
||||
The member start_pos is the beginning byte position can be copied to the buffer. The member copy_len is the maximal number of bytes can be copied to the buffer. The member paragraph_index is the index of paragraph, if value is -1, it will take effect on the whole text. The member buff is the character buffer for saving the gotten text.
|
||||
The member `start_pos` is the beginning byte position can be copied to the
|
||||
buffer. The member `copy_len` is the maximal number of bytes can be copied to
|
||||
the buffer. The member `paragraph_index` is the index of paragraph, if value is
|
||||
-1, it will take effect on the whole text. The member buff is the character
|
||||
buffer for saving the gotten text.
|
||||
|
||||
## 22.3 Notification Codes of Edit Box
|
||||
## Notification Codes of Edit Box
|
||||
|
||||
The edit box has not ES_NOTIFY style, so any edit box can generate notification messages, as listed below:
|
||||
- EN_SETFOCUS: The edit box has received the input focus.
|
||||
- EN_KILLFOCUS: The edit box has lost the input focus.
|
||||
- EN_CHANGE: The content in the edit box has been altered.
|
||||
- EN_UPDATE: The content in the edit box has been altered after edit box received MSG_SETTEXT, EM_RESETCONTENT, or EM_SETLINEHEIGHT message.
|
||||
- EN_ENTER: The user has pressed the ENTER key in the edit box.
|
||||
- EN_MAXTEXT: The inserting text exceeds the maximum limitation of the edit box.
|
||||
- EN_DBLCLK: The edit control is double clicked with the left button of the mouse.
|
||||
- EN_CLICKED: The edit control is clicked with the left button of the mouse.
|
||||
The edit box has not `ES_NOTIFY` style, so any edit box can generate
|
||||
notification messages, as listed below:
|
||||
- `EN_SETFOCUS`: The edit box has received the input focus.
|
||||
- `EN_KILLFOCUS`: The edit box has lost the input focus.
|
||||
- `EN_CHANGE`: The content in the edit box has been altered.
|
||||
- `EN_UPDATE`: The content in the edit box has been altered after edit box
|
||||
received `MSG_SETTEXT`, `EM_RESETCONTENT`, or `EM_SETLINEHEIGHT` message.
|
||||
- `EN_ENTER`: The user has pressed the `ENTER` key in the edit box.
|
||||
- `EN_MAXTEXT`: The inserting text exceeds the maximum limitation of the edit
|
||||
box.
|
||||
- `EN_DBLCLK`: The edit control is double clicked with the left button of the
|
||||
mouse.
|
||||
- `EN_CLICKED`: The edit control is clicked with the left button of the mouse.
|
||||
|
||||
## 22.4 Sample Program
|
||||
## Sample Program
|
||||
|
||||
In the foregoing chapters, we have already seen the use of edit boxes. List 22.1 gives another example of edit boxes, this program copy the input of a single-line edit box to an automatic wrapped multiple-line edit box. Please refer to edit.c file of the demo program package mg-samples of this guide for the complete source code. Effect of running the program is shown in Figure.2.
|
||||
In the foregoing chapters, we have already seen the use of edit boxes. List 1
|
||||
gives another example of edit boxes, this program copy the input of a
|
||||
single-line edit box to an automatic wrapped multiple-line edit box. Please
|
||||
refer to edit.c file of the demo program package `mg-samples` of this guide for
|
||||
the complete source code. Effect of running the program is shown in Figure 2.
|
||||
|
||||
##### List 22.1 Example for using edit boxes
|
||||
|
||||
List 1 Example for using edit boxes
|
||||
|
||||
```cpp
|
||||
#include <stdio.h>
|
||||
@@ -437,149 +484,145 @@ In the foregoing chapters, we have already seen the use of edit boxes. List 22.1
|
||||
#include <minigui/control.h>
|
||||
|
||||
/* Define dialg template */
|
||||
static `DLGTEMPLATE` `DlgBoxInputChar` =
|
||||
static DLGTEMPLATE DlgBoxInputChar =
|
||||
{
|
||||
`WS_BORDER` | `WS_CAPTION`,
|
||||
`WS_EX_NONE`,
|
||||
0, 0, 400, 220,
|
||||
WS_BORDER | WS_CAPTION,
|
||||
WS_EX_NONE,
|
||||
0, 0, 400, 220,
|
||||
#ifdef _LANG_ZHCN
|
||||
"请键入字母",
|
||||
"请键入字母",
|
||||
#else
|
||||
"Please input letters",
|
||||
"Please input letters",
|
||||
#endif
|
||||
0, 0,
|
||||
4, `NULL`,
|
||||
0
|
||||
0, 0,
|
||||
4, NULL,
|
||||
0
|
||||
};
|
||||
|
||||
#define `IDC_CHAR` 100
|
||||
#define `IDC_CHARS` 110
|
||||
#define IDC_CHAR 100
|
||||
#define IDC_CHARS 110
|
||||
|
||||
static `CTRLDATA` `CtrlInputChar` [] =
|
||||
{
|
||||
{
|
||||
`CTRL_STATIC`,
|
||||
`WS_VISIBLE` ,
|
||||
10, 10, 380, 18,
|
||||
`IDC_STATIC`,
|
||||
static CTRLDATA CtrlInputChar [] =
|
||||
{
|
||||
{
|
||||
CTRL_STATIC,
|
||||
WS_VISIBLE ,
|
||||
10, 10, 380, 18,
|
||||
IDC_STATIC,
|
||||
#ifdef _LANG_ZHCN
|
||||
"请输入一个字母:",
|
||||
"请输入一个字母:",
|
||||
#else
|
||||
"Please input a letter:",
|
||||
"Please input a letter:",
|
||||
#endif
|
||||
0
|
||||
},
|
||||
{
|
||||
`CTRL_SLEDIT`,
|
||||
`WS_VISIBLE` | `WS_TABSTOP` | `WS_BORDER` | `ES_CENTER`,
|
||||
10, 40, 80, 25,
|
||||
`IDC_CHAR`,
|
||||
`NULL`,
|
||||
0
|
||||
},
|
||||
{
|
||||
`CTRL_MLEDIT`,
|
||||
`WS_VISIBLE` | `WS_BORDER` | `WS_VSCROLL` | `ES_BASELINE` | `ES_AUTOWRAP`,
|
||||
10, 80, 380, 70,
|
||||
`IDC_CHARS`,
|
||||
`NULL`,
|
||||
0
|
||||
},
|
||||
{
|
||||
`CTRL_BUTTON`,
|
||||
`WS_TABSTOP` | `WS_VISIBLE` | `BS_DEFPUSHBUTTON`,
|
||||
170, 160, 60, 25,
|
||||
`IDOK`,
|
||||
0
|
||||
},
|
||||
{
|
||||
CTRL_SLEDIT,
|
||||
WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_CENTER,
|
||||
10, 40, 80, 25,
|
||||
IDC_CHAR,
|
||||
NULL,
|
||||
0
|
||||
},
|
||||
{
|
||||
CTRL_MLEDIT,
|
||||
WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_BASELINE | ES_AUTOWRAP,
|
||||
10, 80, 380, 70,
|
||||
IDC_CHARS,
|
||||
NULL,
|
||||
0
|
||||
},
|
||||
{
|
||||
CTRL_BUTTON,
|
||||
WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,
|
||||
170, 160, 60, 25,
|
||||
IDOK,
|
||||
#ifdef _LANG_ZHCN
|
||||
"确定",
|
||||
"确定",
|
||||
#else
|
||||
"OK",
|
||||
"OK",
|
||||
#endif
|
||||
0
|
||||
}
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
static void `my_notif_proc` (HWND hwnd, int id, int nc, `DWORD` `add_data`)
|
||||
static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
|
||||
{
|
||||
unsigned char buff [256] = {0};
|
||||
if (id == `IDC_CHAR` && nc == `EN_CHANGE`) {
|
||||
/* Get the user input(the first character) of the single-line
|
||||
* edit box, and insert it to the multiple-line edit box
|
||||
*/
|
||||
`GetWindowText` (hwnd, buff, 4);
|
||||
/* Place the caret postion of the single-line edit box in front,
|
||||
*thus to overlap the old character
|
||||
*/
|
||||
`SendMessage` (hwnd, `EM_SETCARETPOS`, 0, 0);
|
||||
`SendMessage` (GetDlgItem (GetParent (hwnd), `IDC_CHARS`), `MSG_CHAR`, buff[0],
|
||||
0L);
|
||||
}
|
||||
else if (id == `IDC_CHARS` && nc == `EN_CHANGE`) {
|
||||
`GetWindowText` (hwnd, buff, 255);
|
||||
printf ("String: %s\n", buff);
|
||||
}
|
||||
}
|
||||
unsigned char buff [256] = {0};
|
||||
if (id == IDC_CHAR && nc == EN_CHANGE) {
|
||||
/* Get the user input(the first character) of the single-line
|
||||
* edit box, and insert it to the multiple-line edit box
|
||||
*/
|
||||
GetWindowText (hwnd, buff, 4);
|
||||
/* Place the caret postion of the single-line edit box in front,
|
||||
*thus to overlap the old character
|
||||
*/
|
||||
SendMessage (hwnd, EM_SETCARETPOS, 0, 0);
|
||||
SendMessage (GetDlgItem (GetParent (hwnd), IDC_CHARS), MSG_CHAR, buff[0], 0L);
|
||||
}
|
||||
else if (id == IDC_CHARS && nc == EN_CHANGE) {
|
||||
GetWindowText (hwnd, buff, 255);
|
||||
printf ("String: %s\n", buff);
|
||||
}
|
||||
}
|
||||
|
||||
static int `InputCharDialogBoxProc` (HWND `hDlg`, int message, `WPARAM`
|
||||
`wParam`, `LPARAM` `lParam`)
|
||||
static int InputCharDialogBoxProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static `PLOGFONT` `my_font;`
|
||||
`HWND` hwnd;
|
||||
static PLOGFONT my_font;
|
||||
HWND hwnd;
|
||||
|
||||
switch (message) {
|
||||
case `MSG_INITDIALOG`:
|
||||
`my_font` = `CreateLogFont` (NULL, "fmhei", "ISO8859-1",
|
||||
`FONT_WEIGHT_REGULAR`, `FONT_SLANT_ROMAN`, `FONT_FLIP_NIL`,
|
||||
`FONT_OTHER_NIL`, `FONT_UNDERLINE_NONE`, `FONT_STRUCKOUT_NONE`,
|
||||
20, 0);
|
||||
hwnd = `GetDlgItem` (hDlg, `IDC_CHAR`);
|
||||
/* Set the font of the single-line edit box to be a big font */
|
||||
`SetNotificationCallback` (hwnd, `my_notif_proc);`
|
||||
/* Simulate the press of `INSERT` key, and set the edit mode to be overlap mode
|
||||
*/
|
||||
`SendMessage` (hwnd, `MSG_KEYDOWN`, `SCANCODE_INSERT`, 0L);
|
||||
return 1;
|
||||
|
||||
case `MSG_CLOSE`:
|
||||
`EndDialog` (hDlg, `IDCANCEL`);
|
||||
break;
|
||||
|
||||
case `MSG_COMMAND`:
|
||||
switch (wParam) {
|
||||
case `IDOK`:
|
||||
case `IDCANCEL`:
|
||||
`DestroyLogFont` (my_font);
|
||||
`EndDialog` (hDlg, `wParam`);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
switch (message) {
|
||||
case MSG_INITDIALOG:
|
||||
my_font = CreateLogFont (NULL, "fmhei", "ISO8859-1",
|
||||
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_FLIP_NIL,
|
||||
FONT_OTHER_NIL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_NONE,
|
||||
20, 0);
|
||||
hwnd = GetDlgItem (hDlg, IDC_CHAR);
|
||||
/* Set the font of the single-line edit box to be a big font */
|
||||
SetNotificationCallback (hwnd, my_notif_proc);
|
||||
/* Simulate the press of INSERT key, and set the edit mode to be overlap mode */
|
||||
SendMessage (hwnd, MSG_KEYDOWN, SCANCODE_INSERT, 0L);
|
||||
return 1;
|
||||
|
||||
case MSG_CLOSE:
|
||||
EndDialog (hDlg, IDCANCEL);
|
||||
break;
|
||||
|
||||
case MSG_COMMAND:
|
||||
switch (wParam) {
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
DestroyLogFont (my_font);
|
||||
EndDialog (hDlg, wParam);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return DefaultDialogProc (hDlg, message, wParam, lParam);
|
||||
}
|
||||
|
||||
return `DefaultDialogProc` (hDlg, message, `wParam`, `lParam`);
|
||||
}
|
||||
|
||||
int `MiniGUIMain` (int argc, const char* argv[])
|
||||
int MiniGUIMain (int argc, const char* argv[])
|
||||
{
|
||||
|
||||
#ifdef _MGRM_PROCESSES
|
||||
`JoinLayer(NAME_DEF_LAYER` , "edit" , 0 , 0);
|
||||
JoinLayer(NAME_DEF_LAYER , "edit" , 0 , 0);
|
||||
#endif
|
||||
|
||||
#ifdef _LITE_VERSION
|
||||
if (!InitVectorialFonts ()) {
|
||||
printf ("InitVectorialFonts: error.\n");
|
||||
return 1;
|
||||
}
|
||||
if (!InitVectorialFonts ()) {
|
||||
printf ("InitVectorialFonts: error.\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
`DlgBoxInputChar.controls` = `CtrlInputChar`;
|
||||
`DialogBoxIndirectParam` (&DlgBoxInputChar, `HWND_DESKTOP`,
|
||||
`InputCharDialogBoxProc`, 0L);
|
||||
DlgBoxInputChar.controls = CtrlInputChar;
|
||||
DialogBoxIndirectParam (&DlgBoxInputChar, HWND_DESKTOP, InputCharDialogBoxProc, 0L);
|
||||
|
||||
#ifdef _LITE_VERSION
|
||||
`TermVectorialFonts` ();
|
||||
TermVectorialFonts ();
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef _LITE_VERSION
|
||||
@@ -589,7 +632,7 @@ return 0;
|
||||
|
||||

|
||||
|
||||
##### Figure 2 Effect of running the edit box example program
|
||||
Figure 2 Effect of running the edit box example program
|
||||
|
||||
----
|
||||
|
||||
|
Reference in New Issue
Block a user