Changeset 105 for trunk/src/helpers/dialog.c
- Timestamp:
- Sep 27, 2001, 10:29:02 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dialog.c
r103 r105 48 48 #define INCL_WINDIALOGS 49 49 #define INCL_WININPUT 50 #define INCL_WINSTATICS 50 51 #define INCL_WINBUTTONS 51 #define INCL_WIN STATICS52 #define INCL_WINENTRYFIELDS 52 53 #define INCL_WINSYS 53 54 … … 70 71 #include "helpers\stringh.h" 71 72 #include "helpers\winh.h" 73 #include "helpers\xstring.h" 72 74 73 75 /* … … 2131 2133 2132 2134 /* 2135 *@@ cmnTextEntryBox: 2136 * common dialog for entering a text string. 2137 * The dialog has a descriptive text on top 2138 * with an entry field below and "OK" and "Cancel" 2139 * buttons. 2140 * 2141 * The string from the user is returned in a 2142 * new buffer, which must be free'd by the caller. 2143 * Returns NULL if the user pressed "Cancel". 2144 * 2145 * fl can be any combination of the following 2146 * flags: 2147 * 2148 * -- TEBF_REMOVETILDE: tilde ("~") characters 2149 * are removed from pcszTitle before setting 2150 * the title. Useful for reusing menu item 2151 * texts. 2152 * 2153 * -- TEBF_REMOVEELLIPSE: ellipse ("...") strings 2154 * are removed from pcszTitle before setting 2155 * the title. Useful for reusing menu item 2156 * texts. 2157 * 2158 * -- TEBF_SELECTALL: the default text in the 2159 * entry field is initially highlighted. 2160 * 2161 *@@added V0.9.15 (2001-09-14) [umoeller] 2162 */ 2163 2164 PSZ dlghTextEntryBox(HWND hwndOwner, 2165 const char *pcszTitle, // in: dlg title 2166 const char *pcszDescription, // in: descriptive text above entry field 2167 const char *pcszDefault, // in: default text for entry field or NULL 2168 const char *pcszOK, // in: "OK" string 2169 const char *pcszCancel, // in: "Cancel" string 2170 ULONG ulMaxLen, // in: maximum length for entry 2171 ULONG fl, // in: TEBF_* flags 2172 const char *pcszFont) // in: font (e.g. "9.WarpSans") 2173 { 2174 CONTROLDEF 2175 Static = { 2176 WC_STATIC, 2177 NULL, 2178 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_WORDBREAK, 2179 -1, 2180 CTL_COMMON_FONT, 2181 0, 2182 { 300, SZL_AUTOSIZE }, // size 2183 5 // spacing 2184 }, 2185 Entry = { 2186 WC_ENTRYFIELD, 2187 NULL, 2188 WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_MARGIN | ES_AUTOSCROLL, 2189 999, 2190 CTL_COMMON_FONT, 2191 0, 2192 { 300, 20 }, // size 2193 5 // spacing 2194 }, 2195 OKButton = { 2196 WC_BUTTON, 2197 NULL, 2198 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT, 2199 DID_OK, 2200 CTL_COMMON_FONT, 2201 0, 2202 { 100, 30 }, // size 2203 5 // spacing 2204 }, 2205 CancelButton = { 2206 WC_BUTTON, 2207 NULL, 2208 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, 2209 DID_CANCEL, 2210 CTL_COMMON_FONT, 2211 0, 2212 { 100, 30 }, // size 2213 5 // spacing 2214 }; 2215 DLGHITEM DlgTemplate[] = 2216 { 2217 START_TABLE, 2218 START_ROW(0), 2219 CONTROL_DEF(&Static), 2220 START_ROW(0), 2221 CONTROL_DEF(&Entry), 2222 START_ROW(0), 2223 CONTROL_DEF(&OKButton), 2224 CONTROL_DEF(&CancelButton), 2225 END_TABLE 2226 }; 2227 2228 HWND hwndDlg = NULLHANDLE; 2229 PSZ pszReturn = NULL; 2230 XSTRING strTitle; 2231 2232 xstrInitCopy(&strTitle, pcszTitle, 0); 2233 2234 if (fl & (TEBF_REMOVEELLIPSE | TEBF_REMOVETILDE)) 2235 { 2236 ULONG ulOfs; 2237 if (fl & TEBF_REMOVEELLIPSE) 2238 { 2239 ulOfs = 0; 2240 while (xstrFindReplaceC(&strTitle, 2241 &ulOfs, 2242 "...", 2243 "")) 2244 ; 2245 } 2246 2247 if (fl & TEBF_REMOVETILDE) 2248 { 2249 ulOfs = 0; 2250 while (xstrFindReplaceC(&strTitle, 2251 &ulOfs, 2252 "~", 2253 "")) 2254 ; 2255 } 2256 } 2257 2258 Static.pcszText = pcszDescription; 2259 2260 OKButton.pcszText = pcszOK; 2261 CancelButton.pcszText = pcszCancel; 2262 2263 if (NO_ERROR == dlghCreateDlg(&hwndDlg, 2264 hwndOwner, 2265 FCF_TITLEBAR | FCF_SYSMENU | FCF_DLGBORDER | FCF_NOBYTEALIGN, 2266 WinDefDlgProc, 2267 strTitle.psz, 2268 DlgTemplate, // DLGHITEM array 2269 ARRAYITEMCOUNT(DlgTemplate), 2270 NULL, 2271 pcszFont)) 2272 { 2273 HWND hwndEF = WinWindowFromID(hwndDlg, 999); 2274 winhCenterWindow(hwndDlg); 2275 winhSetEntryFieldLimit(hwndEF, ulMaxLen); 2276 if (pcszDefault) 2277 { 2278 WinSetWindowText(hwndEF, (PSZ)pcszDefault); 2279 if (fl & TEBF_SELECTALL) 2280 winhEntryFieldSelectAll(hwndEF); 2281 } 2282 WinSetFocus(HWND_DESKTOP, hwndEF); 2283 if (DID_OK == WinProcessDlg(hwndDlg)) 2284 pszReturn = winhQueryWindowText(hwndEF); 2285 2286 WinDestroyWindow(hwndDlg); 2287 } 2288 2289 xstrClear(&strTitle); 2290 2291 return (pszReturn); 2292 } 2293 2294 /* 2133 2295 *@@ dlghSetPrevFocus: 2134 2296 * "backward" function for rotating the focus … … 2246 2408 } 2247 2409 } 2248 2249 /*2250 *@@ MatchMnemonic:2251 * returns TRUE if the specified control matches2252 *2253 *2254 *@@added V0.9.9 (2001-03-17) [umoeller]2255 */2256 2410 2257 2411 /*
Note:
See TracChangeset
for help on using the changeset viewer.