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.

3895 lines
112 KiB

  1. ---------- NONSHIP\CTL3D\ctl3d.c (12-04-94@22:00) next ----------
  2. 0a1,3648
  3. > /*-----------------------------------------------------------------------
  4. > |
  5. > | CTL3D
  6. > |
  7. > | Copyright Microsoft Corporation 1992. All Rights Reserved.
  8. > |
  9. > |
  10. > | This module contains the functions to give windows controls a 3d effect
  11. > |
  12. > | This source is made public for your edification and debugging pleasure
  13. > |
  14. > | PLEASE do not make any changes or release private versions of this DLL
  15. > | send e-mail to me (wesc) if you have feature requests or bug fixes.
  16. > |
  17. > | Thanks -- Wes.
  18. > |
  19. > |
  20. > | History:
  21. > | 1-Jan-92 : Added OOM handling on GetDC (not really necessary but
  22. > | XL4 OOM failure testing made GetDC return NULL)
  23. > |
  24. > | 1-Jan-92 : Check wasn't getting redrawn when state changed in
  25. > | the default button proc.
  26. > |
  27. > | 29-Jan-92: If button has the focus and app is switched in, we weren't
  28. > | redrawing the entire button check & text. Force redraw
  29. > | of these on WM_SETFOCUS message.
  30. > |
  31. > | 3-Feb-92: Fixed switch in via task manager by erasing the buttons
  32. > | backgound on WM_SETFOCUS (detect this when wParam == NULL)
  33. > |
  34. > | 4-Apr-92: Make it work with OWNERDRAW buttons
  35. > |
  36. > | 22-Apr-92: Removed Excel specific code
  37. > |
  38. > | 19-May-92: Turn it into a DLL
  39. > |
  40. > | May-Jun92: Lots o' fixes & enhancements
  41. > |
  42. > | 23-Jun-92: Added support for hiding, sizing & moving
  43. > |
  44. > | 24-Jun-92: Make checks & radio button circles draw w/ window
  45. > | text color 'cause they are drawn on window bkgnd
  46. > |
  47. > | 30-Jun-92: (0.984) Fix bug where EnableWindow of StaticText doesn't
  48. > | redraw properly. Also disable ctl3d when verWindows > 3.1
  49. > |
  50. > | 1-Jul-92: Added WIN32 support (davegi) (not in this source)
  51. > |
  52. > | 2-Jul-92: (0.984) Disable when verWindows >= 4.0
  53. > |
  54. > | 20-Jul-92: (0.985) Draw focus rects of checks/radios properly on non
  55. > | default sized controls.
  56. > |
  57. > | 21-Jul-92: (0.990) Ctl3dAutoSubclass
  58. > |
  59. > | 21-Jul-92: (0.991) ported DaveGi's WIN32 support
  60. > |
  61. > | 22-Jul-92: (0.991) fixed Ctl3dCtlColor returning fFalse bug
  62. > |
  63. > | 4-Aug-92: (0.992) Graphic designers bug fixes...Now subclass
  64. > | regular buttons + disabled states for checks & radios
  65. > |
  66. > | 6-Aug-92: (0.993) Fix bug where activate via taskman & group
  67. > | box has focus, & not centering text in buttons
  68. > |
  69. > | 6-Aug-92: (0.993) Tweek drawing next to scroll bars.
  70. > |
  71. > | 13-Aug-92: (0.994) Fix button focus rect bug drawing due to
  72. > | Win 3.0 DrawText bug.
  73. > |
  74. > | 14-Aug-92: (1.0) Release of version 1.0
  75. > | Don't draw default button border on BS_DEFPUSHBUTTON
  76. > | pushbuttons
  77. > | Fix bogus bug where Windows hangs when in a AUTORADIOBUTTON
  78. > | hold down space bar and hit arrow key.
  79. > |
  80. > | 23-Sep-92: (1.01) Made Ctl3dCtlColor call DefWindowProc so it works when
  81. > | called in a windproc.
  82. > |
  83. > | 28-Sep-92: (1.02) Added MyGetTextExtent so '&''s not considered in
  84. > | text extents.
  85. > |
  86. > | 08-Dec-92: (1.03) minor tweeks to the button text centering code
  87. > | for Publisher
  88. > |
  89. > | 11-Dec-92: (1.04) added 3d frames to dialogs
  90. > |
  91. > | 15-Dec-92: (1.05) fixed bug where group boxes redraw wrong when
  92. > | Window text is changed to something shorter
  93. > |
  94. > | ??-Dec-92: (1.06) added 3d borders
  95. > |
  96. > | 21-Dec-92: (1.07) added WM_DLGBORDER to disable borders
  97. > |
  98. > | 4-Jan-93: (1.08) fixed WM_SETTEXT bug w/ DLG frames & checks/checkboxes
  99. > | Also, WM_DLGSUBCLASS
  100. > |
  101. > | 22-Feb-93: (1.12) disabled it under Chicago
  102. > |
  103. > | 25-Feb-93: (1.13) re-add fix which allows dialog procs to
  104. > | handle WM_CTLCOLOR messages
  105. > |
  106. > | 26-April-93 (2.0) Changed to allow for second subclass. Now uses class instead of
  107. > | wndproc for subclass determination.
  108. > | store next wndproc in properties with global atoms
  109. > |
  110. > | 06-Jun-93 (2.0) Make a static linked library version.
  111. > |
  112. > |
  113. > -----------------------------------------------------------------------*/
  114. > #include <windows.h>
  115. >
  116. > #ifdef _BORLAND
  117. > #include <mem.h>
  118. > #else
  119. > #include <memory.h>
  120. > #endif
  121. >
  122. > #include <malloc.h>
  123. > #include "ctl3d.h"
  124. >
  125. > #include "stdio.h"
  126. >
  127. > /*-----------------------------------------------------------------------
  128. > |CTL3D Types
  129. > -----------------------------------------------------------------------*/
  130. > #ifdef WIN32
  131. >
  132. > #define Win32Only(e) e
  133. > #define Win16Only(e)
  134. > #define Win32Or16(e32, e16) e32
  135. > #define Win16Or32(e16, e32) e32
  136. >
  137. > #define _loadds
  138. > #define __export
  139. >
  140. > #define FValidLibHandle(hlib) ((hlib) != NULL)
  141. >
  142. > //
  143. > // No concept of far in Win32.
  144. > //
  145. >
  146. > #define MEMCMP memcmp
  147. > #define NPTSTR LPTSTR
  148. >
  149. > //
  150. > // Control IDs are LONG in Win32.
  151. > //
  152. >
  153. > typedef LONG CTLID;
  154. > #define GetControlId(hwnd) GetWindowLong(hwnd, GWL_ID)
  155. >
  156. > //
  157. > // Send a color button message.
  158. > //
  159. >
  160. > #define SEND_COLOR_BUTTON_MESSAGE( hwndParent, hwnd, hdc ) \
  161. > ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLORBTN, (WPARAM) hdc, (LPARAM) hwnd))
  162. >
  163. > //
  164. > // Send a color static message.
  165. > //
  166. >
  167. > #define SEND_COLOR_STATIC_MESSAGE( hwndParent, hwnd, hdc ) \
  168. > ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLORSTATIC, (WPARAM) hdc, (LPARAM) hwnd))
  169. >
  170. > #else
  171. >
  172. > #define CallWindowProcA CallWindowProc
  173. > #define DefWindowProcA DefWindowProc
  174. >
  175. > #define TEXT(a) a
  176. > #define TCHAR char
  177. >
  178. > #ifndef LPTSTR
  179. > #define LPTSTR LPSTR
  180. > #endif
  181. > #define LPCTSTR LPCSTR
  182. > #define NPTSTR NPSTR
  183. >
  184. > #define Win32Only(e)
  185. > #define Win16Only(e) e
  186. > #define Win32Or16(e32, e16) e16
  187. > #define Win16Or32(e16, e32) e16
  188. >
  189. >
  190. > #define FValidLibHandle(hlib) (( hlib ) > 32 )
  191. >
  192. > #define MEMCMP _fmemcmp
  193. >
  194. > typedef WORD CTLID;
  195. > #define GetControlId(h) GetWindowWord(h, GWW_ID)
  196. >
  197. > #define SEND_COLOR_BUTTON_MESSAGE( hwndParent, hwnd, hdc ) \
  198. > ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLOR, (WORD) hdc, MAKELONG(hwnd, CTLCOLOR_BTN)))
  199. >
  200. > #define SEND_COLOR_STATIC_MESSAGE( hwndParent, hwnd, hdc ) \
  201. > ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLOR, (WORD) hdc, MAKELONG(hwnd, CTLCOLOR_STATIC)))
  202. >
  203. >
  204. > typedef struct
  205. > {
  206. > LPARAM lParam;
  207. > WPARAM wParam;
  208. > UINT message;
  209. > HWND hwnd;
  210. > } CWPSTRUCT;
  211. >
  212. > #endif // WIN32
  213. >
  214. > // DBCS far east short cut key support
  215. > #define cchShortCutModeMax 10
  216. > #define chShortCutSbcsPrefix '\036'
  217. > #define chShortCutDbcsPrefix '\037'
  218. >
  219. > #define cchClassMax 16 // max class is "combolbox"+NUL rounded up to 16
  220. >
  221. >
  222. > #define Assert(f)
  223. >
  224. > #define PUBLIC
  225. > #define PRIVATE static
  226. >
  227. > #define fFalse 0
  228. > #define fTrue 1
  229. >
  230. > #define INCBTHOOK 1
  231. > #define OUTCBTHOOK 0
  232. >
  233. > #ifdef _BORLAND
  234. > #define CSCONST(type) type const
  235. > #define CodeLpszDecl(lpszVar, szLit) TCHAR *lpszVar = szLit
  236. > #define _alloca alloca
  237. > #define _memcmp memcmp
  238. > #else
  239. > #ifdef WIN32
  240. > #define CSCONST(type) type const
  241. > #define CodeLpszDecl(lpszVar, szLit) TCHAR *lpszVar = szLit
  242. > #else
  243. > #define CSCONST(type) type _based(_segname("_CODE")) const
  244. > #define CodeLpszDecl(lpszVar, szLit) \
  245. > static CSCONST(char) lpszVar##Code[] = szLit; \
  246. > char far *lpszVar = (char far *)lpszVar##Code
  247. > #endif
  248. > #endif
  249. >
  250. >
  251. > // isomorphic to windows RECT
  252. > typedef struct
  253. > {
  254. > int xLeft;
  255. > int yTop;
  256. > int xRight;
  257. > int yBot;
  258. > } RC;
  259. >
  260. >
  261. > // Windows Versions (Byte order flipped from GetWindowsVersion)
  262. > #define ver30 0x0300
  263. > #define ver31 0x030a
  264. > #define ver40 0x035F
  265. >
  266. > // Border widths
  267. > #define dxBorder 1
  268. > #define dyBorder 1
  269. >
  270. >
  271. > // Index Color Table
  272. > // WARNING: change mpicvSysColors if you change the icv order
  273. > typedef WORD ICV;
  274. > #define icvBtnHilite 0
  275. > #define icvBtnFace 1
  276. > #define icvBtnShadow 2
  277. >
  278. > #define icvBrushMax 3
  279. >
  280. > #define icvBtnText 3
  281. > #define icvWindow 4
  282. > #define icvWindowText 5
  283. > #define icvGrayText 6
  284. > #define icvWindowFrame 7
  285. > #define icvMax 8
  286. >
  287. > typedef COLORREF CV;
  288. >
  289. > // CoLoR Table
  290. > typedef struct
  291. > {
  292. > CV rgcv[icvMax];
  293. > } CLRT;
  294. >
  295. >
  296. > // BRush Table
  297. > typedef struct
  298. > {
  299. > HBRUSH mpicvhbr[icvBrushMax];
  300. > } BRT;
  301. >
  302. >
  303. > // DrawRec3d flags
  304. > #define dr3Left 0x0001
  305. > #define dr3Top 0x0002
  306. > #define dr3Right 0x0004
  307. > #define dr3Bot 0x0008
  308. >
  309. > #define dr3HackBotRight 0x1000 // code size is more important than aesthetics
  310. > #define dr3All 0x000f
  311. > typedef WORD DR3;
  312. >
  313. >
  314. > // Control Types
  315. > // Commdlg types are necessary because commdlg.dll subclasses certain
  316. > // controls before the app can call Ctl3dSubclassDlg.
  317. > #define ctButton 0
  318. > #define ctList 1
  319. > #define ctEdit 2
  320. > #define ctCombo 3
  321. > #define ctStatic 4
  322. > #define ctComboLBox 5
  323. > #define ctMax 6
  324. >
  325. > // ConTroL
  326. > typedef struct
  327. > {
  328. > FARPROC lpfn;
  329. > WNDPROC lpfnDefProc;
  330. > TCHAR szClassName[cchClassMax];
  331. > } CTL;
  332. >
  333. > // Control DEFinition
  334. > typedef struct
  335. > {
  336. > TCHAR sz[20];
  337. > WNDPROC lpfnWndProc;
  338. > BOOL (* lpfnFCanSubclass)(HWND, LONG, WORD, WORD, HWND);
  339. > WORD msk;
  340. > } CDEF;
  341. >
  342. > // CLIent HooK
  343. > typedef struct
  344. > {
  345. > HANDLE hinstApp;
  346. > HANDLE htask;
  347. > HHOOK hhook;
  348. > int iCount;
  349. > DWORD dwFlags;
  350. >
  351. > } CLIHK;
  352. >
  353. > #ifdef WIN32
  354. > #define iclihkMaxBig 1024
  355. > #define iclihkMaxSmall 128
  356. > #else
  357. > #define iclihkMaxBig 32
  358. > #define iclihkMaxSmall 4
  359. > #endif
  360. >
  361. > #ifdef DLL
  362. > #define iclihkMax iclihkMaxBig
  363. > #else
  364. > #ifdef SDLL
  365. > #define iclihkMax iclihkMaxBig
  366. > #else
  367. > #define iclihkMax iclihkMaxSmall
  368. > #define _loadds
  369. > #endif
  370. > #endif
  371. >
  372. > #ifdef SDLL
  373. > extern const HINSTANCE _hModule;
  374. > #endif
  375. >
  376. > // special styles
  377. > // #define bitFCoolButtons 0x0001
  378. >
  379. > /*-----------------------------------------------------------------------
  380. > |CTL3D Function Prototypes
  381. > -----------------------------------------------------------------------*/
  382. > PRIVATE VOID End3dDialogs(VOID);
  383. > PRIVATE BOOL FAR FInit3dDialogs(VOID);
  384. > PRIVATE BOOL DoSubclassCtl(HWND hwnd, WORD grbit, WORD wCallFlags, HWND hwndParent);
  385. > PRIVATE BOOL InternalCtl3dColorChange(BOOL fForce);
  386. > PRIVATE VOID DeleteObjectNull(HANDLE FAR *ph);
  387. > PRIVATE VOID DeleteObjects(VOID);
  388. > PRIVATE int IclihkFromHinst(HANDLE hinst);
  389. >
  390. > LRESULT __export _loadds WINAPI Ctl3dHook(int code, WPARAM wParam, LPARAM lParam);
  391. > LRESULT __export _loadds WINAPI BtnWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam);
  392. > LRESULT __export _loadds WINAPI EditWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam);
  393. > LRESULT __export _loadds WINAPI ListWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam);
  394. > LRESULT __export _loadds WINAPI ComboWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam);
  395. > LRESULT __export _loadds WINAPI StaticWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam);
  396. > LRESULT __export _loadds WINAPI CDListWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam);
  397. > LRESULT __export _loadds WINAPI CDEditWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam);
  398. > WORD __export _loadds WINAPI Ctl3dSetStyle(HANDLE hinst, LPTSTR lpszName, WORD grbit);
  399. >
  400. > LRESULT __export _loadds WINAPI Ctl3dDlgProc(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam);
  401. >
  402. > BOOL FBtn(HWND, LONG, WORD, WORD, HWND);
  403. > BOOL FEdit(HWND, LONG, WORD, WORD, HWND);
  404. > BOOL FList(HWND, LONG, WORD, WORD, HWND);
  405. > BOOL FComboList(HWND, LONG, WORD, WORD, HWND);
  406. > BOOL FCombo(HWND, LONG, WORD, WORD, HWND);
  407. > BOOL FStatic(HWND, LONG, WORD, WORD, HWND);
  408. >
  409. > HBITMAP PASCAL LoadUIBitmap(HANDLE, LPCTSTR, COLORREF, COLORREF, COLORREF, COLORREF, COLORREF, COLORREF);
  410. >
  411. > #ifdef WIN32
  412. > #ifdef DLL
  413. > BOOL CALLBACK LibMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved);
  414. > #else
  415. > #ifdef SDLL
  416. > FAR BOOL Ctl3dLibMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved);
  417. > #else
  418. > FAR BOOL LibMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved);
  419. > #endif
  420. > #endif
  421. > #else
  422. > #ifdef DLL
  423. > int WINAPI LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine);
  424. > #else
  425. > #ifdef SDLL
  426. > int FAR Ctl3dLibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine);
  427. > #else
  428. > #ifdef _BORLAND
  429. > int FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine);
  430. > #else
  431. > int FAR LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine);
  432. > #endif
  433. > #endif
  434. > #endif
  435. > #endif
  436. >
  437. > #ifndef _BORLAND
  438. > #ifndef WIN32
  439. > #pragma alloc_text(INIT_TEXT, Ctl3dSetStyle)
  440. > #pragma alloc_text(INIT_TEXT, Ctl3dColorChange)
  441. > #pragma alloc_text(INIT_TEXT, Ctl3dGetVer)
  442. > #pragma alloc_text(INIT_TEXT, Ctl3dRegister)
  443. > #pragma alloc_text(INIT_TEXT, Ctl3dUnregister)
  444. > #pragma alloc_text(INIT_TEXT, Ctl3dAutoSubclass)
  445. > #pragma alloc_text(INIT_TEXT, Ctl3dEnabled)
  446. > #pragma alloc_text(INIT_TEXT, Ctl3dWinIniChange)
  447. > #pragma alloc_text(INIT_TEXT, DeleteObjects)
  448. > #pragma alloc_text(INIT_TEXT, DeleteObjectNull)
  449. > #pragma alloc_text(INIT_TEXT, InternalCtl3dColorChange)
  450. > #ifdef SDLL
  451. > #pragma alloc_text(INIT_TEXT, Ctl3dLibMain)
  452. > #else
  453. > #pragma alloc_text(INIT_TEXT, LibMain)
  454. > #endif
  455. > #pragma alloc_text(INIT_TEXT, FInit3dDialogs)
  456. > #pragma alloc_text(INIT_TEXT, End3dDialogs)
  457. > #pragma alloc_text(INIT_TEXT, LoadUIBitmap)
  458. > #pragma alloc_text(INIT_TEXT, IclihkFromHinst)
  459. > #endif
  460. > #endif
  461. >
  462. > #ifndef WIN32
  463. > #ifdef DLL
  464. > int FAR PASCAL WEP(int);
  465. > #pragma alloc_text(WEP_TEXT, WEP)
  466. > #endif
  467. > #endif
  468. >
  469. > /*-----------------------------------------------------------------------
  470. > |CTL3D Globals
  471. > -----------------------------------------------------------------------*/
  472. > //These static varables are only access when running 16 bit Windows or Win32s
  473. > //Since this is single threaded access they are OK to be statics and not protected.
  474. > //
  475. > static HHOOK hhookCallWndProcFilterProc;
  476. > static FARPROC lpfnSubclassByHook;
  477. > static HWND SubclasshWnd;
  478. >
  479. > #ifdef WIN32
  480. > CRITICAL_SECTION g_CriticalSection;
  481. > #endif
  482. >
  483. > typedef struct _g3d
  484. > {
  485. > BOOL f3dDialogs;
  486. > int cInited;
  487. > ATOM aCtl3d;
  488. > ATOM aCtl3dHigh;
  489. > ATOM aCtl3dLow;
  490. >
  491. > ATOM aCtl3dDisable;
  492. > // module & windows stuff
  493. > HANDLE hinstLib;
  494. > HANDLE hmodLib;
  495. > WORD verWindows;
  496. > WORD verBase;
  497. >
  498. > // drawing globals
  499. > CLRT clrt;
  500. > BRT brt;
  501. > HBITMAP hbmpCheckboxes;
  502. >
  503. > // Hook cache
  504. > HANDLE htaskCache;
  505. > int iclihkCache;
  506. > int iclihkMac;
  507. > CLIHK rgclihk[iclihkMax];
  508. >
  509. > // Control info
  510. > CTL mpctctl[ctMax];
  511. > FARPROC lpfnDefDlgWndProc;
  512. >
  513. > // System Metrics
  514. > int dxFrame;
  515. > int dyFrame;
  516. > int dyCaption;
  517. > int dxSysMenu;
  518. >
  519. > // Windows functions
  520. > #ifndef WIN32
  521. > #ifdef DLL
  522. > HHOOK (FAR PASCAL *lpfnSetWindowsHookEx)(int, HOOKPROC, HINSTANCE, HANDLE);
  523. > LRESULT (FAR PASCAL *lpfnCallNextHookEx)(HHOOK, int, WPARAM, LPARAM);
  524. > BOOL (FAR PASCAL *lpfnUnhookWindowsHookEx)(HHOOK);
  525. > #endif
  526. > #endif
  527. >
  528. > // DBCS stuff
  529. > char chShortCutPrefix;
  530. > char fDBCS;
  531. >
  532. > } G3D;
  533. >
  534. > G3D g3d;
  535. >
  536. >
  537. > CSCONST(CDEF) mpctcdef[ctMax] =
  538. > {
  539. > { TEXT("Button"), BtnWndProc3d, FBtn, CTL3D_BUTTONS },
  540. > { TEXT("ListBox"), ListWndProc3d, FList, CTL3D_LISTBOXES },
  541. > { TEXT("Edit"), EditWndProc3d, FEdit, CTL3D_EDITS },
  542. > { TEXT("ComboBox"), ComboWndProc3d, FCombo, CTL3D_COMBOS},
  543. > { TEXT("Static"), StaticWndProc3d, FStatic, CTL3D_STATICTEXTS|CTL3D_STATICFRAMES },
  544. > { TEXT("ComboLBox"), ListWndProc3d, FComboList, CTL3D_LISTBOXES },
  545. > };
  546. >
  547. >
  548. > CSCONST (WORD) mpicvSysColor[] =
  549. > {
  550. > COLOR_BTNHIGHLIGHT,
  551. > COLOR_BTNFACE,
  552. > COLOR_BTNSHADOW,
  553. > COLOR_BTNTEXT,
  554. > COLOR_WINDOW,
  555. > COLOR_WINDOWTEXT,
  556. > COLOR_GRAYTEXT,
  557. > COLOR_WINDOWFRAME
  558. > };
  559. >
  560. >
  561. > #define WM_CHECKSUBCLASS (WM_USER+5443)
  562. >
  563. > /*-----------------------------------------------------------------------
  564. > | CTL3D Utility routines
  565. > -----------------------------------------------------------------------*/
  566. >
  567. > PRIVATE FARPROC LpfnGetDefWndProcNull(HWND hwnd)
  568. > {
  569. > if ( hwnd == NULL )
  570. > return NULL;
  571. >
  572. > Win32Only(return (FARPROC) GetProp(hwnd, (LPCTSTR) g3d.aCtl3d));
  573. > Win16Only(return (FARPROC) MAKELONG((UINT) GetProp(hwnd, (LPCSTR) g3d.aCtl3dLow),
  574. > GetProp(hwnd, (LPCSTR) g3d.aCtl3dHigh)));
  575. > }
  576. >
  577. > PRIVATE FARPROC LpfnGetDefWndProc(HWND hwnd, int ct)
  578. > {
  579. > FARPROC lpfnWndProc;
  580. >
  581. > lpfnWndProc = LpfnGetDefWndProcNull(hwnd);
  582. > if ( lpfnWndProc == NULL ) {
  583. > if ( ct == ctMax )
  584. > {
  585. > lpfnWndProc = (FARPROC) g3d.lpfnDefDlgWndProc;
  586. > }
  587. > else
  588. > {
  589. > lpfnWndProc = (FARPROC) g3d.mpctctl[ct].lpfnDefProc;
  590. > }
  591. >
  592. > Win32Only(SetProp(hwnd, (LPCTSTR) g3d.aCtl3d, (HANDLE)(DWORD)lpfnWndProc));
  593. > Win16Only(SetProp(hwnd, (LPCTSTR) g3d.aCtl3dLow, LOWORD(lpfnWndProc)));
  594. > Win16Only(SetProp(hwnd, (LPCTSTR) g3d.aCtl3dHigh, HIWORD(lpfnWndProc)));
  595. > }
  596. > return lpfnWndProc;
  597. >
  598. > }
  599. >
  600. > PRIVATE VOID SubclassWindow(HWND hwnd, FARPROC lpfnSubclassProc)
  601. > {
  602. > FARPROC lpfnWndProc;
  603. >
  604. > // Make sure we don't double subclass (16 | 32 bit subclass??)
  605. > if (GetProp(hwnd, (LPCTSTR) g3d.aCtl3d) ||
  606. > GetProp(hwnd, (LPCTSTR) g3d.aCtl3dLow))
  607. > {
  608. > return;
  609. > }
  610. >
  611. > // Is this already subclassed by CTL3D?
  612. > if (LpfnGetDefWndProcNull(hwnd) == (FARPROC) NULL)
  613. > {
  614. > lpfnWndProc = (FARPROC)SetWindowLong((HWND) hwnd, GWL_WNDPROC, (LONG) lpfnSubclassProc);
  615. > Win32Only(SetProp(hwnd, (LPCTSTR) g3d.aCtl3d, (HANDLE)(DWORD)lpfnWndProc));
  616. > Win16Only(SetProp(hwnd, (LPCTSTR) g3d.aCtl3dLow, LOWORD(lpfnWndProc)));
  617. > Win16Only(SetProp(hwnd, (LPCTSTR) g3d.aCtl3dHigh, HIWORD(lpfnWndProc)));
  618. > }
  619. > }
  620. >
  621. > LRESULT __export _loadds WINAPI CallWndProcFilterProc(int code, WPARAM wParam, LPARAM lParam)
  622. > {
  623. > CWPSTRUCT FAR *cwpStruct;
  624. > LONG l;
  625. >
  626. > cwpStruct = (CWPSTRUCT FAR *) lParam;
  627. >
  628. > l = CallNextHookEx(hhookCallWndProcFilterProc, code, wParam, lParam);
  629. >
  630. > if ( cwpStruct->hwnd == SubclasshWnd )
  631. > {
  632. > UnhookWindowsHookEx(hhookCallWndProcFilterProc);
  633. >
  634. > SubclassWindow(cwpStruct->hwnd, lpfnSubclassByHook);
  635. >
  636. > hhookCallWndProcFilterProc = 0L;
  637. > lpfnSubclassByHook = NULL;
  638. > SubclasshWnd = NULL;
  639. > }
  640. >
  641. > return l;
  642. > }
  643. >
  644. >
  645. > PRIVATE VOID HookSubclassWindow(HWND hWnd, FARPROC lpfnSubclass)
  646. > {
  647. > //
  648. > // Windows 3.1 ( 16 bit ) and Win32s can't sublcass in
  649. > // WH_CBT hook. Must set up a MSG hook and subclasss at
  650. > // WM_GETMINMAXINFO ( for dialogs ) or WM_NCCREATE ( for controls )
  651. > // Any other message and we are out of here.
  652. > //
  653. > // Notes from the inside:
  654. > //
  655. > // The only reason not to get the WM_GETMINMAXINFO/WM_NCCREATE message
  656. > // is if another CBT hook did not allow the window create.
  657. > // This code only runs/works on non multithreaded systems. Thus the global
  658. > // to hold the Hook Proc and subclass proc is OK.
  659. > //
  660. >
  661. > lpfnSubclassByHook = lpfnSubclass;
  662. > SubclasshWnd = hWnd;
  663. >
  664. > Win32Only(hhookCallWndProcFilterProc = SetWindowsHookEx(WH_CALLWNDPROC, (FARPROC)CallWndProcFilterProc, g3d.hmodLib, GetCurrentThreadId()));
  665. > Win16Only(hhookCallWndProcFilterProc = SetWindowsHookEx(WH_CALLWNDPROC, (FARPROC)CallWndProcFilterProc, g3d.hmodLib, GetCurrentTask()));
  666. > }
  667. >
  668. > PRIVATE LRESULT CleanupSubclass(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam, int ct)
  669. > {
  670. > FARPROC lpfnWinProc;
  671. > LRESULT lRet;
  672. >
  673. > lpfnWinProc = LpfnGetDefWndProc(hwnd, ct);
  674. > lRet = CallWindowProc(lpfnWinProc, hwnd, wm, wParam, lParam);
  675. > Win32Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3d));
  676. > Win16Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dLow));
  677. > Win16Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dHigh));
  678. > RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dDisable);
  679. > return lRet;
  680. > }
  681. >
  682. >
  683. > PRIVATE VOID DeleteObjectNull(HANDLE FAR *ph)
  684. > {
  685. > if (*ph != NULL)
  686. > {
  687. > DeleteObject(*ph);
  688. > *ph = NULL;
  689. > }
  690. > }
  691. >
  692. > PRIVATE VOID DeleteObjects(VOID)
  693. > {
  694. > int icv;
  695. >
  696. > for(icv = 0; icv < icvBrushMax; icv++)
  697. > DeleteObjectNull(&g3d.brt.mpicvhbr[icv]);
  698. > DeleteObjectNull(&g3d.hbmpCheckboxes);
  699. > }
  700. >
  701. >
  702. > PRIVATE VOID PatFill(HDC hdc, RC FAR *lprc)
  703. > {
  704. > PatBlt(hdc, lprc->xLeft, lprc->yTop, lprc->xRight-lprc->xLeft, lprc->yBot-lprc->yTop, PATCOPY);
  705. > }
  706. >
  707. >
  708. > /*-----------------------------------------------------------------------
  709. > | DrawRec3d
  710. > |
  711. > |
  712. > | Arguments:
  713. > | HDC hdc:
  714. > | RC FAR *lprc:
  715. > | LONG cvUL:
  716. > | LONG cvLR:
  717. > | WORD grbit;
  718. > |
  719. > | Returns:
  720. > |
  721. > -----------------------------------------------------------------------*/
  722. > PRIVATE VOID DrawRec3d(HDC hdc, RC FAR *lprc, ICV icvUL, ICV icvLR, DR3 dr3)
  723. > {
  724. > COLORREF cvSav;
  725. > RC rc;
  726. >
  727. > cvSav = SetBkColor(hdc, g3d.clrt.rgcv[icvUL]);
  728. >
  729. > // top
  730. > rc = *lprc;
  731. > rc.yBot = rc.yTop+1;
  732. > if (dr3 & dr3Top)
  733. > ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc,
  734. > (LPCTSTR) NULL, 0, (int far *) NULL);
  735. >
  736. > // left
  737. > rc.yBot = lprc->yBot;
  738. > rc.xRight = rc.xLeft+1;
  739. > if (dr3 & dr3Left)
  740. > ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc,
  741. > (LPCTSTR) NULL, 0, (int far *) NULL);
  742. >
  743. > if (icvUL != icvLR)
  744. > SetBkColor(hdc, g3d.clrt.rgcv[icvLR]);
  745. >
  746. > // right
  747. > rc.xRight = lprc->xRight;
  748. > rc.xLeft = rc.xRight-1;
  749. > if (dr3 & dr3Right)
  750. > ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc,
  751. > (LPCTSTR) NULL, 0, (int far *) NULL);
  752. >
  753. > // bot
  754. > if (dr3 & dr3Bot)
  755. > {
  756. > rc.xLeft = lprc->xLeft;
  757. > rc.yTop = rc.yBot-1;
  758. > if (dr3 & dr3HackBotRight)
  759. > rc.xRight -=2;
  760. > ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc,
  761. > (LPCTSTR) NULL, 0, (int far *) NULL);
  762. > }
  763. >
  764. > SetBkColor(hdc, cvSav);
  765. >
  766. > }
  767. >
  768. > #ifdef CANTUSE
  769. > // Windows forces dialog fonts to be BOLD...URRRGH
  770. > PRIVATE VOID MyDrawText(HWND hwnd, HDC hdc, LPSTR lpch, int cch, RC FAR *lprc, int dt)
  771. > {
  772. > TEXTMETRIC tm;
  773. > BOOL fChisled;
  774. >
  775. > fChisled = fFalse;
  776. > if (!IsWindowEnabled(hwnd))
  777. > {
  778. > GetTextMetrics(hdc, &tm);
  779. > if (tm.tmWeight > 400)
  780. > SetTextColor(hdc, g3d.clrt.rgcv[icvGrayText]);
  781. > else
  782. > {
  783. > fChisled = fTrue;
  784. > SetTextColor(hdc, g3d.clrt.rgcv[icvBtnHilite]);
  785. > OffsetRect((LPRECT) lprc, -1, -1);
  786. > }
  787. > }
  788. > DrawText(hdc, lpch, cch, (LPRECT) lprc, dt);
  789. > if (fChisled)
  790. > {
  791. > SetTextColor(hdc, g3d.clrt.rgcv[icvBtnHilite]);
  792. > OffsetRect((LPRECT) lprc, 1, 1);
  793. > DrawText(hdc, lpch, cch, (LPRECT) lprc, dt);
  794. > }
  795. > }
  796. > #endif
  797. >
  798. >
  799. > PRIVATE VOID DrawInsetRect3d(HDC hdc, RC FAR *prc, DR3 dr3)
  800. > {
  801. > RC rc;
  802. >
  803. > rc = *prc;
  804. > DrawRec3d(hdc, &rc, icvWindowFrame, icvBtnFace, (WORD)(dr3 & dr3All));
  805. > rc.xLeft--;
  806. > rc.yTop--;
  807. > rc.xRight++;
  808. > rc.yBot++;
  809. > DrawRec3d(hdc, &rc, icvBtnShadow, icvBtnHilite, dr3);
  810. > }
  811. >
  812. >
  813. > PRIVATE VOID ClipCtlDc(HWND hwnd, HDC hdc)
  814. > {
  815. > RC rc;
  816. >
  817. > GetClientRect(hwnd, (LPRECT) &rc);
  818. > IntersectClipRect(hdc, rc.xLeft, rc.yTop, rc.xRight, rc.yBot);
  819. > }
  820. >
  821. >
  822. > PRIVATE int IclihkFromHinst(HANDLE hinst)
  823. > {
  824. > int iclihk;
  825. >
  826. > for (iclihk = 0; iclihk < g3d.iclihkMac; iclihk++)
  827. > if (g3d.rgclihk[iclihk].hinstApp == hinst)
  828. > return iclihk;
  829. > return -1;
  830. > }
  831. >
  832. >
  833. > PRIVATE VOID MyGetTextExtent(HDC hdc, LPTSTR lpsz, int FAR *lpdx, int FAR *lpdy)
  834. > {
  835. > LPTSTR lpch;
  836. > TCHAR szT[256];
  837. >
  838. > lpch = szT;
  839. > while(*lpsz != '\000')
  840. > {
  841. > if (*lpsz == '&')
  842. > {
  843. > lpsz++;
  844. > if (*lpsz == '\000')
  845. > break;
  846. > }
  847. > //begin DBCS: far east short cut key support
  848. > else if (g3d.fDBCS)
  849. > {
  850. > if (*lpsz == g3d.chShortCutPrefix)
  851. > { // skip only prefix
  852. > lpsz++;
  853. > if (*lpsz == '\000')
  854. > break;
  855. > }
  856. > else if (*lpsz == chShortCutSbcsPrefix || *lpsz == chShortCutDbcsPrefix)
  857. > { // skip both prefix and short cut key
  858. > lpsz++;
  859. > if (*lpsz == '\000')
  860. > break;
  861. > lpsz = Win32Or16(CharNext(lpsz),AnsiNext(lpsz));
  862. > continue;
  863. > }
  864. > }
  865. > //end DBCS
  866. > *lpch++ = *lpsz++;
  867. > }
  868. > *lpch = '\000';
  869. > #ifdef WIN32
  870. > {
  871. > SIZE pt;
  872. >
  873. > GetTextExtentPoint(hdc, szT, lstrlen(szT), &pt);
  874. > *lpdx = pt.cx;
  875. > *lpdy = pt.cy;
  876. > }
  877. > #else
  878. > {
  879. > long dwExt;
  880. >
  881. > dwExt = GetTextExtent(hdc, szT, lpch-(char far *)szT);
  882. > *lpdx = LOWORD(dwExt);
  883. > // Check for Hangeul Windows - JeeP 011194
  884. > if ( (g3d.verWindows >= ver31 && GetSystemMetrics(SM_DBCSENABLED)) ||
  885. > (IsDBCSLeadByte(0xa1) && !IsDBCSLeadByte(0xa0)) )
  886. > *lpdy = HIWORD(dwExt)+1;
  887. > else
  888. > *lpdy = HIWORD(dwExt);
  889. > }
  890. > #endif
  891. > }
  892. >
  893. >
  894. > /*-----------------------------------------------------------------------
  895. > | CTL3D Publics
  896. > -----------------------------------------------------------------------*/
  897. >
  898. >
  899. > PUBLIC BOOL WINAPI Ctl3dRegister(HANDLE hinstApp)
  900. > {
  901. >
  902. > #ifdef WIN32
  903. > #ifndef DLL
  904. > InitializeCriticalSection(&g_CriticalSection);
  905. > #endif
  906. > EnterCriticalSection(&g_CriticalSection);
  907. > #endif
  908. >
  909. > g3d.cInited++;
  910. >
  911. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  912. >
  913. > if (g3d.cInited == 1)
  914. > {
  915. > #ifndef DLL
  916. > #ifdef SDLL
  917. > Win32Only(Ctl3dLibMain(hinstApp, DLL_PROCESS_ATTACH, (LPVOID) NULL));
  918. > Win16Only(Ctl3dLibMain(hinstApp, 0, 0, (LPSTR) NULL));
  919. > #else
  920. > Win32Only(LibMain(hinstApp, DLL_PROCESS_ATTACH, (LPVOID) NULL));
  921. > Win16Only(LibMain(hinstApp, 0, 0, (LPSTR) NULL));
  922. > #endif
  923. > #endif
  924. > FInit3dDialogs();
  925. > }
  926. >
  927. > if (Ctl3dIsAutoSubclass())
  928. > Ctl3dAutoSubclass(hinstApp);
  929. >
  930. > return g3d.f3dDialogs;
  931. > }
  932. >
  933. >
  934. > PUBLIC BOOL WINAPI Ctl3dUnregister(HANDLE hinstApp)
  935. > {
  936. > int iclihk;
  937. > HANDLE hTask;
  938. >
  939. > //
  940. > // Find the task's hook
  941. > //
  942. > Win32Only(hTask = (HANDLE)GetCurrentThreadId());
  943. > Win16Only(hTask = GetCurrentTask());
  944. >
  945. > Win32Only(EnterCriticalSection(&g_CriticalSection));
  946. >
  947. > for (iclihk = 0; iclihk < g3d.iclihkMac; iclihk++)
  948. > {
  949. > if (g3d.rgclihk[iclihk].htask == hTask)
  950. > {
  951. > g3d.rgclihk[iclihk].iCount--;
  952. > if ( g3d.rgclihk[iclihk].iCount == 0 || hinstApp == g3d.rgclihk[iclihk].hinstApp)
  953. > {
  954. > Win32Only(UnhookWindowsHookEx(g3d.rgclihk[iclihk].hhook));
  955. > #ifdef DLL
  956. > Win16Only((*g3d.lpfnUnhookWindowsHookEx)(g3d.rgclihk[iclihk].hhook));
  957. > #else
  958. > Win16Only(UnhookWindowsHookEx(g3d.rgclihk[iclihk].hhook));
  959. > #endif
  960. > g3d.iclihkMac--;
  961. > while(iclihk < g3d.iclihkMac)
  962. > {
  963. > g3d.rgclihk[iclihk] = g3d.rgclihk[iclihk+1];
  964. > iclihk++;
  965. > }
  966. > }
  967. > }
  968. > }
  969. >
  970. > g3d.cInited--;
  971. >
  972. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  973. >
  974. > if (g3d.cInited == 0)
  975. > {
  976. > End3dDialogs();
  977. > }
  978. > return fTrue;
  979. > }
  980. >
  981. >
  982. >
  983. >
  984. > /*-----------------------------------------------------------------------
  985. > | Ctl3dAutoSubclass
  986. > |
  987. > | Automatically subclasses all dialogs of the client app.
  988. > |
  989. > | Note: Due to bugs in Commdlg, an app should still call Ctl3dSubclassDlg
  990. > | for the Commdlg OpenFile and PageSetup dialogs.
  991. > |
  992. > | Arguments:
  993. > | HANDLE hinstApp:
  994. > |
  995. > | Returns:
  996. > |
  997. > -----------------------------------------------------------------------*/
  998. > PUBLIC BOOL WINAPI Ctl3dAutoSubclass(HANDLE hinstApp)
  999. > {
  1000. > return Ctl3dAutoSubclassEx(hinstApp, 0);
  1001. > }
  1002. >
  1003. > PUBLIC BOOL WINAPI Ctl3dAutoSubclassEx(HANDLE hinstApp, DWORD dwFlags)
  1004. > {
  1005. > HHOOK hhook;
  1006. > HANDLE htask;
  1007. > int iclihk;
  1008. >
  1009. > if (g3d.verWindows < ver31)
  1010. > return fFalse;
  1011. > if (!g3d.f3dDialogs)
  1012. > return fFalse;
  1013. >
  1014. > #ifdef WIN32
  1015. > // CTL3D_SUBCLASS_DYNCREATE is considered default in Win32, but
  1016. > // not Win16 for backward compatibility reasons.
  1017. > dwFlags |= CTL3D_SUBCLASS_DYNCREATE;
  1018. > #endif
  1019. > // CTL3D_NOSUBCLASS_DYNCREATE always overrides CTL3D_SUBCLASS_DYNCREATE
  1020. > if (dwFlags & CTL3D_NOSUBCLASS_DYNCREATE)
  1021. > dwFlags &= ~(CTL3D_NOSUBCLASS_DYNCREATE|CTL3D_SUBCLASS_DYNCREATE);
  1022. >
  1023. > Win32Only(EnterCriticalSection(&g_CriticalSection));
  1024. >
  1025. > if (g3d.iclihkMac == iclihkMax)
  1026. > goto Fail;
  1027. >
  1028. > Win32Only(htask = (HANDLE)GetCurrentThreadId());
  1029. > Win16Only(htask = GetCurrentTask());
  1030. > //
  1031. > // Don't set the hook twice for the same task....
  1032. > //
  1033. > for (iclihk = 0; iclihk < g3d.iclihkMac; iclihk++)
  1034. > {
  1035. > if (g3d.rgclihk[iclihk].htask == htask)
  1036. > {
  1037. > g3d.rgclihk[iclihk].iCount++;
  1038. > goto Success;
  1039. > }
  1040. > }
  1041. >
  1042. > Win32Only(hhook = SetWindowsHookEx(WH_CBT, (HOOKPROC)Ctl3dHook, g3d.hmodLib, (DWORD)htask));
  1043. > #ifdef DLL
  1044. > Win16Only(hhook = (*g3d.lpfnSetWindowsHookEx)(WH_CBT, (HOOKPROC) Ctl3dHook, g3d.hmodLib, hinstApp == NULL ? NULL : htask));
  1045. > #else
  1046. > Win16Only(hhook = SetWindowsHookEx(WH_CBT, (HOOKPROC) Ctl3dHook, g3d.hmodLib, hinstApp == NULL ? NULL : htask));
  1047. > #endif
  1048. > if (hhook != NULL)
  1049. > {
  1050. > g3d.rgclihk[g3d.iclihkMac].hinstApp = hinstApp;
  1051. > g3d.rgclihk[g3d.iclihkMac].htask = htask;
  1052. > g3d.rgclihk[g3d.iclihkMac].hhook = hhook;
  1053. > g3d.rgclihk[g3d.iclihkMac].iCount = 1;
  1054. > g3d.rgclihk[g3d.iclihkMac].dwFlags = dwFlags;
  1055. > g3d.htaskCache = htask;
  1056. > g3d.iclihkCache = g3d.iclihkMac;
  1057. > g3d.iclihkMac++;
  1058. > Success:
  1059. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  1060. > return fTrue;
  1061. > }
  1062. > Fail:
  1063. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  1064. > return fFalse;
  1065. > }
  1066. >
  1067. > /*-----------------------------------------------------------------------
  1068. > | Ctl3dIsAutoSubclass
  1069. > |
  1070. > | Returns:
  1071. > | Whether this task has Automatic Subclassing Enabled
  1072. > |
  1073. > -----------------------------------------------------------------------*/
  1074. > PUBLIC BOOL WINAPI Ctl3dIsAutoSubclass()
  1075. > {
  1076. > int iclihk;
  1077. > HANDLE hTask;
  1078. >
  1079. > Win32Only(hTask = (HANDLE)GetCurrentThreadId());
  1080. > Win16Only(hTask = GetCurrentTask());
  1081. >
  1082. > for (iclihk = 0; iclihk < g3d.iclihkMac; iclihk++)
  1083. > {
  1084. > if (g3d.rgclihk[iclihk].htask == hTask)
  1085. > {
  1086. > return TRUE;
  1087. > }
  1088. > }
  1089. > // didn't find task in hook table.
  1090. > return FALSE;
  1091. > }
  1092. >
  1093. > /*-----------------------------------------------------------------------
  1094. > | Ctl3dUnAutoSubclass
  1095. > |
  1096. > -----------------------------------------------------------------------*/
  1097. > PUBLIC BOOL WINAPI Ctl3dUnAutoSubclass()
  1098. > {
  1099. > int iclihk;
  1100. > HANDLE hTask;
  1101. >
  1102. > // Find the task's hook
  1103. > //
  1104. > //
  1105. > Win32Only(hTask = (HANDLE)GetCurrentThreadId());
  1106. > Win16Only(hTask = GetCurrentTask());
  1107. > Win32Only(EnterCriticalSection(&g_CriticalSection));
  1108. > for (iclihk = 0; iclihk < g3d.iclihkMac; iclihk++)
  1109. > {
  1110. > if (g3d.rgclihk[iclihk].htask == hTask)
  1111. > {
  1112. > g3d.rgclihk[iclihk].iCount--;
  1113. > if ( g3d.rgclihk[iclihk].iCount == 0 )
  1114. > {
  1115. > Win32Only(UnhookWindowsHookEx(g3d.rgclihk[iclihk].hhook));
  1116. > #ifdef DLL
  1117. > Win16Only((*g3d.lpfnUnhookWindowsHookEx)(g3d.rgclihk[iclihk].hhook));
  1118. > #else
  1119. > Win16Only(UnhookWindowsHookEx(g3d.rgclihk[iclihk].hhook));
  1120. > #endif
  1121. > g3d.iclihkMac--;
  1122. > while(iclihk < g3d.iclihkMac)
  1123. > {
  1124. > g3d.rgclihk[iclihk] = g3d.rgclihk[iclihk+1];
  1125. > iclihk++;
  1126. > }
  1127. > }
  1128. > }
  1129. > }
  1130. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  1131. > return TRUE;
  1132. > }
  1133. >
  1134. > WORD __export _loadds WINAPI Ctl3dSetStyle(HANDLE hinst, LPTSTR lpszName, WORD grbit)
  1135. > {
  1136. > #ifdef OLD
  1137. > WORD grbitOld;
  1138. >
  1139. > if (!g3d.f3dDialogs)
  1140. > return fFalse;
  1141. >
  1142. > grbitOld = grbitStyle;
  1143. > if (grbit != 0)
  1144. > grbitStyle = grbit;
  1145. >
  1146. > if (hinst != NULL && lpszName != NULL)
  1147. > {
  1148. > HBITMAP hbmpCheckboxesNew;
  1149. >
  1150. > hbmpCheckboxesNew = LoadUIBitmap(hinst, (LPCSTR) lpszName,
  1151. > g3d.clrt.rgcv[icvWindowText],
  1152. > g3d.clrt.rgcv[icvBtnFace],
  1153. > g3d.clrt.rgcv[icvBtnShadow],
  1154. > g3d.clrt.rgcv[icvBtnHilite],
  1155. > g3d.clrt.rgcv[icvWindow],
  1156. > g3d.clrt.rgcv[icvWindowFrame]);
  1157. > if (hbmpCheckboxesNew != NULL)
  1158. > {
  1159. > DeleteObjectNull(&g3d.hbmpCheckboxes);
  1160. > g3d.hbmpCheckboxes = hbmpCheckboxesNew;
  1161. > }
  1162. > }
  1163. >
  1164. > return grbitOld;
  1165. > #endif
  1166. > return 0;
  1167. > }
  1168. >
  1169. >
  1170. > /*-----------------------------------------------------------------------
  1171. > | Ctl3dGetVer
  1172. > |
  1173. > | Returns version of CTL3D library
  1174. > |
  1175. > | Returns:
  1176. > | Major version # in hibyte, minor version # in lobyte
  1177. > |
  1178. > -----------------------------------------------------------------------*/
  1179. > PUBLIC WORD WINAPI Ctl3dGetVer(void)
  1180. > {
  1181. > return 0x0226;
  1182. > }
  1183. >
  1184. >
  1185. > /*-----------------------------------------------------------------------
  1186. > | Ctl3dEnabled
  1187. > |
  1188. > | Returns:
  1189. > | Whether or not controls will be draw with 3d effects
  1190. > -----------------------------------------------------------------------*/
  1191. > PUBLIC BOOL WINAPI Ctl3dEnabled(void)
  1192. > {
  1193. > return g3d.f3dDialogs;
  1194. > }
  1195. >
  1196. >
  1197. >
  1198. > /*-----------------------------------------------------------------------
  1199. > | Ctl3dSubclassCtl
  1200. > |
  1201. > | Subclasses an individual control
  1202. > |
  1203. > | Arguments:
  1204. > | HWND hwnd:
  1205. > |
  1206. > | Returns:
  1207. > | fTrue if control was successfully subclassed
  1208. > |
  1209. > -----------------------------------------------------------------------*/
  1210. > PUBLIC BOOL WINAPI Ctl3dSubclassCtl(HWND hwnd)
  1211. > {
  1212. > if (!g3d.f3dDialogs)
  1213. > return fFalse;
  1214. > return DoSubclassCtl(hwnd, CTL3D_ALL, OUTCBTHOOK, NULL);
  1215. > }
  1216. >
  1217. > /*-----------------------------------------------------------------------
  1218. > | Ctl3dUnsubclassCtl
  1219. > |
  1220. > | Un-Subclasses an individual control
  1221. > |
  1222. > | Arguments:
  1223. > | HWND hwnd:
  1224. > |
  1225. > | Returns:
  1226. > | fTrue if control was successfully subclassed
  1227. > |
  1228. > -----------------------------------------------------------------------*/
  1229. > PUBLIC BOOL WINAPI Ctl3dUnsubclassCtl(HWND hwnd)
  1230. > {
  1231. > FARPROC lpfnWinProc;
  1232. > HWND hwndKids;
  1233. > int ct;
  1234. >
  1235. > if (!g3d.f3dDialogs)
  1236. > return fFalse;
  1237. >
  1238. > lpfnWinProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
  1239. >
  1240. > // Is it a control
  1241. > for (ct = 0; ct < ctMax; ct++)
  1242. > {
  1243. > if ( lpfnWinProc == g3d.mpctctl[ct].lpfn )
  1244. > {
  1245. > lpfnWinProc = LpfnGetDefWndProc(hwnd, ct);
  1246. > Win32Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3d));
  1247. > Win16Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dLow));
  1248. > Win16Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dHigh));
  1249. > SetWindowLong(hwnd, GWL_WNDPROC, (LONG) lpfnWinProc );
  1250. > lpfnWinProc = NULL;
  1251. > ct = ctMax+10;
  1252. > }
  1253. > }
  1254. >
  1255. > // How about a dlg ?
  1256. > if ( ct == ctMax )
  1257. > {
  1258. > if ( lpfnWinProc == (FARPROC) Ctl3dDlgProc )
  1259. > {
  1260. > lpfnWinProc = LpfnGetDefWndProc(hwnd, ct);
  1261. > Win32Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3d));
  1262. > Win16Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dLow));
  1263. > Win16Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dHigh));
  1264. > SetWindowLong(hwnd, GWL_WNDPROC, (LONG) lpfnWinProc );
  1265. > lpfnWinProc = NULL;
  1266. > }
  1267. > else
  1268. > {
  1269. > // None of the above, add disable property
  1270. > SetProp(hwnd,(LPCTSTR) g3d.aCtl3dDisable, (HANDLE) 1);
  1271. > }
  1272. > }
  1273. >
  1274. > //
  1275. > // Now unsubclass all the kids
  1276. > //
  1277. > for (hwndKids = GetWindow(hwnd, GW_CHILD); hwndKids != NULL;
  1278. > hwndKids = GetWindow(hwndKids, GW_HWNDNEXT))
  1279. > {
  1280. > Ctl3dUnsubclassCtl(hwndKids);
  1281. > }
  1282. >
  1283. > return fTrue;
  1284. >
  1285. > }
  1286. >
  1287. >
  1288. > /*-----------------------------------------------------------------------
  1289. > | Ctl3dSubclassCtlEx
  1290. > |
  1291. > | Actually subclass the control
  1292. > |
  1293. > |
  1294. > -----------------------------------------------------------------------*/
  1295. > PUBLIC BOOL WINAPI Ctl3dSubclassCtlEx(HWND hwnd, int ct)
  1296. > {
  1297. > LONG style;
  1298. > BOOL fCan;
  1299. >
  1300. > if (!g3d.f3dDialogs)
  1301. > return fFalse;
  1302. >
  1303. > if (ct < 0 || ct > ctMax)
  1304. > return fFalse;
  1305. >
  1306. > // Is this already subclassed by CTL3D?
  1307. > if (LpfnGetDefWndProcNull(hwnd) != (FARPROC) NULL)
  1308. > return fFalse;
  1309. >
  1310. > // Only subclass it if it is something that we'd normally subclass
  1311. > style = GetWindowLong(hwnd, GWL_STYLE);
  1312. > fCan = mpctcdef[ct].lpfnFCanSubclass(hwnd, style, CTL3D_ALL,
  1313. > OUTCBTHOOK, GetParent(hwnd));
  1314. > if (fCan == fTrue)
  1315. > SubclassWindow(hwnd, g3d.mpctctl[ct].lpfn);
  1316. >
  1317. > return fTrue;
  1318. > }
  1319. >
  1320. > /*-----------------------------------------------------------------------
  1321. > | Ctl3dSubclassDlg
  1322. > |
  1323. > | Call this during WM_INITDIALOG processing.
  1324. > |
  1325. > | Arguments:
  1326. > | hwndDlg:
  1327. > |
  1328. > -----------------------------------------------------------------------*/
  1329. > PUBLIC BOOL WINAPI Ctl3dSubclassDlg(HWND hwndDlg, WORD grbit)
  1330. > {
  1331. > HWND hwnd;
  1332. >
  1333. > if (!g3d.f3dDialogs)
  1334. > return fFalse;
  1335. >
  1336. > for(hwnd = GetWindow(hwndDlg, GW_CHILD); hwnd != NULL;
  1337. > hwnd = GetWindow(hwnd, GW_HWNDNEXT))
  1338. > {
  1339. > DoSubclassCtl(hwnd, grbit, OUTCBTHOOK, NULL);
  1340. > }
  1341. > return fTrue;
  1342. > }
  1343. >
  1344. > /*-----------------------------------------------------------------------
  1345. > | Ctl3dCheckSubclassDlg
  1346. > |
  1347. > | Call this during WM_INITDIALOG processing.
  1348. > |
  1349. > | Arguments:
  1350. > | hwndDlg:
  1351. > |
  1352. > -----------------------------------------------------------------------*/
  1353. > PRIVATE void CheckChildSubclass(HWND hwnd, WORD grbit, HWND hwndParent)
  1354. > {
  1355. > // Is this already subclassed by CTL3D?
  1356. > // Is our property there ?
  1357. > if (LpfnGetDefWndProcNull(hwnd) == (FARPROC) NULL)
  1358. > {
  1359. > // No, how did this slip by, try a subclass again.
  1360. > DoSubclassCtl(hwnd, grbit, OUTCBTHOOK, hwndParent);
  1361. > }
  1362. > else
  1363. > {
  1364. > // Yes, we have subclassed this control.
  1365. > // Is our subclass still on the chain ?
  1366. > BOOL fSubclass;
  1367. >
  1368. > // Make sure subclassing isn't disabled...
  1369. > if (GetProp(hwnd, (LPCTSTR)g3d.aCtl3dDisable))
  1370. > return;
  1371. >
  1372. > fSubclass = 666;
  1373. > SendMessage((HWND) hwnd, WM_CHECKSUBCLASS, 0, (LPARAM)(int FAR *)&fSubclass);
  1374. >
  1375. > if ( fSubclass == 666 ) // Evil
  1376. > {
  1377. > // We have been un-subclassed by some bad app ( common dialogs in Win16 )
  1378. > // Remove the Prop, and subclass again, take that.
  1379. > Win32Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3d));
  1380. > Win16Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dLow));
  1381. > Win16Only(RemoveProp(hwnd, (LPCTSTR) g3d.aCtl3dHigh));
  1382. > DoSubclassCtl(hwnd, grbit, OUTCBTHOOK, hwndParent);
  1383. > }
  1384. > }
  1385. > }
  1386. >
  1387. > PUBLIC BOOL WINAPI Ctl3dCheckSubclassDlg(HWND hwndDlg, WORD grbit)
  1388. > {
  1389. > HWND hwnd, hwnd2;
  1390. >
  1391. > if (!g3d.f3dDialogs)
  1392. > return fFalse;
  1393. >
  1394. > for (hwnd = GetWindow(hwndDlg, GW_CHILD); hwnd != NULL;
  1395. > hwnd = GetWindow(hwnd, GW_HWNDNEXT))
  1396. > {
  1397. > CheckChildSubclass(hwnd, grbit, NULL);
  1398. > for (hwnd2 = GetWindow(hwnd, GW_CHILD); hwnd2 != NULL;
  1399. > hwnd2 = GetWindow(hwnd2, GW_HWNDNEXT))
  1400. > {
  1401. > CheckChildSubclass(hwnd2, grbit, hwnd);
  1402. > }
  1403. > }
  1404. >
  1405. > return fTrue;
  1406. > }
  1407. >
  1408. > /*-----------------------------------------------------------------------
  1409. > | Ctl3dSubclassDlgEx
  1410. > |
  1411. > | Call this during WM_INITDIALOG processing. This is like
  1412. > | Ctl3dSubclassDlg but it also subclasses the dialog window itself
  1413. > | so the app doesn't need to.
  1414. > |
  1415. > | Arguments:
  1416. > | hwndDlg:
  1417. > |
  1418. > -----------------------------------------------------------------------*/
  1419. > PUBLIC BOOL WINAPI Ctl3dSubclassDlgEx(HWND hwndDlg, DWORD grbit)
  1420. > {
  1421. > HWND hwnd;
  1422. >
  1423. > if (!g3d.f3dDialogs)
  1424. > return fFalse;
  1425. >
  1426. > for(hwnd = GetWindow(hwndDlg, GW_CHILD); hwnd != NULL;
  1427. > hwnd = GetWindow(hwnd, GW_HWNDNEXT))
  1428. > {
  1429. > DoSubclassCtl(hwnd, LOWORD(grbit), OUTCBTHOOK, NULL);
  1430. > }
  1431. >
  1432. > //
  1433. > // Now Subclass the dialog window as well
  1434. > //
  1435. > SubclassWindow((HWND) hwndDlg, (FARPROC)Ctl3dDlgProc);
  1436. >
  1437. > return fTrue;
  1438. > }
  1439. >
  1440. >
  1441. > /*-----------------------------------------------------------------------
  1442. > | Ctl3dCtlColor
  1443. > |
  1444. > | Common CTL_COLOR processor for 3d UITF dialogs & alerts.
  1445. > |
  1446. > | Arguments:
  1447. > | hdc:
  1448. > | lParam:
  1449. > |
  1450. > | Returns:
  1451. > | appropriate brush if g3d.f3dDialogs. Returns fFalse otherwise
  1452. > |
  1453. > -----------------------------------------------------------------------*/
  1454. > PUBLIC HBRUSH WINAPI Ctl3dCtlColor(HDC hdc, LPARAM lParam)
  1455. > {
  1456. > #ifdef WIN32
  1457. > return (HBRUSH) fFalse;
  1458. > #else
  1459. > HWND hwndParent;
  1460. >
  1461. > Assert(CTLCOLOR_MSGBOX < CTLCOLOR_BTN);
  1462. > Assert(CTLCOLOR_EDIT < CTLCOLOR_BTN);
  1463. > Assert(CTLCOLOR_LISTBOX < CTLCOLOR_BTN);
  1464. > if(g3d.f3dDialogs)
  1465. > {
  1466. > if (HIWORD(lParam) >= CTLCOLOR_LISTBOX)
  1467. > {
  1468. > if (HIWORD(lParam) == CTLCOLOR_LISTBOX &&
  1469. > (g3d.verWindows >= ver40 ||
  1470. > ((GetWindow(LOWORD(lParam), GW_CHILD) == NULL ||
  1471. > (GetWindowLong(LOWORD(lParam), GWL_STYLE) & 0x03) == CBS_DROPDOWNLIST))))
  1472. > {
  1473. > // if it doesn't have a child then it must be a list box
  1474. > // don't do brush stuff for drop down lists or else
  1475. > // it draws funny grey inside the edit rect
  1476. > goto DefWP;
  1477. > }
  1478. > SetTextColor(hdc, g3d.clrt.rgcv[icvBtnText]);
  1479. > SetBkColor(hdc, g3d.clrt.rgcv[icvBtnFace]);
  1480. > return g3d.brt.mpicvhbr[icvBtnFace];
  1481. > }
  1482. > }
  1483. > DefWP:
  1484. > hwndParent = GetParent(LOWORD(lParam));
  1485. > if (hwndParent == NULL)
  1486. > return fFalse;
  1487. > return (HBRUSH) DefWindowProc(hwndParent, WM_CTLCOLOR, (WPARAM) hdc, (LONG) lParam);
  1488. > #endif
  1489. > }
  1490. >
  1491. >
  1492. >
  1493. > /*-----------------------------------------------------------------------
  1494. > | Ctl3dCtlColorEx
  1495. > |
  1496. > | Common CTL_COLOR processor for 3d UITF dialogs & alerts.
  1497. > |
  1498. > | Arguments:
  1499. > |
  1500. > | Returns:
  1501. > | appropriate brush if g3d.f3dDialogs. Returns fFalse otherwise
  1502. > |
  1503. > -----------------------------------------------------------------------*/
  1504. > PUBLIC HBRUSH WINAPI Ctl3dCtlColorEx(UINT wm, WPARAM wParam, LPARAM lParam)
  1505. > {
  1506. > #ifdef WIN32
  1507. > Assert(WM_CTLCOLORMSGBOX < WM_CTLCOLORBTN);
  1508. > Assert(WM_CTLCOLOREDIT < WM_CTLCOLORBTN);
  1509. > Assert(WM_CTLCOLORLISTBOX < WM_CTLCOLORBTN);
  1510. > if(g3d.f3dDialogs)
  1511. > {
  1512. > if (wm >= WM_CTLCOLORLISTBOX && wm != WM_CTLCOLORSCROLLBAR)
  1513. > {
  1514. > if (wm == WM_CTLCOLORLISTBOX &&
  1515. > (g3d.verWindows >= ver40 ||
  1516. > ((GetWindow((HWND) lParam, GW_CHILD) == NULL ||
  1517. > (GetWindowLong((HWND) lParam, GWL_STYLE) & 0x03) == CBS_DROPDOWNLIST))))
  1518. > {
  1519. > // if it doesn't have a child then it must be a list box
  1520. > // don't do brush stuff for drop down lists or else
  1521. > // it draws funny grey inside the edit rect
  1522. > return (HBRUSH) fFalse;
  1523. > }
  1524. > SetTextColor((HDC) wParam, g3d.clrt.rgcv[icvBtnText]);
  1525. > SetBkColor((HDC) wParam, g3d.clrt.rgcv[icvBtnFace]);
  1526. > return g3d.brt.mpicvhbr[icvBtnFace];
  1527. > }
  1528. > }
  1529. > return (HBRUSH) fFalse;
  1530. > #else
  1531. > return Ctl3dCtlColor(wParam, lParam);
  1532. > #endif
  1533. > }
  1534. >
  1535. >
  1536. > /*-----------------------------------------------------------------------
  1537. > | Ctl3dColorChange
  1538. > |
  1539. > | App calls this when it gets a WM_SYSCOLORCHANGE message
  1540. > |
  1541. > | Returns:
  1542. > | TRUE if successful.
  1543. > |
  1544. > -----------------------------------------------------------------------*/
  1545. > PUBLIC BOOL WINAPI Ctl3dColorChange(VOID)
  1546. > {
  1547. > BOOL bResult;
  1548. > Win32Only(EnterCriticalSection(&g_CriticalSection));
  1549. > bResult = InternalCtl3dColorChange(fFalse);
  1550. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  1551. > return bResult;
  1552. > }
  1553. >
  1554. > PRIVATE LONG WINAPI
  1555. > Ctl3dDlgFramePaintI(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam, BOOL fDefWP);
  1556. >
  1557. > /*-----------------------------------------------------------------------
  1558. > | Ctl3dDlgFramePaint
  1559. > |
  1560. > | App calls this when it gets a NC_PAINT message
  1561. > |
  1562. > | Returns:
  1563. > | TRUE if successful.
  1564. > |
  1565. > -----------------------------------------------------------------------*/
  1566. > PUBLIC LONG WINAPI Ctl3dDlgFramePaint(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  1567. > {
  1568. > return Ctl3dDlgFramePaintI(hwnd, wm, wParam, lParam, TRUE);
  1569. > }
  1570. >
  1571. > // Ctl3dDlgFramePaintI used only internally by Ctl3d
  1572. > PRIVATE LONG WINAPI
  1573. > Ctl3dDlgFramePaintI(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam, BOOL fDefWP)
  1574. > {
  1575. > LONG lResult;
  1576. > LONG lStyle;
  1577. > BOOL fBorder;
  1578. >
  1579. > WNDPROC defProc = fDefWP ? NULL : (WNDPROC) LpfnGetDefWndProc(hwnd, ctMax);
  1580. >
  1581. > if (defProc != NULL)
  1582. > lResult = CallWindowProc((FARPROC)defProc, hwnd, wm, wParam, lParam);
  1583. > else
  1584. > lResult = DefWindowProc(hwnd, wm, wParam, lParam);
  1585. >
  1586. > if (!g3d.f3dDialogs)
  1587. > return lResult;
  1588. >
  1589. > if ( IsIconic(hwnd) )
  1590. > return lResult;
  1591. >
  1592. > fBorder = CTL3D_BORDER;
  1593. > SendMessage(hwnd, WM_DLGBORDER, 0, (LPARAM)(int FAR *)&fBorder);
  1594. > lStyle = GetWindowLong(hwnd, GWL_STYLE);
  1595. > if (fBorder != CTL3D_NOBORDER && (lStyle & (WS_VISIBLE|WS_DLGFRAME|DS_MODALFRAME)) == (WS_VISIBLE|WS_DLGFRAME|DS_MODALFRAME))
  1596. > {
  1597. > BOOL fCaption;
  1598. > HBRUSH hbrSav;
  1599. > HDC hdc;
  1600. > RC rc;
  1601. > RC rcFill;
  1602. > int dyFrameTop;
  1603. >
  1604. > fCaption = (lStyle & WS_CAPTION) == WS_CAPTION;
  1605. > dyFrameTop = g3d.dyFrame - (fCaption ? dyBorder : 0);
  1606. >
  1607. > hdc = GetWindowDC(hwnd);
  1608. > GetWindowRect(hwnd, (LPRECT) &rc);
  1609. > rc.xRight = rc.xRight-rc.xLeft;
  1610. > rc.yBot = rc.yBot-rc.yTop;
  1611. > rc.xLeft = rc.yTop = 0;
  1612. >
  1613. > DrawRec3d(hdc, &rc, icvBtnShadow, icvWindowFrame, dr3All);
  1614. > InflateRect((LPRECT) &rc, -dxBorder, -dyBorder);
  1615. > DrawRec3d(hdc, &rc, icvBtnHilite, icvBtnShadow, dr3All);
  1616. > InflateRect((LPRECT) &rc, -dxBorder, -dyBorder);
  1617. >
  1618. > hbrSav = SelectObject(hdc, g3d.brt.mpicvhbr[icvBtnFace]);
  1619. > rcFill = rc;
  1620. > // Left
  1621. > rcFill.xRight = rcFill.xLeft+g3d.dxFrame;
  1622. > PatFill(hdc, &rcFill);
  1623. > // Right
  1624. > OffsetRect((LPRECT) &rcFill, rc.xRight-rc.xLeft-g3d.dxFrame, 0);
  1625. > PatFill(hdc, &rcFill);
  1626. > // Top
  1627. > rcFill.xLeft = rc.xLeft + g3d.dxFrame;
  1628. > rcFill.xRight = rc.xRight - g3d.dxFrame;
  1629. > rcFill.yBot = rcFill.yTop+dyFrameTop;
  1630. > PatFill(hdc, &rcFill);
  1631. > if (fCaption)
  1632. > {
  1633. > RC rcT;
  1634. >
  1635. > rcT = rcFill;
  1636. > rcT.yTop += dyFrameTop;
  1637. > rcT.yBot = rcT.yTop + g3d.dyCaption;
  1638. > DrawRec3d(hdc, &rcT, icvBtnShadow, icvBtnHilite, dr3All);
  1639. > }
  1640. >
  1641. > // Bottom
  1642. > rcFill.yTop += rc.yBot-rc.yTop-g3d.dxFrame;
  1643. > rcFill.yBot = rcFill.yTop + g3d.dyFrame;
  1644. > PatFill(hdc, &rcFill);
  1645. > #ifdef CHISLEBORDER
  1646. > if (fBorder == CTL3D_CHISLEBORDER)
  1647. > {
  1648. > // This code doesn't work because it draws in the client area
  1649. > GetClientRect(hwnd, (LPRECT) &rc);
  1650. > OffsetRect((LPRECT) &rc, g3d.dxFrame+2*dxBorder, fCaption ? g3d.dyFrame+g3d.dyCaption : g3d.dyFrame+dyBorder);
  1651. > DrawRec3d(hdc, &rc, icvBtnShadow, icvBtnHilite, dr3Bot|dr3Left|dr3Right);
  1652. > rc.xLeft++;
  1653. > rc.xRight--;
  1654. > rc.yBot--;
  1655. > DrawRec3d(hdc, &rc, icvBtnHilite, icvBtnShadow, dr3Bot|dr3Left|dr3Right);
  1656. > }
  1657. > #endif
  1658. > SelectObject(hdc, hbrSav);
  1659. > ReleaseDC(hwnd, hdc);
  1660. > }
  1661. > return lResult;
  1662. > }
  1663. >
  1664. >
  1665. > //begin DBCS: far east short cut key support
  1666. > /*-----------------------------------------------------------------------
  1667. > | CTL3D Far East Support
  1668. > -----------------------------------------------------------------------*/
  1669. >
  1670. > /*-----------------------------------------------------------------------
  1671. > | Ctl3dWinIniChange
  1672. > |
  1673. > | App calls this when it gets a WM_WININICHANGE message
  1674. > |
  1675. > | Returns:
  1676. > | none
  1677. > |
  1678. > -----------------------------------------------------------------------*/
  1679. > PUBLIC VOID WINAPI Ctl3dWinIniChange(void)
  1680. > {
  1681. > TCHAR szShortCutMode[cchShortCutModeMax];
  1682. > CodeLpszDecl(szSectionWindows, TEXT("windows"));
  1683. > CodeLpszDecl(szEntryShortCutKK, TEXT("kanjimenu"));
  1684. > CodeLpszDecl(szEntryShortCutCH, TEXT("hangeulmenu"));
  1685. > CodeLpszDecl(szShortCutSbcsKK, TEXT("roman"));
  1686. > CodeLpszDecl(szShortCutSbcsCH, TEXT("english"));
  1687. > CodeLpszDecl(szShortCutDbcsKK, TEXT("kanji"));
  1688. > CodeLpszDecl(szShortCutDbcsCH, TEXT("hangeul"));
  1689. >
  1690. > if (!g3d.fDBCS)
  1691. > return;
  1692. >
  1693. > Win32Only(EnterCriticalSection(&g_CriticalSection));
  1694. >
  1695. > g3d.chShortCutPrefix = chShortCutSbcsPrefix;
  1696. > GetProfileString(szSectionWindows, szEntryShortCutKK, szShortCutSbcsKK, szShortCutMode, cchShortCutModeMax - 1);
  1697. > if (!lstrcmpi(szShortCutMode, szShortCutDbcsKK))
  1698. > g3d.chShortCutPrefix = chShortCutDbcsPrefix;
  1699. > GetProfileString(szSectionWindows, szEntryShortCutCH, szShortCutSbcsCH, szShortCutMode, cchShortCutModeMax - 1);
  1700. > if (!lstrcmpi(szShortCutMode, szShortCutDbcsCH))
  1701. > g3d.chShortCutPrefix = chShortCutDbcsPrefix;
  1702. >
  1703. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  1704. > }
  1705. > //end DBCS
  1706. >
  1707. >
  1708. >
  1709. > /*-----------------------------------------------------------------------
  1710. > | CTL3D Internal Routines
  1711. > -----------------------------------------------------------------------*/
  1712. >
  1713. >
  1714. > /*-----------------------------------------------------------------------
  1715. > | FInit3dDialogs
  1716. > |
  1717. > | Initialized 3d stuff
  1718. > |
  1719. > -----------------------------------------------------------------------*/
  1720. > PRIVATE BOOL FAR FInit3dDialogs(VOID)
  1721. > {
  1722. > HDC hdc;
  1723. > WNDCLASS wc;
  1724. >
  1725. > #ifdef DLL
  1726. > #ifdef V2
  1727. > int nChars;
  1728. > LPTSTR pCh;
  1729. > static TCHAR MyDirectory[260];
  1730. > TCHAR OkDirectory[260];
  1731. > #endif
  1732. > #endif
  1733. >
  1734. > //if (g3d.verWindows >= ver40)
  1735. > // {
  1736. > // g3d.f3dDialogs = fFalse;
  1737. > // return fFalse;
  1738. > // }
  1739. >
  1740. > Win32Only(EnterCriticalSection(&g_CriticalSection));
  1741. >
  1742. > #ifdef DLL
  1743. > #ifdef V2
  1744. >
  1745. > #ifdef WIN32
  1746. > {
  1747. > TCHAR szT[2];
  1748. > CodeLpszDecl(szSpecial, TEXT("Ctl3d_RunAlways"));
  1749. > if (GetEnvironmentVariable(szSpecial, szT, 2) != 0 && szT[0] == '1')
  1750. > {
  1751. > goto AllowBadInstall;
  1752. > }
  1753. > }
  1754. > #endif
  1755. >
  1756. > #ifdef WIN32
  1757. > #ifdef UNICODE
  1758. > if (GetVersion() & 0x80000000)
  1759. > {
  1760. > Win16Or32(
  1761. > CodeLpszDecl(lpszCtl3d, TEXT("CTL3DV2.DLL")),
  1762. > CodeLpszDecl(lpszCtl3d, TEXT("CTL3D32.DLL")));
  1763. > CodeLpszDecl(lpszBadInstMsg,
  1764. > TEXT("This application uses CTL3D32.DLL, which is not the correct version. ")
  1765. > TEXT("This version of CTL3D32.DLL is designed only for Windows NT systems."));
  1766. > MessageBox(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK);
  1767. > g3d.f3dDialogs = fFalse;
  1768. > goto Return;
  1769. > }
  1770. > #else
  1771. > if (!(GetVersion() & 0x80000000))
  1772. > {
  1773. > Win16Or32(
  1774. > CodeLpszDecl(lpszCtl3d, TEXT("CTL3DV2.DLL")),
  1775. > CodeLpszDecl(lpszCtl3d, TEXT("CTL3D32.DLL")));
  1776. > CodeLpszDecl(lpszBadInstMsg,
  1777. > TEXT("This application uses CTL3D32.DLL, which is not the correct version. ")
  1778. > TEXT("This version of CTL3D32.DLL is designed only for Win32s or Windows 95 systems."));
  1779. > MessageBox(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK);
  1780. > g3d.f3dDialogs = fFalse;
  1781. > goto Return;
  1782. > }
  1783. > #endif
  1784. > #endif
  1785. > nChars = GetModuleFileName(g3d.hinstLib, MyDirectory, sizeof(MyDirectory)Win32Only(/sizeof(TCHAR)));
  1786. > for (pCh = (LPTSTR)(MyDirectory+nChars-1);
  1787. > pCh >= (LPTSTR)MyDirectory;
  1788. > pCh = Win32Or16(CharPrev(MyDirectory, pCh),AnsiPrev(MyDirectory, pCh)))
  1789. > {
  1790. > if ( *pCh == '\\' )
  1791. > {
  1792. > if ( *(pCh-1) != ':' )
  1793. > *pCh = 0;
  1794. > else
  1795. > *(pCh+1) = 0;
  1796. > break;
  1797. > }
  1798. > }
  1799. >
  1800. > nChars = GetSystemDirectory(OkDirectory, sizeof(OkDirectory)Win32Only(/sizeof(TCHAR)));
  1801. > if ( lstrcmpi(MyDirectory,OkDirectory ) )
  1802. > {
  1803. > nChars = GetWindowsDirectory(OkDirectory, sizeof(OkDirectory)Win32Only(/sizeof(TCHAR)));
  1804. > if ( lstrcmpi(MyDirectory,OkDirectory ) )
  1805. > {
  1806. > Win16Or32(
  1807. > CodeLpszDecl(lpszCtl3d, TEXT("CTL3DV2.DLL")),
  1808. > CodeLpszDecl(lpszCtl3d, TEXT("CTL3D32.DLL")));
  1809. > Win16Or32(
  1810. > CodeLpszDecl(lpszBadInstMsg,
  1811. > TEXT("This application uses CTL3DV2.DLL, which has not been correctly installed. ")
  1812. > TEXT("CTL3DV2.DLL must be installed in the Windows system directory.")),
  1813. > CodeLpszDecl(lpszBadInstMsg,
  1814. > TEXT("This application uses CTL3D32.DLL, which has not been correctly installed. ")
  1815. > TEXT("CTL3D32.DLL must be installed in the Windows system directory.")));
  1816. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  1817. > MessageBox(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK );
  1818. > g3d.f3dDialogs = fFalse;
  1819. > goto Return;
  1820. > }
  1821. > }
  1822. >
  1823. > Win32Only(AllowBadInstall:;)
  1824. > #endif
  1825. > #endif
  1826. >
  1827. > hdc = GetDC(NULL);
  1828. > g3d.f3dDialogs = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES) >= 4;
  1829. > // Win 3.1 EGA lies to us...
  1830. > if(GetSystemMetrics(SM_CYSCREEN) == 350 && GetSystemMetrics(SM_CXSCREEN) == 640)
  1831. > g3d.f3dDialogs = fFalse;
  1832. > ReleaseDC(NULL, hdc);
  1833. > if (g3d.f3dDialogs)
  1834. > {
  1835. > int ct;
  1836. > CodeLpszDecl(lpszC3dD, TEXT("C3dD"));
  1837. >
  1838. > CodeLpszDecl(lpszC3d, TEXT("C3d"));
  1839. > CodeLpszDecl(lpszC3dL, TEXT("C3dL"));
  1840. > CodeLpszDecl(lpszC3dH, TEXT("C3dH"));
  1841. >
  1842. > g3d.aCtl3d = GlobalAddAtom(lpszC3d);
  1843. > if (g3d.aCtl3d == 0)
  1844. > {
  1845. > g3d.f3dDialogs = fFalse;
  1846. > goto Return;
  1847. > }
  1848. >
  1849. > g3d.aCtl3dLow = GlobalAddAtom(lpszC3dL);
  1850. > g3d.aCtl3dHigh = GlobalAddAtom(lpszC3dH);
  1851. > if (g3d.aCtl3dLow == 0 || g3d.aCtl3dHigh == 0)
  1852. > {
  1853. > g3d.f3dDialogs = fFalse;
  1854. > return fFalse;
  1855. > }
  1856. >
  1857. > g3d.aCtl3dDisable = GlobalAddAtom(lpszC3dD);
  1858. > if (g3d.aCtl3dDisable == 0)
  1859. > {
  1860. > g3d.f3dDialogs = fFalse;
  1861. > goto Return;
  1862. > }
  1863. >
  1864. > // DBCS
  1865. > g3d.fDBCS = GetSystemMetrics(SM_DBCSENABLED);
  1866. > Ctl3dWinIniChange();
  1867. >
  1868. > if (InternalCtl3dColorChange(fTrue)) // load bitmap & brushes
  1869. > {
  1870. > for (ct = 0; ct < ctMax; ct++)
  1871. > {
  1872. > g3d.mpctctl[ct].lpfn = (FARPROC)mpctcdef[ct].lpfnWndProc;
  1873. > Assert(g3d.mpctctl[ct].lpfn != NULL);
  1874. > GetClassInfo(NULL, mpctcdef[ct].sz, (LPWNDCLASS) &wc);
  1875. > g3d.mpctctl[ct].lpfnDefProc = wc.lpfnWndProc;
  1876. > }
  1877. > if (GetClassInfo(NULL, WC_DIALOG, &wc))
  1878. > g3d.lpfnDefDlgWndProc = (FARPROC) wc.lpfnWndProc;
  1879. > else
  1880. > g3d.lpfnDefDlgWndProc = (FARPROC) DefDlgProc;
  1881. > }
  1882. > else
  1883. > {
  1884. > g3d.f3dDialogs = fFalse;
  1885. > }
  1886. > }
  1887. > Return:
  1888. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  1889. > return g3d.f3dDialogs;
  1890. > }
  1891. >
  1892. >
  1893. >
  1894. > /*-----------------------------------------------------------------------
  1895. > | End3dDialogs
  1896. > |
  1897. > | Called at DLL termination to free 3d dialog stuff
  1898. > -----------------------------------------------------------------------*/
  1899. > PRIVATE VOID End3dDialogs(VOID)
  1900. > {
  1901. > int ct;
  1902. >
  1903. > Win32Only(EnterCriticalSection(&g_CriticalSection));
  1904. >
  1905. > for (ct = 0; ct < ctMax; ct++)
  1906. > {
  1907. > if(g3d.mpctctl[ct].lpfn != NULL)
  1908. > {
  1909. > FreeProcInstance(g3d.mpctctl[ct].lpfn);
  1910. > g3d.mpctctl[ct].lpfn = NULL;
  1911. > }
  1912. > }
  1913. > DeleteObjects();
  1914. > Win32Only(g3d.aCtl3d ? GlobalDeleteAtom(g3d.aCtl3d) : 0);
  1915. > Win16Only(g3d.aCtl3dLow ? GlobalDeleteAtom(g3d.aCtl3dLow) : 0);
  1916. > Win16Only(g3d.aCtl3dHigh ? GlobalDeleteAtom(g3d.aCtl3dHigh) : 0);
  1917. > g3d.aCtl3dDisable ? GlobalDeleteAtom(g3d.aCtl3dDisable) : 0;
  1918. >
  1919. > g3d.f3dDialogs = fFalse;
  1920. >
  1921. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  1922. >
  1923. > }
  1924. >
  1925. >
  1926. > PRIVATE BOOL InternalCtl3dColorChange(BOOL fForce)
  1927. > {
  1928. > ICV icv;
  1929. > CLRT clrtNew;
  1930. > HBITMAP hbmpCheckboxesNew;
  1931. > BRT brtNew;
  1932. >
  1933. > if (!g3d.f3dDialogs)
  1934. > return fFalse;
  1935. >
  1936. > for (icv = 0; icv < icvMax; icv++)
  1937. > clrtNew.rgcv[icv] = GetSysColor(mpicvSysColor[icv]);
  1938. >
  1939. > if (g3d.verWindows == ver30)
  1940. > clrtNew.rgcv[icvBtnHilite] = RGB(0xff, 0xff, 0xff);
  1941. >
  1942. > if (clrtNew.rgcv[icvGrayText] == 0L || clrtNew.rgcv[icvGrayText] == clrtNew.rgcv[icvBtnFace])
  1943. > {
  1944. > if (clrtNew.rgcv[icvBtnFace] == RGB(0x80, 0x80, 0x80))
  1945. > clrtNew.rgcv[icvGrayText] = RGB(0xc0, 0xc0, 0xc0);
  1946. > else
  1947. > clrtNew.rgcv[icvGrayText] = RGB(0x80, 0x80, 0x80);
  1948. > }
  1949. >
  1950. > if (fForce || MEMCMP(&g3d.clrt, &clrtNew, sizeof(CLRT)))
  1951. > {
  1952. > hbmpCheckboxesNew = LoadUIBitmap(g3d.hinstLib, MAKEINTRESOURCE(CTL3D_3DCHECK),
  1953. > clrtNew.rgcv[icvWindowText],
  1954. > clrtNew.rgcv[icvBtnFace],
  1955. > clrtNew.rgcv[icvBtnShadow],
  1956. > clrtNew.rgcv[icvBtnHilite],
  1957. > clrtNew.rgcv[icvWindow],
  1958. > clrtNew.rgcv[icvWindowFrame]);
  1959. >
  1960. > for (icv = 0; icv < icvBrushMax; icv++)
  1961. > brtNew.mpicvhbr[icv] = CreateSolidBrush(clrtNew.rgcv[icv]);
  1962. >
  1963. > for (icv = 0; icv < icvBrushMax; icv++)
  1964. > if (brtNew.mpicvhbr[icv] == NULL)
  1965. > goto OOM;
  1966. >
  1967. > if(hbmpCheckboxesNew != NULL)
  1968. > {
  1969. > DeleteObjects();
  1970. > g3d.brt = brtNew;
  1971. > g3d.clrt = clrtNew;
  1972. > g3d.hbmpCheckboxes = hbmpCheckboxesNew;
  1973. > return fTrue;
  1974. > }
  1975. > else
  1976. > {
  1977. > OOM:
  1978. > for (icv = 0; icv < icvBrushMax; icv++)
  1979. > DeleteObjectNull(&brtNew.mpicvhbr[icv]);
  1980. > DeleteObjectNull(&hbmpCheckboxesNew);
  1981. > return fFalse;
  1982. > }
  1983. > }
  1984. > return fTrue;
  1985. > }
  1986. >
  1987. >
  1988. > /*-----------------------------------------------------------------------
  1989. > | Ctl3dDlgProc
  1990. > |
  1991. > | Subclass DlgProc for use w/ Ctl3dAutoSubclass
  1992. > |
  1993. > |
  1994. > | Arguments:
  1995. > | HWND hwnd:
  1996. > | int wm:
  1997. > | WORD wParam:
  1998. > | LPARAM lParam:
  1999. > |
  2000. > | Returns:
  2001. > |
  2002. > -----------------------------------------------------------------------*/
  2003. > LRESULT __export _loadds WINAPI Ctl3dDlgProc(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  2004. > {
  2005. > HBRUSH hbrush;
  2006. > FARPROC lpfnDlgProc;
  2007. > TCHAR szClass[cchClassMax];
  2008. >
  2009. > if ( wm == WM_NCDESTROY )
  2010. > return CleanupSubclass(hwnd, wm, wParam, lParam, ctMax);
  2011. >
  2012. > if ( GetProp(hwnd,(LPCTSTR) g3d.aCtl3dDisable) )
  2013. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ctMax), hwnd, wm, wParam, lParam);
  2014. >
  2015. > switch (wm)
  2016. > {
  2017. > case WM_CHECKSUBCLASS:
  2018. > *(int FAR *)lParam = fTrue;
  2019. > return ctMax+1000;
  2020. >
  2021. > case WM_INITDIALOG:
  2022. > {
  2023. > long l;
  2024. > BOOL fSubclass;
  2025. > FARPROC lpfnWinProc;
  2026. >
  2027. > lpfnWinProc = LpfnGetDefWndProc(hwnd, ctMax);
  2028. >
  2029. > if (g3d.verWindows >= ver40 && (GetWindowLong(hwnd, GWL_STYLE) & 0x04))
  2030. > fSubclass = fFalse;
  2031. > else
  2032. > fSubclass = fTrue;
  2033. > SendMessage(hwnd, WM_DLGSUBCLASS, 0, (LPARAM)(int FAR *)&fSubclass);
  2034. >
  2035. > if (!fSubclass)
  2036. > {
  2037. > Ctl3dUnsubclassCtl(hwnd);
  2038. > return CallWindowProc(lpfnWinProc, hwnd, wm, wParam, lParam);
  2039. > }
  2040. >
  2041. > l = CallWindowProc(lpfnWinProc, hwnd, wm, wParam, lParam);
  2042. >
  2043. > if (g3d.verWindows < ver40 || !(GetWindowLong(hwnd, GWL_STYLE) & 0x04))
  2044. > Ctl3dCheckSubclassDlg(hwnd, CTL3D_ALL);
  2045. >
  2046. > return l;
  2047. > }
  2048. >
  2049. > case WM_NCPAINT:
  2050. > case WM_NCACTIVATE:
  2051. > case WM_SETTEXT:
  2052. > if (g3d.verWindows >= ver40 || IsIconic(hwnd) )
  2053. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ctMax), hwnd, wm, wParam, lParam);
  2054. > else
  2055. > return Ctl3dDlgFramePaintI(hwnd, wm, wParam, lParam, FALSE);
  2056. >
  2057. > #ifdef WIN32
  2058. > case WM_CTLCOLORSCROLLBAR:
  2059. > case WM_CTLCOLORBTN:
  2060. > case WM_CTLCOLORDLG:
  2061. > case WM_CTLCOLOREDIT:
  2062. > case WM_CTLCOLORLISTBOX:
  2063. > case WM_CTLCOLORMSGBOX:
  2064. > case WM_CTLCOLORSTATIC:
  2065. > #else
  2066. > case WM_CTLCOLOR:
  2067. > #endif
  2068. > // Is this really a dialog
  2069. > GetClassName(hwnd, szClass, sizeof(szClass)Win32Only(/sizeof(TCHAR)));
  2070. > if (lstrcmp(TEXT("#32770"),szClass) != 0 )
  2071. > {
  2072. > #ifdef WIN32
  2073. > hbrush = (HBRUSH) CallWindowProc(LpfnGetDefWndProc(hwnd, ctMax), hwnd,
  2074. > wm-WM_CTLCOLORMSGBOX+CTLMSGOFFSET, wParam, lParam);
  2075. > #else
  2076. > hbrush = (HBRUSH) CallWindowProc(LpfnGetDefWndProc(hwnd, ctMax), hwnd,
  2077. > CTL3D_CTLCOLOR, wParam, lParam);
  2078. > #endif
  2079. > if (hbrush == (HBRUSH) fFalse || hbrush == (HBRUSH)1)
  2080. > hbrush = Ctl3dCtlColorEx(wm, wParam, lParam);
  2081. > }
  2082. > else
  2083. > {
  2084. > lpfnDlgProc = (FARPROC) GetWindowLong(hwnd, DWL_DLGPROC);
  2085. >
  2086. > if (lpfnDlgProc == NULL )
  2087. > {
  2088. > hbrush = Ctl3dCtlColorEx(wm, wParam, lParam);
  2089. > }
  2090. > else
  2091. > {
  2092. > #ifdef WIN32
  2093. > if ( (LONG)lpfnDlgProc > 0xFFFF0000 && g3d.verWindows <= ver31)
  2094. > {
  2095. > // We have a Uni-code / non Unicode issue.
  2096. > // If this is before Daytona, then I CAN NOT call because it may be NULL, but
  2097. > // the returned value is not-null. NT Bug.
  2098. > // So Just send our own message to the window proc instead
  2099. > hbrush = (HBRUSH) CallWindowProc(LpfnGetDefWndProc(hwnd, ctMax), hwnd,
  2100. > wm-WM_CTLCOLORMSGBOX+CTLMSGOFFSET, wParam, lParam);
  2101. > if (hbrush == (HBRUSH) fFalse || hbrush == (HBRUSH)1)
  2102. > hbrush = Ctl3dCtlColorEx(wm, wParam, lParam);
  2103. > }
  2104. > else
  2105. > {
  2106. > #endif
  2107. > hbrush = (HBRUSH) CallWindowProc(lpfnDlgProc, hwnd, wm, wParam, lParam);
  2108. > if (hbrush == (HBRUSH) fFalse || hbrush == (HBRUSH)1)
  2109. > {
  2110. > #ifdef WIN32
  2111. > hbrush = (HBRUSH) CallWindowProc(LpfnGetDefWndProc(hwnd, ctMax), hwnd,
  2112. > wm-WM_CTLCOLORMSGBOX+CTLMSGOFFSET, wParam, lParam);
  2113. > #else
  2114. > hbrush = (HBRUSH) CallWindowProc(LpfnGetDefWndProc(hwnd, ctMax), hwnd,
  2115. > CTL3D_CTLCOLOR, wParam, lParam);
  2116. > #endif
  2117. > if (hbrush == (HBRUSH) fFalse || hbrush == (HBRUSH)1)
  2118. > hbrush = Ctl3dCtlColorEx(wm, wParam, lParam);
  2119. > }
  2120. > }
  2121. > #ifdef WIN32
  2122. > }
  2123. > #endif
  2124. > }
  2125. > if (hbrush != (HBRUSH) fFalse)
  2126. > return (LRESULT)hbrush;
  2127. > break;
  2128. > }
  2129. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ctMax), hwnd, wm, wParam, lParam);
  2130. > }
  2131. >
  2132. > PRIVATE BOOL NEAR DoesChildNeedSubclass(HWND hwnd)
  2133. > {
  2134. > if (!LpfnGetDefWndProcNull(hwnd))
  2135. > return fFalse;
  2136. > if (g3d.verWindows >= ver40 && GetWindowLong(hwnd, GWL_STYLE) & 0x04)
  2137. > return fFalse;
  2138. > return fTrue;
  2139. > }
  2140. >
  2141. > /*-----------------------------------------------------------------------
  2142. > | Ctl3dHook
  2143. > |
  2144. > | CBT Hook to watch for window creation. Automatically subclasses all
  2145. > | dialogs w/ Ctl3dDlgProc
  2146. > |
  2147. > | Arguments:
  2148. > | int code:
  2149. > | WORD wParam:
  2150. > | LPARAM lParam:
  2151. > |
  2152. > | Returns:
  2153. > |
  2154. > -----------------------------------------------------------------------*/
  2155. > LRESULT __export _loadds WINAPI Ctl3dHook(int code, WPARAM wParam, LPARAM lParam)
  2156. > {
  2157. > int iclihk;
  2158. > HANDLE htask;
  2159. >
  2160. > htask = Win32Or16((HANDLE)GetCurrentThreadId(), GetCurrentTask());
  2161. > Win32Only(EnterCriticalSection(&g_CriticalSection));
  2162. > if (htask != g3d.htaskCache)
  2163. > {
  2164. > for (iclihk = 0; iclihk < g3d.iclihkMac; iclihk++)
  2165. > {
  2166. > if (g3d.rgclihk[iclihk].htask == htask)
  2167. > {
  2168. > g3d.iclihkCache = iclihk;
  2169. > g3d.htaskCache = htask;
  2170. > break;
  2171. > }
  2172. > }
  2173. > if ( iclihk == g3d.iclihkMac )
  2174. > {
  2175. > // didn't find task in hook table. This could be bad, but
  2176. > // returning 0L is about all we can doo.
  2177. > //
  2178. > // Actually not. The hhook isn't used anyway just set it to NULL.
  2179. > // and call the next hook..... KGM
  2180. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  2181. > return CallNextHookEx((HHOOK)0L, code, wParam, lParam);
  2182. > }
  2183. > }
  2184. > iclihk = g3d.iclihkCache;
  2185. > Win32Only(LeaveCriticalSection(&g_CriticalSection));
  2186. >
  2187. > if (code == HCBT_CREATEWND)
  2188. > {
  2189. > LPCREATESTRUCT lpcs;
  2190. > lpcs = ((LPCBT_CREATEWND)lParam)->lpcs;
  2191. >
  2192. > if (lpcs->lpszClass == WC_DIALOG)
  2193. > {
  2194. > if (g3d.verBase == 32)
  2195. > {
  2196. > SubclassWindow((HWND)wParam, (FARPROC) Ctl3dDlgProc);
  2197. > }
  2198. > else
  2199. > {
  2200. > HookSubclassWindow((HWND)wParam, (FARPROC) Ctl3dDlgProc);
  2201. > }
  2202. > goto Zing;
  2203. > }
  2204. > if (!(g3d.rgclihk[iclihk].dwFlags & CTL3D_SUBCLASS_DYNCREATE))
  2205. > goto Zing;
  2206. >
  2207. > if (DoesChildNeedSubclass(lpcs->hwndParent) ||
  2208. > (lpcs->hwndParent && g3d.verBase != 24 &&
  2209. > DoesChildNeedSubclass(GetParent(lpcs->hwndParent))))
  2210. > {
  2211. > DoSubclassCtl((HWND)wParam, CTL3D_ALL, INCBTHOOK, lpcs->hwndParent);
  2212. > }
  2213. > }
  2214. >
  2215. > Zing:;
  2216. > Win32Only(return CallNextHookEx(g3d.rgclihk[iclihk].hhook, code, wParam, lParam));
  2217. > #ifdef DLL
  2218. > Win16Only(return (*g3d.lpfnCallNextHookEx)(g3d.rgclihk[iclihk].hhook, code, wParam, lParam));
  2219. > #else
  2220. > Win16Only(return (CallNextHookEx(g3d.rgclihk[iclihk].hhook, code, wParam, lParam)));
  2221. > #endif
  2222. > }
  2223. >
  2224. >
  2225. >
  2226. >
  2227. > /*-----------------------------------------------------------------------
  2228. > | CTL3D F* routines
  2229. > |
  2230. > | These routines determine whether or not the given control may be
  2231. > | subclassed. They may recursively call DoSubclassCtl in the
  2232. > | case of multi-control controls
  2233. > |
  2234. > | Returns:
  2235. > | fTrue if can subclass the given control.
  2236. > -----------------------------------------------------------------------*/
  2237. >
  2238. >
  2239. > PRIVATE BOOL FBtn(HWND hwnd, LONG style, WORD grbit, WORD wCallFlags, HWND hwndParent)
  2240. > {
  2241. > if (g3d.verWindows >= ver40)
  2242. > {
  2243. > return fFalse;
  2244. > }
  2245. > style &= ~(BS_LEFTTEXT);
  2246. > return ( LOWORD(style) >= BS_PUSHBUTTON && LOWORD(style) <= BS_AUTORADIOBUTTON);
  2247. > }
  2248. >
  2249. > PRIVATE BOOL FEdit(HWND hwnd, LONG style, WORD grbit, WORD wCallFlags, HWND hwndParent)
  2250. > {
  2251. > if (g3d.verWindows >= ver40 && hwndParent)
  2252. > {
  2253. > TCHAR szClass[cchClassMax];
  2254. > GetClassName(hwndParent, szClass, sizeof(szClass)Win32Only(/sizeof(TCHAR)));
  2255. > if (lstrcmp(szClass, mpctcdef[ctCombo].sz) == 0 )
  2256. > return fFalse;
  2257. > else
  2258. > return fTrue;
  2259. > }
  2260. > else
  2261. > return fTrue;
  2262. > }
  2263. >
  2264. > PRIVATE BOOL FList(HWND hwnd, LONG style, WORD grbit, WORD wCallFlags, HWND hwndParent)
  2265. > {
  2266. > if (g3d.verWindows >= ver40 && hwndParent)
  2267. > {
  2268. > TCHAR szClass[cchClassMax];
  2269. > GetClassName(hwndParent, szClass, sizeof(szClass)Win32Only(/sizeof(TCHAR)));
  2270. > if (lstrcmp(szClass, mpctcdef[ctCombo].sz) == 0 )
  2271. > return fFalse;
  2272. > else
  2273. > return fTrue;
  2274. > }
  2275. > else
  2276. > return fTrue;
  2277. > }
  2278. >
  2279. > PRIVATE BOOL FComboList(HWND hwnd, LONG style, WORD grbit, WORD wCallFlags, HWND hwndParent)
  2280. > {
  2281. >
  2282. > if (g3d.verWindows >= ver40)
  2283. > return fFalse;
  2284. >
  2285. > if ( wCallFlags == INCBTHOOK )
  2286. > {
  2287. > LONG style;
  2288. > style = GetWindowLong(hwndParent, GWL_STYLE);
  2289. > if (!(((style & 0x0003) == CBS_DROPDOWN) || ((style & 0x0003) == CBS_DROPDOWNLIST)))
  2290. > return fTrue;
  2291. > else
  2292. > return fFalse;
  2293. > }
  2294. >
  2295. > return fTrue;
  2296. > }
  2297. >
  2298. > PRIVATE BOOL FCombo(HWND hwnd, LONG style, WORD grbit, WORD wCallFlags, HWND hwndParent)
  2299. > {
  2300. > HWND hwndEdit;
  2301. > HWND hwndList;
  2302. >
  2303. > if (g3d.verWindows >= ver40)
  2304. > return fFalse;
  2305. >
  2306. > if ((style & 0x0003) == CBS_DROPDOWN)
  2307. > {
  2308. > if ( wCallFlags == INCBTHOOK )
  2309. > {
  2310. > return fFalse;
  2311. > }
  2312. > // Subclass edit so bottom border of the edit draws properly...This case
  2313. > // is specially handled in ListEditPaint3d
  2314. > hwndEdit = GetWindow(hwnd, GW_CHILD);
  2315. > if (hwndEdit != NULL)
  2316. > DoSubclassCtl(hwndEdit, CTL3D_EDITS, wCallFlags, hwnd);
  2317. > return fTrue;
  2318. > }
  2319. > else if ((style & 0x0003) == CBS_DROPDOWNLIST )
  2320. > {
  2321. > return fTrue;
  2322. > }
  2323. > else // assume simple // if ((style & 0x0003) == CBS_SIMPLE)
  2324. > {
  2325. > if ( wCallFlags == INCBTHOOK )
  2326. > {
  2327. > return fTrue;
  2328. > }
  2329. > hwndList = GetWindow(hwnd, GW_CHILD);
  2330. > if (hwndList != NULL)
  2331. > {
  2332. > // Subclass list & edit box so they draw properly. We also
  2333. > // subclass the combo so we can hide/show/move it and the
  2334. > // 3d effects outside the client area get erased
  2335. > DoSubclassCtl(hwndList, CTL3D_LISTBOXES, wCallFlags, hwnd);
  2336. >
  2337. > hwndEdit = GetWindow(hwndList, GW_HWNDNEXT);
  2338. > if (hwndEdit != NULL)
  2339. > DoSubclassCtl(hwndEdit, CTL3D_EDITS, wCallFlags, hwnd);
  2340. > return fTrue;
  2341. > }
  2342. > return fFalse;
  2343. > }
  2344. > }
  2345. >
  2346. > PRIVATE BOOL FStatic(HWND hwnd, LONG style, WORD grbit, WORD wCallFlags, HWND hwndParent)
  2347. > {
  2348. > int wStyle;
  2349. >
  2350. > wStyle = LOWORD(style) & 0xf;
  2351. > return (wStyle != SS_ICON &&
  2352. > ((grbit & CTL3D_STATICTEXTS) &&
  2353. > (wStyle <= SS_RIGHT || wStyle == SS_LEFTNOWORDWRAP) ||
  2354. > ((grbit & CTL3D_STATICFRAMES) &&
  2355. > (wStyle >= SS_BLACKRECT && wStyle <= SS_WHITEFRAME))));
  2356. > }
  2357. >
  2358. >
  2359. >
  2360. > /*-----------------------------------------------------------------------
  2361. > | DoSubclassCtl
  2362. > |
  2363. > | Actually subclass the control
  2364. > |
  2365. > |
  2366. > | Arguments:
  2367. > | HWND hwnd:
  2368. > | WORD grbit:
  2369. > | WORD wCallFlags
  2370. > | Returns:
  2371. > |
  2372. > -----------------------------------------------------------------------*/
  2373. > PRIVATE BOOL DoSubclassCtl(HWND hwnd, WORD grbit, WORD wCallFlags, HWND hwndParent)
  2374. > {
  2375. > LONG style;
  2376. > int ct;
  2377. > BOOL fCan;
  2378. > TCHAR szClass[cchClassMax];
  2379. >
  2380. > // Is this already subclassed by CTL3D?
  2381. > if (LpfnGetDefWndProcNull(hwnd) != (FARPROC) NULL)
  2382. > return fFalse;
  2383. >
  2384. > GetClassName(hwnd, szClass, sizeof(szClass)Win32Only(/sizeof(TCHAR)));
  2385. >
  2386. > for (ct = 0; ct < ctMax; ct++)
  2387. > {
  2388. > if ((mpctcdef[ct].msk & grbit) &&
  2389. > (lstrcmp(mpctcdef[ct].sz,szClass) == 0))
  2390. > {
  2391. > style = GetWindowLong(hwnd, GWL_STYLE);
  2392. > fCan = mpctcdef[ct].lpfnFCanSubclass(hwnd, style, grbit, wCallFlags, hwndParent);
  2393. > if (fCan == fTrue)
  2394. > {
  2395. > if ( wCallFlags == INCBTHOOK && g3d.verBase == 16 )
  2396. > HookSubclassWindow(hwnd, g3d.mpctctl[ct].lpfn);
  2397. > else
  2398. > SubclassWindow(hwnd, g3d.mpctctl[ct].lpfn);
  2399. > }
  2400. > return fCan != fFalse;
  2401. > }
  2402. > }
  2403. >
  2404. > return fFalse;
  2405. > }
  2406. >
  2407. >
  2408. >
  2409. > /*-----------------------------------------------------------------------
  2410. > | Inval3dCtl
  2411. > |
  2412. > | Invalidate the controls rect in response to a WM_SHOWWINDOW or
  2413. > | WM_WINDOWPOSCHANGING message. This is necessary because ctl3d draws
  2414. > | the 3d effects of listboxes, combos & edits outside the controls client
  2415. > | rect.
  2416. > |
  2417. > | Arguments:
  2418. > | HWND hwnd:
  2419. > | WINDOWPOS FAR *lpwp:
  2420. > |
  2421. > | Returns:
  2422. > |
  2423. > -----------------------------------------------------------------------*/
  2424. > PRIVATE VOID Inval3dCtl(HWND hwnd, WINDOWPOS FAR *lpwp)
  2425. > {
  2426. > RC rc;
  2427. > HWND hwndParent;
  2428. > LONG lStyle;
  2429. > unsigned flags;
  2430. >
  2431. > GetWindowRect(hwnd, (LPRECT) &rc);
  2432. > lStyle = GetWindowLong(hwnd, GWL_STYLE);
  2433. > if (lStyle & WS_VISIBLE)
  2434. > {
  2435. > if (lpwp != NULL)
  2436. > {
  2437. > flags = lpwp->flags;
  2438. >
  2439. > //
  2440. > // Is all this necessary ? Are we moving or sizing ?
  2441. > //
  2442. > if ( !((flags & SWP_HIDEWINDOW) || (flags & SWP_SHOWWINDOW)) &&
  2443. > (flags & SWP_NOMOVE) && (flags & SWP_NOSIZE) )
  2444. > // Nope
  2445. > return;
  2446. >
  2447. > // handle integral height listboxes (or any other control which
  2448. > // shrinks from the bottom)
  2449. > if ((flags & (SWP_NOMOVE|SWP_NOSIZE)) == SWP_NOMOVE &&
  2450. > (lpwp->cx == (rc.xRight-rc.xLeft) && lpwp->cy <= (rc.yBot-rc.yTop)))
  2451. > rc.yTop = rc.yTop+lpwp->cy+1; // +1 to offset InflateRect
  2452. > }
  2453. > InflateRect((LPRECT) &rc, 1, 1);
  2454. > hwndParent = GetParent(hwnd);
  2455. > ScreenToClient(hwndParent, (LPPOINT) &rc);
  2456. > ScreenToClient(hwndParent, ((LPPOINT) &rc)+1);
  2457. > if(lStyle & WS_VSCROLL)
  2458. > rc.xRight ++;
  2459. > InvalidateRect(hwndParent, (LPRECT) &rc, fFalse);
  2460. > }
  2461. > }
  2462. >
  2463. > /*-----------------------------------------------------------------------
  2464. > | Val3dCtl
  2465. > |
  2466. > -----------------------------------------------------------------------*/
  2467. > PRIVATE VOID Val3dCtl(HWND hwnd)
  2468. > {
  2469. > RC rc;
  2470. > HWND hwndParent;
  2471. > LONG lStyle;
  2472. >
  2473. > lStyle = GetWindowLong(hwnd, GWL_STYLE);
  2474. > GetWindowRect(hwnd, (LPRECT) &rc);
  2475. > InflateRect((LPRECT) &rc, 1, 1);
  2476. > hwndParent = GetParent(hwnd);
  2477. > ScreenToClient(hwndParent, (LPPOINT) &rc);
  2478. > ScreenToClient(hwndParent, ((LPPOINT) &rc)+1);
  2479. > if(lStyle & WS_VSCROLL)
  2480. > rc.xRight ++;
  2481. > ValidateRect(hwndParent, (LPRECT) &rc);
  2482. > }
  2483. >
  2484. > /*-----------------------------------------------------------------------
  2485. > | CTL3D Subclass Wndprocs
  2486. > -----------------------------------------------------------------------*/
  2487. >
  2488. > /* These values are assumed for bit shifting operations */
  2489. > #define BFCHECK 0x0003
  2490. > #define BFSTATE 0x0004
  2491. > #define BFFOCUS 0x0008
  2492. > #define BFINCLICK 0x0010 /* Inside click code */
  2493. > #define BFCAPTURED 0x0020 /* We have mouse capture */
  2494. > #define BFMOUSE 0x0040 /* Mouse-initiated */
  2495. > #define BFDONTCLICK 0x0080 /* Don't check on get focus */
  2496. >
  2497. > #define bpText 0x0002
  2498. > #define bpCheck 0x0004
  2499. > #define bpFocus 0x0008 // must be same as BFFOCUS
  2500. > #define bpBkgnd 0x0010
  2501. > #define bpEraseGroupText 0x0020
  2502. >
  2503. > PRIVATE VOID DrawPushButton(HWND hwnd, HDC hdc, RC FAR *lprc, LPTSTR lpch, int cch, WORD bs, BOOL fDown)
  2504. > {
  2505. > // int dxyBrdr;
  2506. > int dxyShadow;
  2507. > HBRUSH hbrSav;
  2508. > RC rcInside;
  2509. > rcInside = *lprc;
  2510. >
  2511. > // if (!(grbitStyle & bitFCoolButtons))
  2512. > {
  2513. > DrawRec3d(hdc, lprc, icvWindowFrame, icvWindowFrame, dr3All);
  2514. > InflateRect((LPRECT) &rcInside, -1, -1);
  2515. > if (bs == LOWORD(BS_DEFPUSHBUTTON) && IsWindowEnabled(hwnd))
  2516. > {
  2517. > // dxyBrdr = 2;
  2518. > DrawRec3d(hdc, &rcInside, icvWindowFrame, icvWindowFrame, dr3All);
  2519. > InflateRect((LPRECT) &rcInside, -1, -1);
  2520. > }
  2521. > // else
  2522. > // dxyBrdr = 1;
  2523. >
  2524. > // Notch the corners
  2525. > PatBlt(hdc, lprc->xLeft, lprc->yTop, dxBorder, dyBorder, PATCOPY);
  2526. > /* Top xRight corner */
  2527. > PatBlt(hdc, lprc->xRight - dxBorder, lprc->yTop, dxBorder, dyBorder, PATCOPY);
  2528. > /* yBot xLeft corner */
  2529. > PatBlt(hdc, lprc->xLeft, lprc->yBot - dyBorder, dxBorder, dyBorder, PATCOPY);
  2530. > /* yBot xRight corner */
  2531. > PatBlt(hdc, lprc->xRight - dxBorder, lprc->yBot - dyBorder, dxBorder, dyBorder, PATCOPY);
  2532. > dxyShadow = 1 + !fDown;
  2533. > }
  2534. > // else
  2535. > // dxyShadow = 1;
  2536. >
  2537. > // draw upper left hilite/shadow
  2538. >
  2539. > if (fDown)
  2540. > hbrSav = SelectObject(hdc, g3d.brt.mpicvhbr[icvBtnShadow]);
  2541. > else
  2542. > hbrSav = SelectObject(hdc, g3d.brt.mpicvhbr[icvBtnHilite]);
  2543. >
  2544. > PatBlt(hdc, rcInside.xLeft, rcInside.yTop, dxyShadow,
  2545. > (rcInside.yBot - rcInside.yTop), PATCOPY);
  2546. > PatBlt(hdc, rcInside.xLeft, rcInside.yTop,
  2547. > (rcInside.xRight - rcInside.xLeft), dxyShadow, PATCOPY);
  2548. >
  2549. > // draw lower right shadow (only if not down)
  2550. > if (!fDown) // || (grbitStyle & bitFCoolButtons))
  2551. > {
  2552. > int i;
  2553. >
  2554. > if (fDown)
  2555. > SelectObject(hdc, g3d.brt.mpicvhbr[icvBtnHilite]);
  2556. > else
  2557. > SelectObject(hdc, g3d.brt.mpicvhbr[icvBtnShadow]);
  2558. >
  2559. > rcInside.yBot--;
  2560. > rcInside.xRight--;
  2561. >
  2562. > for (i = 0; i < dxyShadow; i++)
  2563. > {
  2564. > PatBlt(hdc, rcInside.xLeft, rcInside.yBot,
  2565. > rcInside.xRight - rcInside.xLeft + dxBorder, dyBorder,
  2566. > PATCOPY);
  2567. > PatBlt(hdc, rcInside.xRight, rcInside.yTop, dxBorder,
  2568. > rcInside.yBot - rcInside.yTop, PATCOPY);
  2569. > if (i < dxyShadow-1)
  2570. > InflateRect((LPRECT) &rcInside, -dxBorder, -dyBorder);
  2571. > }
  2572. > }
  2573. > // draw the button face
  2574. >
  2575. > rcInside.xLeft++;
  2576. > rcInside.yTop++;
  2577. >
  2578. > SelectObject(hdc, g3d.brt.mpicvhbr[icvBtnFace]);
  2579. > PatBlt(hdc, rcInside.xLeft, rcInside.yTop, rcInside.xRight-rcInside.xLeft,
  2580. > rcInside.yBot - rcInside.yTop, PATCOPY);
  2581. >
  2582. > // Draw the durned text
  2583. >
  2584. > if(!IsWindowEnabled(hwnd))
  2585. > SetTextColor(hdc, g3d.clrt.rgcv[icvGrayText]);
  2586. >
  2587. > {
  2588. > int dy;
  2589. > int dx;
  2590. >
  2591. > MyGetTextExtent(hdc, lpch, &dx, &dy);
  2592. > rcInside.yTop += (rcInside.yBot-rcInside.yTop-dy)/2;
  2593. > rcInside.xLeft += (rcInside.xRight-rcInside.xLeft-dx)/2;
  2594. > rcInside.yBot = min(rcInside.yTop+dy, rcInside.yBot);
  2595. > rcInside.xRight = min(rcInside.xLeft+dx, rcInside.xRight);
  2596. > }
  2597. >
  2598. > if (fDown)
  2599. > {
  2600. > OffsetRect((LPRECT) &rcInside, 1, 1);
  2601. > rcInside.xRight = min(rcInside.xRight, lprc->xRight-3);
  2602. > rcInside.yBot = min(rcInside.yBot, lprc->yBot-3);
  2603. > }
  2604. >
  2605. > DrawText(hdc, lpch, cch, (LPRECT) &rcInside, DT_LEFT|DT_SINGLELINE);
  2606. >
  2607. > if (hwnd == GetFocus())
  2608. > {
  2609. > InflateRect((LPRECT) &rcInside, 1, 1);
  2610. > IntersectRect((LPRECT) &rcInside, (LPRECT) &rcInside, (LPRECT) lprc);
  2611. > DrawFocusRect(hdc, (LPRECT) &rcInside);
  2612. > }
  2613. >
  2614. > if (hbrSav)
  2615. > SelectObject(hdc, hbrSav);
  2616. > }
  2617. >
  2618. >
  2619. > /*-----------------------------------------------------------------------
  2620. > | BtnPaint
  2621. > |
  2622. > | Paint a button
  2623. > |
  2624. > | Arguments:
  2625. > | HWND hwnd:
  2626. > | HDC hdc:
  2627. > | int bp:
  2628. > |
  2629. > | Returns:
  2630. > |
  2631. > -----------------------------------------------------------------------*/
  2632. > PRIVATE VOID BtnPaint(HWND hwnd, HDC hdc, int bp)
  2633. > {
  2634. > RC rc;
  2635. > RC rcClient;
  2636. > HFONT hfont;
  2637. > int bs;
  2638. > int bf;
  2639. > HBRUSH hbrBtn;
  2640. > HWND hwndParent;
  2641. > int xBtnBmp;
  2642. > int yBtnBmp;
  2643. > HBITMAP hbmpSav;
  2644. > HDC hdcMem;
  2645. > TCHAR szTitle[256];
  2646. > int cch;
  2647. > BOOL fEnabled;
  2648. > BOOL fLeftText;
  2649. >
  2650. > bs = (int) GetWindowLong(hwnd, GWL_STYLE);
  2651. > fLeftText = (bs & Win32Or16(0x00000020, 0x0020));
  2652. > bs &= Win32Or16(0x0000001F, 0x001F);
  2653. > hwndParent = GetParent(hwnd);
  2654. > SetBkMode(hdc, OPAQUE);
  2655. > GetClientRect(hwnd, (LPRECT)&rcClient);
  2656. > rc = rcClient;
  2657. > if((hfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0L)) != NULL)
  2658. > hfont = SelectObject(hdc, hfont);
  2659. >
  2660. > SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
  2661. > SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
  2662. > hbrBtn = SEND_COLOR_BUTTON_MESSAGE(hwndParent, hwnd, hdc);
  2663. > hbrBtn = SelectObject(hdc, hbrBtn);
  2664. > IntersectClipRect(hdc, rc.xLeft, rc.yTop, rc.xRight, rc.yBot);
  2665. > if(bp & bpBkgnd && (bs != BS_GROUPBOX))
  2666. > PatBlt(hdc, rc.xLeft, rc.yTop, rc.xRight-rc.xLeft, rc.yBot-rc.yTop, PATCOPY);
  2667. >
  2668. > fEnabled = IsWindowEnabled(hwnd);
  2669. > bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
  2670. > yBtnBmp = 0;
  2671. > xBtnBmp = (((bf&BFCHECK) != 0) | ((bf&BFSTATE) >> 1)) * 14;
  2672. > if (!fEnabled)
  2673. > xBtnBmp += 14*(2+((bf&BFCHECK) != 0));
  2674. > if(bp & (bpText|bpFocus) ||
  2675. > bs == BS_PUSHBUTTON || bs == BS_DEFPUSHBUTTON)
  2676. > cch = GetWindowText(hwnd, szTitle, sizeof(szTitle)Win32Only(/sizeof(TCHAR)));
  2677. > switch(bs)
  2678. > {
  2679. > #ifdef DEBUG
  2680. > default:
  2681. > Assert(fFalse);
  2682. > break;
  2683. > #endif
  2684. > case BS_PUSHBUTTON:
  2685. > case BS_DEFPUSHBUTTON:
  2686. > DrawPushButton(hwnd, hdc, &rcClient, szTitle, cch, LOWORD(bs), bf & BFSTATE);
  2687. > break;
  2688. >
  2689. > case BS_RADIOBUTTON:
  2690. > case BS_AUTORADIOBUTTON:
  2691. > yBtnBmp = 13;
  2692. > goto DrawBtn;
  2693. > case BS_3STATE:
  2694. > case BS_AUTO3STATE:
  2695. > Assert((BFSTATE >> 1) == 2);
  2696. > if((bf & BFCHECK) == 2)
  2697. > yBtnBmp = 26;
  2698. > // fall through
  2699. > case BS_CHECKBOX:
  2700. > case BS_AUTOCHECKBOX:
  2701. > DrawBtn:
  2702. > if(bp & bpCheck)
  2703. > {
  2704. > hdcMem = CreateCompatibleDC(hdc);
  2705. > if(hdcMem != NULL)
  2706. > {
  2707. > hbmpSav = SelectObject(hdcMem, g3d.hbmpCheckboxes);
  2708. > if(hbmpSav != NULL)
  2709. > {
  2710. > if (fLeftText)
  2711. > BitBlt(hdc, rc.xRight - 14, rc.yTop+(rc.yBot-rc.yTop-13)/2,
  2712. > 14, 13, hdcMem, xBtnBmp, yBtnBmp, SRCCOPY);
  2713. > else
  2714. > BitBlt(hdc, rc.xLeft, rc.yTop+(rc.yBot-rc.yTop-13)/2,
  2715. > 14, 13, hdcMem, xBtnBmp, yBtnBmp, SRCCOPY);
  2716. > SelectObject(hdcMem, hbmpSav);
  2717. > }
  2718. > DeleteDC(hdcMem);
  2719. > }
  2720. > }
  2721. > if(bp & bpText)
  2722. > {
  2723. > // BUG! this assumes we have only 1 hbm3dCheck type
  2724. > if (fLeftText)
  2725. > rc.xRight = rcClient.xRight - (14+4);
  2726. > else
  2727. > rc.xLeft = rcClient.xLeft + 14+4;
  2728. > if(!fEnabled)
  2729. > SetTextColor(hdc, g3d.clrt.rgcv[icvGrayText]);
  2730. > DrawText(hdc, szTitle, cch, (LPRECT) &rc, DT_VCENTER|DT_LEFT|DT_SINGLELINE);
  2731. > }
  2732. > if(bp & bpFocus)
  2733. > {
  2734. > int dx;
  2735. > int dy;
  2736. >
  2737. > MyGetTextExtent(hdc, szTitle, &dx, &dy);
  2738. > rc.yTop = (rc.yBot-rc.yTop-dy)/2;
  2739. > rc.yBot = rc.yTop+dy;
  2740. > rc.xLeft = rcClient.xLeft;
  2741. > if (fLeftText)
  2742. > {
  2743. > rc.xLeft = rcClient.xLeft;
  2744. > rcClient.xRight -= (14+4);
  2745. > }
  2746. > else
  2747. > rc.xLeft = rcClient.xLeft + (14+4);
  2748. > rc.xRight = rc.xLeft + dx;
  2749. > InflateRect((LPRECT) &rc, 1, 1);
  2750. > IntersectRect((LPRECT) &rc, (LPRECT) &rc, (LPRECT) &rcClient);
  2751. > DrawFocusRect(hdc, (LPRECT) &rc);
  2752. > }
  2753. > break;
  2754. > case BS_GROUPBOX:
  2755. > if(bp & (bpText|bpCheck))
  2756. > {
  2757. > int dy;
  2758. > int dx;
  2759. >
  2760. > MyGetTextExtent(hdc, szTitle, &dx, &dy);
  2761. > if (dy == 0)
  2762. > {
  2763. > int dxT;
  2764. > MyGetTextExtent(hdc, TEXT("X"), &dxT, &dy);
  2765. > }
  2766. >
  2767. > rc.xLeft += 4;
  2768. > rc.xRight = rc.xLeft + dx + 4;
  2769. > rc.yBot = rc.yTop + dy;
  2770. >
  2771. > if (bp & bpEraseGroupText)
  2772. > {
  2773. > RC rcT;
  2774. >
  2775. > rcT = rc;
  2776. > rcT.xRight = rcClient.xRight;
  2777. > // Hack!
  2778. > ClientToScreen(hwnd, (LPPOINT) &rcT);
  2779. > ClientToScreen(hwnd, ((LPPOINT) &rcT)+1);
  2780. > ScreenToClient(hwndParent, (LPPOINT) &rcT);
  2781. > ScreenToClient(hwndParent, ((LPPOINT) &rcT)+1);
  2782. > InvalidateRect(hwndParent, (LPRECT) &rcT, fTrue);
  2783. > return;
  2784. > }
  2785. >
  2786. > rcClient.yTop += dy/2;
  2787. > rcClient.xRight--;
  2788. > rcClient.yBot--;
  2789. > DrawRec3d(hdc, &rcClient, icvBtnShadow, icvBtnShadow, dr3All);
  2790. > OffsetRect((LPRECT) &rcClient, 1, 1);
  2791. > DrawRec3d(hdc, &rcClient, icvBtnHilite, icvBtnHilite, dr3All);
  2792. >
  2793. > if(!fEnabled)
  2794. > SetTextColor(hdc, g3d.clrt.rgcv[icvGrayText]);
  2795. > DrawText(hdc, szTitle, cch, (LPRECT) &rc, DT_LEFT|DT_SINGLELINE);
  2796. > }
  2797. > break;
  2798. > }
  2799. >
  2800. > SelectObject(hdc, hbrBtn);
  2801. > if(hfont != NULL)
  2802. > SelectObject(hdc, hfont);
  2803. > }
  2804. >
  2805. > LRESULT __export _loadds WINAPI BtnWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  2806. > {
  2807. > LONG lRet;
  2808. > LONG lStyle;
  2809. > PAINTSTRUCT ps;
  2810. > HDC hdc;
  2811. > int bf;
  2812. > int bfNew;
  2813. > int bp;
  2814. >
  2815. > if ( wm == WM_NCDESTROY )
  2816. > return CleanupSubclass(hwnd, wm, wParam, lParam, ctButton);
  2817. >
  2818. > if ( GetProp(hwnd,(LPCTSTR) g3d.aCtl3dDisable) )
  2819. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ctButton), hwnd, wm, wParam, lParam);
  2820. >
  2821. > switch(wm)
  2822. > {
  2823. > case WM_CHECKSUBCLASS:
  2824. > *(int FAR *)lParam = fTrue;
  2825. > return ctButton+1000;
  2826. >
  2827. > case WM_SETTEXT:
  2828. > lStyle = GetWindowLong(hwnd, GWL_STYLE);
  2829. > if ((lStyle & WS_VISIBLE) && (LOWORD(lStyle) & 0x1f) == BS_GROUPBOX)
  2830. > {
  2831. > // total hack -- if group box text length shortens then
  2832. > // we have to erase the old text. BtnPaint will Invalidate
  2833. > // the rect of the text so everything will redraw.
  2834. > bp = bpText | bpEraseGroupText;
  2835. > }
  2836. > else
  2837. > {
  2838. > bp = bpText|bpCheck|bpBkgnd;
  2839. > }
  2840. > goto DoIt;
  2841. >
  2842. > case BM_SETSTATE:
  2843. > case BM_SETCHECK:
  2844. > bp = bpCheck;
  2845. > goto DoIt;
  2846. > case WM_KILLFOCUS:
  2847. > // HACK! Windows will go into an infinite loop trying to sync the
  2848. > // states of the AUTO_RADIOBUTTON in this group. (we turn off the
  2849. > // visible bit so it gets skipped in the enumeration)
  2850. > // Disable this code by clearing the STATE bit
  2851. > if ((LOWORD(GetWindowLong(hwnd, GWL_STYLE)) & 0x1F) == BS_AUTORADIOBUTTON)
  2852. > SendMessage(hwnd, BM_SETSTATE, 0, 0L);
  2853. > bp = 0;
  2854. > goto DoIt;
  2855. > case WM_ENABLE:
  2856. > bp = bpCheck | bpText;
  2857. > goto DoIt;
  2858. > case WM_SETFOCUS:
  2859. > // HACK! if wParam == NULL we may be activated via the task manager
  2860. > // Erase background of control because a WM_ERASEBKGND messsage has not
  2861. > // arrived yet for the dialog
  2862. > // bp = wParam == (WPARAM)NULL ? (bpCheck | bpText | bpBkgnd) : (bpCheck | bpText);
  2863. > bp = bpCheck | bpText | bpBkgnd;
  2864. > DoIt:
  2865. > bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
  2866. > if((lStyle = GetWindowLong(hwnd, GWL_STYLE)) & WS_VISIBLE)
  2867. > {
  2868. > if ( wm != WM_SETFOCUS )
  2869. > SetWindowLong(hwnd, GWL_STYLE, lStyle & ~(WS_VISIBLE));
  2870. > lRet = CallWindowProc(LpfnGetDefWndProc(hwnd, ctButton), hwnd, wm, wParam, lParam);
  2871. >
  2872. > if ( wm != WM_SETFOCUS )
  2873. > SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE)|WS_VISIBLE);
  2874. > bfNew = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
  2875. > if((wm != BM_SETSTATE && wm != BM_SETCHECK) ||
  2876. > bf != bfNew)
  2877. > {
  2878. > hdc = GetDC(hwnd);
  2879. > if (hdc != NULL)
  2880. > {
  2881. > Assert(BFFOCUS == bpFocus);
  2882. > /* If the check state changed, redraw no matter what,
  2883. > because it won't have during the above call to the def
  2884. > wnd proc */
  2885. > if ((bf & BFCHECK) != (bfNew & BFCHECK))
  2886. > bp |= bpCheck;
  2887. > ExcludeUpdateRgn(hdc, hwnd);
  2888. > BtnPaint(hwnd, hdc, bp|((bf^bfNew)&BFFOCUS));
  2889. > ReleaseDC(hwnd, hdc);
  2890. > }
  2891. > }
  2892. > return lRet;
  2893. > }
  2894. > break;
  2895. > case WM_PAINT:
  2896. > bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
  2897. > if ((hdc = (HDC) wParam) == NULL)
  2898. > hdc = BeginPaint(hwnd, &ps);
  2899. > if(GetWindowLong(hwnd, GWL_STYLE) & WS_VISIBLE)
  2900. > BtnPaint(hwnd, hdc, bpText|bpCheck|(bf&BFFOCUS));
  2901. > if (wParam == (WPARAM)NULL)
  2902. > EndPaint(hwnd, &ps);
  2903. > return 0L;
  2904. > }
  2905. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ctButton), hwnd, wm, wParam, lParam);
  2906. > }
  2907. >
  2908. >
  2909. > void ListEditPaint3d(HWND hwnd, BOOL fEdit, int ct)
  2910. > {
  2911. > CTLID id;
  2912. > RC rc;
  2913. > HDC hdc;
  2914. > HWND hwndParent;
  2915. > LONG lStyle;
  2916. > DR3 dr3;
  2917. >
  2918. > if(!((lStyle = GetWindowLong(hwnd, GWL_STYLE)) & WS_VISIBLE))
  2919. > return;
  2920. >
  2921. > if ((ct == ctCombo && (lStyle & 0x003) == CBS_DROPDOWNLIST))
  2922. > {
  2923. > if ( SendMessage(hwnd, CB_GETDROPPEDSTATE,0,0L) )
  2924. > return;
  2925. > }
  2926. >
  2927. > if (fEdit)
  2928. > HideCaret(hwnd);
  2929. >
  2930. > GetWindowRect(hwnd, (LPRECT) &rc);
  2931. >
  2932. > ScreenToClient(hwndParent = GetParent(hwnd), (LPPOINT) &rc);
  2933. > ScreenToClient(hwndParent, ((LPPOINT) &rc)+1);
  2934. >
  2935. > hdc = GetDC(hwndParent);
  2936. >
  2937. > dr3 = dr3All;
  2938. >
  2939. > if(lStyle & WS_HSCROLL)
  2940. > dr3 = dr3 & ~dr3Bot;
  2941. >
  2942. > if(lStyle & WS_VSCROLL)
  2943. > dr3 = dr3 & ~dr3Right;
  2944. >
  2945. > // don't draw the top if it's a listbox of a simple combo
  2946. > id = GetControlId(hwnd);
  2947. > if (id == (CTLID) (1000 + fEdit))
  2948. > {
  2949. > TCHAR szClass[cchClassMax];
  2950. > BOOL fSubclass = 666;
  2951. > int ctParent;
  2952. >
  2953. > // could be superclassed!
  2954. > fSubclass = 666;
  2955. > ctParent = (int)SendMessage(hwndParent, WM_CHECKSUBCLASS, 0, (LPARAM)(int FAR *)&fSubclass);
  2956. >
  2957. > // could be subclassed!
  2958. > GetClassName(hwndParent, szClass, sizeof(szClass)Win32Only(/sizeof(TCHAR)));
  2959. > if (lstrcmp(szClass, mpctcdef[ctCombo].sz) == 0 ||
  2960. > (fSubclass == fTrue && ctParent == ctCombo+1000))
  2961. > {
  2962. > HWND hwndComboParent;
  2963. >
  2964. > hwndComboParent = GetParent(hwndParent);
  2965. >
  2966. > Win16Only(GetWindowRect(hwnd, (LPRECT) &rc));
  2967. > Win16Only(ScreenToClient(hwndComboParent, (LPPOINT) &rc));
  2968. > Win16Only(ScreenToClient(hwndComboParent, ((LPPOINT) &rc)+1));
  2969. >
  2970. > Win32Only(MapWindowPoints(hwndParent, hwndComboParent, (POINT*)&rc, 2));
  2971. >
  2972. > ReleaseDC(hwndParent, hdc);
  2973. > hdc = GetDC(hwndComboParent);
  2974. >
  2975. > if (fEdit)
  2976. > {
  2977. > RC rcList;
  2978. > HWND hwndList;
  2979. > long style;
  2980. >
  2981. > style = GetWindowLong(hwndParent, GWL_STYLE);
  2982. > if (!(((style & 0x0003) == CBS_DROPDOWN)
  2983. > || ((style & 0x0003) == CBS_DROPDOWNLIST)))
  2984. > {
  2985. > dr3 &= ~dr3Bot;
  2986. >
  2987. > hwndList = GetWindow(hwndParent, GW_CHILD);
  2988. > GetWindowRect(hwndList, (LPRECT) &rcList);
  2989. >
  2990. > // Some ugly shit goin' on here!
  2991. > rc.xRight -= rcList.xRight-rcList.xLeft;
  2992. > DrawInsetRect3d(hdc, &rc, dr3Bot|dr3HackBotRight);
  2993. > rc.xRight += rcList.xRight-rcList.xLeft;
  2994. > }
  2995. > else
  2996. > {
  2997. > //
  2998. > // Is the drop down on the parent down ? if so don't paint.
  2999. > //
  3000. > if ( SendMessage(hwndParent, CB_GETDROPPEDSTATE,0,0L) )
  3001. > {
  3002. > ReleaseDC(hwndComboParent, hdc);
  3003. > ShowCaret(hwnd);
  3004. > return;
  3005. > }
  3006. > }
  3007. > }
  3008. > else
  3009. > {
  3010. > rc.yTop++;
  3011. > dr3 &= ~dr3Top;
  3012. > }
  3013. >
  3014. > hwndParent = hwndComboParent;
  3015. >
  3016. > }
  3017. > }
  3018. >
  3019. > DrawInsetRect3d(hdc, &rc, dr3);
  3020. >
  3021. > if ((ct == ctCombo && (lStyle & 0x003) == CBS_DROPDOWNLIST))
  3022. > {
  3023. > rc.xLeft = rc.xRight - GetSystemMetrics(SM_CXVSCROLL);
  3024. > DrawRec3d(hdc, &rc, icvWindowFrame, icvWindowFrame, dr3Right|dr3Bot);
  3025. > Val3dCtl(hwnd);
  3026. > }
  3027. > else {
  3028. > if (lStyle & WS_VSCROLL)
  3029. > {
  3030. > int SaveLeft;
  3031. >
  3032. > rc.xRight++;
  3033. > DrawRec3d(hdc, &rc, icvBtnHilite, icvBtnHilite, dr3Right);
  3034. > rc.xRight--;
  3035. > SaveLeft = rc.xLeft;
  3036. > rc.xLeft = rc.xRight - GetSystemMetrics(SM_CXVSCROLL);
  3037. > DrawRec3d(hdc, &rc, icvWindowFrame, icvWindowFrame, dr3Bot);
  3038. > rc.xLeft = SaveLeft;
  3039. > }
  3040. > if (lStyle & WS_HSCROLL)
  3041. > {
  3042. > rc.yBot++;
  3043. > DrawRec3d(hdc, &rc, icvBtnHilite, icvBtnHilite, dr3Bot);
  3044. > rc.yBot--;
  3045. > rc.yTop = rc.yBot - GetSystemMetrics(SM_CXHSCROLL);
  3046. > DrawRec3d(hdc, &rc, icvWindowFrame, icvWindowFrame, dr3Right);
  3047. > }
  3048. > }
  3049. >
  3050. > ReleaseDC(hwndParent, hdc);
  3051. > if (fEdit)
  3052. > ShowCaret(hwnd);
  3053. >
  3054. > }
  3055. >
  3056. >
  3057. > LONG ShareEditComboWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam, int ct)
  3058. > {
  3059. > LONG l;
  3060. > LONG style;
  3061. >
  3062. > if ( wm == WM_NCDESTROY )
  3063. > return CleanupSubclass(hwnd, wm, wParam, lParam, ct);
  3064. >
  3065. > if ( GetProp(hwnd,(LPCTSTR) g3d.aCtl3dDisable) )
  3066. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ct), hwnd, wm, wParam, lParam);
  3067. >
  3068. > l = CallWindowProc(LpfnGetDefWndProc(hwnd,ct), hwnd, wm, wParam, lParam);
  3069. > if (ct == ctCombo)
  3070. > {
  3071. > style = GetWindowLong(hwnd, GWL_STYLE);
  3072. > if ((style & 0x0003) == CBS_DROPDOWN)
  3073. > return l;
  3074. > }
  3075. >
  3076. > switch(wm)
  3077. > {
  3078. > case WM_CHECKSUBCLASS:
  3079. > *(int FAR *)lParam = fTrue;
  3080. > return ctEdit+1000;
  3081. >
  3082. > case WM_SHOWWINDOW:
  3083. > if (g3d.verWindows < ver31 && wParam == 0)
  3084. > Inval3dCtl(hwnd, (WINDOWPOS FAR *) NULL);
  3085. > break;
  3086. > case WM_WINDOWPOSCHANGING:
  3087. > if (g3d.verWindows >= ver31)
  3088. > Inval3dCtl(hwnd, (WINDOWPOS FAR *) lParam);
  3089. > break;
  3090. >
  3091. > case WM_PAINT:
  3092. > {
  3093. > if (ct != ctCombo ||
  3094. > (((style & 0x0003) == CBS_DROPDOWN) || ((style & 0x0003) == CBS_DROPDOWNLIST)))
  3095. > ListEditPaint3d(hwnd, TRUE, ct);
  3096. > }
  3097. > break;
  3098. > }
  3099. > return l;
  3100. > }
  3101. >
  3102. >
  3103. > LRESULT __export _loadds WINAPI EditWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  3104. > {
  3105. > return ShareEditComboWndProc3d(hwnd, wm, wParam, lParam, ctEdit);
  3106. > }
  3107. >
  3108. >
  3109. > LONG SharedListWndProc(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam, unsigned ct)
  3110. > {
  3111. > LONG l;
  3112. >
  3113. > if ( wm == WM_NCDESTROY )
  3114. > return CleanupSubclass(hwnd, wm, wParam, lParam, ct);
  3115. >
  3116. > if ( GetProp(hwnd,(LPCTSTR) g3d.aCtl3dDisable) )
  3117. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ct), hwnd, wm, wParam, lParam);
  3118. >
  3119. > switch(wm)
  3120. > {
  3121. > case WM_CHECKSUBCLASS:
  3122. > *(int FAR *)lParam = fTrue;
  3123. > return ctList+1000;
  3124. >
  3125. > case WM_SHOWWINDOW:
  3126. > if (g3d.verWindows < ver31 && wParam == 0)
  3127. > Inval3dCtl(hwnd, (WINDOWPOS FAR *) NULL);
  3128. > break;
  3129. > case WM_WINDOWPOSCHANGING:
  3130. > if (g3d.verWindows >= ver31)
  3131. > Inval3dCtl(hwnd, (WINDOWPOS FAR *) lParam);
  3132. > break;
  3133. > case WM_PAINT:
  3134. > l = CallWindowProc(LpfnGetDefWndProc(hwnd, ct), hwnd, wm, wParam, lParam);
  3135. > ListEditPaint3d(hwnd, FALSE, ct);
  3136. > return l;
  3137. > case WM_NCCALCSIZE:
  3138. > {
  3139. > RC rc;
  3140. > RC rcNew;
  3141. > HWND hwndParent;
  3142. >
  3143. > // Inval3dCtl handles this case under Win 3.1
  3144. > if (g3d.verWindows >= ver31)
  3145. > break;
  3146. >
  3147. > GetWindowRect(hwnd, (LPRECT) &rc);
  3148. > #ifdef UNREACHABLE
  3149. > if (g3d.verWindows >= ver31)
  3150. > {
  3151. > hwndParent = GetParent(hwnd);
  3152. > ScreenToClient(hwndParent, (LPPOINT) &rc);
  3153. > ScreenToClient(hwndParent, ((LPPOINT) &rc)+1);
  3154. > }
  3155. > #endif
  3156. >
  3157. > l = CallWindowProc(LpfnGetDefWndProc(hwnd, ct), hwnd, wm, wParam, lParam);
  3158. >
  3159. > rcNew = *(RC FAR *)lParam;
  3160. > InflateRect((LPRECT) &rcNew, 2, 1); // +1 for border (Should use AdjustWindowRect)
  3161. > if (rcNew.yBot < rc.yBot)
  3162. > {
  3163. > rcNew.yTop = rcNew.yBot+1;
  3164. > rcNew.yBot = rc.yBot+1;
  3165. >
  3166. > #ifdef ALWAYS
  3167. > if (g3d.verWindows < ver31)
  3168. > #endif
  3169. > {
  3170. > hwndParent = GetParent(hwnd);
  3171. > ScreenToClient(hwndParent, (LPPOINT) &rcNew);
  3172. > ScreenToClient(hwndParent, ((LPPOINT) &rcNew)+1);
  3173. > }
  3174. >
  3175. > InvalidateRect(hwndParent, (LPRECT) &rcNew, TRUE);
  3176. > }
  3177. > return l;
  3178. > }
  3179. > }
  3180. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ct), hwnd, wm, wParam, lParam);
  3181. > }
  3182. >
  3183. > LRESULT __export _loadds WINAPI ListWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  3184. > {
  3185. > return SharedListWndProc(hwnd, wm, wParam, lParam, ctList);
  3186. > }
  3187. >
  3188. >
  3189. >
  3190. > LRESULT __export _loadds WINAPI ComboWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  3191. > {
  3192. > switch(wm)
  3193. > {
  3194. > case WM_CHECKSUBCLASS:
  3195. > *(int FAR *)lParam = fTrue;
  3196. > return ctCombo+1000;
  3197. > }
  3198. >
  3199. > return ShareEditComboWndProc3d(hwnd, wm, wParam, lParam, ctCombo);
  3200. > }
  3201. >
  3202. > void StaticPrint(HWND hwnd, HDC hdc, RC FAR *lprc, LONG style)
  3203. > {
  3204. > WORD dt;
  3205. > LONG cv;
  3206. > Win16Or32(HANDLE , LPTSTR )hText;
  3207. > int TextLen;
  3208. >
  3209. > PatBlt(hdc, lprc->xLeft, lprc->yTop, lprc->xRight-lprc->xLeft, lprc->yBot-lprc->yTop, PATCOPY);
  3210. >
  3211. > TextLen = GetWindowTextLength(hwnd);
  3212. >
  3213. > #ifndef WIN32
  3214. > hText = LocalAlloc(LPTR|LMEM_NODISCARD,(TextLen+5)*sizeof(TCHAR));
  3215. > #else
  3216. > hText = _alloca((TextLen+5)*sizeof(TCHAR));
  3217. > #endif
  3218. > if (hText == NULL)
  3219. > return;
  3220. >
  3221. > if (GetWindowText(hwnd, (NPTSTR)hText, TextLen+2*sizeof(TCHAR)) == 0)
  3222. > {
  3223. > #ifndef WIN32
  3224. > LocalFree(hText);
  3225. > #endif
  3226. > return;
  3227. > }
  3228. >
  3229. > if ((style & 0x000f) == SS_LEFTNOWORDWRAP)
  3230. > dt = DT_NOCLIP | DT_EXPANDTABS;
  3231. > else
  3232. > {
  3233. > dt = LOWORD(DT_NOCLIP | DT_EXPANDTABS | DT_WORDBREAK | ((style & 0x0000000f)-SS_LEFT));
  3234. > }
  3235. >
  3236. > if (style & SS_NOPREFIX)
  3237. > dt |= DT_NOPREFIX;
  3238. >
  3239. > if (style & WS_DISABLED)
  3240. > cv = SetTextColor(hdc, g3d.clrt.rgcv[icvGrayText]);
  3241. >
  3242. > DrawText(hdc, (NPTSTR)hText, -1, (LPRECT) lprc, dt);
  3243. >
  3244. > #ifndef WIN32
  3245. > LocalFree(hText);
  3246. > #endif
  3247. >
  3248. > if (style & WS_DISABLED)
  3249. > cv = SetTextColor(hdc, cv);
  3250. > }
  3251. >
  3252. > void StaticPaint(HWND hwnd, HDC hdc)
  3253. > {
  3254. > LONG style;
  3255. > RC rc;
  3256. >
  3257. > style = GetWindowLong(hwnd, GWL_STYLE);
  3258. > if(!(style & WS_VISIBLE))
  3259. > return;
  3260. >
  3261. > GetClientRect(hwnd, (LPRECT) &rc);
  3262. > switch(style & 0x0f)
  3263. > {
  3264. > case SS_BLACKRECT:
  3265. > case SS_BLACKFRAME: // Inset rect
  3266. > DrawRec3d(hdc, &rc, icvBtnShadow, icvBtnHilite, dr3All);
  3267. > break;
  3268. > case SS_GRAYRECT:
  3269. > case SS_GRAYFRAME:
  3270. > rc.xLeft++;
  3271. > rc.yTop++;
  3272. > DrawRec3d(hdc, &rc, icvBtnHilite, icvBtnHilite, dr3All);
  3273. > OffsetRect((LPRECT) &rc, -1, -1);
  3274. > DrawRec3d(hdc, &rc, icvBtnShadow, icvBtnShadow, dr3All);
  3275. > break;
  3276. > case SS_WHITERECT: // outset rect
  3277. > case SS_WHITEFRAME:
  3278. > DrawRec3d(hdc, &rc, icvBtnHilite, icvBtnShadow, dr3All);
  3279. > break;
  3280. > case SS_LEFT:
  3281. > case SS_CENTER:
  3282. > case SS_RIGHT:
  3283. > case SS_LEFTNOWORDWRAP:
  3284. > {
  3285. > HANDLE hfont;
  3286. > HBRUSH hbr;
  3287. >
  3288. > if((hfont = (HANDLE)SendMessage(hwnd, WM_GETFONT, 0, 0L)) != NULL)
  3289. > hfont = SelectObject(hdc, hfont);
  3290. > SetBkMode(hdc, OPAQUE);
  3291. >
  3292. > if(( hbr = SEND_COLOR_STATIC_MESSAGE(GetParent(hwnd), hwnd, hdc)) != NULL)
  3293. > hbr = SelectObject(hdc, hbr);
  3294. >
  3295. > StaticPrint(hwnd, hdc, (RC FAR *)&rc, style);
  3296. >
  3297. > if (hfont != NULL)
  3298. > SelectObject(hdc, hfont);
  3299. >
  3300. > if (hbr != NULL)
  3301. > SelectObject(hdc, hbr);
  3302. > }
  3303. > break;
  3304. > }
  3305. > }
  3306. >
  3307. >
  3308. > LRESULT __export _loadds WINAPI StaticWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  3309. > {
  3310. > HDC hdc;
  3311. > PAINTSTRUCT ps;
  3312. >
  3313. > if ( wm == WM_NCDESTROY )
  3314. > return CleanupSubclass(hwnd, wm, wParam, lParam, ctStatic);
  3315. >
  3316. > if ( GetProp(hwnd,(LPCTSTR) g3d.aCtl3dDisable) )
  3317. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ctStatic), hwnd, wm, wParam, lParam);
  3318. >
  3319. > switch (wm)
  3320. > {
  3321. > case WM_CHECKSUBCLASS:
  3322. > *(int FAR *)lParam = fTrue;
  3323. > return ctStatic+1000;
  3324. >
  3325. > case WM_PAINT:
  3326. > if ((hdc = (HDC) wParam) == NULL)
  3327. > {
  3328. > hdc = BeginPaint(hwnd, &ps);
  3329. > ClipCtlDc(hwnd, hdc);
  3330. > }
  3331. > StaticPaint(hwnd, hdc);
  3332. > if (wParam == (WPARAM)NULL)
  3333. > EndPaint(hwnd, &ps);
  3334. > return 0L;
  3335. >
  3336. > case WM_ENABLE:
  3337. > hdc = GetDC(hwnd);
  3338. > ClipCtlDc(hwnd, hdc);
  3339. > StaticPaint(hwnd, hdc);
  3340. > ReleaseDC(hwnd, hdc);
  3341. > return 0L;
  3342. > }
  3343. > return CallWindowProc(LpfnGetDefWndProc(hwnd, ctStatic), hwnd, wm, wParam, lParam);
  3344. > }
  3345. >
  3346. >
  3347. > /*-----------------------------------------------------------------------
  3348. > | LibMain
  3349. > -----------------------------------------------------------------------*/
  3350. > #ifdef WIN32
  3351. > #ifdef DLL
  3352. > BOOL CALLBACK LibMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
  3353. > #else
  3354. > #ifdef SDLL
  3355. > BOOL FAR Ctl3dLibMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
  3356. > #else
  3357. > BOOL FAR LibMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
  3358. > #endif
  3359. > #endif
  3360. > {
  3361. > WORD wT;
  3362. > DWORD dwVersion;
  3363. > BOOL (WINAPI* pfnDisableThreadLibraryCalls)(HMODULE);
  3364. > HMODULE hKernel;
  3365. >
  3366. > switch(dwReason)
  3367. > {
  3368. > case DLL_PROCESS_ATTACH:
  3369. > // call DisableThreadLibraryCalls if available
  3370. > hKernel = GetModuleHandleA("KERNEL32.DLL");
  3371. > *(FARPROC*)&pfnDisableThreadLibraryCalls =
  3372. > GetProcAddress(hKernel, "DisableThreadLibraryCalls");
  3373. > if (pfnDisableThreadLibraryCalls != NULL)
  3374. > (*pfnDisableThreadLibraryCalls)(hModule);
  3375. >
  3376. > #ifdef DLL
  3377. > InitializeCriticalSection(&g_CriticalSection);
  3378. > #endif
  3379. > EnterCriticalSection(&g_CriticalSection);
  3380. > #ifdef SDLL
  3381. > g3d.hinstLib = g3d.hmodLib = _hModule;
  3382. > #else
  3383. > g3d.hinstLib = g3d.hmodLib = hModule;
  3384. > #endif
  3385. >
  3386. > dwVersion = (DWORD)GetVersion();
  3387. > wT = LOWORD(dwVersion);
  3388. > // get adjusted windows version
  3389. > g3d.verWindows = (LOBYTE(wT) << 8) | HIBYTE(wT);
  3390. > // Win32s or Win32 for real (Chicago reports Win32s)
  3391. > g3d.verBase =
  3392. > (dwVersion & 0x80000000) && g3d.verWindows < ver40 ? 16 : 32;
  3393. >
  3394. > g3d.dxFrame = GetSystemMetrics(SM_CXDLGFRAME)-dxBorder;
  3395. > g3d.dyFrame = GetSystemMetrics(SM_CYDLGFRAME)-dyBorder;
  3396. > g3d.dyCaption = GetSystemMetrics(SM_CYCAPTION);
  3397. > g3d.dxSysMenu = GetSystemMetrics(SM_CXSIZE);
  3398. >
  3399. > LeaveCriticalSection(&g_CriticalSection);
  3400. > }
  3401. > return TRUE;
  3402. > }
  3403. > #else
  3404. > #ifdef DLL
  3405. > int WINAPI LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  3406. > #else
  3407. > #ifdef SDLL
  3408. > int FAR Ctl3dLibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  3409. > #else
  3410. > #ifdef _BORLAND
  3411. > BOOL FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  3412. > #else
  3413. > BOOL FAR LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  3414. > #endif
  3415. > #endif
  3416. > #endif
  3417. > {
  3418. > WORD wT;
  3419. > #ifdef DLL
  3420. >
  3421. > #ifdef V2
  3422. > CodeLpszDecl(lpszCtl3d, "CTL3DV2");
  3423. > #else
  3424. > CodeLpszDecl(lpszCtl3d, "CTL3D");
  3425. > #endif
  3426. >
  3427. > CodeLpszDecl(lpszUser, "user.exe");
  3428. > CodeLpszDecl(lpszSetWindowsHookEx, "SETWINDOWSHOOKEX");
  3429. > CodeLpszDecl(lpszUnhookWindowsHookEx, "UNHOOKWINDOWSHOOKEX");
  3430. > CodeLpszDecl(lpszCallNextHookEx, "CALLNEXTHOOKEX");
  3431. > #endif
  3432. >
  3433. > g3d.hinstLib = hModule;
  3434. > #ifdef DLL
  3435. > g3d.hmodLib = GetModuleHandle(lpszCtl3d);
  3436. > #else
  3437. > #ifdef SDLL
  3438. > g3d.hinstLib = _hModule;
  3439. > g3d.hmodLib = GetModuleHandle(MAKELP(0,_hModule));
  3440. > #else
  3441. > g3d.hmodLib = hModule;
  3442. > #endif
  3443. > #endif
  3444. > wT = LOWORD( GetVersion() );
  3445. > g3d.verWindows = (LOBYTE(wT) << 8) | HIBYTE(wT);
  3446. >
  3447. > if ( GetWinFlags() & 0x4000 )
  3448. > g3d.verBase = 24; // More then 16, not yet 32....WOW box on NT
  3449. > else
  3450. > g3d.verBase = 16; // Regular old 3.1
  3451. >
  3452. > g3d.dxFrame = GetSystemMetrics(SM_CXDLGFRAME)-dxBorder;
  3453. > g3d.dyFrame = GetSystemMetrics(SM_CYDLGFRAME)-dyBorder;
  3454. > g3d.dyCaption = GetSystemMetrics(SM_CYCAPTION);
  3455. > g3d.dxSysMenu = GetSystemMetrics(SM_CXSIZE);
  3456. >
  3457. > #ifdef DLL
  3458. > if (g3d.verWindows >= ver31)
  3459. > {
  3460. > HANDLE hlib;
  3461. >
  3462. > hlib = LoadLibrary(lpszUser);
  3463. > if (FValidLibHandle(hlib))
  3464. > {
  3465. > (FARPROC) g3d.lpfnSetWindowsHookEx = GetProcAddress(hlib, lpszSetWindowsHookEx);
  3466. > (FARPROC) g3d.lpfnUnhookWindowsHookEx = GetProcAddress(hlib, lpszUnhookWindowsHookEx);
  3467. > (FARPROC) g3d.lpfnCallNextHookEx = GetProcAddress(hlib, lpszCallNextHookEx);
  3468. > FreeLibrary(hlib);
  3469. > }
  3470. > }
  3471. > #endif
  3472. > return 1;
  3473. > }
  3474. > #endif // win32
  3475. >
  3476. > // convert a RGB into a RGBQ
  3477. > #define RGBQ(dw) RGB(GetBValue(dw),GetGValue(dw),GetRValue(dw))
  3478. >
  3479. > //
  3480. > // LoadUIBitmap() - load a bitmap resource
  3481. > //
  3482. > // load a bitmap resource from a resource file, converting all
  3483. > // the standard UI colors to the current user specifed ones.
  3484. > //
  3485. > // this code is designed to load bitmaps used in "gray ui" or
  3486. > // "toolbar" code.
  3487. > //
  3488. > // the bitmap must be a 4bpp windows 3.0 DIB, with the standard
  3489. > // VGA 16 colors.
  3490. > //
  3491. > // the bitmap must be authored with the following colors
  3492. > //
  3493. > // Window Text Black (index 0)
  3494. > // Button Shadow gray (index 7)
  3495. > // Button Face lt gray (index 8)
  3496. > // Button Highlight white (index 15)
  3497. > // Window Color yellow (index 11)
  3498. > // Window Frame green (index 10)
  3499. > //
  3500. > // Example:
  3501. > //
  3502. > // hbm = LoadUIBitmap(hInstance, "TestBmp",
  3503. > // GetSysColor(COLOR_WINDOWTEXT),
  3504. > // GetSysColor(COLOR_BTNFACE),
  3505. > // GetSysColor(COLOR_BTNSHADOW),
  3506. > // GetSysColor(COLOR_BTNHIGHLIGHT),
  3507. > // GetSysColor(COLOR_WINDOW),
  3508. > // GetSysColor(COLOR_WINDOWFRAME));
  3509. > //
  3510. > // Author: JimBov, ToddLa
  3511. > //
  3512. > //
  3513. > #ifdef WIN32
  3514. >
  3515. > HBITMAP PASCAL LoadUIBitmap(
  3516. > HANDLE hInstance, // EXE file to load resource from
  3517. > LPCTSTR szName, // name of bitmap resource
  3518. > COLORREF rgbText, // color to use for "Button Text"
  3519. > COLORREF rgbFace, // color to use for "Button Face"
  3520. > COLORREF rgbShadow, // color to use for "Button Shadow"
  3521. > COLORREF rgbHighlight, // color to use for "Button Hilight"
  3522. > COLORREF rgbWindow, // color to use for "Window Color"
  3523. > COLORREF rgbFrame) // color to use for "Window Frame"
  3524. > {
  3525. > HBITMAP hbm;
  3526. > LPBITMAPINFO lpbi;
  3527. > HRSRC hrsrc;
  3528. > HGLOBAL h;
  3529. > HDC hdc;
  3530. > DWORD size;
  3531. >
  3532. > //
  3533. > // Load the bitmap resource and make a writable copy.
  3534. > //
  3535. >
  3536. > hrsrc = FindResource(hInstance, szName, RT_BITMAP);
  3537. > if (!hrsrc)
  3538. > return(NULL);
  3539. > size = SizeofResource( hInstance, hrsrc );
  3540. > h = LoadResource(hInstance,hrsrc);
  3541. > if (!h)
  3542. > return(NULL);
  3543. >
  3544. > lpbi = ( LPBITMAPINFO ) GlobalAlloc( GPTR, size );
  3545. >
  3546. > if (!lpbi)
  3547. > return(NULL);
  3548. >
  3549. > CopyMemory( lpbi, h, size );
  3550. >
  3551. > *( LPCOLORREF ) &lpbi->bmiColors[0] = RGBQ(rgbText); // Black
  3552. > *( LPCOLORREF ) &lpbi->bmiColors[7] = RGBQ(rgbShadow); // gray
  3553. > *( LPCOLORREF ) &lpbi->bmiColors[8] = RGBQ(rgbFace); // lt gray
  3554. > *( LPCOLORREF ) &lpbi->bmiColors[15] = RGBQ(rgbHighlight); // white
  3555. > *( LPCOLORREF ) &lpbi->bmiColors[11] = RGBQ(rgbWindow); // yellow
  3556. > *( LPCOLORREF ) &lpbi->bmiColors[10] = RGBQ(rgbFrame); // green
  3557. >
  3558. > hdc = GetDC(NULL);
  3559. >
  3560. > hbm = CreateDIBitmap(hdc, &lpbi->bmiHeader, CBM_INIT, (LPBYTE)(&lpbi->bmiColors[ 16 ]),
  3561. > lpbi, DIB_RGB_COLORS);
  3562. >
  3563. > ReleaseDC(NULL, hdc);
  3564. > GlobalFree( lpbi );
  3565. >
  3566. > return(hbm);
  3567. > }
  3568. >
  3569. > #else
  3570. >
  3571. > HBITMAP PASCAL LoadUIBitmap(
  3572. > HANDLE hInstance, // EXE file to load resource from
  3573. > LPCTSTR szName, // name of bitmap resource
  3574. > COLORREF rgbText, // color to use for "Button Text"
  3575. > COLORREF rgbFace, // color to use for "Button Face"
  3576. > COLORREF rgbShadow, // color to use for "Button Shadow"
  3577. > COLORREF rgbHighlight, // color to use for "Button Hilight"
  3578. > COLORREF rgbWindow, // color to use for "Window Color"
  3579. > COLORREF rgbFrame) // color to use for "Window Frame"
  3580. > {
  3581. > LPBYTE lpb;
  3582. > HBITMAP hbm;
  3583. > LPBITMAPINFOHEADER lpbi;
  3584. > HANDLE h;
  3585. > HDC hdc;
  3586. > LPDWORD lprgb;
  3587. >
  3588. > h = LoadResource(hInstance,FindResource(hInstance, szName, RT_BITMAP));
  3589. >
  3590. > lpbi = (LPBITMAPINFOHEADER)LockResource(h);
  3591. >
  3592. > if (!lpbi)
  3593. > return(NULL);
  3594. >
  3595. > #ifdef NOTNEEDEDFORCTL3D
  3596. > if (lpbi->biSize != sizeof(BITMAPINFOHEADER))
  3597. > return NULL;
  3598. >
  3599. > if (lpbi->biBitCount != 4)
  3600. > return NULL;
  3601. > #endif
  3602. >
  3603. > lprgb = (LPDWORD)((LPBYTE)lpbi + (int)lpbi->biSize);
  3604. > lpb = (LPBYTE)(lprgb + 16);
  3605. >
  3606. > lprgb[0] = RGBQ(rgbText); // Black
  3607. >
  3608. > // lprgb[7] = RGBQ(rgbFace); // lt gray
  3609. > // lprgb[8] = RGBQ(rgbShadow); // gray
  3610. >
  3611. > lprgb[7] = RGBQ(rgbShadow); // gray
  3612. > lprgb[8] = RGBQ(rgbFace); // lt gray
  3613. >
  3614. > lprgb[15] = RGBQ(rgbHighlight); // white
  3615. > lprgb[11] = RGBQ(rgbWindow); // yellow
  3616. > lprgb[10] = RGBQ(rgbFrame); // green
  3617. >
  3618. > hdc = GetDC(NULL);
  3619. >
  3620. > hbm = CreateDIBitmap(hdc, lpbi, CBM_INIT, (LPVOID)lpb,
  3621. > (LPBITMAPINFO)lpbi, DIB_RGB_COLORS);
  3622. >
  3623. > ReleaseDC(NULL, hdc);
  3624. > UnlockResource(h);
  3625. > FreeResource(h);
  3626. >
  3627. > return(hbm);
  3628. > }
  3629. >
  3630. >
  3631. > #endif // win32
  3632. >
  3633. >
  3634. > /*-----------------------------------------------------------------------
  3635. > |
  3636. > | DLL specific routines
  3637. > |
  3638. > ---------------------------------------------------------------WESC----*/
  3639. >
  3640. > #ifndef WIN32
  3641. > #ifdef DLL
  3642. > /*-----------------------------------------------------------------------
  3643. > | WEP
  3644. > -----------------------------------------------------------------------*/
  3645. > int FAR PASCAL WEP (int wSystemExit)
  3646. > {
  3647. > return 1;
  3648. > }
  3649. > #endif
  3650. > #endif
  3651. ---------- NONSHIP\CTL3D\ctl3d.c (02-06-95@00:43) next ----------
  3652. 111a112
  3653. > #define NO_STRICT
  3654. 233a235
  3655. > #define CodeLpszDeclA(lpszVar, szLit) char *lpszVar = szLit
  3656. 239a242
  3657. > #define CodeLpszDeclA(lpszVar, szLit) char *lpszVar = szLit
  3658. 244a248,250
  3659. > #define CodeLpszDeclA(lpszVar, szLit) \
  3660. > static CSCONST(char) lpszVar##Code[] = szLit; \
  3661. > char far *lpszVar = (char far *)lpszVar##Code
  3662. 1179c1185
  3663. < return 0x0226;
  3664. ---
  3665. > return 0x0227;
  3666. 1759,1764c1765,1770
  3667. < CodeLpszDecl(lpszCtl3d, TEXT("CTL3DV2.DLL")),
  3668. < CodeLpszDecl(lpszCtl3d, TEXT("CTL3D32.DLL")));
  3669. < CodeLpszDecl(lpszBadInstMsg,
  3670. < TEXT("This application uses CTL3D32.DLL, which is not the correct version. ")
  3671. < TEXT("This version of CTL3D32.DLL is designed only for Windows NT systems."));
  3672. < MessageBox(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK);
  3673. ---
  3674. > CodeLpszDeclA(lpszCtl3d, "CTL3DV2.DLL"),
  3675. > CodeLpszDeclA(lpszCtl3d, "CTL3D32.DLL"));
  3676. > CodeLpszDeclA(lpszBadInstMsg,
  3677. > "This application uses CTL3D32.DLL, which is not the correct version. "
  3678. > "This version of CTL3D32.DLL is designed only for Windows NT systems.");
  3679. > MessageBoxA(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK);
  3680. 1772,1777c1778,1783
  3681. < CodeLpszDecl(lpszCtl3d, TEXT("CTL3DV2.DLL")),
  3682. < CodeLpszDecl(lpszCtl3d, TEXT("CTL3D32.DLL")));
  3683. < CodeLpszDecl(lpszBadInstMsg,
  3684. < TEXT("This application uses CTL3D32.DLL, which is not the correct version. ")
  3685. < TEXT("This version of CTL3D32.DLL is designed only for Win32s or Windows 95 systems."));
  3686. < MessageBox(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK);
  3687. ---
  3688. > CodeLpszDeclA(lpszCtl3d, "CTL3DV2.DLL"),
  3689. > CodeLpszDeclA(lpszCtl3d, "CTL3D32.DLL"));
  3690. > CodeLpszDeclA(lpszBadInstMsg,
  3691. > "This application uses CTL3D32.DLL, which is not the correct version. "
  3692. > "This version of CTL3D32.DLL is designed only for Win32s or Windows 95 systems.");
  3693. > MessageBoxA(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK);
  3694. 1805,1806c1811,1812
  3695. < CodeLpszDecl(lpszCtl3d, TEXT("CTL3DV2.DLL")),
  3696. < CodeLpszDecl(lpszCtl3d, TEXT("CTL3D32.DLL")));
  3697. ---
  3698. > CodeLpszDeclA(lpszCtl3d, "CTL3DV2.DLL"),
  3699. > CodeLpszDeclA(lpszCtl3d, "CTL3D32.DLL"));
  3700. 1808,1813c1814,1819
  3701. < CodeLpszDecl(lpszBadInstMsg,
  3702. < TEXT("This application uses CTL3DV2.DLL, which has not been correctly installed. ")
  3703. < TEXT("CTL3DV2.DLL must be installed in the Windows system directory.")),
  3704. < CodeLpszDecl(lpszBadInstMsg,
  3705. < TEXT("This application uses CTL3D32.DLL, which has not been correctly installed. ")
  3706. < TEXT("CTL3D32.DLL must be installed in the Windows system directory.")));
  3707. ---
  3708. > CodeLpszDeclA(lpszBadInstMsg,
  3709. > "This application uses CTL3DV2.DLL, which has not been correctly installed. "
  3710. > "CTL3DV2.DLL must be installed in the Windows system directory."),
  3711. > CodeLpszDeclA(lpszBadInstMsg,
  3712. > "This application uses CTL3D32.DLL, which has not been correctly installed. "
  3713. > "CTL3D32.DLL must be installed in the Windows system directory."));
  3714. 1815c1821
  3715. < MessageBox(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK );
  3716. ---
  3717. > MessageBoxA(NULL, lpszBadInstMsg, lpszCtl3d, MB_ICONSTOP | MB_OK );
  3718. 3420c3426
  3719. < CodeLpszDecl(lpszCtl3d, "CTL3DV2");
  3720. ---
  3721. > CodeLpszDeclA(lpszCtl3d, "CTL3DV2");
  3722. 3422c3428
  3723. < CodeLpszDecl(lpszCtl3d, "CTL3D");
  3724. ---
  3725. > CodeLpszDeclA(lpszCtl3d, "CTL3D");
  3726. 3425,3428c3431,3434
  3727. < CodeLpszDecl(lpszUser, "user.exe");
  3728. < CodeLpszDecl(lpszSetWindowsHookEx, "SETWINDOWSHOOKEX");
  3729. < CodeLpszDecl(lpszUnhookWindowsHookEx, "UNHOOKWINDOWSHOOKEX");
  3730. < CodeLpszDecl(lpszCallNextHookEx, "CALLNEXTHOOKEX");
  3731. ---
  3732. > CodeLpszDeclA(lpszUser, "user.exe");
  3733. > CodeLpszDeclA(lpszSetWindowsHookEx, "SETWINDOWSHOOKEX");
  3734. > CodeLpszDeclA(lpszUnhookWindowsHookEx, "UNHOOKWINDOWSHOOKEX");
  3735. > CodeLpszDeclA(lpszCallNextHookEx, "CALLNEXTHOOKEX");
  3736. ---------- NONSHIP\CTL3D\ctl3d.c (02-17-95@14:41) next ----------
  3737. 172a173
  3738. > #define MessageBoxA MessageBox
  3739. 635a637
  3740. > BOOL fSubclass;
  3741. 638c640,646
  3742. < SubclassWindow(cwpStruct->hwnd, lpfnSubclassByHook);
  3743. ---
  3744. > if (g3d.verWindows >= ver40 && (GetWindowLong(cwpStruct->hwnd, GWL_STYLE) & 0x04))
  3745. > fSubclass = fFalse;
  3746. > else
  3747. > fSubclass = fTrue;
  3748. > SendMessage(cwpStruct->hwnd, WM_DLGSUBCLASS, 0, (LPARAM)(int FAR *)&fSubclass);
  3749. > if (fSubclass)
  3750. > SubclassWindow(cwpStruct->hwnd, lpfnSubclassByHook);
  3751. 1185c1193
  3752. < return 0x0227;
  3753. ---
  3754. > return 0x0228;
  3755. 1274c1282,1287
  3756. < SetProp(hwnd,(LPCTSTR) g3d.aCtl3dDisable, (HANDLE) 1);
  3757. ---
  3758. > if (GetProp(hwnd, (LPCTSTR) g3d.aCtl3d) ||
  3759. > GetProp(hwnd, (LPCTSTR) g3d.aCtl3dLow) ||
  3760. > GetProp(hwnd, (LPCTSTR) g3d.aCtl3dHigh))
  3761. > {
  3762. > SetProp(hwnd,(LPCTSTR) g3d.aCtl3dDisable, (HANDLE) 1);
  3763. > }
  3764. 2200c2213,2220
  3765. < SubclassWindow((HWND)wParam, (FARPROC) Ctl3dDlgProc);
  3766. ---
  3767. > BOOL fSubclass;
  3768. > if (g3d.verWindows >= ver40 && (GetWindowLong((HWND)wParam, GWL_STYLE) & 0x04))
  3769. > fSubclass = fFalse;
  3770. > else
  3771. > fSubclass = fTrue;
  3772. > SendMessage((HWND)wParam, WM_DLGSUBCLASS, 0, (LPARAM)(int FAR *)&fSubclass);
  3773. > if (fSubclass)
  3774. > SubclassWindow((HWND)wParam, (FARPROC) Ctl3dDlgProc);
  3775. ---------- NONSHIP\CTL3D\ctl3d.c (04-04-95@01:04) next ----------
  3776. 618a619,631
  3777. > #ifdef WIN32
  3778. > if (g3d.fDBCS && !IsWindowUnicode(hwnd))
  3779. > {
  3780. > TCHAR szClass[cchClassMax];
  3781. > GetClassName(hwnd, szClass, cchClassMax);
  3782. > if (lstrcmpi(szClass, TEXT("edit")) == 0)
  3783. > {
  3784. > lpfnWndProc = (FARPROC)SetWindowLongA(hwnd, GWL_WNDPROC,(LONG)lpfnSubclassProc);
  3785. > goto SetProps;
  3786. > }
  3787. > }
  3788. > #endif
  3789. >
  3790. 619a633
  3791. > SetProps:
  3792. 1193c1207
  3793. < return 0x0228;
  3794. ---
  3795. > return 0x0229;
  3796. ---------- NONSHIP\CTL3D\ctl3d.c (06-26-95@18:09) next ----------
  3797. 2388c2388
  3798. < wStyle = LOWORD(style) & 0xf;
  3799. ---
  3800. > wStyle = LOWORD(style) & 0x1f;
  3801. 2393c2393,2394
  3802. < (wStyle >= SS_BLACKRECT && wStyle <= SS_WHITEFRAME))));
  3803. ---
  3804. > ((wStyle >= SS_BLACKRECT && wStyle <= SS_WHITEFRAME) ||
  3805. > (g3d.verWindows < ver40 && wStyle >= 0x10 && wStyle <= 0x12)))));
  3806. 3300c3301
  3807. < switch(style & 0x0f)
  3808. ---
  3809. > switch(style & 0x1f)
  3810. 3307a3309,3311
  3811. > case 0x10:
  3812. > case 0x11:
  3813. > case 0x12:
  3814. ---------- NONSHIP\CTL3D\ctl3d.c (07-13-95@20:24) next ----------
  3815. 491a492,494
  3816. > ATOM aCtl3dOld;
  3817. > ATOM aCtl3dHighOld;
  3818. > ATOM aCtl3dLowOld;
  3819. 565,566c568,569
  3820. <
  3821. < #define WM_CHECKSUBCLASS (WM_USER+5443)
  3822. ---
  3823. > #define WM_CHECKSUBCLASS_OLD (WM_USER+5443)
  3824. > #define WM_CHECKSUBCLASS (WM_USER+5444)
  3825. 610,611c613,618
  3826. < if (GetProp(hwnd, (LPCTSTR) g3d.aCtl3d) ||
  3827. < GetProp(hwnd, (LPCTSTR) g3d.aCtl3dLow))
  3828. ---
  3829. > if (GetProp(hwnd, (LPCTSTR) g3d.aCtl3dOld) ||
  3830. > GetProp(hwnd, (LPCTSTR) g3d.aCtl3d) ||
  3831. > GetProp(hwnd, (LPCTSTR) g3d.aCtl3dLow) ||
  3832. > GetProp(hwnd, (LPCTSTR) g3d.aCtl3dLowOld) ||
  3833. > GetProp(hwnd, (LPCTSTR) g3d.aCtl3dHigh) ||
  3834. > GetProp(hwnd, (LPCTSTR) g3d.aCtl3dHighOld))
  3835. 1207c1214
  3836. < return 0x0229;
  3837. ---
  3838. > return 0x0231;
  3839. 1404a1412,1413
  3840. > if ( fSubclass == 666 )
  3841. > SendMessage((HWND) hwnd, WM_CHECKSUBCLASS_OLD, 0, (LPARAM)(int FAR *)&fSubclass);
  3842. 1869,1871c1878,1883
  3843. < CodeLpszDecl(lpszC3d, TEXT("C3d"));
  3844. < CodeLpszDecl(lpszC3dL, TEXT("C3dL"));
  3845. < CodeLpszDecl(lpszC3dH, TEXT("C3dH"));
  3846. ---
  3847. > CodeLpszDecl(lpszC3dOld, TEXT("C3d"));
  3848. > CodeLpszDecl(lpszC3dLOld, TEXT("C3dL"));
  3849. > CodeLpszDecl(lpszC3dHOld, TEXT("C3dH"));
  3850. > CodeLpszDecl(lpszC3d, TEXT("C3dNew"));
  3851. > CodeLpszDecl(lpszC3dL, TEXT("C3dLNew"));
  3852. > CodeLpszDecl(lpszC3dH, TEXT("C3dHNew"));
  3853. 1872a1885,1890
  3854. > g3d.aCtl3dOld = GlobalAddAtom(lpszC3dOld);
  3855. > if (g3d.aCtl3dOld == 0)
  3856. > {
  3857. > g3d.f3dDialogs = fFalse;
  3858. > goto Return;
  3859. > }
  3860. 1879a1898,1905
  3861. > g3d.aCtl3dLowOld = GlobalAddAtom(lpszC3dLOld);
  3862. > g3d.aCtl3dHighOld = GlobalAddAtom(lpszC3dHOld);
  3863. > if (g3d.aCtl3dLowOld == 0 || g3d.aCtl3dHighOld == 0)
  3864. > {
  3865. > g3d.f3dDialogs = fFalse;
  3866. > return fFalse;
  3867. > }
  3868. >
  3869. 1945,1947c1971,1976
  3870. < Win32Only(g3d.aCtl3d ? GlobalDeleteAtom(g3d.aCtl3d) : 0);
  3871. < Win16Only(g3d.aCtl3dLow ? GlobalDeleteAtom(g3d.aCtl3dLow) : 0);
  3872. < Win16Only(g3d.aCtl3dHigh ? GlobalDeleteAtom(g3d.aCtl3dHigh) : 0);
  3873. ---
  3874. > g3d.aCtl3dOld ? GlobalDeleteAtom(g3d.aCtl3dOld) : 0;
  3875. > g3d.aCtl3d ? GlobalDeleteAtom(g3d.aCtl3d) : 0;
  3876. > g3d.aCtl3dLowOld ? GlobalDeleteAtom(g3d.aCtl3dLowOld) : 0;
  3877. > g3d.aCtl3dHighOld ? GlobalDeleteAtom(g3d.aCtl3dHighOld) : 0;
  3878. > g3d.aCtl3dLow ? GlobalDeleteAtom(g3d.aCtl3dLow) : 0;
  3879. > g3d.aCtl3dHigh ? GlobalDeleteAtom(g3d.aCtl3dHigh) : 0;
  3880. 2047a2077
  3881. > case WM_CHECKSUBCLASS_OLD:
  3882. 2861a2892
  3883. > case WM_CHECKSUBCLASS_OLD:
  3884. 2994a3026,3028
  3885. > if (fSubclass == 666)
  3886. > ctParent = (int)SendMessage(hwndParent, WM_CHECKSUBCLASS_OLD, 0, (LPARAM)(int FAR *)&fSubclass);
  3887. >
  3888. 3116a3151
  3889. > case WM_CHECKSUBCLASS_OLD:
  3890. 3159a3195
  3891. > case WM_CHECKSUBCLASS_OLD:
  3892. 3232a3269
  3893. > case WM_CHECKSUBCLASS_OLD:
  3894. 3362a3400
  3895. > case WM_CHECKSUBCLASS_OLD: