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.

2776 lines
93 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WUWIND.C
  8. * WOW32 16-bit User API support
  9. *
  10. * History:
  11. * Created 07-Mar-1991 by Jeff Parsons (jeffpar)
  12. * 12-FEB-92 mattfe changed WU32EnumTaskWindows to access 16 bit TDB
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. MODNAME(wuwind.c);
  17. // From wumsg.c [SendDlgItemMesssage caching]
  18. extern HWND hdlgSDIMCached ;
  19. // From wuman.c [Identify thunked system class WndProcs]
  20. extern WORD gUser16CS;
  21. // From wkman.c [hinst/hmod for user32]
  22. extern HANDLE ghInstanceUser32;
  23. // dwExStyle is used by the CreateWindow and CreateWindowEx thunks
  24. // so that they can use a common procedure (don't worry, the current
  25. // task cannot be preempted during its use)
  26. STATIC ULONG dwExStyle;
  27. // Some apps (DASHboard from HP) try to get PROGMAN to save its settings
  28. // in a funky way. This variable is used to help detect these guys.
  29. // Bobday 5/29/93
  30. HWND hwndProgman = (HWND)0;
  31. /*++
  32. void AdjustWindowRect(<lpRect>, <dwStyle>, <bMenu>)
  33. LPRECT <lpRect>;
  34. DWORD <dwStyle>;
  35. BOOL <bMenu>;
  36. The %AdjustWindowRect% function computes the required size of the window
  37. rectangle based on the desired client-rectangle size. The window rectangle
  38. can then be passed to the %CreateWindow% function to create a window whose
  39. client area is the desired size. A client rectangle is the smallest
  40. rectangle that completely encloses a client area. A window rectangle is the
  41. smallest rectangle that completely encloses the window. The dimensions of
  42. the resulting window rectangle depend on the window styles and on whether
  43. the window has a menu.
  44. <lpRect>
  45. Points to a %RECT% structure that contains the coordinates of the
  46. client rectangle.
  47. <dwStyle>
  48. Specifies the window styles of the window whose client rectangle
  49. is to be converted.
  50. <bMenu>
  51. Specifies whether the window has a menu.
  52. This function does not return a value.
  53. This function assumes a single menu row. If the menu bar wraps to two or
  54. more rows, the coordinates are incorrect.
  55. --*/
  56. ULONG FASTCALL WU32AdjustWindowRect(PVDMFRAME pFrame)
  57. {
  58. RECT t1;
  59. register PADJUSTWINDOWRECT16 parg16;
  60. GETARGPTR(pFrame, sizeof(ADJUSTWINDOWRECT16), parg16);
  61. WOW32VERIFY(GETRECT16(parg16->f1, &t1));
  62. AdjustWindowRect(
  63. &t1,
  64. LONG32(parg16->f2),
  65. BOOL32(parg16->f3)
  66. );
  67. PUTRECT16(parg16->f1, &t1);
  68. FREEARGPTR(parg16);
  69. RETURN(0);
  70. }
  71. /*++
  72. void AdjustWindowRectEx(<lpRect>, <dwStyle>, <bMenu>, <dwExStyle>)
  73. LPRECT <lpRect>;
  74. DWORD <dwStyle>;
  75. BOOL <bMenu>;
  76. DWORD <dwExStyle>;
  77. The %AdjustWindowRectEx% function computes the required size of the
  78. rectangle of a window with extended style based on the desired
  79. client-rectangle size. The window rectangle can then be passed to the
  80. %CreateWindowEx% function to create a window whose client area is the
  81. desired size.
  82. A client rectangle is the smallest rectangle that completely encloses a
  83. client area. A window rectangle is the smallest rectangle that completely
  84. encloses the window. The dimensions of the resulting window rectangle
  85. depends on the window styles and on whether the window has a menu.
  86. <lpRect>
  87. Points to a %RECT% structure that contains the coordinates of the
  88. client rectangle.
  89. <dwStyle>
  90. Specifies the window styles of the window whose client rectangle
  91. is to be converted.
  92. <bMenu>
  93. Specifies whether the window has a menu.
  94. <dwExStyle>
  95. Specifies the extended style of the window being created.
  96. This function does not return a value.
  97. This function assumes a single menu row. If the menu bar wraps to two or
  98. more rows, the coordinates are incorrect.
  99. --*/
  100. ULONG FASTCALL WU32AdjustWindowRectEx(PVDMFRAME pFrame)
  101. {
  102. RECT t1;
  103. register PADJUSTWINDOWRECTEX16 parg16;
  104. GETARGPTR(pFrame, sizeof(ADJUSTWINDOWRECTEX16), parg16);
  105. WOW32VERIFY(GETRECT16(parg16->f1, &t1));
  106. AdjustWindowRectEx(
  107. &t1,
  108. LONG32(parg16->f2),
  109. BOOL32(parg16->f3),
  110. DWORD32(parg16->f4)
  111. );
  112. PUTRECT16(parg16->f1, &t1);
  113. FREEARGPTR(parg16);
  114. RETURN(0);
  115. }
  116. /*++
  117. HWND ChildWindowFromPoint(<hwndParent>, <Point>)
  118. HWND <hwndParent>;
  119. POINT <Point>;
  120. The %ChildWindowFromPoint% function determines which, if any, of the child
  121. windows belonging to the given parent window contains the specified point.
  122. <hwndParent>
  123. Identifies the parent window.
  124. <Point>
  125. Specifies the client coordinates of the point to be tested.
  126. The return value identifies the child window that contains the point. It is
  127. NULL if the given point lies outside the parent window. If the point is
  128. within the parent window but is not contained within any child window, the
  129. handle of the parent window is returned.
  130. --*/
  131. ULONG FASTCALL WU32ChildWindowFromPoint(PVDMFRAME pFrame)
  132. {
  133. ULONG ul;
  134. POINT t2;
  135. register PCHILDWINDOWFROMPOINT16 parg16;
  136. GETARGPTR(pFrame, sizeof(CHILDWINDOWFROMPOINT16), parg16);
  137. COPYPOINT16(parg16->f2, t2);
  138. ul = GETHWND16(ChildWindowFromPoint(HWND32(parg16->f1), t2));
  139. FREEARGPTR(parg16);
  140. RETURN(ul);
  141. }
  142. /*++
  143. HWND ChildWindowFromPointEx(<hwndParent>, <Point>, <Flags>)
  144. HWND <hwndParent>;
  145. POINT <Point>;
  146. UINT <Flags>;
  147. The %ChildWindowFromPointEx% function determines which, if any, of the child
  148. windows belonging to the given parent window contains the specified point.
  149. <hwndParent>
  150. Identifies the parent window.
  151. <Point>
  152. Specifies the client coordinates of the point to be tested.
  153. <Flags>
  154. Skipping flags
  155. The return value identifies the child window that contains the point. It is
  156. NULL if the given point lies outside the parent window. If the point is
  157. within the parent window but is not contained within any child window, the
  158. handle of the parent window is returned.
  159. --*/
  160. ULONG FASTCALL WU32ChildWindowFromPointEx(PVDMFRAME pFrame)
  161. {
  162. ULONG ul;
  163. POINT pt32;
  164. register PCHILDWINDOWFROMPOINTEX16 parg16;
  165. GETARGPTR(pFrame, sizeof(CHILDWINDOWFROMPOINTEX16), parg16);
  166. COPYPOINT16(parg16->pt, pt32);
  167. ul = GETHWND16(ChildWindowFromPointEx(HWND32(parg16->hwnd), pt32, DWORD32(parg16->wFlags)));
  168. FREEARGPTR(parg16);
  169. RETURN(ul);
  170. }
  171. /*++
  172. HWND CreateWindow(<lpClassName>, <lpWindowName>, <dwStyle>, <X>, <Y>,
  173. <nWidth>, <nHeight>, <hwndParent>, <hMenu>, <hInstance>, <lpParam>)
  174. LPSTR <lpClassName>;
  175. LPSTR <lpWindowName>;
  176. DWORD <dwStyle>;
  177. int <X>;
  178. int <Y>;
  179. int <nWidth>;
  180. int <nHeight>;
  181. HWND <hwndParent>;
  182. HMENU <hMenu>;
  183. HANDLE <hInstance>;
  184. LPSTR <lpParam>;
  185. The %CreateWindow% function creates an overlapped, pop-up, or child
  186. window. The %CreateWindow% function specifies the window class, window
  187. title, window style, and (optionally) initial position and size of the
  188. window. The %CreateWindow% function also specifies the window's parent (if
  189. any) and menu.
  190. For overlapped, pop-up, and child windows, the %CreateWindow% function sends
  191. WM_CREATE, WM_GETMINMAXINFO, and WM_NCCREATE messages to the window. The
  192. <lParam> parameter of the WM_CREATE message contains a pointer to a
  193. %CREATESTRUCT% structure. If WS_VISIBLE style is given, %CreateWindow%
  194. sends the window all the messages required to activate and show the window.
  195. If the window style specifies a title bar, the window title pointed to by
  196. the <lpWindowName> parameter is displayed in the title bar. When using
  197. %CreateWindow% to create controls such as buttons, check boxes, and text
  198. controls, the <lpWindowName> parameter specifies the text of the control.
  199. <lpClassName>
  200. Points to a null-terminated string that names the window class. The
  201. class name can be any name registered with the RegisterClass function or
  202. any of the predefined control-class names specified in Table T.2,
  203. "Control Classes."
  204. <lpWindowName>
  205. Points to a null-terminated string that represents the window name.
  206. <dwStyle>
  207. Specifies the style of window being created. It can be any
  208. combination of the styles given in Table *** <$R[C#]> ***.3, Window
  209. Styles the control styles given in Table 4.4, Control Styles, or a
  210. combination of styles created by using the bitwise OR operator. ,
  211. <X>
  212. Specifies the initial <x>-position of the window. For an
  213. overlapped or pop-up window, the <X> parameter is the initial
  214. <x>-coordinate of the window's upper-left corner (in screen
  215. coordinates). If this value is CW_USEDEFAULT, Windows selects the
  216. default position for the window's upper-left corner. For a child window,
  217. <X> is the <x>-coordinate of the upper-left corner of the window in the
  218. client area of its parent window.
  219. <Y>
  220. Specifies the initial <y>-position of the window. For an
  221. overlapped window, the <Y> parameter is the initial <y>-coordinate of
  222. the window's upper-left corner. For a pop-up window, <Y> is the
  223. <y>-coordinate (in screen coordinates) of the upper-left corner of the
  224. pop-up window. For list-box controls, <Y> is the <y>-coordinate of the
  225. upper-left corner of the control's client area. For a child window, <Y>
  226. is the <y>-coordinate of the upper-left corner of the child window. All
  227. of these coordinates are for the window, not the window's client area.
  228. <nWidth>
  229. Specifies the width (in device units) of the window. For
  230. overlapped windows, the <nWidth> parameter is either the window's width
  231. (in screen coordinates) or CW_USEDEFAULT. If <nWidth> is CW_USEDEFAULT,
  232. Windows selects a default width and height for the window (the default
  233. width extends from the initial <x>-position to the right edge of the
  234. screen, and the default height extends from the initial <y>-position to
  235. the top of the icon area).
  236. <nHeight>
  237. Specifies the height (in device units) of the window. For
  238. overlapped windows, the <nHeight> parameter is the window's height in
  239. screen coordinates. If the <nWidth> parameter is CW_USEDEFAULT, Windows
  240. ignores <nHeight>.
  241. <hwndParent>
  242. Identifies the parent or owner window of the window being
  243. created. A valid window handle must be supplied when creating a child
  244. window or an owned window. An owned window is an overlapped window that
  245. is destroyed when its owner window is destroyed, hidden when its owner
  246. is made iconic, and which is always displayed on top of its owner
  247. window. For pop-up windows, a handle can be supplied, but is not
  248. required. If the window does not have a parent or is not owned by
  249. another window, the <hwndParent> parameter must be set to NULL.
  250. <hMenu>
  251. Identifies a menu or a child-window identifier. The meaning
  252. depends on the window style. For overlapped or pop-up windows, the
  253. <hMenu> parameter identifies the menu to be used with the window. It can
  254. be NULL, if the class menu is to be used. For child windows, <hMenu>
  255. specifies the child-window identifier, an integer value that is used by
  256. a dialog-box control to notify its parent of events (such as the
  257. EN_HSCROLL message). The child-window identifier is determined by the
  258. application and should be unique for all child windows with the same
  259. parent window.
  260. <hInstance>
  261. Identifies the instance of the module to be associated with the
  262. window.
  263. <lpParam>
  264. Points to a value that is passed to the window through the
  265. %CREATESTRUCT% structure referenced by the <lParam> parameter of
  266. the WM_CREATE message. If an application is calling %CreateWindow% to
  267. create a multiple document interface (MDI) client window, <lpParam> must
  268. point to a %CLIENTCREATESTRUCT% structure.
  269. The return value identifies the new window. It is NULL if the window is not
  270. created.
  271. The %CreateWindow% function sends a WM_CREATE message to to the window
  272. procedure before it returns.
  273. For overlapped windows where the <X> parameter is CW_USEDEFAULT, the <Y>
  274. parameter can be one of the show-style parameters described with the
  275. %ShowWindow% function, or, for the first overlapped window to be created by
  276. the application, it can be the <nCmdShow> parameter passed to the WinMain
  277. function.
  278. BUTTON
  279. Designates a small rectangular child window that represents a button the
  280. user can turn on or off by clicking it. Button controls can be used
  281. alone or in groups, and can either be labeled or appear without text.
  282. Button controls typically change appearance when the user clicks them.
  283. COMBOBOX
  284. Designates a control consisting of a selection field similar to an edit
  285. control plus a list box. The list box may be displayed at all times or
  286. may be dropped down when the user selects a pop box next to the
  287. selection field.
  288. Depending on the style of the combo box, the user can or cannot edit the
  289. contents of the selection field. If the list box is visible, typing
  290. characters into the selection box will cause the first list box entry
  291. that matches the characters typed to be highlighted. Conversely,
  292. selecting an item in the list box displays the selected text in the
  293. selection field.
  294. EDIT
  295. Designates a rectangular child window in which the user can enter text
  296. from the keyboard. The user selects the control, and gives it the input
  297. focus by clicking it or moving to it by using the ^TAB^ key. The user
  298. can enter text when the control displays a flashing caret. The mouse can
  299. be used to move the cursor and select characters to be replaced, or to
  300. position the cursor for inserting characters. The ^BACKSPACE^ key can be
  301. used to delete characters.
  302. Edit controls use the variable-pitch system font and display ANSI
  303. characters. Applications compiled to run with previous versions of
  304. Windows display text with a fixed-pitch system font unless they have
  305. been marked by the Windows 3.0 %MARK% utility with the %MEMORY FONT%
  306. option. An application can also send the WM_SETFONT message to the edit
  307. control to change the default font.
  308. Edit controls expand tab characters into as many space characters as are
  309. required to move the cursor to the next tab stop. Tab stops are assumed
  310. to be at every eighth character position.
  311. LISTBOX
  312. Designates a list of character strings. This control is used whenever an
  313. application needs to present a list of names, such as filenames, that
  314. the user can view and select. The user can select a string by pointing
  315. to it and clicking. When a string is selected, it is highlighted and a
  316. notification message is passed to the parent window. A vertical or
  317. horizontal scroll bar can be used with a list-box control to scroll
  318. lists that are too long for the control window. The list box
  319. automatically hides or shows the scroll bar as needed.
  320. MDICLIENT
  321. Designates an MDI client window. The MDI client window receives messages
  322. which control the MDI application's child windows. The recommended style
  323. bits are WS_CLIPCHILDREN and WS_CHILD. To create a scrollable MDI client
  324. window which allows the user to scroll MDI child windows into view, an
  325. application can also use the WS_HSCROLL and WS_VSCROLL styles.
  326. SCROLLBAR
  327. Designates a rectangle that contains a thumb and has direction arrows at
  328. both ends. The scroll bar sends a notification message to its parent
  329. window whenever the user clicks the control. The parent window is
  330. responsible for updating the thumb position, if necessary. Scroll-bar
  331. controls have the same appearance and function as scroll bars used in
  332. ordinary windows. Unlike scroll bars, scroll-bar controls can be
  333. positioned anywhere in a window and used whenever needed to provide
  334. scrolling input for a window.
  335. The scroll-bar class also includes size-box controls. A size-box control
  336. is a small rectangle that the user can expand to change the size of the
  337. window.
  338. STATIC
  339. Designates a simple text field, box, or rectangle that can be used to
  340. label, box, or separate other controls. Static controls take no input
  341. and provide no output.
  342. DS_LOCALEDIT
  343. Specifies that edit controls in the dialog box will use memory in the
  344. application's data segment. By default, all edit controls in dialog
  345. boxes use memory outside the application's data segment. This feature
  346. may be suppressed by adding the DS_LOCALEDIT flag to the STYLE command
  347. for the dialog box. If this flag is not used, EM_GETHANDLE and
  348. EM_SETHANDLE messages must not be used since the storage for the control
  349. is not in the application's data segment. This feature does not affect
  350. edit controls created outside of dialog boxes.
  351. DS_MODALFRAME
  352. Creates a dialog box with a modal dialog-box frame that can be combined
  353. with a title bar and System menu by specifying the WS_CAPTION and
  354. WS_SYSMENU styles.
  355. DS_NOIDLEMSG
  356. Suppresses WM_ENTERIDLE messages that Windows would otherwise send to
  357. the owner of the dialog box while the dialog box is displayed.
  358. DS_SYSMODAL
  359. Creates a system-modal dialog box.
  360. WS_BORDER
  361. Creates a window that has a border.
  362. WS_CAPTION
  363. Creates a window that has a title bar (implies the WS_BORDER style).
  364. This style cannot be used with the WS_DLGFRAME style.
  365. WS_CHILD
  366. Creates a child window. Cannot be used with the WS_POPUP style.
  367. WS_CHILDWINDOW
  368. Creates a child window that has the WS_CHILD style.
  369. WS_CLIPCHILDREN
  370. Excludes the area occupied by child windows when drawing within the
  371. parent window. Used when creating the parent window.
  372. WS_CLIPSIBLINGS
  373. Clips child windows relative to each other; that is, when a particular
  374. child window receives a paint message, the WS_CLIPSIBLINGS style clips
  375. all other overlapped child windows out of the region of the child window
  376. to be updated. (If WS_CLIPSIBLINGS is not given and child windows
  377. overlap, it is possible, when drawing within the client area of a child
  378. window, to draw within the client area of a neighboring child window.)
  379. For use with the WS_CHILD style only.
  380. WS_DISABLED
  381. Creates a window that is initially disabled.
  382. WS_DLGFRAME
  383. Creates a window with a double border but no title.
  384. WS_GROUP
  385. Specifies the first control of a group of controls in which the user can
  386. move from one control to the next by using the ^DIRECTION^ keys. All
  387. controls defined with the WS_GROUP style after the first control belong
  388. to the same group. The next control with the WS_GROUP style ends the
  389. style group and starts the next group (that is, one group ends where the
  390. next begins). Only dialog boxes use this style.
  391. WS_HSCROLL
  392. Creates a window that has a horizontal scroll bar.
  393. WS_ICONIC
  394. Creates a window that is initially iconic. For use with the
  395. WS_OVERLAPPED style only.
  396. WS_MAXIMIZE
  397. Creates a window of maximum size.
  398. WS_MAXIMIZEBOX
  399. Creates a window that has a maximize box.
  400. WS_MINIMIZE
  401. Creates a window of minimum size.
  402. WS_MINIMIZEBOX
  403. Creates a window that has a minimize box.
  404. WS_OVERLAPPED
  405. Creates an overlapped window. An overlapped window has a caption and a
  406. border.
  407. WS_OVERLAPPEDWINDOW
  408. Creates an overlapped window having the WS_OVERLAPPED, WS_CAPTION,
  409. WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles.
  410. WS_POPUP
  411. Creates a pop-up window. Cannot be used with the WS_CHILD style.
  412. WS_POPUPWINDOW
  413. Creates a pop-up window that has the WS_BORDER, WS_POPUP, and WS_SYSMENU
  414. styles. The WS_CAPTION style must be combined with the WS_POPUPWINDOW
  415. style to make the system menu visible.
  416. WS_SYSMENU
  417. Creates a window that has a System-menu box in its title bar. Used only
  418. for windows with title bars.
  419. WS_TABSTOP
  420. Specifies one of any number of controls through which the user can move
  421. by using the ^TAB^ key. The ^TAB^ key moves the user to the next control
  422. specified by the WS_TABSTOP style. Only dialog boxes use this style.
  423. WS_THICKFRAME
  424. Creates a window with a thick frame that can be used to size the
  425. window.
  426. WS_VISIBLE
  427. Creates a window that is initially visible. This applies to overlapped
  428. and pop-up windows. For overlapped windows, the <Y> parameter is used as
  429. a %ShowWindow% function parameter.
  430. WS_VSCROLL
  431. Creates a window that has a vertical scroll bar.
  432. --*/
  433. ULONG FASTCALL WU32CreateWindow(PVDMFRAME pFrame)
  434. {
  435. dwExStyle = 0;
  436. // this is a hack for MS Explorapedia -- see bug #189004 -- handle recycling
  437. // the app destroys this 1st hwnd it squirreled away -- which is the problem
  438. if(CURRENTPTD()->dwWOWCompatFlagsEx & WOWCF_CREATEBOGUSHWND) {
  439. // we detect this version by the offset of the return address
  440. if((pFrame->vpCSIP & 0x0000FFFF) == 0x8DBB)
  441. W32CreateWindow(pFrame);
  442. }
  443. return W32CreateWindow(pFrame);
  444. }
  445. /*++
  446. HWND CreateWindowEx(<dwExStyle>, <lpszClass>, <lpszName>,
  447. <dwStyle>, <x>, <y>, <cx>, <cy>, <hwndParent>, <hMenu>,
  448. <hInstance>, <lpCreateParams>)
  449. DWORD <dwExStyle>;
  450. LPSTR <lpszClass>;
  451. LPSTR <lpszName>;
  452. DWORD <dwStyle>;
  453. int <x>;
  454. int <y>;
  455. int <cx>;
  456. int <cy>;
  457. HWND <hwndParent>;
  458. HMENU <hMenu>;
  459. HANDLE <hInstance>;
  460. LPSTR <lpCreateParams>;
  461. The %CreateWindowEx% function creates an overlapped, pop-up, or child window
  462. with an extended style specified in the <dwExStyle> parameter. Otherwise,
  463. this function is identical to the %CreateWindow% function. See the
  464. description of the %CreateWindow% function for more information on creating
  465. a window and for a full descriptions of the other parameters of
  466. %CreateWindowEx%.
  467. <dwExStyle>
  468. Specifies the extended style of the window being created. It may be one
  469. of the following values:
  470. WS_EX_DLGMODALFRAME
  471. Designates a window with a double border that may optionally be created
  472. with a title bar by specifying the WS_CAPTION style flag in the
  473. <dwStyle> parameter.
  474. WS_EX_NOPARENTNOTIFY
  475. Specifies that a child window created with this style will not send the
  476. WM_PARENTNOTIFY message to its parent window when the child window is
  477. created or destroyed.
  478. WS_EX_TOPMOST
  479. ???
  480. WS_EX_ACCEPTFILES
  481. ???
  482. <lpszClass>
  483. Points to a null-terminated string containing the name of the window
  484. class.
  485. <lpszName>
  486. Points to a null-terminated string containing the window name.
  487. <dwStyle>
  488. Specifies the style of window being created.
  489. <x>
  490. Specifies the initial left side position of the window.
  491. <y>
  492. Specifies the initial top position of the window.
  493. <cx>
  494. Specifies the width (in device units) of the window.
  495. <cy>
  496. Specifies the height (in device units) of the window.
  497. <hwndParent>
  498. Identifies the parent or owner window of the window being
  499. created.
  500. <hMenu>
  501. Identifies a menu or a child-window identifier. The meaning
  502. depends on the window style.
  503. <hInstance>
  504. Identifies the instance of the module to be associated with the
  505. window.
  506. <lpCreateParams>
  507. Contains any application-specific creation parameters. The window being
  508. created may access this data when the %CREATESTRUCT% structure is passed
  509. to the window via the WM_NCCREATE and WM_CREATE messages.
  510. The return value identifies the new window. It is NULL if the window is not
  511. created.
  512. The %CreateWindowEx% function sends the following messages to the window
  513. being created:
  514. WM_NCCREATE
  515. WM_NCCALCSIZE
  516. WM_CREATE
  517. WM_OTHERWINDOWCREATED
  518. --*/
  519. ULONG FASTCALL WU32CreateWindowEx(PVDMFRAME pFrame)
  520. {
  521. register PCREATEWINDOWEX16 parg16;
  522. GETARGPTR(pFrame, sizeof(CREATEWINDOWEX16), parg16);
  523. /*
  524. * We've had problems with apps setting new (Win 5.0) bits, like WS_EX_LAYERED.
  525. * This causes Real Bad Problems with thos apps. Keep Wow apps from doing that.
  526. * FritzS
  527. */
  528. dwExStyle = DWORD32(parg16->f1) & WS_EX_VALID40;
  529. FREEARGPTR(parg16);
  530. RETURN(W32CreateWindow(pFrame));
  531. }
  532. #ifdef FE_SB
  533. // HACK for Director 4.0J
  534. #define MAXNUMOFSTR 20
  535. typedef struct _DIRECTOR {
  536. HWND hwnd; // handle of director window
  537. UCHAR orgstr[2]; // application oreginal string
  538. } DIRECTOR, *PDIRECTOR;
  539. DIRECTOR director[MAXNUMOFSTR];
  540. #endif // FE_SB
  541. ULONG FASTCALL W32CreateWindow(PVDMFRAME pFrame)
  542. {
  543. PSZ psz1;
  544. PSZ pszClass;
  545. PSZ psz2;
  546. HWND hwnd32;
  547. HMENU hmenu32;
  548. register PCREATEWINDOW16 parg16;
  549. CLIENTCREATESTRUCT clientcreatestruct;
  550. LPVOID vpparam;
  551. CHAR szAtomName[WOWCLASS_ATOM_NAME];
  552. DWORD dwStyle;
  553. #ifdef FE_SB
  554. PDIRECTOR pdirector;
  555. unsigned char * pszTmp;
  556. #endif // FE_SB
  557. GETARGPTR(pFrame, sizeof(CREATEWINDOW16), parg16);
  558. GETPSZIDPTR(parg16->vpszClass, psz1);
  559. GETPSZPTR(parg16->vpszWindow, psz2);
  560. if ( HIWORD(psz1) == 0 ) {
  561. pszClass = szAtomName;
  562. GetAtomName( (ATOM)psz1, pszClass, WOWCLASS_ATOM_NAME );
  563. } else {
  564. pszClass = psz1;
  565. }
  566. //
  567. // For child windows, the hMenu parameter is just a child window ID
  568. //
  569. if (DWORD32(parg16->dwStyle) & WS_CHILD) {
  570. hmenu32 = (HMENU)parg16->hMenu;
  571. // Invalidate SendDlgItemMessage cache
  572. hdlgSDIMCached = NULL ;
  573. }
  574. else
  575. hmenu32 = (HMENU32(parg16->hMenu));
  576. if (WOW32_stricmp(pszClass, "MDIClient")) {
  577. vpparam = (LPVOID)DWORD32(parg16->vpParam);
  578. } else {
  579. GETCLIENTCREATESTRUCT16(parg16->vpParam, &clientcreatestruct );
  580. vpparam = &clientcreatestruct;
  581. }
  582. dwStyle = DWORD32(parg16->dwStyle);
  583. #ifdef FE_SB
  584. if (CURRENTPTD()->dwWOWCompatFlagsFE & WOWCF_FE_DIRECTOR_START && psz2) {
  585. pdirector = director;
  586. while (pdirector->hwnd)
  587. pdirector++;
  588. for ((PSZ)pszTmp = psz2; *pszTmp; pszTmp++) {
  589. if (IsDBCSLeadByte(*pszTmp)) {
  590. if (*(pszTmp+1) < 0x40 || *(pszTmp+1) > 0xfc) {
  591. pdirector->orgstr[0] = *pszTmp;
  592. pdirector->orgstr[1] = *(pszTmp+1);
  593. *(pszTmp+1) = *pszTmp = 0x7c;
  594. pdirector++;
  595. }
  596. pszTmp++;
  597. }
  598. }
  599. }
  600. #endif // FE_SB
  601. hwnd32 = (pfnOut.pfnCsCreateWindowEx)(
  602. dwExStyle,
  603. pszClass,
  604. psz2,
  605. dwStyle,
  606. INT32DEFAULT(parg16->x),
  607. INT32DEFAULT(parg16->y),
  608. INT32DEFAULT(parg16->cx),
  609. INT32DEFAULT(parg16->cy),
  610. HWND32(parg16->hwndParent),
  611. hmenu32,
  612. HMODINST32(parg16->hInstance),
  613. vpparam,
  614. CW_FLAGS_ANSI);
  615. #ifdef FE_SB
  616. if (CURRENTPTD()->dwWOWCompatFlagsFE & WOWCF_FE_DIRECTOR_START) {
  617. pdirector = director;
  618. for (; pdirector->orgstr[0]; pdirector++) {
  619. if (hwnd32)
  620. if (!pdirector->hwnd)
  621. pdirector->hwnd = hwnd32;
  622. else
  623. if (!pdirector->hwnd)
  624. pdirector->orgstr[1] = pdirector->orgstr[0] = 0;
  625. }
  626. }
  627. #endif // FE_SB
  628. #ifdef DEBUG
  629. if (hwnd32) {
  630. CHAR szClassName[80];
  631. LOGDEBUG(LOG_WARNING,(" Window %04x created on class = %s\n", GETHWND16(hwnd32),
  632. (GetClassName(hwnd32, szClassName, sizeof(szClassName)) ? szClassName : "Unknown")));
  633. } else {
  634. LOGDEBUG(LOG_WARNING,(" CreateWindow failed, class = %s\n", pszClass));
  635. }
  636. #endif
  637. FREEPSZPTR(psz1);
  638. FREEPSZPTR(psz2);
  639. FREEARGPTR(parg16);
  640. RETURN((ULONG) GETHWND16(hwnd32));
  641. }
  642. /*++
  643. HANDLE BeginDeferWindowPos(<nNumWindows>)
  644. int <nNumWindows>;
  645. The %BeginDeferWindowPos% function allocates memory to contain a multiple
  646. window-position data structure and returns a handle to the structure. The
  647. %DeferWindowPos% function fills this structure with information about the
  648. target position for a window that is about to be moved. The
  649. %EndDeferWindowPos% function accepts this structure and instantaneously
  650. repositions the windows using the information stored in the structure.
  651. <nNumWindows>
  652. Specifies the initial number of windows for which position information
  653. is to be stored in the structure. The %DeferWindowPos% function
  654. increases the size of the structure if needed.
  655. The return value identifies the multiple window-position structure. The
  656. return value is NULL if system resources are not available to allocate the
  657. structure.
  658. --*/
  659. ULONG FASTCALL WU32DeferWindowPos(PVDMFRAME pFrame)
  660. {
  661. ULONG ul = 0;
  662. HDWP h32;
  663. register PDEFERWINDOWPOS16 parg16;
  664. GETARGPTR(pFrame, sizeof(DEFERWINDOWPOS16), parg16);
  665. h32 = HDWP32(parg16->f1);
  666. if ( h32 ) {
  667. ul = (ULONG) DeferWindowPos(
  668. h32,
  669. HWND32(parg16->f2),
  670. HWNDIA32(parg16->f3),
  671. INT32(parg16->f4),
  672. INT32(parg16->f5),
  673. INT32(parg16->f6),
  674. INT32(parg16->f7),
  675. WORD32(parg16->f8) & SWP_VALID
  676. );
  677. }
  678. else {
  679. goto WDWP_error;
  680. }
  681. if (ul != (ULONG) h32) {
  682. FREEHDWP16(parg16->f1);
  683. ul = GETHDWP16(ul);
  684. LOGDEBUG (12, ("WOW::DeferWindowsPos: ul = %08x, h32 = %08x\n", ul, h32));
  685. }
  686. else {
  687. ul = parg16->f1;
  688. LOGDEBUG (12, ("WOW::DeferWindowsPos: ul = %08x, parg = %08x\n", ul, parg16->f1));
  689. }
  690. WDWP_error:
  691. FREEARGPTR(parg16);
  692. RETURN(ul);
  693. }
  694. /*++
  695. BOOL DestroyWindow(<hwnd>)
  696. HWND <hwnd>;
  697. The %DestroyWindow% function destroys the specified window. The
  698. %DestroyWindow% function sends appropriate messages to the window to
  699. deactivate it and remove the input focus. It also destroys the window's
  700. menu, flushes the application queue, destroys outstanding timers, removes
  701. clipboard ownership, and breaks the clipboard-viewer chain, if the window is
  702. at the top of the viewer chain. It sends WM_DESTROY and WM_NCDESTROY
  703. messages to the window.
  704. If the given window is the parent of any windows, these child windows are
  705. automatically destroyed when the parent window is destroyed. The
  706. %DestroyWindow% function destroys child windows first, and then the window
  707. itself.
  708. The %DestroyWindow% function also destroys modeless dialog boxes created by
  709. the %CreateDialog% function.
  710. <hwnd>
  711. Identifies the window to be destroyed.
  712. The return value specifies whether or not the specified window is destroyed.
  713. It is TRUE if the window is destroyed. Otherwise, it is FALSE.
  714. If the window being destroyed is a top-level window, a
  715. WM_OTHERWINDOWDESTROYED message will be broadcast to all top-level windows.
  716. If the window being destroyed is a child window and does not have the
  717. WS_NOPARENTNOTIFY style set, then a WM_PARENTNOTIFY message is sent to the
  718. parent.
  719. --*/
  720. ULONG FASTCALL WU32DestroyWindow(PVDMFRAME pFrame)
  721. {
  722. ULONG ul;
  723. register PDESTROYWINDOW16 parg16;
  724. GETARGPTR(pFrame, sizeof(DESTROYWINDOW16), parg16);
  725. ul = GETBOOL16(DestroyWindow(HWND32(parg16->f1)));
  726. // Invalidate SendDlgItemMessage cache
  727. hdlgSDIMCached = NULL ;
  728. #ifdef FE_SB
  729. if (CURRENTPTD()->dwWOWCompatFlagsFE & WOWCF_FE_DIRECTOR_START) {
  730. PDIRECTOR pdirector = director;
  731. for (; pdirector->hwnd; ) {
  732. if (parg16->f1 == (WORD)pdirector->hwnd) {
  733. PDIRECTOR ptmp = pdirector;
  734. do {
  735. ptmp->hwnd = (ptmp+1)->hwnd;
  736. ptmp->orgstr[0] = (ptmp+1)->orgstr[0];
  737. ptmp->orgstr[1] = (ptmp+1)->orgstr[1];
  738. ptmp++;
  739. } while (ptmp->hwnd);
  740. }
  741. else
  742. pdirector++;
  743. }
  744. }
  745. #endif // FE_SB
  746. FREEARGPTR(parg16);
  747. RETURN(ul);
  748. }
  749. /*++
  750. void EndDeferWindowPos(<hWinPosInfo>)
  751. HANDLE <hWinPosInfo>;
  752. The %EndDeferWindowPos% function simultaneously updates the position and
  753. size of one or more windows in a single screen-refresh cycle. The
  754. <hWinPosInfo> parameter identifies a multiple window-position structure that
  755. contains the update information for the windows. The %DeferWindowPos%
  756. function stores the update information in the structure; the
  757. %BeginDeferWindowPos% function creates the initial structure used by these
  758. functions.
  759. <hWinPosInfo>
  760. Identifies a multiple window-position structure that contains size
  761. and position information for one or more windows. This structure is
  762. returned by the %BeginDeferWindowPos% function or the most recent call to
  763. the %DeferWindowPos% function.
  764. This function does not return a value.
  765. --*/
  766. ULONG FASTCALL WU32EndDeferWindowPos(PVDMFRAME pFrame)
  767. {
  768. ULONG ul;
  769. register PENDDEFERWINDOWPOS16 parg16;
  770. GETARGPTR(pFrame, sizeof(ENDDEFERWINDOWPOS16), parg16);
  771. ul = (ULONG)EndDeferWindowPos(HDWP32(parg16->f1));
  772. FREEHDWP16(parg16->f1);
  773. FREEARGPTR(parg16);
  774. RETURN(ul);
  775. }
  776. BOOL W32EnumWindowFunc(HWND hwnd, DWORD lParam)
  777. {
  778. BOOL fReturn;
  779. PARM16 Parm16;
  780. WOW32ASSERT(lParam);
  781. Parm16.EnumWndProc.hwnd = GETHWND16(hwnd);
  782. STOREDWORD(Parm16.EnumWndProc.lParam, ((PWNDDATA)lParam)->dwUserWndParam);
  783. CallBack16(RET_ENUMWINDOWPROC, &Parm16, ((PWNDDATA)lParam)->vpfnEnumWndProc, (PVPVOID)&fReturn);
  784. return (BOOL16)fReturn;
  785. }
  786. /*++
  787. BOOL EnumChildWindows(<hwndParent>, <lpEnumFunc>, <lParam>)
  788. HWND <hwndParent>;
  789. FARPROC <lpEnumFunc>;
  790. DWORD <lParam>;
  791. The %EnumChildWindows% function enumerates the child windows that belong to
  792. the specified parent window by passing the handle of each child window, in
  793. turn, to the application-supplied callback function pointed to by the
  794. <lpEnumFunc> parameter.
  795. The %EnumChildWindows% function continues to enumerate windows until the
  796. called function returns zero or until the last child window has been
  797. enumerated.
  798. <hwndParent>
  799. Identifies the parent window whose child windows are to be enumerated.
  800. <lpEnumFunc>
  801. Is the procedure-instance address of the callback function.
  802. <lParam>
  803. Specifies the value to be passed to the callback function for
  804. the application's use.
  805. The return value is TRUE if all child windows have been enumerated.
  806. Otherwise, it is FALSE.
  807. This function does not enumerate pop-up windows that belong to the
  808. <hwndParent> parameter.
  809. The address passed as the <lpEnumFunc> parameter must be created by using
  810. the %MakeProcInstance% function.
  811. The callback function must use the Pascal calling convention and must be
  812. declared %FAR%.
  813. Callback Function:
  814. BOOL FAR PASCAL <EnumFunc>(<hwnd>, <lParam>)
  815. HWND <hwnd>;
  816. DWORD <lParam>;
  817. <EnumFunc> is a placeholder for the application-supplied function name. The
  818. actual name must be exported by including it in an %EXPORTS% statement in
  819. the application's module-definition file.
  820. <hwnd>
  821. Identifies the window handle.
  822. <lParam>
  823. Specifies the long parameter argument of the %EnumChildWindows%
  824. function.
  825. The callback function should return TRUE to continue enumeration; it should
  826. return FALSE to stop enumeration.
  827. --*/
  828. ULONG FASTCALL WU32EnumChildWindows(PVDMFRAME pFrame)
  829. {
  830. ULONG ul;
  831. WNDDATA WndData;
  832. register PENUMCHILDWINDOWS16 parg16;
  833. GETARGPTR(pFrame, sizeof(ENUMCHILDWINDOWS16), parg16);
  834. WndData.vpfnEnumWndProc = DWORD32(parg16->f2);
  835. WndData.dwUserWndParam = DWORD32(parg16->f3);
  836. ul = GETBOOL16(EnumChildWindows(HWND32(parg16->f1),
  837. (WNDENUMPROC)W32EnumWindowFunc,
  838. (LONG)&WndData));
  839. FREEARGPTR(parg16);
  840. RETURN(ul);
  841. }
  842. /*++
  843. BOOL EnumTaskWindows(<hTask>, <lpEnumFunc>, <lParam>)
  844. HANDLE <hTask>;
  845. FARPROC <lpEnumFunc>;
  846. DWORD <lParam>;
  847. The %EnumTaskWindows% function enumerates all windows associated with the
  848. <hTask> parameter, which is returned by the %GetCurrentTask% function. (A
  849. task is any program that executes as an independent unit. All applications
  850. are executed as tasks and each instance of an application is a task.) The
  851. enumeration terminates when the callback function, pointed to by
  852. <lpEnumFunc>, returns FALSE.
  853. <hTask>
  854. Identifies the specified task. The GetCurrentTask function returns this
  855. handle.
  856. <lpEnumFunc>
  857. Specifies the procedure-instance address of the window's callback
  858. function.
  859. <lParam>
  860. Specifies the 32-bit value that contains additional parameters
  861. that are sent to the callback function pointed to by <lpEnumFunc>.
  862. The return value specifies the outcome of the function. It is TRUE if all
  863. the windows associated with a particular task are enumerated. Otherwise, it
  864. is FALSE.
  865. The callback function must use the Pascal calling convention and must be
  866. declared %FAR%. The callback function must have the following form:
  867. Callback Function:
  868. BOOL FAR PASCAL <EnumFunc>(<hwnd>, <lParam>)
  869. HWND <hwnd>;
  870. DWORD <lParam>;
  871. <EnumFunc> is a placeholder for the application-supplied function name. The
  872. actual name must be exported by including it in an %EXPORTS% statement in
  873. the application's module-definition file.
  874. <hwnd>
  875. Identifies a window associated with the current task.
  876. <lParam>
  877. Specifies the same argument that was passed to the %EnumTaskWindows%
  878. function.
  879. The callback function can carry out any desired task. It must return TRUE to
  880. continue enumeration, or FALSE to stop it.
  881. --*/
  882. ULONG FASTCALL WU32EnumTaskWindows(PVDMFRAME pFrame)
  883. {
  884. ULONG ul;
  885. WNDDATA WndData;
  886. register PENUMTASKWINDOWS16 parg16;
  887. GETARGPTR(pFrame, sizeof(ENUMTASKWINDOWS16), parg16);
  888. WndData.vpfnEnumWndProc = DWORD32(parg16->f2);
  889. WndData.dwUserWndParam = DWORD32(parg16->f3);
  890. ul = GETBOOL16(EnumThreadWindows(THREADID32(parg16->f1),
  891. (WNDENUMPROC)W32EnumWindowFunc,
  892. (LONG)&WndData));
  893. FREEARGPTR(parg16);
  894. RETURN(ul);
  895. }
  896. /*++
  897. BOOL EnumWindows(<lpEnumFunc>, <lParam>)
  898. FARPROC <lpEnumFunc>;
  899. DWORD <lParam>;
  900. The %EnumWindows% function enumerates all parent windows on the screen by
  901. passing the handle of each window, in turn, to the callback function pointed
  902. to by the <lpEnumFunc> parameter. Child windows are not enumerated.
  903. The %EnumWindows% function continues to enumerate windows until the called
  904. function returns zero or until the last window has been enumerated.
  905. <lpEnumFunc>
  906. Is the procedure-instance address of the callback function. See the
  907. following "Comments" section for details.
  908. <lParam>
  909. Specifies the value to be passed to the callback function for
  910. the application's use.
  911. The return value is TRUE if all windows have been enumerated. Otherwise, it
  912. is FALSE.
  913. The address passed as the <lpEnumFunc> parameter must be created by using
  914. the %MakeProcInstance% function.
  915. The callback function must use the Pascal calling convention and must be
  916. declared %FAR%. The callback function must have the following form:
  917. Callback Function:
  918. BOOL FAR PASCAL <EnumFunc>(<hwnd>, <lParam>)
  919. HWND <hwnd>;
  920. DWORD <lParam>;
  921. <EnumFunc> is a placeholder for the application-supplied function name. The
  922. actual name must be exported by including it in an %EXPORTS% statement in
  923. the application's module-definition file.
  924. <hwnd>
  925. Identifies the window handle.
  926. <lParam>
  927. Specifies the 32-bit argument of the %EnumWindows% function.
  928. The function must return TRUE to continue enumeration, or FALSE to stop it.
  929. --*/
  930. ULONG FASTCALL WU32EnumWindows(PVDMFRAME pFrame)
  931. {
  932. ULONG ul;
  933. WNDDATA WndData;
  934. register PENUMWINDOWS16 parg16;
  935. GETARGPTR(pFrame, sizeof(ENUMWINDOWS16), parg16);
  936. WndData.vpfnEnumWndProc = DWORD32(parg16->f1);
  937. WndData.dwUserWndParam = DWORD32(parg16->f2);
  938. ul = GETBOOL16(EnumWindows((WNDENUMPROC)W32EnumWindowFunc, (LONG)&WndData));
  939. FREEARGPTR(parg16);
  940. RETURN(ul);
  941. }
  942. /*++
  943. HWND FindWindow(<lpClassName>, <lpWindowName>)
  944. LPSTR <lpClassName>;
  945. LPSTR <lpWindowName>;
  946. The %FindWindow% function returns the handle of the window whose class is
  947. given by the <lpClassName> parameter and whose window name, or caption, is
  948. given by the <lpWindowName> parameter. This function does not search child
  949. windows.
  950. <lpClassName>
  951. Points to a null-terminated string that specifies the window's class
  952. name. If lpClassName is NULL, all class names match.
  953. <lpWindowName>
  954. Points to a null-terminated string that specifies the window name (the
  955. window's text caption). If <lpWindowName> is NULL, all window names
  956. match.
  957. The return value identifies the window that has the specified class name and
  958. window name. It is NULL if no such window is found.
  959. --*/
  960. ULONG FASTCALL WU32FindWindow(PVDMFRAME pFrame)
  961. {
  962. ULONG ul;
  963. PSZ psz1;
  964. PSZ psz2;
  965. PSZ pszClass;
  966. register PFINDWINDOW16 parg16;
  967. CHAR szAtomName[WOWCLASS_ATOM_NAME];
  968. GETARGPTR(pFrame, sizeof(FINDWINDOW16), parg16);
  969. GETPSZIDPTR(parg16->f1, psz1);
  970. GETOPTPTR(parg16->f2, 0, psz2);
  971. if ( psz1 && HIWORD(psz1) == 0 ) {
  972. pszClass = szAtomName;
  973. GetAtomName( (ATOM)psz1, pszClass, WOWCLASS_ATOM_NAME );
  974. } else {
  975. pszClass = psz1;
  976. }
  977. // Some apps during their installation try to find Program Manager's
  978. // window handle by doing FindWindow. Once they get the window handle
  979. // then they do DDE with program manager to create app group. An app
  980. // can call FindWindow in one of the three ways.
  981. //
  982. // FindWindow ("progman", NULL)
  983. // FindWindow (NULL, "program manager")
  984. // FindWindow ("progman", "program manager")
  985. //
  986. // The case 2 and 3 of the above will fail on NT because the title of
  987. // the program manager window under NT is "Program Manager - xxx\yyy".
  988. // Where xxx is the domain name and yyy is the user name.
  989. //
  990. // To provide the Win 3.1 compatibility to the 16 bit apps, we check for
  991. // the above cases. For these cases we call FindWindow ("progman", NULL)
  992. // to get the window handle of the program manager's top level window.
  993. //
  994. // AmiPro calls FindWindow as case two of the above to find the window
  995. // handle of the program manager to do DDE with.
  996. // ChandanC, 5/18/93
  997. //
  998. // Some apps send WM_SYSCOMMAND - SC_CLOSE messages to program manager
  999. // with the shift key down to get it to save its settings. They do
  1000. // this by 1st finding the program manager window...
  1001. if ((pszClass && !WOW32_stricmp (pszClass, "progman")) ||
  1002. (psz2 && !WOW32_stricmp (psz2, "program manager"))) {
  1003. ul = GETHWND16(FindWindow("progman", NULL));
  1004. // Some apps send WM_SYSCOMMAND - SC_CLOSE messages to program manager
  1005. // with the shift key down to get it to save its settings. They do
  1006. // this by 1st finding the program manager window...
  1007. // So, save this window handle for later.
  1008. hwndProgman = (HWND)ul;
  1009. }
  1010. else {
  1011. ul = GETHWND16(FindWindow(pszClass, psz2));
  1012. }
  1013. FREEPSZPTR(psz1);
  1014. FREEPSZPTR(psz2);
  1015. FREEARGPTR(parg16);
  1016. RETURN(ul);
  1017. }
  1018. /*++
  1019. HWND GetActiveWindow(VOID)
  1020. The %GetActiveWindow% function retrieves the window handle of the active
  1021. window. The active window is either the window that has the current input
  1022. focus, or the window explicitly made active by the %SetActiveWindow%
  1023. function.
  1024. This function has no parameters.
  1025. The return value identifies the active window.
  1026. --*/
  1027. ULONG FASTCALL WU32GetActiveWindow(PVDMFRAME pFrame)
  1028. {
  1029. ULONG ul;
  1030. UNREFERENCED_PARAMETER(pFrame);
  1031. ul = (ULONG)GetActiveWindow();
  1032. // GetActiveWindow returned NULL. So try GetForegroundWindow.
  1033. // Some apps like Toolbook donot paint if GetActiveWindow returns NULL.
  1034. //
  1035. // Alternatively we can return the wowexec's window handle.. basically
  1036. // something NON-NULL
  1037. //
  1038. // NOTE: Win31 and Win32 GetActiveWindow differ semantically and hence
  1039. // the need for fooling with this API.
  1040. //
  1041. // - Nanduri Ramakrishna
  1042. //
  1043. // We need to do something different now, since JimA recently changed
  1044. // GetForegroundWindow() so that it can return NULL if the caller doesn't
  1045. // have access to the foreground window.
  1046. //
  1047. // - Dave Hart
  1048. //
  1049. // When GetForegroundWindow() returns null, now we return wowexec's
  1050. // window handle. This theoretically could have some strange effects
  1051. // since it is a hidden window. It might be better to return, say,
  1052. // the desktop window. However, for reasons currently unknown,
  1053. // this screws a shutdown scenario with Micrografix Designer (it
  1054. // gpfaults).
  1055. // - Neil Sandlin
  1056. if (ul == (ULONG)NULL) {
  1057. ul = (ULONG)GetForegroundWindow();
  1058. }
  1059. if (ul == (ULONG)NULL) {
  1060. ul = (ULONG)ghwndShell;
  1061. }
  1062. ul = GETHWND16(ul);
  1063. WOW32ASSERT(ul);
  1064. RETURN(ul);
  1065. }
  1066. /*++
  1067. HDC GetWindowDC(<hwnd>)
  1068. HWND <hwnd>;
  1069. The %GetWindowDC% function retrieves the display context for the entire
  1070. window, including caption bar, menus, and scroll bars. A window display
  1071. context permits painting anywhere in a window, including the caption bar,
  1072. menus, and scroll bars, since the origin of the context is the upper-left
  1073. corner of the window instead of the client area.
  1074. %GetWindowDC% assigns default attributes to the display context each time it
  1075. retrieves the context. Previous attributes are lost.
  1076. <hwnd>
  1077. Identifies the window whose display context is to be retrieved.
  1078. The return value identifies the display context for the given window if the
  1079. function is successful. Otherwise, it is NULL.
  1080. The %GetWindowDC% function is intended to be used for special painting
  1081. effects within a window's nonclient area. Painting in nonclient areas of any
  1082. window is not recommended.
  1083. The %GetSystemMetrics% function can be used to retrieve the dimensions of
  1084. various parts of the nonclient area, such as the caption bar, menu, and
  1085. scroll bars.
  1086. After painting is complete, the %ReleaseDC% function must be called to
  1087. release the display context. Failure to release a window display context
  1088. will have serious effects on painting requested by applications.
  1089. --*/
  1090. ULONG FASTCALL WU32GetWindowDC(PVDMFRAME pFrame)
  1091. {
  1092. ULONG ul;
  1093. register PGETWINDOWDC16 parg16;
  1094. HAND16 htask16 = pFrame->wTDB;
  1095. GETARGPTR(pFrame, sizeof(GETWINDOWDC16), parg16);
  1096. ReleaseCachedDCs(htask16, parg16->f1, 0, 0, SRCHDC_TASK16_HWND16);
  1097. ul = GETHDC16(GetWindowDC(
  1098. HWND32(parg16->f1)
  1099. ));
  1100. if (ul)
  1101. StoreDC(htask16, parg16->f1, (HAND16)ul);
  1102. FREEARGPTR(parg16);
  1103. RETURN(ul);
  1104. }
  1105. /*++
  1106. LONG GetWindowLong(<hwnd>, <nIndex>)
  1107. HWND <hwnd>;
  1108. int <nIndex>;
  1109. The %GetWindowLong% function retrieves information about the window
  1110. identified by the <hwnd> parameter.
  1111. <hwnd>
  1112. Identifies the window.
  1113. <nIndex>
  1114. Specifies the byte offset of the value to be retrieved. It can
  1115. also be one of the following values:
  1116. GWL_EXSTYLE
  1117. Extended window style.
  1118. GWL_STYLE
  1119. Window style
  1120. GWL_WNDPROC
  1121. Long pointer to the window function
  1122. The return value specifies information about the given window.
  1123. To access any extra four-byte values allocated when the window-class
  1124. structure was created, use a positive byte offset as the index specified by
  1125. the <nIndex> parameter, starting at zero for the first four-byte value in
  1126. the extra space, 4 for the next four-byte value and so on.
  1127. --*/
  1128. ULONG FASTCALL WU32GetWindowLong(PVDMFRAME pFrame)
  1129. {
  1130. ULONG ul;
  1131. INT iOffset;
  1132. register PWW pww;
  1133. register PGETWINDOWLONG16 parg16;
  1134. GETARGPTR(pFrame, sizeof(GETWINDOWLONG16), parg16);
  1135. // Make sure Win32 didn't change offsets for GWL constants
  1136. #if (GWL_WNDPROC != (-4) || GWL_STYLE != (-16) || GWL_EXSTYLE != (-20) || DWL_MSGRESULT != (0))
  1137. #error Win16/Win32 GWL constants differ
  1138. #endif
  1139. #ifndef WIN16_GWW_HINSTANCE
  1140. #define WIN16_GWW_HINSTANCE (-6)
  1141. #define WIN16_GWW_HWNDPARENT (-8)
  1142. #define WIN16_GWW_ID (-12)
  1143. #endif
  1144. // Make sure the 16-bit app is requesting allowable offsets
  1145. iOffset = INT32(parg16->f2);
  1146. WOW32ASSERT(iOffset >= 0 ||
  1147. iOffset == GWL_WNDPROC ||
  1148. iOffset == GWL_STYLE || iOffset == GWL_EXSTYLE ||
  1149. iOffset == WIN16_GWW_HINSTANCE ||
  1150. iOffset == WIN16_GWW_HWNDPARENT ||
  1151. iOffset == WIN16_GWW_ID );
  1152. ul = 0;
  1153. switch( iOffset ) {
  1154. case DWL_DLGPROC:
  1155. case GWL_WNDPROC:
  1156. if (pww = FindPWW(HWND32(parg16->f1))) {
  1157. DWORD dwWndProc32Cur;
  1158. if ((iOffset == DWL_DLGPROC) && !(pww->state & WF_DIALOG_WINDOW)) {
  1159. goto defgwl;
  1160. }
  1161. dwWndProc32Cur = GetWindowLong(HWND32(parg16->f1), iOffset);
  1162. if (IsWOWProc (dwWndProc32Cur)) {
  1163. if ( HIWORD(dwWndProc32Cur) == WNDPROC_HANDLE ) {
  1164. /*
  1165. ** Has a 32-bit WindowProc that is a handle-based value
  1166. ** (if it needs a 32-bit Ansi-Unicode transition, or
  1167. ** vice versa.)
  1168. */
  1169. ul = GetThunkWindowProc( dwWndProc32Cur, NULL, pww, HWND32(parg16->f1) );
  1170. } else {
  1171. /*
  1172. ** Has a WOW WindowProc
  1173. */
  1174. //Unmark the proc and restore the high bits from rpl field
  1175. UnMarkWOWProc (dwWndProc32Cur,ul);
  1176. }
  1177. } else {
  1178. /*
  1179. ** Has a 32-bit WindowProc
  1180. */
  1181. if (dwWndProc32Cur) {
  1182. ul = GetThunkWindowProc( dwWndProc32Cur, NULL, pww, HWND32(parg16->f1) );
  1183. }
  1184. }
  1185. }
  1186. break;
  1187. case GWL_EXSTYLE:
  1188. // Lotus Approach needs the WS_EX_TOPMOST bit cleared on
  1189. // GetWindowLong of NETDDE AGENT window.
  1190. ul = GetWindowLong(HWND32(parg16->f1), iOffset);
  1191. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_GWLCLRTOPMOST) {
  1192. char szBuf[40];
  1193. if (GetClassName(HWND32(parg16->f1), szBuf, sizeof(szBuf))) {
  1194. if (!WOW32_stricmp(szBuf, "NDDEAgnt")) {
  1195. ul &= !WS_EX_TOPMOST;
  1196. }
  1197. }
  1198. }
  1199. break;
  1200. defgwl:
  1201. default:
  1202. // This is a real HACK for PowerBuild 3.0. Before we change the offset
  1203. // from 2 to 4, we nneed to make sure that we are doing it correctly for
  1204. // this specific class.
  1205. // The class in this case is "PaList".
  1206. //
  1207. // ChandanC Marh 9th 1994
  1208. //
  1209. if (iOffset == 2) {
  1210. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_GWLINDEX2TO4) {
  1211. char Buffer[40];
  1212. if (GetClassName (HWND32(parg16->f1), Buffer, sizeof(Buffer))) {
  1213. if (!WOW32_stricmp (Buffer, "PaList")) {
  1214. iOffset = 4;
  1215. }
  1216. }
  1217. }
  1218. }
  1219. ul = GetWindowLong(HWND32(parg16->f1), iOffset);
  1220. break;
  1221. case WIN16_GWW_HINSTANCE:
  1222. /*
  1223. ** We might need to set the high 16-bits to
  1224. ** some mysterious value (See Win 3.1 WND structure)
  1225. */
  1226. ul = GetGWW_HINSTANCE(HWND32(parg16->f1));
  1227. break;
  1228. case WIN16_GWW_HWNDPARENT:
  1229. /*
  1230. ** We might need to set the high 16-bits to
  1231. ** some mysterious value (See Win 3.1 WND structure)
  1232. */
  1233. ul = (ULONG)GETHWND16((HAND32)GetWindowLong(HWND32(parg16->f1),
  1234. GWL_HWNDPARENT));
  1235. break;
  1236. case WIN16_GWW_ID:
  1237. /*
  1238. ** We might need to set the high 16-bits to
  1239. ** some mysterious value (See Win 3.1 WND structure)
  1240. */
  1241. ul = (ULONG)((WORD)GetWindowLong(HWND32(parg16->f1), GWL_ID));
  1242. break;
  1243. }
  1244. FREEARGPTR(parg16);
  1245. RETURN(ul);
  1246. }
  1247. /*++
  1248. HANDLE GetWindowTask(<hwnd>)
  1249. HWND <hwnd>;
  1250. The %GetWindowTask% function searches for the handle of a task associated
  1251. with the <hwnd> parameter. A task is any program that executes as an
  1252. independent unit. All applications are executed as tasks. Each instance of
  1253. an application is a task.
  1254. <hwnd>
  1255. Identifies the window for which a task handle is retrieved.
  1256. The return value identifies the task associated with a particular window.
  1257. --*/
  1258. ULONG FASTCALL WU32GetWindowTask(PVDMFRAME pFrame)
  1259. {
  1260. register PGETWINDOWTASK16 parg16;
  1261. DWORD dwThreadID, dwProcessID;
  1262. PTD ptd;
  1263. GETARGPTR(pFrame, sizeof(GETWINDOWTASK16), parg16);
  1264. dwThreadID = GetWindowThreadProcessId(HWND32(parg16->f1), &dwProcessID);
  1265. //
  1266. // return corresponding htask16 if window belongs to a WOW thread
  1267. // else return WowExec's htask.
  1268. //
  1269. ptd = ThreadProcID32toPTD(dwThreadID, dwProcessID);
  1270. if (ptd == NULL) {
  1271. ptd = gptdShell;
  1272. }
  1273. FREEARGPTR(parg16);
  1274. return (ULONG)ptd->htask16;
  1275. }
  1276. /*++
  1277. int GetWindowText(<hwnd>, <lpString>, <nMaxCount>)
  1278. HWND <hwnd>;
  1279. LPSTR <lpString>;
  1280. int <nMaxCount>;
  1281. The %GetWindowText% function copies the given window's caption title (if it
  1282. has one) into the buffer pointed to by the <lpString> parameter. If the
  1283. <hwnd> parameter identifies a control, the %GetWindowText% function copies
  1284. the text within the control instead of copying the caption.
  1285. <hwnd>
  1286. Identifies the window or control whose caption or text is to be copied.
  1287. <lpString>
  1288. Points to the buffer that is to receive the copied string.
  1289. <nMaxCount>
  1290. Specifies the maximum number of characters to be copied to the
  1291. buffer. If the string is longer than the number of characters specified
  1292. in the <nMaxCount> parameter, it is truncated.
  1293. The return value specifies the length of the copied string. It is zero if
  1294. the window has no caption or if the caption is empty.
  1295. This function causes a WM_GETTEXT message to be sent to the given window or
  1296. control.
  1297. --*/
  1298. ULONG FASTCALL WU32GetWindowText(PVDMFRAME pFrame)
  1299. {
  1300. ULONG ul;
  1301. VPVOID vp;
  1302. PSZ psz2;
  1303. register PGETWINDOWTEXT16 parg16;
  1304. GETARGPTR(pFrame, sizeof(GETWINDOWTEXT16), parg16);
  1305. ALLOCVDMPTR(parg16->f2, parg16->f3, psz2);
  1306. vp = parg16->f2;
  1307. ul = GETINT16(GetWindowText(HWND32(parg16->f1), psz2, WORD32(parg16->f3)));
  1308. // special case to keep common dialog structs in sync (see wcommdlg.c)
  1309. Check_ComDlg_pszptr(CURRENTPTD()->CommDlgTd, vp);
  1310. FLUSHVDMPTR(parg16->f2, (USHORT)ul+1, psz2);
  1311. FREEVDMPTR(psz2);
  1312. FREEARGPTR(parg16);
  1313. RETURN(ul);
  1314. }
  1315. /*++
  1316. WORD GetWindowWord(<hwnd>, <nIndex>)
  1317. HWND <hwnd>;
  1318. int <nIndex>;
  1319. The %GetWindowWord% function retrieves information about the window
  1320. identified by <hwnd>.
  1321. <hwnd>
  1322. Identifies the window.
  1323. <nIndex>
  1324. Specifies the byte offset of the value to be retrieved. It can
  1325. also be one of the following values:
  1326. GWL_HINSTANCE
  1327. Instance handle of the module that owns the window.
  1328. GWL_HWNDPARENT
  1329. Handle of the parent window, if any. The %SetParent% function changes
  1330. the parent window of a child window. An application should not call the
  1331. %SetWindowLong% function to change the parent of a child window.
  1332. GWL_ID
  1333. Control ID of the child window.
  1334. The return value specifies information about the given window.
  1335. To access any extra two-byte values allocated when the window-class
  1336. structure was created, use a positive byte offset as the index specified by
  1337. the <nIndex> parameter, starting at zero for the first two-byte value in the
  1338. extra space, 2 for the next two-byte value and so on.
  1339. --*/
  1340. ULONG FASTCALL WU32GetWindowWord(PVDMFRAME pFrame)
  1341. {
  1342. ULONG ul;
  1343. HWND hwnd;
  1344. INT iOffset;
  1345. PWW pww;
  1346. PGETWINDOWWORD16 parg16;
  1347. GETARGPTR(pFrame, sizeof(GETWINDOWWORD16), parg16);
  1348. // Make sure Win32 didn't change offsets
  1349. #if (GWL_HINSTANCE != (-6) || GWL_HWNDPARENT != (-8) || GWL_ID != (-12))
  1350. #error Win16/Win32 window-word constants differ
  1351. #endif
  1352. // Make sure the 16-bit app is requesting allowable offsets
  1353. iOffset = INT32(parg16->f2);
  1354. WOW32ASSERT(iOffset >= 0 ||
  1355. iOffset == GWL_HINSTANCE ||
  1356. iOffset == GWL_STYLE ||
  1357. iOffset == GWL_HWNDPARENT || iOffset == GWL_ID);
  1358. hwnd = HWND32(parg16->f1);
  1359. switch(iOffset) {
  1360. case GWL_STYLE:
  1361. // Wordperfect for windows calls GetWindowWord with GWL_STYLE.
  1362. ul = (ULONG)GetWindowLong(hwnd, iOffset);
  1363. break;
  1364. case GWL_HINSTANCE:
  1365. ul = GetGWW_HINSTANCE(hwnd);
  1366. break;
  1367. case GWL_HWNDPARENT:
  1368. ul = (ULONG)GETHWND16((HAND32)GetWindowLong(hwnd, iOffset));
  1369. break;
  1370. case GWL_ID:
  1371. ul = GetWindowLong(hwnd, iOffset);
  1372. if (!(GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD)) {
  1373. ul = (ULONG)GETHMENU16(ul);
  1374. }
  1375. break;
  1376. // Under Windows index 4 of a static control could be the icon
  1377. case 4:
  1378. pww = FindPWW(hwnd);
  1379. if (pww) {
  1380. if (((pww->style & SS_TYPEMASK) == SS_ICON) &&
  1381. (GETICLASS(pww, hwnd) == WOWCLASS_STATIC)) {
  1382. ul = SendMessage(hwnd, STM_GETICON, 0, 0);
  1383. return GETHICON16(ul);
  1384. }
  1385. }
  1386. // FALL THROUGH!
  1387. default:
  1388. //
  1389. // Offset is non-negative, this is the cbWndExtra bytes that
  1390. // are fair game.
  1391. //
  1392. //
  1393. // Gross app hack for Adonis' Clip-Art Window Shopper online
  1394. // clipart software that comes with CA-Cricket Presents.
  1395. // These people SetWindowWord(hwnd, 3, wWhatever), thereby
  1396. // overwriting the 4th and 5th bytes of per-window data.
  1397. // The edit control itself only uses the first 2 bytes
  1398. // on 3.1, and has 6 bytes reserved, so this works. On
  1399. // NT the first 4 bytes are used (32-bit handle), and so
  1400. // this P.O.S. overwrites the high byte of the handle.
  1401. // So if it's the compatibility flag is set and the class name
  1402. // matches the one this bogus app uses, and it's storing a
  1403. // word at offset 3, change it to 4. This is safe because
  1404. // the NT edit control only uses the first 4 of its 6
  1405. // reserved window extra bytes.
  1406. //
  1407. if (3 == iOffset && (CURRENTPTD()->dwWOWCompatFlags & WOWCF_EDITCTRLWNDWORDS)) {
  1408. char szClassName[30];
  1409. if (GetClassName(hwnd, szClassName, sizeof(szClassName)) &&
  1410. !WOW32_strcmp(szClassName, "SuperPassEdit")) {
  1411. iOffset = 4;
  1412. LOGDEBUG(LOG_ALWAYS,("WOW WU32GetWindowWord: SHOPPER hack triggered, using offset 4, rc = %x.\n",
  1413. GetWindowWord(hwnd, iOffset)));
  1414. }
  1415. }
  1416. ul = GetWindowWord(hwnd, iOffset);
  1417. break;
  1418. }
  1419. FREEARGPTR(parg16);
  1420. RETURN(ul);
  1421. }
  1422. //
  1423. // GetGWW_HINSTANCE is a common implementation for GetWindowWord(GWW_HINSTANCE)
  1424. // and GetWindowLong(GWW_HINSTANCE).
  1425. //
  1426. ULONG FASTCALL GetGWW_HINSTANCE(HWND hwnd)
  1427. {
  1428. DWORD dwProcessID32, dwThreadID32;
  1429. ULONG ul;
  1430. PWOAINST pWOA;
  1431. PTD ptd;
  1432. HTASK16 htask16;
  1433. dwProcessID32 = (DWORD)-1;
  1434. dwThreadID32 = GetWindowThreadProcessId( hwnd, &dwProcessID32 );
  1435. ul = (ULONG)GetWindowLong(hwnd, GWL_HINSTANCE);
  1436. if ( ISINST16(ul) ) {
  1437. //
  1438. // This could be a valid HINST in another WOW VDM,
  1439. // in which case we need to hide it from this VDM.
  1440. //
  1441. if (dwProcessID32 != GetCurrentProcessId() &&
  1442. dwProcessID32 != (DWORD)-1) {
  1443. ul = (ULONG)ghInstanceUser32;
  1444. goto ElseClause;
  1445. }
  1446. }
  1447. else
  1448. {
  1449. ElseClause:
  1450. // here if ul = NULL or ul = 0xZZZZ0000
  1451. //
  1452. // if (ul is 0xZZZZ0000) return 16bit user.exe instance.
  1453. // PowerBuilder 3.0 does
  1454. // hInst = GetWindowWord(Dialog, GWL_HINSTANCE)
  1455. // hIcon = CreateIcon(... hInst ...);
  1456. // CreateIcon will fail if hInst is invalid (say BOGUSGDT). So
  1457. // we return 16bit user.exe hinstance in all such cases.
  1458. //
  1459. // Some 32-bit applications put 0 in the HINSTANCE
  1460. // stuff for their window (its optional for 32-bit windows).
  1461. //
  1462. //
  1463. // Check if this window belongs to a task we spawned via
  1464. // WinOldAp, if so, return WinOldAp's hmodule.
  1465. //
  1466. ptd = CURRENTPTD();
  1467. EnterCriticalSection(&ptd->csTD);
  1468. pWOA = ptd->pWOAList;
  1469. while (pWOA && pWOA->dwChildProcessID != dwProcessID32) {
  1470. pWOA = pWOA->pNext;
  1471. }
  1472. if (pWOA) {
  1473. ul = pWOA->ptdWOA->hInst16;
  1474. LOGDEBUG(LOG_ALWAYS, ("WOW32 GetWindowWord(0x%x, GWW_HINSTANCE) returning 0x%04x\n",
  1475. hwnd, ul));
  1476. } else {
  1477. ul = (ul) ? gUser16hInstance : ul;
  1478. if (cHtaskAliasCount != 0 ) {
  1479. //
  1480. // Must be some 32-bit process, not a wow app's window
  1481. //
  1482. if ( dwThreadID32 != 0 ) {
  1483. htask16 = FindHtaskAlias( dwThreadID32 );
  1484. if ( htask16 != 0 ) {
  1485. ul = (ULONG)htask16;
  1486. }
  1487. }
  1488. }
  1489. }
  1490. LeaveCriticalSection(&ptd->csTD);
  1491. }
  1492. return ul;
  1493. }
  1494. /*++
  1495. UINT MenuItemFromPoint(<hwndParent>, <Menu>, <Point>)
  1496. HWND <hwndParent>;
  1497. HMENU <Menu>;
  1498. POINT <Point>;
  1499. The %MenuItemFromPoint% function determines which, if any, of the menu
  1500. items belonging to the given parent window contains the specified point.
  1501. <hwndParent>
  1502. Identifies the parent window.
  1503. <Point>
  1504. Specifies the client coordinates of the point to be tested.
  1505. The return value identifies the menu item that contains the point. It is
  1506. -1 if the given point lies outside the parent window. If the point is
  1507. within the parent window but is not contained within any menu item, -1
  1508. is returned.
  1509. --*/
  1510. ULONG FASTCALL WU32MenuItemFromPoint(PVDMFRAME pFrame)
  1511. {
  1512. ULONG ul;
  1513. POINT pt32;
  1514. register PMENUITEMFROMPOINT16 parg16;
  1515. GETARGPTR(pFrame, sizeof(MENUITEMFROMPOINT16), parg16);
  1516. COPYPOINT16(parg16->ptScreen, pt32);
  1517. ul = MenuItemFromPoint(HWND32(parg16->hwnd), HMENU32(parg16->hmenu), pt32);
  1518. FREEARGPTR(parg16);
  1519. RETURN(ul);
  1520. }
  1521. /*++
  1522. BOOL MoveWindow(<hwnd>, <left>, <top>, <width>, <height>, <fRepaint>)
  1523. HWND <hwnd>;
  1524. int <left>;
  1525. int <top>;
  1526. int <width>;
  1527. int <height>;
  1528. BOOL <fRepaint>;
  1529. The %MoveWindow% function changes the position and dimensions of a window.
  1530. <hwnd>
  1531. Identifies the window to change.
  1532. <left>
  1533. Specifies the new position of the left side of the window.
  1534. <top>
  1535. Specifies the new position of the top of the window.
  1536. <width>
  1537. Specifies the new width of the window.
  1538. <height>
  1539. Specifies the new height of the window.
  1540. <fRepaint>
  1541. Specifies whether or not the window is to be repainted. If this
  1542. parameter is TRUE, the window is repainted.
  1543. The return value is nonzero if the function is successful. Otherwise it is
  1544. zero. (updated for Win3.1 compatability -- this returned void for Win3.0)
  1545. For top-level windows the <left> and <top> parameters are relative to the
  1546. upper-left corner of the screen. For child windows, they are relative to the
  1547. upper-left corner of the parent window's client area.
  1548. The %MoveWindow% function sends a WM_GETMINMAXINFO message to the window
  1549. being moved. This gives the window being moved the opportunity to modify
  1550. the default values for the largest and smallest possible windows. If the
  1551. parameters to the %MoveWindow% function exceed these values, the values will
  1552. be replaced by the minimum or maximum values specified in the
  1553. WM_GETMINMAXINFO message.
  1554. --*/
  1555. ULONG FASTCALL WU32MoveWindow(PVDMFRAME pFrame)
  1556. {
  1557. ULONG ul;
  1558. register PMOVEWINDOW16 parg16;
  1559. GETARGPTR(pFrame, sizeof(MOVEWINDOW16), parg16);
  1560. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_DBASEHANDLEBUG) {
  1561. RECT ParentRect;
  1562. RECT ScreenRect;
  1563. GetWindowRect(GetDesktopWindow(), &ScreenRect);
  1564. if ((INT32(parg16->f2) > ScreenRect.right) ||
  1565. (INT32(parg16->f3) > ScreenRect.bottom) ||
  1566. (INT32(parg16->f4) > ScreenRect.right) ||
  1567. (INT32(parg16->f5) > ScreenRect.bottom)) {
  1568. int x, y, cx, cy;
  1569. GetWindowRect(GetParent(HWND32(parg16->f1)), &ParentRect);
  1570. x = ParentRect.left;
  1571. y = ParentRect.top;
  1572. cx = ParentRect.right - ParentRect.left;
  1573. cy = ParentRect.bottom - ParentRect.top;
  1574. ul = GETBOOL16(MoveWindow(HWND32(parg16->f1), x, y, cx, cy,
  1575. BOOL32(parg16->f6)));
  1576. FREEARGPTR(parg16);
  1577. RETURN(ul);
  1578. }
  1579. }
  1580. ul = GETBOOL16(MoveWindow(HWND32(parg16->f1),
  1581. INT32(parg16->f2),
  1582. INT32(parg16->f3),
  1583. INT32(parg16->f4),
  1584. INT32(parg16->f5),
  1585. BOOL32(parg16->f6)));
  1586. FREEARGPTR(parg16);
  1587. RETURN(ul);
  1588. }
  1589. /*++
  1590. void ScrollWindow(<hwnd>, <XAmount>, <YAmount>, <lpRect>, <lpClipRect>)
  1591. HWND <hwnd>;
  1592. int <XAmount>;
  1593. int <YAmount>;
  1594. LPRECT <lpRect>;
  1595. LPRECT <lpClipRect>;
  1596. The %ScrollWindow% function scrolls a window by moving the contents of the
  1597. window's client area the number of units specified by the <XAmount>
  1598. parameter along the screen's <x>-axis and the number of units specified by
  1599. the <YAmount> parameter along the <y>-axis. The scroll moves right if
  1600. <XAmount> is positive and left if it is negative. The scroll moves down if
  1601. <YAmount> is positive and up if it is negative.
  1602. <hwnd>
  1603. Identifies the window whose client area is to be scrolled.
  1604. <XAmount>
  1605. Specifies the amount (in device units) to scroll in the <x>
  1606. direction.
  1607. <YAmount>
  1608. Specifies the amount (in device units) to scroll in the <y>
  1609. direction.
  1610. <lpRect>
  1611. Points to a %RECT% structure that specifies the portion of
  1612. the client area to be scrolled. If <lpRect> is NULL, the entire client
  1613. area is scrolled.
  1614. <lpClipRect>
  1615. Points to a %RECT% structure that specifies the clipping
  1616. rectangle to be scrolled. Only bits inside this rectangle are scrolled.
  1617. If <lpClipRect> is NULL, the entire window is scrolled.
  1618. This function does not return a value.
  1619. If the caret is in the window being scrolled, %ScrollWindow% automatically
  1620. hides the caret to prevent it from being erased, then restores the caret
  1621. after the scroll is finished. The caret position is adjusted accordingly.
  1622. The area uncovered by the %ScrollWindow% function is not repainted, but is
  1623. combined into the window's update region. The application will eventually
  1624. receive a WM_PAINT message notifying it that the region needs repainting. To
  1625. repaint the uncovered area at the same time the scrolling is done, call the
  1626. %UpdateWindow% function immediately after calling %ScrollWindow%.
  1627. If the <lpRect> parameter is NULL, the positions of any child windows in the
  1628. window are offset by the amount specified by <XAmount> and <YAmount>, and
  1629. any invalid (unpainted) areas in the window are also offset. %ScrollWindow%
  1630. is faster when <lpRect> is NULL.
  1631. If the <lpRect> parameter is not NULL, the positions of child windows are
  1632. <not> changed, and invalid areas in the window are <not> offset. To prevent
  1633. updating problems when <lpRect> is not NULL, call the %UpdateWindow%
  1634. function to repaint the window before calling %ScrollWindow%.
  1635. --*/
  1636. ULONG FASTCALL WU32ScrollWindow(PVDMFRAME pFrame)
  1637. {
  1638. RECT t4, *p4;
  1639. RECT t5, *p5;
  1640. register PSCROLLWINDOW16 parg16;
  1641. GETARGPTR(pFrame, sizeof(SCROLLWINDOW16), parg16);
  1642. p4 = GETRECT16(parg16->f4, &t4);
  1643. p5 = GETRECT16(parg16->f5, &t5);
  1644. ScrollWindow(
  1645. HWND32(parg16->f1),
  1646. INT32(parg16->f2),
  1647. INT32(parg16->f3),
  1648. p4,
  1649. p5
  1650. );
  1651. FREEARGPTR(parg16);
  1652. RETURN(0);
  1653. }
  1654. /*++
  1655. LONG SetWindowLong(<hwnd>, <nIndex>, <dwNewLong>)
  1656. HWND <hwnd>;
  1657. int <nIndex>;
  1658. DWORD <dwNewLong>;
  1659. The %SetWindowLong% function changes an attribute of the window specified by
  1660. the <hwnd> parameter.
  1661. <hwnd>
  1662. Identifies the window.
  1663. <nIndex>
  1664. Specifies the byte offset of the attribute to be changed. It may
  1665. also be one of the following values:
  1666. GWL_EXSTYLE
  1667. Sets a new extended window style.
  1668. GWL_STYLE
  1669. Sets a new window style.
  1670. GWL_WNDPROC
  1671. Sets a new long pointer to the window procedure.
  1672. <dwNewLong>
  1673. Specifies the replacement value.
  1674. The return value specifies the previous value of the specified long
  1675. integer.
  1676. If the %SetWindowLong% function and the GWL_WNDPROC index are used to set a
  1677. new window function, that function must have the window-function form and be
  1678. exported in the module-definition file of the application. For more
  1679. information, see the %RegisterClass% function, earlier in this chapter.
  1680. Calling %SetWindowLong% with the GCL_WNDPROC index creates a subclass of the
  1681. window class used to create the window. See Chapter 1, Window Manager
  1682. Interface Functions, for more information on window subclassing. An
  1683. application should not attempt to create a window subclass for standard
  1684. Windows controls such as combo boxes and buttons.
  1685. To access any extra four-byte values allocated when the window-class
  1686. structure was created, use a positive byte offset as the index specified by
  1687. the <nIndex> parameter, starting at zero for the first four-byte value in
  1688. the extra space, 4 for the next four-byte value and so on.
  1689. --*/
  1690. ULONG FASTCALL WU32SetWindowLong(PVDMFRAME pFrame)
  1691. {
  1692. ULONG ul;
  1693. INT iOffset, iClass;
  1694. register PWW pww;
  1695. register PSETWINDOWLONG16 parg16;
  1696. GETARGPTR(pFrame, sizeof(SETWINDOWLONG16), parg16);
  1697. // Make sure Win32 didn't change offsets for GWL constants
  1698. #if (GWL_WNDPROC != (-4) || GWL_STYLE != (-16) || GWL_EXSTYLE != (-20))
  1699. #error Win16/Win32 GWL constants differ
  1700. #endif
  1701. // Make sure the 16-bit app is requesting allowable offsets
  1702. iOffset = INT32(parg16->f2);
  1703. WOW32ASSERT(iOffset >= 0 ||
  1704. iOffset == GWL_WNDPROC ||
  1705. iOffset == GWL_STYLE || iOffset == GWL_EXSTYLE);
  1706. ul = 0;
  1707. if ((iOffset == GWL_WNDPROC) || (iOffset == DWL_DLGPROC)) {
  1708. if (pww = FindPWW(HWND32(parg16->f1))) {
  1709. DWORD dwWndProc32Old;
  1710. DWORD dwWndProc32New;
  1711. if ((iOffset == DWL_DLGPROC) && !(pww->state & WF_DIALOG_WINDOW)) {
  1712. goto defswp;
  1713. }
  1714. // Look to see if the new 16:16 proc is a thunk for a 32-bit proc.
  1715. dwWndProc32New = IsThunkWindowProc(LONG32(parg16->f3), &iClass );
  1716. if ( dwWndProc32New != 0 ) {
  1717. //
  1718. // They are attempting to set the window proc to an existing
  1719. // 16-bit thunk that is really just a thunk for a 32-bit
  1720. // routine. We can just set it back to the 32-bit routine.
  1721. //
  1722. dwWndProc32Old = SetWindowLong(HWND32(parg16->f1), iOffset, dwWndProc32New);
  1723. // If the 32 bit set failed, perhaps because its another process,
  1724. // then we want to fail too
  1725. if (!dwWndProc32Old)
  1726. goto SWL_Cleanup;
  1727. } else {
  1728. //
  1729. // They are attempting to set it to a real 16:16 proc.
  1730. //
  1731. LONG l;
  1732. l = LONG32(parg16->f3);
  1733. // mark the proc as WOW proc and save the high bits in the RPL
  1734. //
  1735. // Don't mark a NULL proc since USER32 DefWindowProcWorker
  1736. // looks specifically for NULL. WOW used to do this correctly
  1737. // but was broken by a performance enhancement checkin. This
  1738. // fixes VC1.52 debugging.
  1739. //
  1740. if (l) {
  1741. MarkWOWProc (l,l);
  1742. }
  1743. dwWndProc32Old = SetWindowLong(HWND32(parg16->f1), iOffset, l);
  1744. // If the 32 bit set failed, perhaps because its another process,
  1745. // then we want to fail too
  1746. if (!dwWndProc32Old)
  1747. goto SWL_Cleanup;
  1748. }
  1749. if ( IsWOWProc (dwWndProc32Old)) {
  1750. if ( HIWORD(dwWndProc32Old) == WNDPROC_HANDLE ) {
  1751. //
  1752. // If the return value was a handle to a proc (due to
  1753. // the need for unicode-ansi transitions, or vice versa)
  1754. // then treat it as a 32-bit thunk.
  1755. //
  1756. ul = GetThunkWindowProc(dwWndProc32Old, NULL, pww, HWND32(parg16->f1));
  1757. } else {
  1758. //
  1759. // Previous proc was a 16:16 proc
  1760. //
  1761. //Unmark the proc and restore the high bits from rpl field
  1762. UnMarkWOWProc (dwWndProc32Old,ul);
  1763. }
  1764. } else {
  1765. //
  1766. // Previous proc was a 32-bit proc, use an allocated thunk
  1767. //
  1768. ul = GetThunkWindowProc(dwWndProc32Old, NULL, pww, HWND32(parg16->f1));
  1769. }
  1770. }
  1771. }
  1772. else { // not GWL_WNDPROC or GWL_DLGPROC
  1773. LONG new;
  1774. defswp:
  1775. new = LONG32(parg16->f3);
  1776. /*
  1777. * We need to keep Wow apps from putting garbage in post-4.0 bits in
  1778. * the extended style DWORD. Kiplinger's TaxCut 97 sets the WS_EX_LAYERED
  1779. * bit on their help window, which is quite unfortunate.
  1780. */
  1781. if (iOffset == GWL_EXSTYLE) {
  1782. new &= WS_EX_VALID40;
  1783. new |= (GetWindowLong(HWND32(parg16->f1), GWL_EXSTYLE) & ~WS_EX_VALID40);
  1784. }
  1785. // This is a real HACK for PowerBuild 3.0. Before we change the offset
  1786. // from 2 to 4, we nneed to make sure that we are doing it for this
  1787. // specific class.
  1788. // The class in this case is "PaList".
  1789. //
  1790. // ChandanC Marh 9th 1994
  1791. //
  1792. if (iOffset == 2) {
  1793. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_GWLINDEX2TO4) {
  1794. char Buffer[40];
  1795. if (GetClassName (HWND32(parg16->f1), Buffer, sizeof(Buffer))) {
  1796. if (!WOW32_stricmp (Buffer, "PaList")) {
  1797. iOffset = 4;
  1798. }
  1799. }
  1800. }
  1801. }
  1802. ul = SetWindowLong(HWND32(parg16->f1), iOffset, new);
  1803. }
  1804. SWL_Cleanup:
  1805. FREEARGPTR(parg16);
  1806. RETURN(ul);
  1807. }
  1808. /*++
  1809. BOOL ShowWindow(<hWnd>, <nCmdShow>)
  1810. HWND <hWnd>;
  1811. int <nCmdShow>;
  1812. The %ShowWindow% function sets the specified windows show state.
  1813. <hWnd>
  1814. Handle to the window.
  1815. <nCmdShow>
  1816. Specifies how the window is to be shown. This value can have any of the
  1817. following values:
  1818. SW_FORCEMINIMIZE
  1819. Minimizes a window, even if the thread that owns the window is hung.
  1820. This flag should only be used when minimizing windows from a different
  1821. thread.
  1822. SW_HIDE
  1823. Hides the window and activiates another window.
  1824. SW_MINIMIZE
  1825. Minimizes the specified window and activates the next top-level window
  1826. in the Z order.
  1827. SW_RESTORE
  1828. Activates and displays the window. If the window is minimized or maximized,
  1829. the system restores it to its original size and position. An application
  1830. should specify this flag when restoring a minimized window.
  1831. SW_SHOW
  1832. Activiates the window and displays it in its current size and position.
  1833. SW_SHOWDEFAULT
  1834. Sets the show state based on the SW_ value specified in the STARTUPINFO
  1835. structure passed to the CreateProcess() function by the program that started
  1836. the application.
  1837. SW_SHOWMAXIMIZED
  1838. Activates the window and displays it as a minimized window.
  1839. SW_SHOWMINNOACTIVE
  1840. Displays the window as a minimized window. This value is similar to
  1841. SW_SHOWMINIMIZED, except the window is not activated.
  1842. SW_SHOWNA
  1843. Displays the window in its current size and position. This value is similar
  1844. to SW_SHOW, except the window is not activated.
  1845. SW_SHOWNOACTIVATE
  1846. Displays a window in its most recent size and position. This value is similar
  1847. to SW_SHOWNORMAL, except the window is not activated.
  1848. SW_SHOWNORMAL
  1849. Activates and displays a window. If the window is minimized or maximized,
  1850. the system restores it to its orignial size and position. An application
  1851. should specify this flag when displaying the window for the first time.
  1852. This function returns nonzero if the window if the window was previously visible.
  1853. It returns zero if the window was previously hidden.
  1854. The first time an application calls ShowWindow(), it should use the WinMain
  1855. function's <nCmdShow> parameter as its <nCmdShow> parameter. Subsequent calls to
  1856. ShowWindow() must use one of the values in the given list, instead of the one
  1857. specified by the WinMain function's <nCmdShow> parameter.
  1858. --*/
  1859. ULONG FASTCALL WU32ShowWindow(PVDMFRAME pFrame)
  1860. {
  1861. BOOL bReturn = FALSE;
  1862. register PSHOWWINDOW16 parg16;
  1863. GETARGPTR(pFrame, sizeof(SHOWWINDOW16), parg16);
  1864. bReturn = ShowWindow(HWND32(parg16->f1), INT32(parg16->f2));
  1865. // WHISTLER RAID BUG #348251
  1866. // The artgalry.exe window would remain behind autosketches window after it was
  1867. // invoked. This hack works in conjuction with the GACF2_GIVEUPFOREGROUND
  1868. // compatibility flag, applied to the app that will not give up the foreground.
  1869. // In order to move the 16bit window to the top, we have to call
  1870. // SetForegroundWindow() on the hwnd. We only want to call this if the windows
  1871. // show bit is set and the window is active.
  1872. if((INT32(parg16->f2) | SW_SHOW) && (bReturn == 0) && (CURRENTPTD()->dwWOWCompatFlags2 & WOWCF2_SETFOREGROUND))
  1873. {
  1874. SetForegroundWindow(HWND32(parg16->f1));
  1875. LOGDEBUG(LOG_WARNING, ("WU32ShowWindow: SetForegroundWindow called. HWND=%x STYLE=%x\n",
  1876. HWND32(parg16->f1),
  1877. INT32(parg16->f2)));
  1878. }
  1879. FREEARGPTR(parg16);
  1880. RETURN((ULONG)bReturn);
  1881. }
  1882. /*++
  1883. BOOL SetWindowPos(<hwnd>, <hwndInsertAfter>, <X>, <Y>, <cx>, <cy>, <wFlags>)
  1884. HWND <hwnd>;
  1885. HWND <hwndInsertAfter>;
  1886. int <X>;
  1887. int <Y>;
  1888. int <cx>;
  1889. int <cy>;
  1890. WORD <wFlags>;
  1891. The %SetWindowPos% function changes the size, position, and ordering of
  1892. child, pop-up, and top-level windows. Child, pop-up, and top-level windows
  1893. are ordered according to their appearance on the screen; the topmost window
  1894. receives the highest rank, and it is the first window in the list. This
  1895. ordering is recorded in a window list.
  1896. <hwnd>
  1897. Identifies the window that will be positioned.
  1898. <hwndInsertAfter>
  1899. Identifies a window in the window-manager's list that will
  1900. precede the positioned window.
  1901. <X>
  1902. Specifies the <x->coordinate of the window's upper-left corner.
  1903. <Y>
  1904. Specifies the <y->coordinate of the window's upper-left corner.
  1905. <cx>
  1906. Specifies the new window's width.
  1907. <cy>
  1908. Specifies the new window's height.
  1909. <wFlags>
  1910. Specifies one of eight possible 16-bit values that affect the
  1911. sizing and positioning of the window. It must be one of the following
  1912. values:
  1913. SWP_DRAWFRAME
  1914. Draws a frame (defined in the window's class description) around the
  1915. window.
  1916. SWP_HIDEWINDOW
  1917. Hides the window.
  1918. SWP_NOACTIVATE
  1919. Does not activate the window.
  1920. SWP_NOMOVE
  1921. Retains current position (ignores the <x> and <y> parameters).
  1922. SWP_NOSIZE
  1923. Retains current size (ignores the <cx> and <cy> parameters).
  1924. SWP_NOREDRAW
  1925. Does not redraw changes.
  1926. SWP_NOZORDER
  1927. Retains current ordering (ignores the <hwndInsertAfter> parameter).
  1928. SWP_SHOWWINDOW
  1929. Displays the window.
  1930. The return value is nonzero if the function is successful. Otherwise it is
  1931. zero. (updated for Win3.1 compatability -- this returned void for Win3.0)
  1932. If the SWP_NOZORDER flag is not specified, Windows places the window
  1933. identified by the <hwnd> parameter in the position following the window
  1934. identified by the <hwndInsertAfter> parameter. If <hwndInsertAfter> is NULL,
  1935. Windows places the window identified by <hwnd> at the top of the list. If
  1936. <hwndInsertAfter> is set to 1, Windows places the window identified by
  1937. <hwnd> at the bottom of the list.
  1938. If the SWP_SHOWWINDOW or the SWP_HIDEWINDOW flags are set, scrolling and
  1939. moving cannot be done simultaneously.
  1940. All coordinates for child windows are relative to the upper-left corner of
  1941. the parent window's client area.
  1942. --*/
  1943. ULONG FASTCALL WU32SetWindowPos(PVDMFRAME pFrame)
  1944. {
  1945. ULONG ul;
  1946. register PSETWINDOWPOS16 parg16;
  1947. GETARGPTR(pFrame, sizeof(SETWINDOWPOS16), parg16);
  1948. #ifdef FE_IME
  1949. // MSKKBUG:3866 HWND_IMETOPMOST for MS-DRAW
  1950. if ( (HWND)INT32(parg16->f2) == (HWND)-3 )
  1951. ul = GETBOOL16(SetWindowPos(HWND32(parg16->f1),
  1952. HWND_TOPMOST,
  1953. INT32(parg16->f3),
  1954. INT32(parg16->f4),
  1955. INT32(parg16->f5),
  1956. INT32(parg16->f6),
  1957. WORD32(parg16->f7) & SWP_VALID));
  1958. else
  1959. #endif // FE_IME
  1960. ul = GETBOOL16(SetWindowPos(HWND32(parg16->f1),
  1961. HWNDIA32(parg16->f2),
  1962. INT32(parg16->f3),
  1963. INT32(parg16->f4),
  1964. INT32(parg16->f5),
  1965. INT32(parg16->f6),
  1966. WORD32(parg16->f7) & SWP_VALID));
  1967. FREEARGPTR(parg16);
  1968. RETURN(ul);
  1969. }
  1970. /*++
  1971. void SetWindowText(<hwnd>, <lpString>)
  1972. The %SetWindowText% function sets the given window's caption title (if one
  1973. exists) to the string pointed to by the <lpString> parameter. If the <hwnd>
  1974. parameter is a handle to a control, the %SetWindowText% function sets the
  1975. text within the control instead of within the caption.
  1976. <hwnd>
  1977. Identifies the window or control whose text is to be changed.
  1978. <lpString>
  1979. Points to a null-terminated string.
  1980. This function does not return a value.
  1981. --*/
  1982. ULONG FASTCALL WU32SetWindowText(PVDMFRAME pFrame)
  1983. {
  1984. PSZ psz2;
  1985. register PSETWINDOWTEXT16 parg16;
  1986. HANDLE handle;
  1987. GETARGPTR(pFrame, sizeof(SETWINDOWTEXT16), parg16);
  1988. GETPSZPTR(parg16->f2, psz2);
  1989. handle = HWND32(parg16->f1);
  1990. if (NULL != psz2) {
  1991. AddParamMap((DWORD)psz2, FETCHDWORD(parg16->f2));
  1992. }
  1993. if (CURRENTPTD()->dwWOWCompatFlags & WOWCF_DBASEHANDLEBUG) {
  1994. if (NULL == handle) {
  1995. handle = (HANDLE) ((PTDB)SEGPTR(pFrame->wTDB,0))->TDB_CompatHandle;
  1996. }
  1997. }
  1998. SetWindowText(handle, psz2);
  1999. // if we used param map successfully - then nuke there
  2000. if (NULL != psz2) {
  2001. DeleteParamMap((DWORD)psz2, PARAM_32, NULL);
  2002. }
  2003. FREEPSZPTR(psz2);
  2004. FREEARGPTR(parg16);
  2005. RETURN(0);
  2006. }
  2007. /*++
  2008. WORD SetWindowWord(<hwnd>, <nIndex>, <wNewWord>)
  2009. The %SetWindowWord% function changes an attribute of the window specified by
  2010. the <hwnd> parameter.
  2011. <hwnd>
  2012. Identifies the window to be modified.
  2013. <nIndex>
  2014. Specifies the byte offset of the word to be changed. It can also
  2015. be one of the following values:
  2016. GWL_HINSTANCE
  2017. Instance handle of the module that owns the window.
  2018. GWL_ID
  2019. Control ID of the child window.
  2020. <wNewWord>
  2021. Specifies the replacement value.
  2022. The return value specifies the previous value of the specified word.
  2023. To access any extra two-byte values allocated when the window-class
  2024. structure was created, use a positive byte offset as the index specified by
  2025. the <nIndex> parameter, starting at zero for the first two-byte value in the
  2026. extra space, 2 for the next two-byte value and so on.
  2027. --*/
  2028. ULONG FASTCALL WU32SetWindowWord(PVDMFRAME pFrame)
  2029. {
  2030. ULONG ul;
  2031. HWND hwnd;
  2032. INT iOffset;
  2033. PSETWINDOWWORD16 parg16;
  2034. PWW pww;
  2035. GETARGPTR(pFrame, sizeof(SETWINDOWWORD16), parg16);
  2036. // Make sure Win32 didn't change offsets
  2037. #if (GWL_HINSTANCE != (-6) || GWL_HWNDPARENT != (-8) || GWL_ID != (-12))
  2038. #error Win16/Win32 window-word constants differ
  2039. #endif
  2040. // Make sure the 16-bit app is requesting allowable offsets
  2041. iOffset = INT32(parg16->f2);
  2042. WOW32ASSERT(iOffset >= 0 ||
  2043. iOffset == GWL_HINSTANCE || iOffset == GWL_ID ||
  2044. iOffset == GWL_HWNDPARENT);
  2045. hwnd = HWND32(parg16->f1);
  2046. ul = WORD32(parg16->f3);
  2047. switch(iOffset) {
  2048. case GWL_HINSTANCE:
  2049. ul = GETHINST16(SetWindowLong(hwnd,
  2050. iOffset,
  2051. (LONG)HMODINST32(parg16->f3)));
  2052. break;
  2053. case GWL_HWNDPARENT:
  2054. // ul = 0; // not allowed to set this
  2055. ul = SetWindowLong(hwnd, iOffset, (LONG)HWND32(parg16->f3));
  2056. ul = GETHWND16((HAND32)ul);
  2057. break;
  2058. case GWL_ID:
  2059. {
  2060. // if this isn't a child window then the value should be a
  2061. // menu handle
  2062. BOOL fChild = (GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD);
  2063. ul = SetWindowLong(hwnd,
  2064. iOffset,
  2065. fChild ? (LONG)ul : (LONG)HMENU32(parg16->f3));
  2066. if (!fChild)
  2067. ul = (ULONG)GETHMENU16(ul);
  2068. // Invalidate the SendDlgItemMessage cache
  2069. hdlgSDIMCached = NULL ;
  2070. }
  2071. break;
  2072. // Under Windows index 4 of a static control could be the icon
  2073. case 4:
  2074. pww = FindPWW(hwnd);
  2075. if (pww) {
  2076. if (((pww->style & SS_TYPEMASK) == SS_ICON) &&
  2077. (GETICLASS(pww, hwnd) == WOWCLASS_STATIC)) {
  2078. ul = SendMessage(hwnd, STM_SETICON, (WPARAM)HICON32(ul), 0);
  2079. return GETHICON16(ul);
  2080. }
  2081. }
  2082. // FALL THROUGH!
  2083. default:
  2084. //
  2085. // Offset is non-negative, this is the cbWndExtra bytes that
  2086. // are fair game.
  2087. //
  2088. //
  2089. // Gross app hack for Adonis' Clip-Art Window Shopper online
  2090. // clipart software that comes with CA-Cricket Presents.
  2091. // These people SetWindowWord(hwnd, 3, wWhatever), thereby
  2092. // overwriting the 4th and 5th bytes of per-window data.
  2093. // The edit control itself only uses the first 2 bytes
  2094. // on 3.1, and has 6 bytes reserved, so this works. On
  2095. // NT the first 4 bytes are used (32-bit handle), and so
  2096. // this P.O.S. overwrites the high byte of the handle.
  2097. // So if it's an app called "SHOPPER" and it's storing a
  2098. // word at offset 3, change it to 4. This is safe because
  2099. // the NT edit control only uses the first 4 of its 6
  2100. // reserved window extra bytes.
  2101. //
  2102. if (3 == iOffset && (CURRENTPTD()->dwWOWCompatFlags & WOWCF_EDITCTRLWNDWORDS)) {
  2103. char szClassName[30];
  2104. if (GetClassName(hwnd, szClassName, sizeof(szClassName)) &&
  2105. !WOW32_strcmp(szClassName, "SuperPassEdit")) {
  2106. iOffset = 4;
  2107. LOGDEBUG(LOG_ALWAYS,("WOW WU32SetWindowWord: SHOPPER hack triggered, using offset 4.\n"));
  2108. }
  2109. }
  2110. ul = SetWindowWord(hwnd, iOffset, (WORD)ul);
  2111. break;
  2112. }
  2113. FREEARGPTR(parg16);
  2114. RETURN(ul);
  2115. }
  2116. /*++ user
  2117. void UpdateWindow(<hwnd>)
  2118. The %UpdateWindow% function updates the client area of the given window by
  2119. sending a WM_PAINT message to the window if the update region for the window
  2120. is not empty. The %UpdateWindow% function sends a WM_PAINT message directly
  2121. to the window function of the given window, bypassing the application
  2122. queue. If the update region is empty, no message is sent.
  2123. <hwnd>
  2124. Identifies the window to be updated.
  2125. This function does not return a value.
  2126. --*/
  2127. ULONG FASTCALL WU32UpdateWindow(PVDMFRAME pFrame)
  2128. {
  2129. register PUPDATEWINDOW16 parg16;
  2130. GETARGPTR(pFrame, sizeof(UPDATEWINDOW16), parg16);
  2131. UpdateWindow(
  2132. HWND32(parg16->f1)
  2133. );
  2134. FREEARGPTR(parg16);
  2135. RETURN(0xcdef); // ack! same as win31
  2136. }
  2137. /*++
  2138. HWND WindowFromPoint(<Point>)
  2139. The %WindowFromPoint% function identifies the window that contains the given
  2140. point; <Point> must specify the screen coordinates of a point on the screen.
  2141. <Point>
  2142. Specifies a %POINT% structure that defines the point to be checked.
  2143. The return value identifies the window in which the point lies. It is NULL
  2144. if no window exists at the given point.
  2145. --*/
  2146. ULONG FASTCALL WU32WindowFromPoint(PVDMFRAME pFrame)
  2147. {
  2148. ULONG ul;
  2149. POINT t1;
  2150. register PWINDOWFROMPOINT16 parg16;
  2151. GETARGPTR(pFrame, sizeof(WINDOWFROMPOINT16), parg16);
  2152. COPYPOINT16(parg16->f1, t1);
  2153. ul = GETHWND16(WindowFromPoint(t1));
  2154. FREEARGPTR(parg16);
  2155. RETURN(ul);
  2156. }