Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.8 KiB

  1. /****************************************************************************\
  2. * edmlonce.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * dec 1990 mikeke from win30
  7. \****************************************************************************/
  8. #include "precomp.h"
  9. #pragma hdrstop
  10. /***************************************************************************\
  11. * MLCreate
  12. *
  13. * Creates the edit control for the window hwnd by allocating memory as
  14. * required from the application's heap. Notifies parent if no memory error
  15. * (after cleaning up if needed). Returns TRUE if no error else return s
  16. * -1.
  17. *
  18. * History:
  19. \***************************************************************************/
  20. LONG MLCreate(
  21. PED ped,
  22. LPCREATESTRUCT lpCreateStruct)
  23. {
  24. LONG windowStyle;
  25. LPWSTR lpszName;
  26. /*
  27. * Get values from the window instance data structure and put them in
  28. * the ped so that we can access them easier.
  29. */
  30. windowStyle = ped->pwnd->style;
  31. /*
  32. * Do the standard creation stuff.
  33. */
  34. if (!ECCreate(ped, windowStyle)) {
  35. return -1;
  36. }
  37. /*
  38. * Allocate line start array in local heap and lock it down.
  39. */
  40. ped->chLines = (LPICH)UserLocalAlloc(HEAP_ZERO_MEMORY, 2 * sizeof(int));
  41. if (ped->chLines == NULL) {
  42. return -1;
  43. }
  44. /*
  45. * Call it one line of text.
  46. */
  47. ped->cLines = 1;
  48. /*
  49. * If app wants WS_VSCROLL or WS_HSCROLL, it automatically gets
  50. * AutoVScroll or AutoHScroll.
  51. */
  52. if ((windowStyle & ES_AUTOVSCROLL) || (windowStyle & WS_VSCROLL)) {
  53. ped->fAutoVScroll = 1;
  54. }
  55. if (ped->format != ES_LEFT) {
  56. /*
  57. * If user wants right or center justified text, then we turn off
  58. * AUTOHSCROLL and WS_HSCROLL since non-left styles don't make sense
  59. * otherwise.
  60. */
  61. windowStyle &= ~WS_HSCROLL;
  62. ClearWindowState(ped->pwnd, WFHSCROLL);
  63. ped->fAutoHScroll = FALSE;
  64. } else if (windowStyle & WS_HSCROLL) {
  65. ped->fAutoHScroll = TRUE;
  66. }
  67. ped->fWrap = (!ped->fAutoHScroll && !(windowStyle & WS_HSCROLL));
  68. /*
  69. * Max # chars we will allow user to enter.
  70. */
  71. ped->cchTextMax = MAXTEXT;
  72. /*
  73. * Set the default font to be the system font.
  74. */
  75. ECSetFont(ped, NULL, FALSE);
  76. /*
  77. * Set the window text if needed and notify parent if not enough memory to
  78. * set the initial text.
  79. */
  80. if ((ULONG_PTR)lpCreateStruct->lpszName > gHighestUserAddress) {
  81. lpszName = REBASEPTR(ped->pwnd, (PVOID)lpCreateStruct->lpszName);
  82. } else {
  83. lpszName = (LPWSTR)lpCreateStruct->lpszName;
  84. }
  85. if (!ECSetText(ped, (LPSTR)lpszName)) {
  86. return -1;
  87. }
  88. return TRUE;
  89. }