home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1999 March / VPR9903A.BIN / APUPDATE / VC / Tx300d / TX300D.LZH / EVENT.C < prev    next >
Text File  |  1997-06-16  |  9KB  |  361 lines

  1. // イベントマクロ
  2. //2.90 で追加
  3.  
  4. #include <windows.h>
  5. #ifndef __FLAT__
  6. extern "shell.dll" {
  7.     #include <shellapi.h>
  8. }
  9. #endif
  10.  
  11. #ifdef __FLAT__
  12.  
  13. // WZ Maileditor event
  14. //2.98 970311 全面変更
  15.  
  16. //2.90 ここではダイアログボックスなどのUIはできません。
  17. void at_ehInit(TX* text)
  18. {
  19.     if (text->ehHwnd) {
  20.         if (!text->mail) {
  21.             text->mail = malloc(sizeof(MAIL));
  22.             if (text->mail) memset(text->mail,0,sizeof(MAIL));
  23.         }
  24.         if (!text->ehHwndBase) {
  25.             HWND hwndBase = text->ehHwnd;
  26.             while(1) {
  27.                 hwndBase = GetParent(hwndBase);
  28.                 if (hwndBase) {
  29.                     DWORD style = GetWindowLong(hwndBase,GWL_STYLE);
  30.                     if ((style & WS_POPUP) || (style & WS_CAPTION)) {
  31.                         mchar buff[CCHPATHNAME];
  32.                         GetWindowText(hwndBase,buff,cchof(buff));
  33.                         if (buff[0]) {// キャプションが実際にあるか調べる
  34.                             text->ehHwndBase = hwndBase;
  35.                             break;
  36.                         }
  37.                     }
  38.                 } else {
  39.                     break;
  40.                 }
  41.             }
  42.         }
  43.         if (text->mail) {
  44.             if (text->ehHwndBase) {
  45.                 GetWindowText(text->ehHwndBase,text->mail->szCaptionOriginal,cchof(text->mail->szCaptionOriginal));
  46.                 sstrcpy(text->mail->szCaption,text->mail->szCaptionOriginal);
  47.                 //
  48.                 txstr sz = text->mail->szCaptionOriginal;
  49.                 sz += "(WZで編集中)";
  50.                 SetWindowText(text->ehHwndBase,sz);
  51.             }
  52.         }
  53.     }
  54. }
  55.  
  56. //2.90 ここではダイアログボックスなどのUIはできません。
  57. void at_ehTerm(TX* text)
  58. {
  59.     if (text->ehHwnd) {
  60.         EnableWindow(text->ehHwnd,TRUE);
  61.         if (text->ehHwndBase) {
  62.             EnableWindow(text->ehHwndBase,TRUE);
  63.             if (text->mail) {
  64.                 SetWindowText(text->ehHwndBase,text->mail->szCaptionOriginal);
  65.             }
  66.             text->ehHwndBase = NULL;
  67.         }
  68.         text->ehHwnd = NULL;
  69.         text->share->neh--;
  70.         if (text->mail) {
  71.             free(text->mail);
  72.             text->mail = NULL;
  73.         }
  74.     }
  75. }
  76.  
  77. #endif
  78.  
  79. void at_open(TX* text)
  80. {
  81. }
  82.  
  83. extern "html" BOOL TXAPI TXCMD uiNewPage(TX* text);
  84. void at_htmlnew(TX* text)
  85. {
  86. //2.99C 970326 
  87.     uiNewPage(text);
  88. }
  89.  
  90. //## html browser dde
  91. // thanks taniyamaさん
  92. //2.99C 970326 new
  93.  
  94. #include "ddewz.h"
  95. #include "ddewz.h"
  96. #import "shellapi"
  97.  
  98. LPCSTR pNnService = "Netscape";
  99. LPCSTR pIeService = "IExplore";
  100. LPCSTR pTopic = "WWW_OpenURL";
  101.  
  102. static BOOL ddeConnectBrowser(void)
  103. {
  104. #if 1
  105.     if (ddeConnect(pNnService,pTopic)) return TRUE;// はじめNN
  106.     if (ddeConnect(pIeService,pTopic)) return TRUE;// つぎIE
  107.     return FALSE;
  108. #else
  109.     // レジストリで指定されてる方が優先みたいで、以下はだめだった
  110.     switch(text->share->config.modeHtml) {
  111.         case HTML_IE: {
  112.             return ddeConnect(pIeService,pTopic);
  113.         }
  114.         case HTML_NN: return ddeConnect(pNnService,pTopic);
  115.         default: {
  116.             if (ddeConnect(pNnService,pTopic)) return TRUE;// はじめNN
  117.             if (ddeConnect(pIeService,pTopic)) return TRUE;// つぎIE
  118.             break;
  119.         }
  120.     }
  121.     return FALSE;
  122. #endif
  123. }
  124.  
  125. static BOOL htmlDdeView(mchar* szfilename)
  126. {
  127. // szfilenameにはファイル名かURLを指定できる
  128.     if (szfilename && szfilename[0]) {
  129.         if (ddeConnectBrowser()) {
  130.             mchar szUrl[CCHPATHNAME + 16];
  131.             if (pathGetMode(szfilename) == PATH_URL) {
  132.                 sstrcpy(szUrl,szfilename);
  133.             } else {
  134.                 sprintf(szUrl,"file:///%s",szfilename);
  135.             }
  136.             ddeExecute(szUrl);
  137.             ddeDisconnect();
  138.         } else {
  139.             shellExecute(szfilename,"open");
  140.         }
  141.         return TRUE;
  142.     }
  143.     return FALSE;
  144. }
  145.  
  146. //## クリッカブルURL & E-mail
  147.  
  148. BOOL TXAPI openMail(TX* text,mchar* szMailAddress)
  149. {
  150. // メールアドレスszMailAddressのオープン処理をここに記述。
  151. //2.90 
  152.     ShellExecute(text->hwndbase,"open","mailto:" + szMailAddress,NULL,NULL,SW_SHOWNORMAL);
  153.     return TRUE;
  154. }
  155.  
  156. BOOL TXAPI openURL(TX* text,mchar* szURL)
  157. {
  158. // URL(szURL)のオープン処理をここに記述。
  159. //2.90 
  160. #if 1//2.99C 970326 DDEで開くようにした。szURLにファイル名も指定できる。
  161.     return htmlDdeView(szURL);
  162. #else
  163.     ShellExecute(text->hwndbase,"open",szURL,NULL,NULL,SW_SHOWNORMAL);
  164.     return TRUE;
  165. #endif
  166. }
  167.  
  168. //##ファイルプレビュー
  169. //2.99 970318 
  170.  
  171. static mchar _szcfgBinary[] = "バイナリファイル";
  172. static mchar _szMsGossick[] = "MS ゴシック";
  173. permanent int p_lfHeight = 9;
  174. permanent BOOL p_AutoWidth = FALSE;
  175.  
  176. static void txSetFontstyleText(TX* text,mchar* lfFaceName,int lfHeight)
  177. {
  178.     FONTSTYLE* fs = &text->tFontstyle[FONTTX_TEXT];
  179.     strcpy(fs->tlfFaceName[IFONT_STD],lfFaceName);
  180.     strcpy(fs->tlfFaceName[IFONT_ANK],lfFaceName);
  181.     fs->tlfHeight[IFONT_STD] = lfHeight;
  182.     fs->tlfHeight[IFONT_ANK] = lfHeight;
  183. }
  184.  
  185. static void txSetConfigPreview(TX* text)
  186. {
  187.     txSetFontstyleText(text,_szMsGossick,p_lfHeight);
  188.     text->fSetWidthByWindow = p_AutoWidth;
  189.     text->fSilent = TRUE;    // 不要なattentionを出さない
  190.     text->fTxsemNoUI = TRUE;//2.98 970304 HTMLのファイルオープンプレビューで体裁の変化確認ダイアログが出ることがあった
  191.     sstrcpy(text->szMenuMouseR,"右クリック_ファイルプレビュー");
  192. }
  193.  
  194. void at_pf(HWND hctrl,mchar* szfilename,int mode)
  195. {
  196. // szfilename: NULLの場合あり
  197. //2.99 970318 
  198.     if (hctrl) {
  199.         TX* text = (LPVOID)SendMessage(hctrl,TXWM_GETTX,0,0);
  200.         if (text) {
  201.             if (!text->share->config.fFilePreview) {//2.99D 970402 
  202.                 return;
  203.             }
  204.             BOOL fBinary = FALSE;
  205.             BOOL fFD = FALSE;//3.00A3 970508 
  206.             txClose(text);
  207. //if (szfilename) information(szfilename);
  208. #if 1//2.99B 970322 ルードディレクトリでディレクトリを選択するとエラーが出た
  209.             if (
  210.                 szfilename && pathIsFileName(szfilename) &&
  211.                 !pathIsExt(szfilename,".lnk")//2.99I 970405 WZ32だとLNKファイルを解決してファイルプレビューしようとしていて、「オープンできません」と出ることがあった
  212.             ) {
  213.                 mchar szGroup[CCHWORD];
  214.                 if (
  215.                     szfilename &&
  216.                     pathGetExtGroup(pathGetExt(szfilename),szGroup) &&
  217.                     !stricmp(szGroup,_szcfgBinary)
  218.                 ) {
  219.                     //2.98 970308 バイナリファイルはファイルプレビューしない
  220.                     fBinary = TRUE;
  221.                     txSetFileName(text,NULL);
  222.                 } else if (pathGetDriveType(szfilename) == DRIVE_REMOVABLE) {
  223.                     //3.00A3 970508 FD,MOではファイルプレビューしないようにした
  224.                     fFD = TRUE;
  225.                     txSetFileName(text,NULL);
  226.                 } else {
  227.                     txSetFileName(text,szfilename);
  228.                 }
  229.             } else {
  230.                 //2.97A 970303 
  231.                 txSetFileName(text,NULL);
  232.             }
  233. #else
  234.             if (
  235.                 szfilename && (
  236.                     pathIsWild(szfilename) ||
  237.                     pathIsDirectory(szfilename)    //2.99 970319 
  238.                 )
  239.             ) {
  240.                 //2.97A 970303 
  241.                 txSetFileName(text,NULL);
  242.             } else {
  243.                 mchar szGroup[CCHWORD];
  244.                 if (
  245.                     szfilename &&
  246.                     pathGetExtGroup(pathGetExt(szfilename),szGroup) &&
  247.                     !stricmp(szGroup,_szcfgBinary)
  248.                 ) {
  249.                     //2.98 970308 バイナリファイルはファイルプレビューしない
  250.                     fBinary = TRUE;
  251.                     txSetFileName(text,NULL);
  252.                 } else {
  253.                     txSetFileName(text,szfilename);
  254.                 }
  255.             }
  256. #endif
  257.             //
  258.             txSetConfigPreview(text);
  259.             text->sizefileMax = 16384;//2.99 970318 プレビューのサイズを制限した
  260.             text->fReadOnly = TRUE;//2.99 970318 リードオンリーとした
  261.             text->fKcAuto = text->share->config.fKcAuto;//3.00B1 970612 ファイルプレビューでもconfig.fKcAutoを参照
  262.             text->fSpaceLeft = text1->fSpaceLeft;//3.00B2 970616 
  263.             //
  264.             txOpenText(text);
  265.             if (fBinary) {
  266.                 txInsert(text,"(バイナリファイルなので内容省略)");
  267.             } else if (fFD) {
  268.                 txInsert(text,"(フロッピー,MOのファイルなので高速化のため、内容省略)");
  269.             }
  270.         }
  271.     }
  272. }
  273.  
  274. pf_fontToBig
  275. {
  276.     p_lfHeight++;
  277.     txSetFontstyleText(text,_szMsGossick,p_lfHeight);
  278.     txFlush(text);
  279. }
  280.  
  281. pf_fontToSmall
  282. {
  283.     if (p_lfHeight > 3) {
  284.         p_lfHeight--;
  285.     }
  286.     txSetFontstyleText(text,_szMsGossick,p_lfHeight);
  287.     txFlush(text);
  288. }
  289.  
  290. pf_autoWidth
  291. {
  292.     txConfigOp(text,TXCONFIGOP_EXTSETUPDISPSTYLE,0);
  293.     p_AutoWidth ^= 1;
  294.     text->fSetWidthByWindow = p_AutoWidth;
  295.     txFlush(text);
  296. }
  297.  
  298. // ファイルの内容をすべて読み込む
  299. pf_loadall
  300. {
  301. #if 1///3.00A 970501 ファイルプレビューで「ファイルの内容をすべて読み込む」を実行するとエラーになった
  302.     TX* text = textf;    // txCloseでtextfが変化するので。
  303.     txstr szfilename = text->szfilename;
  304.     txClose(text);
  305.     txSetFileName(text,szfilename);
  306.     //
  307.     txSetConfigPreview(text);
  308.     text->sizefileMax = 0;
  309.     text->fReadOnly = FALSE;
  310.     //
  311.     txOpenText(text);
  312.     // textfをtextにセット
  313.     // textf = textとするよりも次の方が良いだろう
  314.     SetFocus(NULL);
  315.     SetFocus(text->hwndtext);
  316.     //
  317.     return TRUE;
  318. #else
  319.     txstr szfilename = text->szfilename;
  320.     txClose(text);
  321.     txSetFileName(text,szfilename);
  322.     //
  323.     txSetConfigPreview(text);
  324.     text->sizefileMax = 0;
  325.     text->fReadOnly = FALSE;
  326.     //
  327.     txOpenText(text);
  328.     return TRUE;
  329. #endif
  330. }
  331.  
  332. // 上書き保存
  333. pf_save
  334. {
  335.     if (text->sizefileMax) {// ファイルプレビュー中なら...
  336.         information("プレビューのために、ファイルの内容が省略されていて、保存できません");
  337.         return FALSE;
  338.     } else {
  339.         return txuiSave(text);
  340.     }
  341. }
  342.  
  343. WORD at_cmdcheck(WZCMD wzcmd)
  344. {
  345.     mchar* szcmd = wzcmdToSzcmd(wzcmd);
  346.     if (!szcmd) return 0;
  347.     if (!stricmp(szcmd,"\m.pf_save")) {
  348.         if (text->sizefileMax) return MF_GRAYED;
  349.         if (text->szfilename[0] == 0) return MF_GRAYED;//3.00A3 970508
  350.         return 0;
  351.     } else if (!stricmp(szcmd,"\m.pf_loadall")) {
  352.         if (text->szfilename[0] == 0) return MF_GRAYED;//3.00A3 970508 Binary,FDでプレビューしてないときは、すべてロード不可。ファイル名がわからない
  353.         if (text->sizefileMax) return 0;
  354.         if (!text->sizefileMax) return MF_CHECKED;
  355.     } else if (!stricmp(szcmd,"\m.pf_autoWidth")) {
  356.         if (p_AutoWidth) return MF_CHECKED;
  357.     }
  358.     return 0;
  359. }
  360.  
  361.