Gets a string from the user Parameters: buf - buffer the string is written to. should be initialized to default value maxsize - the length of buf title - the title for the input window prompt - the prompt for the input box Returns: false if cancel was pressed on the dialog, else true If false returned, buf is unchanged
| 107 | // Returns: false if cancel was pressed on the dialog, else true |
| 108 | // If false returned, buf is unchanged |
| 109 | bool InputString(char *buf, int maxsize, char *title, char *prompt, CWnd *wnd) { |
| 110 | CEditLineDialog dlg(title, prompt, buf, 0, wnd); |
| 111 | |
| 112 | if (dlg.DoModal() == IDOK) { |
| 113 | strncpy(buf, (char *)dlg.GetText(), maxsize); |
| 114 | buf[maxsize - 1] = 0; // strncpy doesn't terminate if string is too long |
| 115 | return 1; |
| 116 | } else |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | // Gets a number from the user |
| 121 | // Parameters: n - filled in the with return value |
no test coverage detected