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.

555 lines
14 KiB

  1. /*---------------------------------------------------------------------------*\
  2. | WINCHAT MAIN HEADER FILE
  3. | This is the main header file for the application.
  4. |
  5. |
  6. | Copyright (c) Microsoft Corp., 1990-1993
  7. |
  8. | created: 01-Nov-91
  9. | history: 01-Nov-91 <clausgi> created.
  10. | 29-Dec-92 <chriswil> port to NT, cleanup.
  11. | 19-Oct-93 <chriswil> unicode enhancements from a-dianeo.
  12. |
  13. \*---------------------------------------------------------------------------*/
  14. //////////// compile options //////////////
  15. #define BRD 6
  16. ///////////////////////////////////////////
  17. #ifdef WIN16
  18. #define APIENTRY FAR PASCAL
  19. #define ERROR_NO_NETWORK 0
  20. #endif
  21. #ifdef PROTOCOL_NEGOTIATE
  22. typedef DWORD PCKT; // Bitfield capabilities.
  23. #define CHT_VER 0x100 // Version 1.00 of WinChat.
  24. #define PCKT_TEXT 0x00000001 // All versions had better support this.
  25. #endif
  26. // Constants.
  27. //
  28. #define SZBUFSIZ 255 // maximum size buffer.
  29. #define SMLRCBUF 32 // size A .rc file buffer
  30. #define BIGRCBUF 64 // size B .rc file buffer
  31. #define UNCNLEN 32 //
  32. #define CTRL_V 22 // Edit-control paste acccelerator.
  33. #define IDACCELERATORS 1 // Menu accelerator resource ID.
  34. // Menuhelp Constants.
  35. //
  36. #define MH_BASE 0x1000
  37. #define MH_POPUPBASE 0x1100
  38. // Child-Window ID's for send/receive windows.
  39. //
  40. #define ID_BASE 0x0CAC
  41. #define ID_EDITSND (ID_BASE + 0)
  42. #define ID_EDITRCV (ID_BASE + 1)
  43. // Child-Window Identifiers for toolbar/statusbar.
  44. //
  45. #define IDC_TOOLBAR 200
  46. #define IDBITMAP 201
  47. #define IDSTATUS 202
  48. // Menu Identifiers.
  49. //
  50. #define IDM_EDITFIRST IDM_EDITUNDO
  51. #define IDM_EDITLAST IDM_EDITSELECT
  52. #define IDM_ABOUT 100
  53. #define IDM_DIAL 101
  54. #define IDM_HANGUP 102
  55. #define IDM_ANSWER 103
  56. #define IDM_EXIT 104
  57. #define IDM_EDITUNDO 105
  58. #define IDM_EDITCUT 106
  59. #define IDM_EDITCOPY 107
  60. #define IDM_EDITPASTE 108
  61. #define IDM_EDITCLEAR 109
  62. #define IDM_EDITSELECT 110
  63. #define IDM_SOUND 111
  64. #define IDM_PREFERENCES 112
  65. #define IDM_FONT 113
  66. #define IDM_CONTENTS 114
  67. #define IDM_SEARCHHELP 115
  68. #define IDM_HELPHELP 116
  69. #define IDM_COLOR 117
  70. #define IDM_TOPMOST 118
  71. #define IDM_CLOCK 119
  72. #define IDM_TOOLBAR 120
  73. #define IDM_STATUSBAR 121
  74. #define IDM_SWITCHWIN 122
  75. #define IDX_DEFERFONTCHANGE 123
  76. #define IDX_UNICODECONV 126
  77. #define IDM_FIRST IDM_ABOUT
  78. #define IDH_SELECTCOMPUTER 200
  79. #ifdef PROTOCOL_NEGOTIATE
  80. #define IDX_DEFERPROTOCOL 124
  81. #endif
  82. // Resource-String Identifiers.
  83. //
  84. #define IDS_HELV 1
  85. #define IDS_APPNAME 2
  86. #define IDS_LONGAPPNAME 3
  87. #define IDS_SYSERR 4
  88. #define IDS_CONNECTTO 5
  89. #define IDS_ALREADYCONNECT 6
  90. #define IDS_ABANDONFIRST 7
  91. #define IDS_DIALING 8
  92. #define IDS_YOUCALLER 9
  93. #define IDS_NOTCALLED 10
  94. #define IDS_NOTCONNECTED 11
  95. #define IDS_CONNECTABANDON 12
  96. #define IDS_HANGINGUP 13
  97. #define IDS_HASTERMINATED 14
  98. #define IDS_CONNECTEDTO 15
  99. #define IDS_ISCALLING 16
  100. #define IDS_CONNECTING 17
  101. #define IDS_SERVICENAME 18
  102. #define IDS_DIALHELP 19
  103. #define IDS_ANSWERHELP 20
  104. #define IDS_HANGUPHELP 21
  105. #define IDS_NOCONNECT 22
  106. #define IDS_ALWAYSONTOP 23
  107. #define IDS_NOCONNECTTO 24
  108. #define IDS_NONETINSTALLED 25
  109. #define IDS_INISECTION 26
  110. #define IDS_INIPREFKEY 27
  111. #define IDS_INIFONTKEY 28
  112. #define IDS_INIRINGIN 29
  113. #define IDS_INIRINGOUT 30
  114. #define IDS_TSNOTSUPPORTED 31
  115. // Edit-Control Notification codes. These
  116. // are sent to the parent of the edit
  117. // control just as any system-notify is.
  118. //
  119. #define EN_CHAR 0x060F
  120. #define EN_PASTE 0x0610
  121. // FE specific
  122. #define EN_DBCS_STRING 0x0611
  123. // Chat formats. These are used to identify
  124. // the type of data being transfered in a
  125. // DDE transaction.
  126. //
  127. #define CHT_CHAR 0x100
  128. #define CHT_FONTA 0x101
  129. #define CHT_PASTEA 0x102
  130. #define CHT_UNICODE 0x110
  131. #define CHT_FONTW 0x111
  132. #define CHT_PASTEW 0x112
  133. // FE specific (not Taiwan)
  134. #define CHT_DBCS_STRING 0x103
  135. #ifdef PROTOCOL_NEGOTIATE
  136. #define CHT_PROTOCOL 0x105
  137. #endif
  138. #if 0
  139. #define CHT_HPENDATA 0x103 // defined in WFW311. Conflicts w/DBCS.
  140. #define CHT_CLEARPENDATA 0x104 //
  141. #define CHT_ADDCHATTER 0x106 //
  142. #define CHT_DELCHATTER 0x107 //
  143. #define CHT_CHARBURST 0x108 //
  144. #endif
  145. // Window Related Functions (winchat.c)
  146. //
  147. int PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
  148. LRESULT CALLBACK MainWndProc(HWND,UINT,WPARAM,LPARAM);
  149. LRESULT CALLBACK EditProc(HWND,UINT,WPARAM,LPARAM);
  150. BOOL FAR InitApplication(HINSTANCE);
  151. BOOL FAR InitInstance(HINSTANCE,int);
  152. VOID FAR UpdateButtonStates(VOID);
  153. VOID FAR AdjustEditWindows(VOID);
  154. LONG FAR myatol(LPTSTR);
  155. BOOL FAR appGetComputerName(LPTSTR);
  156. VOID DrawShadowRect(HDC,LPRECT);
  157. VOID SendFontToPartner(VOID);
  158. VOID DoRing(LPCTSTR);
  159. VOID ClearEditControls(VOID);
  160. // Initialization Routines (wcinit.c)
  161. //
  162. VOID FAR SaveFontToIni(VOID);
  163. VOID FAR SaveBkGndToIni(VOID);
  164. VOID FAR InitFontFromIni(VOID);
  165. VOID FAR LoadIntlStrings(VOID);
  166. VOID FAR SaveWindowPlacement(PWINDOWPLACEMENT);
  167. BOOL FAR ReadWindowPlacement(PWINDOWPLACEMENT);
  168. VOID FAR CreateTools(HWND);
  169. VOID FAR DeleteTools(HWND);
  170. VOID FAR CreateChildWindows(HWND);
  171. // Window handler routines (winchat.c)
  172. //
  173. VOID appWMCreateProc(HWND);
  174. VOID appWMWinIniChangeProc(HWND);
  175. VOID appWMSetFocusProc(HWND);
  176. VOID appWMMenuSelectProc(HWND,WPARAM,LPARAM);
  177. VOID appWMTimerProc(HWND);
  178. VOID appWMPaintProc(HWND);
  179. VOID appWMDestroyProc(HWND);
  180. BOOL appWMCommandProc(HWND,WPARAM,LPARAM);
  181. VOID appWMInitMenuProc(HMENU);
  182. VOID appWMSizeProc(HWND,WPARAM,LPARAM);
  183. BOOL appWMEraseBkGndProc(HWND);
  184. LRESULT appWMSysCommandProc(HWND,WPARAM,LPARAM);
  185. HBRUSH appWMCtlColorProc(HWND,WPARAM,LPARAM);
  186. HICON appWMQueryDragIconProc(HWND);
  187. // DDE Related Functions.
  188. //
  189. HDDEDATA CALLBACK DdeCallback(UINT,UINT,HCONV,HSZ,HSZ,HDDEDATA,DWORD,DWORD);
  190. HDDEDATA CreateCharData(VOID);
  191. HDDEDATA CreatePasteData(VOID);
  192. // FE specific
  193. HDDEDATA CreateDbcsStringData(VOID);
  194. #ifdef PROTOCOL_NEGOTIATE
  195. HDDEDATA CreateProtocolData(VOID);
  196. PCKT GetCurrentPckt(VOID);
  197. VOID FlagIntersection(PCKT);
  198. VOID AnnounceSupport(VOID);
  199. #endif
  200. //
  201. //
  202. typedef UINT (WINAPI *WNETCALL)(HWND,LPTSTR,LPTSTR,WORD,DWORD);
  203. HINSTANCE APIENTRY WNetGetCaps(WORD);
  204. // Chat Data.
  205. // This data-structure must maintain
  206. // fixed-size fields so that they may
  207. // be transfered accross platforms.
  208. //
  209. #ifndef RC_INVOLKED
  210. #define LF_XPACKFACESIZE 32
  211. #define XCHATSIZEA 60
  212. #define XCHATSIZEW 92
  213. #pragma pack(2)
  214. typedef struct tagXPACKFONTA
  215. {
  216. WORD lfHeight;
  217. WORD lfWidth;
  218. WORD lfEscapement;
  219. WORD lfOrientation;
  220. WORD lfWeight;
  221. BYTE lfItalic;
  222. BYTE lfUnderline;
  223. BYTE lfStrikeOut;
  224. BYTE lfCharSet;
  225. BYTE lfOutPrecision;
  226. BYTE lfClipPrecision;
  227. BYTE lfQuality;
  228. BYTE lfPitchAndFamily;
  229. CHAR lfFaceName[LF_XPACKFACESIZE];
  230. } XPACKFONTA;
  231. typedef struct tagXPACKFONTW
  232. {
  233. WORD lfHeight;
  234. WORD lfWidth;
  235. WORD lfEscapement;
  236. WORD lfOrientation;
  237. WORD lfWeight;
  238. BYTE lfItalic;
  239. BYTE lfUnderline;
  240. BYTE lfStrikeOut;
  241. BYTE lfCharSet;
  242. BYTE lfOutPrecision;
  243. BYTE lfClipPrecision;
  244. BYTE lfQuality;
  245. BYTE lfPitchAndFamily;
  246. WCHAR lfFaceName[LF_XPACKFACESIZE];
  247. } XPACKFONTW;
  248. typedef struct _CHATDATAA
  249. {
  250. WORD type;
  251. union
  252. {
  253. // This data for DBCS string transfer.
  254. //
  255. struct
  256. {
  257. DWORD SelPos;
  258. DWORD size;
  259. HGLOBAL hString;
  260. } cd_dbcs;
  261. // This data for character transfer.
  262. //
  263. struct
  264. {
  265. DWORD SelPos;
  266. WORD Char;
  267. } cd_char;
  268. // This data for remote font change.
  269. //
  270. struct
  271. {
  272. XPACKFONTA lf;
  273. COLORREF cref;
  274. COLORREF brush;
  275. } cd_win;
  276. // This data for remote paste.
  277. //
  278. struct
  279. {
  280. DWORD SelPos;
  281. DWORD size;
  282. } cd_paste;
  283. #ifdef PROTOCOL_NEGOTIATE
  284. // This data for Protocol Negotiate.
  285. //
  286. struct
  287. {
  288. DWORD dwVer;
  289. PCKT pckt;
  290. } cd_protocol;
  291. #endif
  292. } uval;
  293. } CHATDATAA;
  294. typedef struct _CHATDATAW
  295. {
  296. WORD type;
  297. union
  298. {
  299. // This data for DBCS string transfer.
  300. //
  301. struct
  302. {
  303. DWORD SelPos;
  304. DWORD size;
  305. HGLOBAL hString;
  306. } cd_dbcs;
  307. // This data for character transfer.
  308. //
  309. struct
  310. {
  311. DWORD SelPos;
  312. WORD Char;
  313. } cd_char;
  314. // This data for remote font change.
  315. //
  316. struct
  317. {
  318. XPACKFONTW lf;
  319. COLORREF cref;
  320. COLORREF brush;
  321. } cd_win;
  322. // This data for remote paste.
  323. //
  324. struct
  325. {
  326. DWORD SelPos;
  327. DWORD size;
  328. } cd_paste;
  329. #ifdef PROTOCOL_NEGOTIATE
  330. // This data for Protocol Negotiate.
  331. //
  332. struct
  333. {
  334. DWORD dwVer;
  335. PCKT pckt;
  336. } cd_protocol;
  337. #endif
  338. } uval;
  339. } CHATDATAW;
  340. #pragma pack()
  341. typedef XPACKFONTA *PXPACKFONTA;
  342. typedef XPACKFONTA NEAR *NPXPACKFONTA;
  343. typedef XPACKFONTA FAR *LPXPACKFONTA;
  344. typedef CHATDATAA *PCHATDATAA;
  345. typedef CHATDATAA NEAR *NPCHATDATAA;
  346. typedef CHATDATAA FAR *LPCHATDATAA;
  347. typedef XPACKFONTW *PXPACKFONTW;
  348. typedef XPACKFONTW NEAR *NPXPACKFONTW;
  349. typedef XPACKFONTW FAR *LPXPACKFONTW;
  350. typedef CHATDATAW *PCHATDATAW;
  351. typedef CHATDATAW NEAR *NPCHATDATAW;
  352. typedef CHATDATAW FAR *LPCHATDATAW;
  353. #ifdef UNICODE
  354. #define XPACKFONT XPACKFONTW
  355. #else
  356. #define XPACKFONT XPACKFONTA
  357. #endif
  358. typedef XPACKFONT *PXPACKFONT;
  359. typedef XPACKFONT NEAR *NPXPACKFONT;
  360. typedef XPACKFONT FAR *LPXPACKFONT;
  361. #ifdef UNICODE
  362. #define CHATDATA CHATDATAW
  363. #else
  364. #define CHATDATA CHATDATAA
  365. #endif
  366. typedef CHATDATA *PCHATDATA;
  367. typedef CHATDATA NEAR *NPCHATDATA;
  368. typedef CHATDATA FAR *LPCHATDATA;
  369. #endif
  370. // Chat state info struct
  371. //
  372. typedef struct _CHATSTATE
  373. {
  374. UINT fConnected : 1;
  375. UINT fConnectPending : 1;
  376. UINT fAllowAnswer : 1;
  377. UINT fIsServer : 1;
  378. UINT fServerVerified : 1;
  379. UINT fInProcessOfDialing : 1;
  380. UINT fSound : 1;
  381. UINT fMMSound : 1;
  382. UINT fUseOwnFont : 1;
  383. UINT fSideBySide : 1;
  384. UINT fMinimized : 1;
  385. UINT fTopMost : 1;
  386. UINT fToolBar : 1;
  387. UINT fStatusBar : 1;
  388. UINT fUnicode : 1;
  389. #ifdef PROTOCOL_NEGOTIATE
  390. UINT fProtocolSent : 1;
  391. #endif
  392. } CHATSTATE;
  393. typedef CHATSTATE *PCHATSTATE;
  394. typedef CHATSTATE NEAR *NPCHATSTATE;
  395. typedef CHATSTATE FAR *LPCHATSTATE;
  396. // Insertable macroes.
  397. //
  398. #define KILLSOUND {if(ChatState.fMMSound) sndPlaySound(NULL,SND_ASYNC);}
  399. #define SetStatusWindowText(x) {if(hwndStatus)SendMessage(hwndStatus,SB_SETTEXT,0,(LPARAM)(LPSTR)(x));}
  400. // Helpfull porting macroes. These were necessary
  401. // especially for notification codes which changed
  402. // drastically between DOS/WIN and NT.
  403. //
  404. #ifdef WIN32
  405. #define GET_WM_MENUSELECT_CMD(wParam,lParam) (UINT)(int)(short)LOWORD(wParam)
  406. #define GET_WM_MENUSELECT_FLAGS(wParam,lParam) (UINT)(int)(short)HIWORD(wParam)
  407. #define GET_WM_MENUSELECT_HMENU(wParam,lParam) (HMENU)lParam
  408. #define SET_EM_SETSEL_WPARAM(nStart,nEnd) (WPARAM)nStart
  409. #define SET_EM_SETSEL_LPARAM(nStart,nEnd) (LPARAM)nEnd
  410. #define GET_WM_CTLCOLOREDIT_HDC(wParam,lParam) (HDC)wParam
  411. #define GET_WM_CTLCOLOREDIT_HWND(wParam,lParam) (HWND)lParam
  412. #define GET_EN_SETFOCUS_NOTIFY(wParam,lParam) (UINT)HIWORD(wParam)
  413. #define GET_EN_SETFOCUS_CMD(wParam,lParam) (UINT)LOWORD(wParam)
  414. #define GET_EN_SETFOCUS_HWND(wParam,lParam) (HWND)lParam
  415. #define SET_EN_NOTIFY_WPARAM(id,notify,hwnd) (WPARAM)MAKELONG(id,notify)
  416. #define SET_EN_NOTIFY_LPARAM(id,notify,hwnd) (LPARAM)hwnd
  417. #define WNETGETCAPS(wFlag) NULL
  418. #define WNETGETUSER(szlocal,szuser,ncount) WNetGetUser(szlocal,szuser,ncount)
  419. #define SETMESSAGEQUEUE(size) size
  420. #else
  421. int APIENTRY ShellAbout(HWND hWnd, LPSTR szApp, LPSTR szOtherStuff, HICON hIcon);
  422. #define GET_WM_MENUSELECT_CMD(wParam,lParam) (UINT)wParam
  423. #define GET_WM_MENUSELECT_FLAGS(wParam,lParam) (UINT)(LOWORD(lParam))
  424. #define GET_WM_MENUSELECT_HMENU(wParam,lParam) (HMENU)(HIWORD(lParam))
  425. #define SET_EM_SETSEL_WPARAM(nStart,nEnd) (WPARAM)0
  426. #define SET_EM_SETSEL_LPARAM(nStart,nEnd) (LPARAM)(MAKELONG(nStart,nEnd))
  427. #define GET_WM_CTLCOLOREDIT_HDC(wParam,lParam) (HDC)wParam
  428. #define GET_WM_CTLCOLOREDIT_HWND(wParam,lParam) (HWND)(LOWORD(lParam))
  429. #define GET_EN_SETFOCUS_NOTIFY(wParam,lParam) (UINT)(HIWORD(lParam))
  430. #define GET_EN_SETFOCUS_CMD(wParam,lParam) (UINT)wParam
  431. #define GET_EN_SETFOCUS_HWND(wParam,lParam) (HWND)(LOWORD(lParam))
  432. #define SET_EN_NOTIFY_WPARAM(id,notify,hwnd) (WPARAM)id
  433. #define SET_EN_NOTIFY_LPARAM(id,notify,hwnd) (LPARAM)(MAKELONG(hwnd,notify))
  434. #define WNETGETCAPS(wFlag) WNetGetCaps(wFlag)
  435. #define WNETGETUSER(szlocal,szuser,ncount) ERROR_NO_NETWORK
  436. #define SETMESSAGEQUEUE(size) SetMessageQueue(size)
  437. #endif
  438. VOID PackFont(LPXPACKFONT,LPLOGFONT);
  439. VOID UnpackFont(LPLOGFONT,LPXPACKFONT);
  440. VOID StartIniMapping(VOID);
  441. VOID EndIniMapping(VOID);
  442. #ifndef ByteCountOf
  443. #define ByteCountOf(x) sizeof(TCHAR)*(x)
  444. #endif
  445. #include "globals.h"