home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 August / VPR9808B.BIN / APUPDATE / VC / Tx300d / TX300D.LZH / WINDOW.C < prev    next >
C/C++ Source or Header  |  1997-05-09  |  28KB  |  1,274 lines

  1. // WZ EDITOR 標準機能 ウィンドウ
  2. // Copyright 1995-96 TY
  3.  
  4. //{###ウィンドウ}
  5.  
  6. //1.01A WZ.EXEとソースプログラム統合。WZ.EXE側でこのソースプログラムを#includeするようにした
  7.  
  8. #ifdef __TXC__
  9.  
  10. #include <windows.h>
  11. #include <windowsx.h>
  12.  
  13. #include "dialog.h"
  14. #include "_filer.h"
  15.  
  16. #ifndef __FLAT__
  17.     extern "user.exe" BOOL WINAPI IsIconic(HWND);
  18. #endif
  19.  
  20. #endif    //__TXC__
  21.  
  22. static mchar szAppName[] = "WZ Editor";
  23. #if 0//2.99 970312 szAppName2廃止
  24. #ifdef __FLAT__
  25. static mchar szAppName2[] = " - WZ Editor";
  26. #endif
  27. #endif
  28.  
  29. int TXAPI txIsFocusSub(TX* text)
  30. {
  31. //2.99C 970325 new
  32. // サブウィンドウがなければ-1,
  33. // サブウィンドウにフォーカスがあればTRUE,なければFALSEを返す
  34.     if (text->hwndtext2) {
  35.         if (text->fFocus2) return TRUE;
  36.         return FALSE;
  37.     } else if (text->text2) {
  38.         if (text->fMultiChild) return TRUE;
  39.         return FALSE;
  40.     }
  41.     return -1;
  42. }
  43.  
  44. void TXAPI txSetFocusSub(TX* text,BOOL fSub)
  45. {
  46.     switch(fSub) {
  47.         case 0: {
  48.             if (text->hwndtext2) {
  49. #if 1//2.99D 970402 ちらつきを抑えた
  50.                 text->fUndraw++;
  51.                 text->fUndispCursor++;
  52.                 SetFocus(text->hwndtext);
  53.                 text->fUndispCursor--;
  54.                 text->fUndraw--;
  55.                 txDispAll(text);
  56. #else
  57.                 SetFocus(text->hwndtext);
  58. #endif
  59.             } else if (text->text2 && text->fMultiChild) {
  60.                 SetFocus(text->text2->hwndtext);
  61.             } else {
  62.                 SetFocus(text->hwndtext);
  63.             }
  64.             break;
  65.         }
  66.         case 1: {
  67.             if (text->hwndtext2) {
  68.                 SetFocus(text->hwndtext2);
  69.             } else if (text->text2 && !text->fMultiChild) {
  70.                 SetFocus(text->text2->hwndtext);
  71.             } else {
  72.                 SetFocus(text->hwndtext);
  73.             }
  74.             break;
  75.         }
  76.     }
  77. }
  78.  
  79. //##次のウィンドウを返す
  80.  
  81. BOOL TXAPI wndtxIsEditor(HWND hwnd)
  82. {
  83. // hwndがWZ Editorかどうか返す
  84. //1.01Aで追加
  85.     mchar szcaption[128];
  86.     GetWindowText(hwnd,szcaption,sizeof(szcaption));
  87.     if (_fwin40) {//1.00H4 "ファイル名 - WZ"キャプションに対応
  88. #ifdef __FLAT__
  89.     #if 1//2.99 970312 
  90.         int lchAppName = sizeof(szAppName) - 1;
  91.         int lch = strlen(szcaption);
  92.         if (lch >= lchAppName) {
  93.             if (!strnicmp(szcaption + lch - lchAppName,szAppName,lchAppName)) {
  94.                 return TRUE;
  95.             }
  96.         }
  97.         return FALSE;
  98.     #else
  99.         if (strstr(szcaption,szAppName2)) return TRUE;
  100.     #endif
  101. #endif
  102.     } else {
  103.         if (!strnicmp(szcaption,szAppName,sizeof(szAppName)-1)) return TRUE;
  104.     }
  105.     return FALSE;
  106. }
  107.  
  108. HWND _wndtxGetNext(BOOL fquery,BOOL fEditorOnly)
  109. {
  110.     HWND ret = NULL;
  111.     HWND cur = GetWindow(GetDesktopWindow(),GW_CHILD);
  112.     //1.00H5 再利用窓にはマッチしないようにした
  113.     wzlock(LOCK_WZPROCESS);
  114.     for (;cur;cur = GetNextWindow(cur,GW_HWNDNEXT)) {
  115.         int i = textSearch(cur);
  116.         
  117. //statprintf("%d",i);beep();wait(100);
  118.         if (i != -1) {
  119.             if (
  120.                 cur != textf->hwndbase &&//2.93 text1->textf
  121.                 (
  122.                     (fEditorOnly == 0) ||
  123.                     (fEditorOnly == 1 && wndtxIsEditor(cur)) ||
  124.                     (
  125.                         fEditorOnly == 2 && (
  126.                             wndtxIsEditor(cur) ||
  127.                             (text1->share->tWzprocess[i].modeProcess & WZPROCESS_EDITORLIKE)
  128.                         )
  129.                     )
  130.                 ) &&
  131.                 !GetWindow(cur,GW_OWNER) &&
  132.                 (!fquery || SendMessage(cur,WM_TXQUERYCLOSE,0,0) == TRUE)
  133.             ) {
  134. //statprintf("found",i);beep();wait(100);
  135. #if 0
  136. {
  137.     mchar szcaption[128];
  138.     GetWindowText(cur,szcaption,sizeof(szcaption));
  139.     information(szcaption);
  140. }
  141. #endif
  142.                 ret = cur;
  143.                 break;
  144.             }
  145.         }
  146.     }
  147.     wzunlock(LOCK_WZPROCESS);
  148.     
  149.     return ret;
  150. }
  151.  
  152. HWND TXAPI wndtxGetNext(void)
  153. {
  154. // 次画面のWZのウィンドウハンドルを返します。
  155. // なければNULLを返します。
  156. // WZ EditorだけでなくWZ FilerやGrepなどにもマッチします
  157. //1.00Cで追加
  158.     return _wndtxGetNext(FALSE,FALSE);
  159. }
  160.  
  161. HWND TXAPI wndtxGetNextEditor(void)
  162. {
  163. // 次画面のWZ Editorのウィンドウハンドルを返します。
  164. // なければNULLを返します。
  165. // WZ FilerやGrepなどにはマッチしません
  166. //1.01Aで追加
  167.     return _wndtxGetNext(FALSE,TRUE);
  168. }
  169.  
  170. // WM_TXQUERYCLOSEを送ってはねられるウィンドウは除く
  171. HWND wndtxGetNext2(void)
  172. {
  173.     return _wndtxGetNext(TRUE,FALSE);
  174. }
  175.  
  176. //##オリジナルウィンドウ位置、サイズ
  177.  
  178. // Win32では他インスタンスのウィンドウの補足ウィンドウメモリにアクセスはできるが、
  179. // ポインタとしてはアクセスできない。
  180. void TXAPI wndtxSetOriginalRect(HWND hwnd,RECT *r)
  181. {
  182. //2.99C 970325 TXAPI
  183.     int i;
  184.     wzlock(LOCK_WZPROCESS);
  185.     i = textSearch(hwnd);
  186.     if (i != -1) {
  187.         #ifdef __TXC__
  188.         SHARE *sh = text->share;
  189.         #endif
  190.         sh->tWzprocess[i].rectOriginal = *r;
  191.     }
  192. //statprintf("%d %d %d %d",r->left,r->top,r->right,r->bottom);wait(100);
  193.     wzunlock(LOCK_WZPROCESS);
  194. }
  195.  
  196. void TXAPI wndtxGetOriginalRect(HWND hwnd,RECT *r)
  197. {
  198. //2.99C 970325 TXAPI
  199.     int i;
  200.     wzlock(LOCK_WZPROCESS);
  201.     i = textSearch(hwnd);
  202.     if (i != -1) {
  203.         #ifdef __TXC__
  204.         SHARE *sh = text->share;
  205.         #endif
  206.         *r = sh->tWzprocess[i].rectOriginal;
  207.     }
  208.     wzunlock(LOCK_WZPROCESS);
  209. }
  210.  
  211. void TXAPI wndtxSetOriginalSize(HWND hwnd,SIZE *s)
  212. {
  213. //2.99C 970325 TXAPI
  214. #if 1///3.00A 970502 別プロセスのWZがあるとき「ウィンドウ|重ねて表示」でアプリエラーが起きることがあった
  215.     SetWindowWord(hwnd,4,s->cx);
  216.     SetWindowWord(hwnd,6,s->cy);
  217. #else
  218.     TXBASE_CONTEXT* p = hwndbaseGetContext(hwnd);
  219.     p->sizeOriginal = *s;
  220. #endif
  221. }
  222.  
  223. void TXAPI wndtxGetOriginalSize(HWND hwnd,SIZE *s)
  224. {
  225. //2.99C 970325 TXAPI
  226. #if 1///3.00A 970502 別プロセスのWZがあるとき「ウィンドウ|重ねて表示」でアプリエラーが起きることがあった
  227.     s->cx = GetWindowWord(hwnd,4);
  228.     s->cy = GetWindowWord(hwnd,6);
  229. #else
  230.     TXBASE_CONTEXT* p = hwndbaseGetContext(hwnd);
  231.     *s = p->sizeOriginal;
  232. #endif
  233. }
  234.  
  235. //##メッセージ送信
  236.  
  237. LRESULT TXAPI SendMessageOther(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
  238. {
  239. // 他のWZにメッセージを送信し、処理を待ち、結果を返します。
  240. // 送信先のWZがビジー状態またはハングしているときは5秒待っても
  241. // 送信できなければ処理は中止し、0を返します。
  242. // WZ16ではSendMessageをそのまま実行します。
  243. //2.00Bで追加
  244. #ifdef __FLAT__
  245.     DWORD result;
  246.     if (SendMessageTimeout(hwnd,uMsg,wParam,lParam,SMTO_NORMAL,5000,&result)) {
  247.         return result;
  248.     }
  249.     return 0;
  250. #else
  251.     return SendMessage(hwnd,uMsg,wParam,lParam);
  252. #endif
  253. }
  254.  
  255. #ifdef __TXC__
  256.  
  257. //##ウィンドウの切り換え
  258.  
  259. static void _next(int d)
  260. {
  261.     int nMax = text->share->nOpen;
  262.     
  263.     if (
  264.         IsIconic(text->hwndbase) ||
  265.         !IsWindowVisible(text->hwndbase) ||
  266.         nMax <= 1
  267.     ) {
  268.         return;
  269.     }
  270.     int idx;
  271.     for (idx = 0; idx < nMax; idx ++) {
  272.         if (text->hwndbase == textRead(idx)) {
  273.             break;
  274.         }
  275.     }
  276.     do {
  277.         idx += d;
  278.         if (idx < 0) idx = nMax - 1;
  279.         idx %= nMax;
  280.         HWND cur = textRead(idx);
  281.         if (
  282.             cur &&
  283.             !IsIconic(cur) &&
  284.             IsWindowVisible(cur)    //1.01A WZ32+Win95でwindow.Nextでwziconが居るとウィンドウが切り替わらなかった
  285.         ) {
  286.             break;
  287.         }
  288.     } while (text->hwndbase != textRead(idx));
  289.     HWND cur = textRead(idx);
  290.     if (cur) wndtxSetActive(cur);
  291. }
  292.  
  293. Next
  294. {
  295. // WZの次のウィンドウへ切り替え
  296. // アイコン化されたウィンドウは除外して切り替える
  297. // Thanks dieさん
  298. //2.99A 970321 {#MS} ^{F6} %{F6} -> ^{F6}
  299. //{#MS} ^{F6}
  300.     _next(1);
  301. }
  302.  
  303. Prev
  304. {
  305. // WZの手前のウィンドウへ切り替え
  306. // アイコン化されたウィンドウは除外して切り替える
  307. // Thanks dieさん
  308. //1.01A で追加
  309. //2.99A 970321 {#MS} +^{F6} new
  310. //{#MS} +^{F6}
  311.     _next(-1);
  312. }
  313.  
  314. //##ウィンドウを一覧表示して切り換え
  315.  
  316. #define IDD_LIST    100
  317.  
  318. // hwndがトップレベルウィンドウとして存在するか返す
  319. BOOL wndGetExistToplevel(HWND hwnd)
  320. {
  321.     HWND cur = GetWindow(GetDesktopWindow(),GW_CHILD);
  322.     while(cur) {
  323.         if (cur == hwnd) return TRUE;
  324.         cur = GetWindow(cur,GW_HWNDNEXT);
  325.     }
  326.     return FALSE;
  327. }
  328.  
  329. // textのOpenの順番で作る
  330. static int WindowList(HANDLE handle,BOOL fMenu,int iMenu)
  331. {
  332.     int lchAppName = sizeof(szAppName)-1;
  333.     int number = 1;
  334.     int i;
  335.     int j;
  336.     
  337.     for (i = 0;i < text->share->nOpen;i++) {
  338. #if 1
  339.         HWND cur = textRead(i);
  340.         if (!cur) continue;
  341. #else
  342.         // for TEST
  343.         HWND cur = text->share->tWzprocess[i].hwnd;
  344. #endif
  345.         BOOL fexist = wndGetExistToplevel(cur);
  346.         if (fexist && GetWindow(cur,GW_OWNER)) {
  347.             // オーナが居る場合は無視
  348.         } else {
  349.             #define CAPTIONSIZE    (CCHAPPNAME + CCHPATHNAME)
  350.             mchar szcaption[3 + CAPTIONSIZE];// 3:for "&1 "
  351.             mchar *p = szcaption;
  352.             
  353.             // menu command key
  354.             if (fMenu) {
  355.                 *p++ = '&';
  356.                 if (number <= 9) {
  357.                     *p++ = '0' + number;
  358.                 } else {
  359.                     *p++ = ' ';
  360.                 }
  361.                 *p++ = ' ';
  362.             }
  363.             number++;
  364. #if 0000
  365.             // edited ?
  366.             if (wndtxCall(cur,"txGetEdit")) {
  367.                 *p++ = '*';
  368.             } else {
  369.                 *p++ = ' ';
  370.             }
  371. #endif
  372.             *p++ = ' ';
  373.             // get caption
  374.             if (fexist) {
  375.                 GetWindowText(cur,p,CAPTIONSIZE);
  376.                 // Editorなら、アプリ名を取り除く
  377.                 if (!_fwin40) {
  378.                     if (!strnicmp(p,szAppName,lchAppName)) {
  379.                         strcpy(p,p+lchAppName+3);//+3:" - "
  380.                     }
  381.                 }
  382.             } else {
  383.                 // アプリエラーなどで落ちた
  384.                 strcpy(p,"(無効ウィンドウ)");
  385.             }
  386.             // add
  387.             if (fMenu) {
  388.                 UINT fCheck = (cur == text->hwndbase) * MF_CHECKED;
  389.                 if (iMenu == -1) {
  390.                     #if 1//2.95 970129 
  391.                     AppendMenu(handle,MF_STRING|fCheck,IDM_TXWINDOWTOP + i,szcaption);
  392.                     #else
  393.                     menuStr(handle,szcaption,IDM_TXWINDOWTOP + i);
  394.                     #endif
  395.                 } else {
  396.                     InsertMenu(handle,iMenu,MF_BYPOSITION|MF_STRING|fCheck,IDM_TXWINDOWTOP + i,szcaption);
  397.                     iMenu++;
  398.                 }
  399.             } else {
  400.                 SendMessage(handle,LB_ADDSTRING,0,(LPARAM)szcaption);
  401.             }
  402.             // search
  403.             if (text->hwndbase == cur) j = i;
  404.         }
  405.     }
  406.     return j;
  407. }
  408.  
  409. //1.90 
  410. int menuWindowList(HMENU hmenu,int i)
  411. {
  412.     WindowList(hmenu,TRUE,i);
  413.     return TRUE;
  414. }
  415.  
  416. //1.90 
  417. BOOL TXCMDBASE stdout(TX* text)
  418. {
  419. // 標準出力ウィンドウを開く
  420. // TX-Cのコンパイル経過や結果が表示されます。
  421.     PostMessage(text->hwndbase,WM_COMMAND,IDM_TXSTDOUTOPEN,0);
  422.     return TRUE;
  423. }
  424.  
  425. BOOL dlgprocSelectWindow(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
  426. {
  427.     switch(message) {
  428.         case WM_INITDIALOG: {
  429.             HWND hwndList = GetDlgItem(hwnd,IDD_LIST);
  430.             SendMessage(hwndList,LB_SETCURSEL,WindowList(hwndList,FALSE,0),0L);
  431.             SetFocus(hwndList);
  432.             return FALSE;
  433.         }
  434.         case WM_COMMAND: {
  435.             int id = LOWORD(wParam);
  436.             if (id == IDOK) {
  437.                 HWND hwndList = GetDlgItem(hwnd,IDD_LIST);
  438.                 int nSel;
  439.                 
  440.                 nSel = SendMessage(hwndList,LB_GETCURSEL,0,0);
  441.                 if (nSel != LB_ERR) {
  442.                     EndDialog(hwnd,TRUE);
  443.                     HWND cur = textRead(nSel);
  444.                     if (cur) {
  445.                         wndtxSetActive(cur);
  446.                     }
  447.                 } else {
  448.                     EndDialog(hwnd,FALSE);
  449.                 }
  450.                 return TRUE;
  451.             }
  452.             return FALSE;
  453.         }
  454.         case WM_WKKEYDOWN: {
  455.             switch(LOWORD(lParam)) {
  456.                 case VK_ESCAPE:
  457.                 case VK_DOWN:
  458.                 case VK_UP:
  459.                 case VK_LEFT:
  460.                 case VK_RIGHT:
  461.                 case VK_RETURN: {
  462.                     return FALSE;
  463.                 }
  464.                 default: {
  465.                     HWND hwndList = GetDlgItem(hwnd,IDD_LIST);
  466.                     HWND next = 0;
  467.                     int iSel;
  468.                     
  469.                     iSel = SendMessage(hwndList,LB_GETCURSEL,0,0);
  470.                     if (iSel != LB_ERR) {
  471.                         //1.00H4 次のウィンドウを調べる
  472.                         int i;
  473.                         for (i = iSel + 1;i < text->share->nOpen;i++) {
  474.                             next = textRead(i);
  475.                             if (!next) break;
  476.                         }
  477.                         for (i = 0;i <= iSel;i++) {
  478.                             next = textRead(i);
  479.                             if (!next) break;
  480.                         }
  481.                     }
  482.                     EndDialog(hwnd,FALSE);
  483.                     if (next) wndtxSetActive(next);
  484.                     return TRUE;
  485.                 }
  486.             }
  487.             return FALSE;
  488.         }
  489.     }
  490.     return FALSE;
  491. }
  492.  
  493. uiSelect
  494. {
  495. // ウィンドウ選択ダイアログを表示して、切り換えます。
  496.     HDIALOG hd = dialog("編集テキスト");
  497.     {
  498.         PMACROFUNC pfunc;
  499.         
  500.         if (macroGetFuncAddress("dlgprocSelectWindow",&pfunc)) {
  501.             dialogSetHook(hd,&pfunc);
  502.         }
  503.     }
  504.     dialogControlHookKey(hd);
  505.     dialogControlID(hd,IDD_LIST);
  506.     _dialogList(hd,NULL,60,12);    //3.00A 970429 45->60 window.uiSelectのファイル名表示のウィンドウの横幅を拡大
  507.     dialogOpen(hd);
  508. }
  509.  
  510. //##ウィンドウ汎用API
  511.  
  512. static BOOL hwndIsText(HWND hwnd)
  513. {
  514.     int i;
  515.     
  516.     for (i = 0;i < text->share->nOpen;i++) {
  517.         if (hwnd == textRead(i)) {
  518.             return TRUE;
  519.         }
  520.     }
  521.     return FALSE;
  522. }
  523.  
  524. // curの次のWZ窓を返す
  525. static HWND textGetNext(HWND cur)
  526. {
  527.     while(1) {
  528.         cur = GetNextWindow(cur,GW_HWNDNEXT);
  529.         if (!cur) return NULL;
  530.         if (hwndIsText(cur) && !GetWindow(cur,GW_OWNER)) return cur;
  531.     }
  532. }
  533.  
  534. // curの以前のTX windowを返す
  535. static HWND textGetPrev(HWND cur)
  536. {
  537.     while(1) {
  538.         cur = GetNextWindow(cur,GW_HWNDPREV);
  539.         if (!cur) return NULL;
  540.         if (hwndIsText(cur) && !GetWindow(cur,GW_OWNER)) return cur;
  541.     }
  542. }
  543.  
  544. // 画面の一番奥にあるWZ窓を返す
  545. static HWND textGetLast(void)
  546. {
  547.     HWND hwnd = GetWindow(GetDesktopWindow(),GW_CHILD);
  548.     // get last window
  549.     while(1) {
  550.         HWND hwndnext = GetWindow(hwnd,GW_HWNDNEXT);
  551.         if (!hwndnext) break;
  552.         hwnd = hwndnext;
  553.     }
  554.     // hwnd is TX?
  555.     if (hwndIsText(hwnd) && !GetWindow(hwnd,GW_OWNER)) {
  556.         // OK
  557.     } else {
  558.         hwnd = textGetPrev(hwnd);
  559.     }
  560.     return hwnd;
  561. }
  562.  
  563. // 画面の一番手前にあるWZ窓を返す
  564. static HWND textGetTop(void)
  565. {
  566.     HWND hwnd = GetWindow(GetDesktopWindow(),GW_CHILD);
  567.     while(hwnd) {
  568.         hwnd = GetWindow(hwnd,GW_HWNDNEXT);
  569.         if (hwndIsText(hwnd) && !GetWindow(hwnd,GW_OWNER)) break;
  570.     }
  571.     return hwnd;
  572. }
  573.  
  574. BOOL TXAPI wndtxMove(HWND hwndbase,int x,int y,int cx,int cy,BOOL bRepaint)
  575. {
  576. // ウィンドウを移動します。
  577. // WindowsAPIのMoveWindowと同じですが、WZの[ウィンドウ]-[並べて表示]が実行されたとき、
  578. // hwndbaseのサイズがcx,cyで表示されるように設定作業をします
  579. //1.01A で追加
  580.     SIZE s;
  581.     s.cx = cx;
  582.     s.cy = cy;
  583.     wndtxSetOriginalSize(hwndbase,&s);
  584.     return MoveWindow(hwndbase,x,y,cx,cy,bRepaint);
  585. }
  586.  
  587. DWORD TXAPI wndtxCallUi(HWND hwndbase,mchar *szapi)
  588. {
  589. // WZ16ではwndtxCallを使って、ダイアログを開くマクロを呼びだすと
  590. // キーやマウスが反応しなくなることがあるという問題があります。
  591. // このAPIを使ってこの問題を回避できます。
  592. // WZ32ではこのAPIはwndtxCallと全く同じです。
  593. // ●制限事項
  594. // ・wz.exe内部のAPIは呼び出せません。マクロの呼び出しに使ってください
  595. // ・返り値は取れません。いつもTRUEを返します。
  596. //1.01Aで追加
  597. #ifdef __FLAT__
  598.     return wndtxCall(hwndbase,szapi);
  599. #else
  600.     wndtxSetActive(hwndbase);
  601.     PostMessage(hwndbase,WM_TXCALL,0,(LPARAM)szapi);
  602.     return TRUE;
  603. #endif
  604. }
  605.  
  606. DWORD TXAPI wndtxCallNext(mchar *szapi)
  607. {
  608. // wndtxCallを使って次画面のWZのszapiを呼び出します
  609. // 次画面のウィンドウがあればwndtxCallの返り値、なければ0を返します。
  610. //1.00Cで追加
  611.     HWND hwnd = wndtxGetNext();
  612.     if (hwnd) {
  613.         return wndtxCall(hwnd,szapi);
  614.     }
  615.     return 0;
  616. }
  617.  
  618. DWORD TXAPI wndtxCallBoth(mchar *szapi)
  619. {
  620. // wndtxCallを使って現在画面と次画面のWZのszapiを呼び出します
  621. // 次画面のウィンドウがあれば現在画面のwndtxCallの返り値、なければ0を返します。
  622. //1.00Cで追加
  623.     HWND hwnd = wndtxGetNext();
  624.     if (hwnd) {
  625.         DWORD ret = wndtxCall(textf->hwndbase,szapi);//2.96A 970214 text1->textf
  626.         wndtxCall(hwnd,szapi);
  627.         return ret;
  628.     }
  629.     return 0;
  630. }
  631.  
  632. static int GetModeFocus(void);
  633. static void SetModeFocus(TX* textFrame,int modeFocus);
  634.  
  635. static BOOL txSwitchSub(void)
  636. {
  637. //2.99C 970324 new
  638.     int modeFocus = GetModeFocus();
  639. //statprintf("%d",modeFocus);wait(500);
  640.     if (modeFocus < 0) return FALSE;
  641.     TX* textFrame = txGetFrame(text);
  642.     BOOL fText2 = (text->hwndtext2 || text->text2);    // 分割中?
  643.     if (fText2) {
  644.         modeFocus++;
  645.         if (modeFocus == 2) modeFocus = 0;
  646.         SetModeFocus(textFrame,modeFocus);
  647.         return TRUE;
  648.     }
  649.     return FALSE;
  650. }
  651.  
  652. DWORD TXAPI wndtxCallNextEx(mchar *szapi)
  653. {
  654. // ウィンドウ分割中は分割された他方、分割中でなければ次画面の
  655. // WZのszapiを呼び出します
  656. // 呼び出した返り値を返します。
  657. //2.99C 970324 new
  658.     if (txSwitchSub()) {
  659.         DWORD ret = txCall(textf,szapi);
  660.         txSwitchSub();
  661.         return ret;
  662.     } else {
  663.         return wndtxCallNext(szapi);
  664.     }
  665. }
  666.  
  667. DWORD TXAPI wndtxCallBothEx(mchar *szapi)
  668. {
  669. // ウィンドウ分割中は分割された他方、分割中でなければ次画面のWZのszapiと、
  670. // 現在画面のszapiを呼び出します
  671. // 次画面のウィンドウがあれば現在画面のwndtxCallの返り値、なければ0を返します。
  672. //2.99C 970324 new
  673.     if (txSwitchSub()) {
  674.         txCall(textf,szapi);
  675.         txSwitchSub();
  676.         return txCall(textf,szapi);
  677.     } else {
  678.         return wndtxCallBoth(szapi);
  679.     }
  680. }
  681.  
  682. void TXAPI txWindowMove(tx *text,int x,int y)
  683. {
  684. // ウィンドウ位置を移動します
  685.     RECT r;
  686.     GetWindowRect(text->hwndbase,&r);
  687.     MoveWindow(text->hwndbase,x,y,r.right - r.left,r.bottom - r.top,TRUE);
  688. }
  689.  
  690. void TXAPI txWindowResize(tx *text,int cx,int cy)
  691. {
  692. // ウィンドウサイズを変更します
  693.     RECT r;
  694.     GetWindowRect(text->hwndbase,&r);
  695.     MoveWindow(text->hwndbase,r.left,r.top,cx,cy,TRUE);
  696. }
  697.  
  698. void TXAPI txWindowSetPos(tx *text,int x,int y,int cx,int cy)
  699. {
  700. // ウィンドウ位置とサイズを変更します
  701.     MoveWindow(text->hwndbase,x,y,cx,cy,TRUE);
  702. }
  703.  
  704. static int GetEditorWindowCount(void)
  705. {
  706.     int ret = 0;
  707.     int i;
  708.     
  709.     for (i = 0;i < text->share->nOpen;i++) {
  710.         HWND cur = textRead(i);
  711.         if (cur && wndtxIsEditor(cur)) ret++;
  712.     }
  713.     return ret;
  714. }
  715.  
  716. //##ウィンドウの分割表示
  717.  
  718. //1.00H 
  719. //2.00B TXAPI
  720. void TXAPI GetWorkRect(RECT *r)
  721. {
  722. #ifdef __FLAT__
  723.     if (SystemParametersInfo(SPI_GETWORKAREA,sizeof(RECT),r,0)) return;
  724. #endif
  725.     r->left = r->top = 0;
  726.     r->right = GetSystemMetrics(SM_CXSCREEN);
  727.     r->bottom = GetSystemMetrics(SM_CYSCREEN);
  728. }
  729.  
  730. BOOL TXAPI wndtxMoveWindowTemp(HWND hwnd,int x,int y,int cx,int cy,BOOL fredraw)
  731. {
  732. // オリジナル位置の変更をしないでウィンドウをMoveWindowする
  733. //2.00E5で追加
  734.     int i;
  735.     wzlock(LOCK_WZPROCESS);
  736.     i = textSearch(hwnd);
  737.     if (i != -1) {
  738.         text1->share->tWzprocess[i].fWndMoving = TRUE;
  739.     }
  740.     wzunlock(LOCK_WZPROCESS);
  741.     //
  742.     BOOL ret = MoveWindow(hwnd,x,y,cx,cy,fredraw);
  743.     //
  744.     wzlock(LOCK_WZPROCESS);
  745.     i = textSearch(hwnd);
  746.     if (i != -1) {
  747.         text1->share->tWzprocess[i].fWndMoving = FALSE;
  748.     }
  749.     wzunlock(LOCK_WZPROCESS);
  750.     return ret;
  751. }
  752.  
  753. // アイコン化されてる時はMoveWindowしない
  754. // 実行するとアイコンも変に移動してしまう
  755. //1.01A オリジナル位置の変更もしない
  756. static void myMoveWindow(HWND hwnd,int x,int y,int cx,int cy,BOOL fredraw,RECT* rBase)
  757. {
  758.     if (!IsIconic(hwnd)) {
  759. #if 1//2.00E txGetWideの改良に伴う変更
  760.     #if 1//2.00E5 
  761.         if (rBase) {
  762.             x += rBase->left;
  763.             y += rBase->top;
  764.         }
  765.         wndtxMoveWindowTemp(hwnd,x,y,cx,cy,fredraw);
  766.     #else
  767.         int i;
  768.         wzlock(LOCK_WZPROCESS);
  769.         i = textSearch(hwnd);
  770.         if (i != -1) {
  771.             text1->share->tWzprocess[i].fWndMoving = TRUE;
  772.         }
  773.         wzunlock(LOCK_WZPROCESS);
  774.         {
  775.             if (rBase) {
  776.                 x += rBase->left;
  777.                 y += rBase->top;
  778.             }
  779.             MoveWindow(hwnd,x,y,cx,cy,fredraw);
  780.         }
  781.         wzlock(LOCK_WZPROCESS);
  782.         i = textSearch(hwnd);
  783.         if (i != -1) {
  784.             text1->share->tWzprocess[i].fWndMoving = FALSE;
  785.         }
  786.         wzunlock(LOCK_WZPROCESS);
  787.     #endif
  788. #else
  789.         RECT r;
  790.         wndtxGetOriginalRect(hwnd,&r);
  791.         if (rBase) {
  792.             x += rBase->left;
  793.             y += rBase->top;
  794.         }
  795.         MoveWindow(hwnd,x,y,cx,cy,fredraw);
  796.         wndtxSetOriginalRect(hwnd,&r);
  797. #endif
  798.     }
  799. }
  800.  
  801. void TXAPI wndtxMoveOriginal(HWND hwnd)
  802. {
  803. //2.95 970128 hwndをオリジナル位置に戻す
  804.     RECT r;
  805.     wndtxGetOriginalRect(hwnd,&r);
  806.     if (IsZoomed(hwnd)) ShowWindow(hwnd,SW_SHOWNORMAL);
  807.     MoveWindow(hwnd,r.left,r.top,r.right - r.left,r.bottom - r.top,TRUE);
  808. }
  809.  
  810. static HWND mytextGetNext(HWND hwnd)
  811. {
  812. //2.99D 970401 NT3.51でWZ Icon常駐で「ウィンドウ|左右に並べる」でWZ Iconのオープンダイアログでた
  813.     while(1) {
  814.         hwnd = textGetNext(hwnd);
  815.         if (!hwnd) break;
  816.         if (!IsIconic(hwnd)) break;// アイコン化されてるのは無視(WZ Icon etc)
  817.     }
  818.     return hwnd;
  819. }
  820.  
  821. // 'D','d'はtxDup用
  822. void settile(int mode)
  823. {
  824.     if (toupper(mode) == 'D') {
  825.         text->share->modeSplit = 'V';
  826.     } else {
  827.         text->share->modeSplit = mode;
  828.     }
  829.     if (toupper(mode) == 'C') {
  830.         //1.00F 「重ねて表示」改良
  831.         HWND hwnd = textGetLast();
  832.         HWND thwnd[MAXOPEN];
  833.         int n = 0;
  834.         for (;hwnd;hwnd = textGetPrev(hwnd)) {
  835.             if (IsIconic(hwnd)) {
  836.                 // アイコン化されているものは無視
  837.             } else {
  838.                 if (n == MAXOPEN) break;
  839.                 thwnd[n++] = hwnd;
  840.             }
  841.         }
  842.         if (mode == 'c') {//1.01A 画面分割前の状態にウィンドウの位置を戻す[ウィンドウ]-[元に戻す]コマンドを追加
  843.             int i;
  844.             for (i = 0;i < n;i++) {
  845.                 HWND hwnd = thwnd[i];
  846.                 wndtxMoveOriginal(hwnd);
  847.             }
  848.         } else {
  849.             int cxd = LOWORD(GetDialogBaseUnits()) * 4;
  850.             int cyd = HIWORD(GetDialogBaseUnits()) * 3 / 2;
  851.             int x = 0;
  852.             int y = 0;
  853.             int i;
  854.             for (i = 0;i < n;i++) {
  855.                 HWND hwnd = thwnd[i];
  856.                 //1.00F2 [ウィンドウ]-[重ねて表示]でウィンドウサイズが全部同じになっていた
  857.                 SIZE s;
  858.                 wndtxGetOriginalSize(hwnd,&s);
  859.                 if (IsZoomed(hwnd)) ShowWindow(hwnd,SW_SHOWNORMAL);
  860.                 {
  861.                     RECT r;
  862.                     GetWorkRect(&r);
  863.                     if (s.cx == CW_USEDEFAULT) s.cx = r.right - r.left;
  864.                     if (s.cy == CW_USEDEFAULT) s.cy = r.bottom - r.top;
  865.                 }
  866.                 //
  867.                 myMoveWindow(hwnd,x,y,s.cx,s.cy,TRUE,NULL);
  868.                 x += cxd;
  869.                 y += cyd;
  870.             }
  871.         }
  872.     } else {
  873.         HWND hwnd = GetDesktopWindow();
  874.         HWND thwnd[4] = {0,0,0,0};
  875.         int cx,cy;
  876.         int i;
  877.         int imax = (mode == 'T')? 4:2;
  878.         int ncount = text->share->nOpen;
  879.         if (imax > ncount) imax = ncount;
  880.         // get screen size
  881.         RECT rWork;
  882.         GetWorkRect(&rWork);
  883.         cx = rWork.right - rWork.left;
  884.         cy = rWork.bottom - rWork.top;
  885.         // for txDup
  886.         if (mode == 'D') {
  887.             myMoveWindow(text->hwndbase,0,0,cx,cy/2,TRUE,&rWork);
  888.             return;
  889.         } else if (mode == 'd') {
  890.             myMoveWindow(text->hwndbase,0,cy/2,cx,cy/2,FALSE,&rWork);
  891.             return;
  892.         }
  893.         // get screen top wndtx
  894.         hwnd = GetWindow(hwnd,GW_CHILD);
  895.         // hwnd is TX ?
  896.         if (hwndIsText(hwnd) && !GetWindow(hwnd,GW_OWNER)) {
  897.             // OK
  898.         } else {
  899.             hwnd = textGetNext(hwnd);
  900.         }
  901.         //
  902.         for (i = 0;hwnd && i < imax;i++,hwnd = mytextGetNext(hwnd)) {
  903.             int x = 0;
  904.             int y = 0;
  905.             
  906. #if 0
  907.             //TEST WZ FilerなどがWindow分割されないように
  908.             while(1) {
  909.                 if (wndtxIsEditor(hwnd)) break;
  910.                 hwnd = textGetNext(hwnd);
  911.                 if (!hwnd) break;
  912.             }
  913.             if (!hwnd) break;
  914. #endif
  915.             thwnd[i] = hwnd;
  916.             //
  917.             if (i & 1) x = cx/2;
  918.             if (i >= 2) y = cy/2;
  919.             if (IsZoomed(hwnd)) ShowWindow(hwnd,SW_SHOWNORMAL);//1.00C
  920.             if (imax == 1) {
  921.                 myMoveWindow(hwnd,x,y,cx,cy,TRUE,&rWork);
  922.             } else if (imax == 2) {
  923.                 if (mode == 'V') {
  924.                     if (i == 0) {
  925.                         myMoveWindow(hwnd,0,0,cx,cy/2,TRUE,&rWork);
  926.                     } else {
  927.                         myMoveWindow(hwnd,0,cy/2,cx,cy/2,TRUE,&rWork);
  928.                     }
  929.                 } else {
  930.                     myMoveWindow(hwnd,x,y,cx/2,cy,TRUE,&rWork);
  931.                 }
  932.             } else {
  933.                 myMoveWindow(hwnd,x,y,cx/2,cy/2,TRUE,&rWork);
  934.             }
  935.         }
  936. #if 1    // 全て前面に出す
  937.         for (i = imax;i--;) {
  938.     #ifdef __FLAT__//1.97 ウィンドウの順番がおかしかった
  939.             HWND hwndbase = thwnd[i];
  940.             if (hwndbase) {
  941.                 if (!SendMessage(hwndbase,WM_TXGETFMESSAGELOOP,0,0)) return;
  942.                 hwndbase = wndtxGetActive(hwndbase);
  943.                 if (hwndbase) {
  944.                     SetActiveWindow(hwndbase);
  945.                     if (IsIconic(hwndbase)) ShowWindow(hwndbase,SW_RESTORE);//1.00F アイコン化されてるのを戻す様にした
  946.                 }
  947.             }
  948.     #else
  949.             wndtxSetActive(thwnd[i]);
  950.     #endif
  951.         }
  952. #endif
  953.     }
  954. }
  955.  
  956. BOOL TXCMDBASE TileH(TX* text)
  957. {
  958. // 横に分割
  959.     settile('H');
  960.     return TRUE;
  961. }
  962.  
  963. BOOL TXCMDBASE TileV(TX* text)
  964. {
  965. // 縦に分割
  966.     settile('V');
  967.     return TRUE;
  968. }
  969.  
  970. BOOL TXCMDBASE TileOverlap(TX* text)
  971. {
  972. // 重ねて表示
  973.     settile('C');
  974.     return TRUE;
  975. }
  976.  
  977. BOOL TXCMDBASE TileUndo(TX* text)
  978. {
  979. // 元に戻す
  980. //1.01A で追加
  981.     settile('c');
  982.     return TRUE;
  983. }
  984.  
  985. BOOL TXCMDBASE Tile(TX* text)
  986. {
  987. // 並べて表示
  988.     settile('T');
  989.     return TRUE;
  990. }
  991.  
  992. //##ウィンドウコマンド
  993.  
  994. static void fully(BOOL fMax,BOOL fSetOriginalPos)
  995. {
  996.     RECT rWork;
  997.     GetWorkRect(&rWork);
  998.     RECT r;
  999.     GetWindowRect(text->hwndbase,&r);
  1000.     if (fMax) {// タイトルバーとメニューバーのサイズを引く
  1001.         RECT rc;
  1002.         GetClientRect(text->hwndbase,&rc);
  1003.         ClientToScreen(text->hwndbase,(POINT*)&rc);
  1004.         int d = (rc.top - r.top) - 2;
  1005.         rWork.top -= d;
  1006. //information("%d %d %d %d",r.left,rWork.top,rectCx(&r),rectCy(&rWork));
  1007.     }
  1008. #if 1//3.00A2 970507 
  1009.     if (fSetOriginalPos) {
  1010.         txWindowSetPos(text,r.left,rWork.top,rectCx(&r),rectCy(&rWork));
  1011.     } else {
  1012.         wndtxMoveWindowTemp(
  1013.             text->hwndbase,
  1014.             r.left,rWork.top,rectCx(&r),rectCy(&rWork),
  1015.             TRUE
  1016.         );
  1017.     }
  1018. #else
  1019.     #if 1//2.95 970128 オリジナル位置を変更しない
  1020.     wndtxMoveWindowTemp(
  1021.         text->hwndbase,
  1022.         r.left,rWork.top,rectCx(&r),rectCy(&rWork),
  1023.         TRUE
  1024.     );
  1025.     #else
  1026.     txWindowSetPos(text,r.left,rWork.top,rectCx(&r),rectCy(&rWork));
  1027.     #endif
  1028. #endif
  1029. }
  1030.  
  1031. BOOL TXCMDBASE FullY(TX* text)
  1032. {
  1033. // ウィンドウの高さをフルに
  1034. //3.00A2 970507 3.00ではオリジナル位置を変更しなかったが、変更するようにした(WZ2の仕様に戻した)。
  1035.     fully(FALSE,TRUE);
  1036.     return TRUE;
  1037. }
  1038.  
  1039. FullY1
  1040. {
  1041. // ウィンドウの高さをフルに
  1042. // オリジナル位置を変更しない
  1043. //3.00A2 970507 new WZ3.00のwindow.FullYと同じ機能を提供
  1044.     fully(TRUE,FALSE);
  1045. }
  1046.  
  1047. FullY2
  1048. {
  1049. // タイトルバーとメニューを消して高さをフルに
  1050.     fully(TRUE,FALSE);
  1051. }
  1052.  
  1053. Minimize
  1054. {
  1055. // アイコン化
  1056. //1.00Fで追加
  1057.     PostMessage(text->hwndbase,WM_SYSCOMMAND,SC_MINIMIZE,0);
  1058. }
  1059.  
  1060. Maximize
  1061. {
  1062. // 最大化
  1063. //1.00Fで追加
  1064.     PostMessage(text->hwndbase,WM_SYSCOMMAND,SC_MAXIMIZE,0);
  1065. }
  1066.  
  1067. Restore
  1068. {
  1069. // 元のサイズに戻す
  1070. //1.00Fで追加
  1071.     PostMessage(text->hwndbase,WM_SYSCOMMAND,SC_RESTORE,0);
  1072. }
  1073.  
  1074. TaskList
  1075. {
  1076. // アプリケーションの切り替え
  1077. //1.00Fで追加
  1078.     PostMessage(text->hwndbase,WM_SYSCOMMAND,SC_TASKLIST,0);
  1079. }
  1080.  
  1081. Resize
  1082. {
  1083. // リサイズ開始
  1084. //1.00Fで追加
  1085.     PostMessage(text->hwndbase,WM_SYSCOMMAND,SC_SIZE,0);
  1086. }
  1087.  
  1088. Move
  1089. {
  1090. // 移動開始
  1091. //1.00Fで追加
  1092.     PostMessage(text->hwndbase,WM_SYSCOMMAND,SC_MOVE,0);
  1093. }
  1094.  
  1095. ScreenSave
  1096. {
  1097. // スクリーンセーバがコントロールパネルで設定してあれば起動
  1098. //1.00Fで追加
  1099.     PostMessage(text->hwndbase,WM_SYSCOMMAND,SC_SCREENSAVE,0);
  1100. }
  1101.  
  1102. Close
  1103. {
  1104. // 閉じる
  1105. //1.00Fで追加
  1106.     PostMessage(text->hwndbase,WM_SYSCOMMAND,SC_CLOSE,0);
  1107. }
  1108.  
  1109. BOOL TXCMDBASE uiQuitAllForce(TX* text)
  1110. {
  1111. // 全てのWZ窓を強制終了
  1112. // マクロを開発していてハングしたときにできる、
  1113. // 「ファイル|全てのWZ Editorを閉じる」を実行しても消えない幽霊ウィンドウを
  1114. // 閉じるためのコマンドです。
  1115.     if (question("全てのWZ窓を終了します。保存していないテキストは失われます。よろしいですか?") == IDYES) {
  1116.         wzlock(LOCK_WZPROCESS);//1.00H5 
  1117.         int i;
  1118.         for (i = 0;i < text->share->nOpen;i++) {
  1119.             PostMessage(text->share->tWzprocess[i].hwnd,WM_TXQUIT,0,0);
  1120.         }
  1121.         wzunlock(LOCK_WZPROCESS);//1.00H5 
  1122.         return TRUE;
  1123.     }
  1124.     return FALSE;
  1125. }
  1126.  
  1127. //2.90 
  1128. DoCaption
  1129. {
  1130.     wndtxDoCaption();
  1131. }
  1132.  
  1133. extern "outline" BOOL tlSetActive(TX* text);
  1134.  
  1135. static int GetModeFocus(void)
  1136. {
  1137. // -1:err 0:本文 1:サブ 2:アウトライン
  1138.     HWND hwndFocus = GetFocus();
  1139.     if (!hwndFocus) return -1;
  1140.     int modeFocus = 0;
  1141.     TX* textFrame = txGetFrame(text);
  1142.     if (textFrame->fOutline && GetParent(hwndFocus) == textFrame->hwndOutline) {
  1143.         modeFocus = 2;
  1144. #if 1//2.99C 970325 
  1145.     } else if (txIsFocusSub(text) == TRUE) {
  1146.         modeFocus = 1;
  1147.     } else {
  1148.         modeFocus = 0;
  1149.     }
  1150. #else
  1151.     } else if (text->hwndtext2) {
  1152.         modeFocus = text->fFocus2 ? 1 : 0;
  1153.     } else if (text->text2) {
  1154.         modeFocus = text->fMultiChild ? 1 : 0;
  1155.     }
  1156. #endif
  1157.     return modeFocus;
  1158. }
  1159.  
  1160. static void SetModeFocus(TX* textFrame,int modeFocus)
  1161. {
  1162.     switch(modeFocus) {
  1163.         case 0: {
  1164. #if 1//2.99C 970325 
  1165.             txSetFocusSub(text,FALSE);
  1166. #else
  1167.             if (text->hwndtext2) {
  1168.                 SetFocus(text->hwndtext);
  1169.             } else if (text->text2 && text->fMultiChild) {
  1170.                 SetFocus(text->text2->hwndtext);
  1171.             } else {
  1172.                 SetFocus(text->hwndtext);
  1173.             }
  1174. #endif
  1175.             break;
  1176.         }
  1177.         case 1: {
  1178. #if 1//2.99C 970325 
  1179.             txSetFocusSub(text,TRUE);
  1180. #else
  1181.             if (text->hwndtext2) {
  1182.                 SetFocus(text->hwndtext2);
  1183.             } else if (text->text2 && !text->fMultiChild) {
  1184.                 SetFocus(text->text2->hwndtext);
  1185.             } else {
  1186.                 SetFocus(text->hwndtext);
  1187.             }
  1188. #endif
  1189.             break;
  1190.         }
  1191.         case 2: {
  1192.             tlSetActive(text);
  1193.             break;
  1194.         }
  1195.     }
  1196. }
  1197.  
  1198. //2.93 
  1199. //3.00A4 970509 フォーカスを移動したかどうか返す
  1200. switchSub
  1201. {
  1202. // 本文/サブウィンドウ行き来
  1203.     int modeFocus = GetModeFocus();
  1204.     int modeFocus0 = modeFocus;//3.00A4 970509 
  1205. //statprintf("%d",modeFocus);wait(500);
  1206.     if (modeFocus < 0) return FALSE;
  1207.     BOOL fText2 = (text->hwndtext2 || text->text2);    // 分割中?
  1208.     TX* textFrame = txGetFrame(text);
  1209.     //
  1210.     modeFocus++;
  1211.     if (modeFocus == 3) modeFocus = 0;
  1212.     if (modeFocus == 1 && !fText2) {
  1213.         // text2がない場合
  1214.         modeFocus++;
  1215.     }
  1216.     if (modeFocus == 2 && !textFrame->fOutline) {
  1217.         modeFocus = 0;
  1218.     }
  1219.     //
  1220.     if (modeFocus == modeFocus0) {
  1221.         //3.00A4 970509 
  1222.         return FALSE;
  1223.     } else {
  1224.         SetModeFocus(textFrame,modeFocus);
  1225.         txDispLocate(textf);//2.96 970210 多重化時のウィンドウ切り替えで、スクロールバーのエレベータがフラッシュされなかった
  1226.         return TRUE;
  1227.     }
  1228. }
  1229.  
  1230. BOOL TXCMD biggerSub(TX* text)
  1231. {
  1232. // 本文/サブウィンドウ拡大
  1233.     TXBASE_CONTEXT* context = hwndbaseGetContext(text->hwndbase);
  1234.     BOOL fFocusSub = FALSE;
  1235.     if (text->hwndtext2) {
  1236.         if (GetFocus() == text->hwndtext2) {
  1237.             fFocusSub = TRUE;
  1238.         }
  1239.     } else if (text->text2) {
  1240.         if (text->fMultiChild) {
  1241.             fFocusSub = TRUE;
  1242.         }
  1243.     } else {
  1244.         return FALSE;
  1245.     }
  1246.     int rate = SendMessage(context->hwndPartition,WMPB_GETRATE,0,0);
  1247.     fFocusSub ? (rate -= 10) : (rate += 10);
  1248.     if (10 <= rate && rate <= 90) {
  1249. //statprintf("%d",rate);
  1250.         SendMessage(context->hwndPartition,WMPB_SETRATE,rate,0);
  1251.     }
  1252.     return TRUE;
  1253. }
  1254.  
  1255. closeSub
  1256. {
  1257. // サブウィンドウ閉じる
  1258.     int modeFocus = GetModeFocus();
  1259.     if (modeFocus == 2) {
  1260.         call("outline.sw");
  1261.         return TRUE;
  1262.     }
  1263.     if (txOp(text,TXOP_TXCLOSESUB,0,0)) {
  1264.         return TRUE;
  1265.     }
  1266.     if (text->fOutline) {
  1267.         call("outline.sw");
  1268.         return TRUE;
  1269.     }
  1270.     return FALSE;
  1271. }
  1272.  
  1273. #endif
  1274.