DictionaryDlg.cpp
上传用户:xztxsm
上传日期:2007-01-02
资源大小:23k
文件大小:47k
源码类别:

RichEdit

开发平台:

Visual C++

  1. // DictionaryDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Dictionary.h"
  5. #include "DictionaryDlg.h"
  6. #include "windows.h"
  7. #include "ddraw.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. //Globals
  14. #define MAXTEXT 50
  15. int dictLength, dictHeight;
  16. int cxScreen, cyScreen;
  17. long initx, inity;
  18. CPoint init;
  19. CDC * pCDC;
  20. CRect crect,rect;
  21. char buffer[100];
  22. char glob;
  23. CSize bitSize, bitSize_ro, bitSize_gr;
  24. CPoint bitPt, bitPt_ro, bitPt_gr;
  25. CWnd * pWnd;
  26. TC_ITEM TabCtrlItem;
  27. int lungime, lantet;
  28. char *pbufer, *antet, *pbuf;
  29. int w,h,W,H;
  30. CWnd * pButton;
  31. Ctopic * topica, * context, * prefix, * sufix, *tabactiv;
  32. Csearch *cautare;
  33. int nr_topica, nr_context, nr_prefix, nr_sufix, nractiv, nr_struct;
  34. CFile f;
  35. CFont font;
  36. CHARFORMAT2 cfr;
  37. CString find, input, title, oldinput;
  38. BOOL first, last, right_is_big, flg_search=FALSE;
  39. int contor_text=0;
  40. long car_current, car_activ, last_find=-1;
  41. int old_topic=-1;
  42. BOOL bIsMoving;
  43. CBrush myBrush, oldBrush, m_HollowBrush, m_BrushPat2, m_BrushPat3;
  44. BITMAP grstruct, rostruct;
  45. typedef struct
  46. {
  47. int contor_text;
  48. long car_current;
  49. long car_activ;
  50. int old_topic;
  51. long last_find;
  52. }CStackSearch;
  53. CStackSearch stiva[100];
  54. int index_stiva=-1;
  55. DDSURFACEDESC iDDSurfaceDesc;
  56. LPDIRECTDRAW        lpDD;
  57. LPDIRECTDRAW2       lpDD2;
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CDictionaryDlg dialog
  60. CDictionaryDlg::CDictionaryDlg(CWnd* pParent /*=NULL*/)
  61. : CDialog(CDictionaryDlg::IDD, pParent)
  62. {
  63. //{{AFX_DATA_INIT(CDictionaryDlg)
  64. // NOTE: the ClassWizard will add member initialization here
  65. //}}AFX_DATA_INIT
  66. m_hIcon = AfxGetApp()->LoadIcon(IDR_DICT);
  67. }
  68. void CDictionaryDlg::DoDataExchange(CDataExchange* pDX)
  69. {
  70. CDialog::DoDataExchange(pDX);
  71. //{{AFX_DATA_MAP(CDictionaryDlg)
  72. // NOTE: the ClassWizard will add DDX and DDV calls here
  73. //}}AFX_DATA_MAP
  74. }
  75. BEGIN_MESSAGE_MAP(CDictionaryDlg, CDialog)
  76. //{{AFX_MSG_MAP(CDictionaryDlg)
  77. ON_WM_PAINT()
  78. ON_BN_CLICKED(IDC_BUTONHELP, OnHelp)
  79. ON_BN_CLICKED(IDC_BUTONABOUT, OnAbout)
  80. ON_BN_CLICKED(IDC_BUTONCLOSE, OnClose)
  81. ON_WM_QUERYDRAGICON()
  82. ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab)
  83. ON_NOTIFY(EN_MSGFILTER, IDC_LEFT, OnMsgfilterLeft)
  84. ON_NOTIFY(EN_MSGFILTER, IDC_RIGHT, OnMsgfilterRight)
  85. ON_NOTIFY(EN_MSGFILTER, IDC_TOP, OnMsgfilterTop)
  86. ON_NOTIFY(EN_MSGFILTER, IDC_TAB, OnMsgfilterTab)
  87. ON_BN_CLICKED(IDC_BUTON, OnSwitch)
  88. ON_BN_CLICKED(IDC_SEARCHB, On_Search)
  89. // ON_EN_VSCROLL(IDC_LEFT, OnVscrollLeft)
  90. // ON_EN_VSCROLL(IDC_RIGHT, OnVscrollRight)
  91. ON_WM_LBUTTONDOWN()
  92. ON_WM_MOUSEMOVE()
  93. ON_WM_CHAR()
  94. ON_WM_ERASEBKGND()
  95. ON_WM_CTLCOLOR()
  96. ON_COMMAND(ID_BACK, OnBack)
  97. ON_COMMAND(ID_CLOSE, OnClose)
  98. //}}AFX_MSG_MAP
  99. END_MESSAGE_MAP()
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CDictionaryDlg message handlers
  102. BOOL CDictionaryDlg::OnInitDialog()
  103. {
  104. CDialog::OnInitDialog();
  105. HRESULT        ddrval;
  106. LPDIRECTDRAW   lpDD;
  107. m_hAccel = LoadAccelerators(AfxGetInstanceHandle(), 
  108.     MAKEINTRESOURCE(IDR_ACCELERATOR1));
  109. SetIcon(m_hIcon, TRUE); // Set big icon
  110. SetIcon(m_hIcon, FALSE); // Set small icon
  111. // set the new size of dialog in crect
  112. this->GetClientRect(&crect);
  113. cxScreen=GetSystemMetrics(SM_CXSCREEN);
  114. cyScreen=GetSystemMetrics(SM_CYSCREEN);
  115. dictLength=crect.Width();
  116. dictHeight=crect.Height();
  117. if(dictLength!=559&&dictHeight!=282)
  118. {
  119. dictLength=559;
  120. dictHeight=282;
  121. }
  122. this->SetWindowPos(NULL,(cxScreen-dictLength)/2,(cyScreen-dictHeight)/2,dictLength,dictHeight,SWP_SHOWWINDOW);
  123. // set the icon
  124. this->GetClientRect(&rect);
  125. rect.SetRect(0,0,32,32);
  126. m_hIcon=LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_DICT));
  127. InvalidateRect(&rect);
  128. // set the title
  129. BITMAP bmstruct;
  130. if(m_Bitmap.LoadBitmap(MAKEINTRESOURCE(IDB_TITLE)))
  131. {
  132. m_hBitmap=LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_TITLE));
  133. m_Bitmap.GetBitmap(&bmstruct);
  134. bitPt.x=(dictLength-bmstruct.bmWidth-120)/2;
  135. bitPt.y=bmstruct.bmHeight;
  136. bitPt.y=3;
  137. rect.SetRect(bitPt.x,bitPt.y,bmstruct.bmWidth,bmstruct.bmHeight);
  138. InvalidateRect(&rect);
  139. }
  140. //set the font for buttons
  141. font.DeleteObject();
  142. LOGFONT lf;
  143.  lf.lfHeight         = -15 ;
  144.      lf.lfWidth          = 0 ;
  145.      lf.lfEscapement     = 0 ;
  146.      lf.lfOrientation    = 0 ;
  147.      lf.lfWeight         = 700;//iAttributes & EZ_ATTR_BOLD      ? 700 : 0 ;
  148.      lf.lfItalic         = 0;//iAttributes & EZ_ATTR_ITALIC    ?   1 : 0 ;
  149.      lf.lfUnderline      = 0;//iAttributes & EZ_ATTR_UNDERLINE ?   1 : 0 ;
  150.      lf.lfStrikeOut      = 0;//iAttributes & EZ_ATTR_STRIKEOUT ?   1 : 0 ;
  151.      lf.lfCharSet        = 0 ;
  152.      lf.lfOutPrecision   = 0 ;
  153.      lf.lfClipPrecision  = 0 ;
  154.      lf.lfQuality        = 0 ;
  155.      lf.lfPitchAndFamily = 0 ;
  156.      strcpy (lf.lfFaceName, "arial") ;
  157.  font.CreateFontIndirect(&lf);
  158. // set the buttons:
  159. rect.SetRect(dictLength-25,0,dictLength-5,20);
  160. m_closeButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_ICON, rect, this, IDC_BUTONCLOSE);
  161. rect.SetRect(dictLength-75,0,dictLength-25,20);
  162. m_aboutButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_BITMAP, rect, this, IDC_BUTONABOUT);
  163. // m_aboutButton.SetFont(&font, TRUE);
  164. // m_aboutButton.SetWindowText("Help");
  165. rect.SetRect(dictLength-125,0,dictLength-75,20);
  166. m_helpButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_BITMAP, rect, this, IDC_BUTONHELP);
  167. /* CFont *Font1 = GetDlgItem(IDC_BUTONHELP)->GetFont();
  168. LOGFONT LogFont;
  169. Font1->GetLogFont(&LogFont);
  170. LogFont.lfHeight = 12;
  171. LogFont.lfWidth = 8;
  172. lstrcpy (LogFont.lfFaceName, "Times");
  173. CFont * Font2;
  174. Font2->CreateFontIndirect(&LogFont);
  175. GetDlgItem(IDC_BUTONHELP)->SetFont(Font2);
  176. m_aboutButton.SetWindowText("Help");
  177. */
  178.    
  179. m_hAbout = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_ABOUT)); 
  180. pButton = GetDlgItem(IDC_BUTONABOUT); 
  181. ::SendMessage(pButton->m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (WPARAM)m_hAbout); 
  182. m_hHelp = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_HELP)); 
  183. pButton = GetDlgItem(IDC_BUTONHELP); 
  184. ::SendMessage(pButton->m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (WPARAM)m_hHelp); 
  185. m_hIconClose = ::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_CLOSE)); 
  186. pButton = GetDlgItem(IDC_BUTONCLOSE); 
  187. ::SendMessage(pButton->m_hWnd, BM_SETIMAGE, IMAGE_ICON, (WPARAM)m_hIconClose); 
  188. //set ControlTab
  189. CSize newSize(50,20);
  190. rect.SetRect(-1,22,dictLength,46/*dictHeight*/);
  191. m_Tab.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_EX_TRANSPARENT, rect, this, IDC_TAB);
  192. TabCtrlItem.mask = TCIF_IMAGE;
  193. m_hList.Create(IDB_LIST,61,0,NULL);
  194. for (int i=0; i<7; i++)
  195. {
  196. TabCtrlItem.iImage=i;
  197. m_Tab.InsertItem(i,&TabCtrlItem);
  198. }
  199. m_Tab.SetImageList(&m_hList);
  200. // m_Tab.SetItemSize(newSize);
  201. m_Bmp.LoadBitmap(MAKEINTRESOURCE(IDB_PAT));
  202. VERIFY(m_HollowBrush.CreateStockObject(HOLLOW_BRUSH));
  203. // set the top richedit
  204. rect.SetRect(105, 51, dictLength-10, 71);
  205. m_Top.Create(ES_NOHIDESEL|WS_CHILD|WS_VISIBLE|ES_READONLY|ES_MULTILINE|WS_TABSTOP, rect, this, IDC_TOP);
  206. m_Top.SetFont(&font, TRUE);
  207.     m_Top.SetBackgroundColor(FALSE, RGB(192,192,192));
  208. // set the left richedit
  209. rect.SetRect(0,50,102,dictHeight-5);
  210. m_Left.CreateEx(WS_EX_TRANSPARENT, "RICHEDIT20A", "",
  211. ES_NOHIDESEL|WS_CHILD|WS_VISIBLE|ES_READONLY|
  212. ES_MULTILINE| ES_AUTOVSCROLL|
  213. WS_BORDER|WS_VSCROLL|WS_TABSTOP, rect, this, IDC_LEFT, NULL);
  214.          
  215. /* m_Left.Create( ES_NOHIDESEL|WS_CHILD|WS_VISIBLE|ES_READONLY|
  216. ES_MULTILINE| ES_AUTOVSCROLL|
  217. WS_BORDER|WS_VSCROLL|WS_TABSTOP, rect, this, IDC_LEFT);
  218. */
  219. pCDC=this->GetDC();
  220. // set the right richedit
  221. rect.SetRect(102,70,dictLength-5,dictHeight-5);
  222. m_Right.CreateEx(WS_EX_TRANSPARENT, "RICHEDIT20A", "", 
  223. ES_NOHIDESEL| WS_CHILD|WS_VISIBLE|ES_READONLY|
  224. ES_MULTILINE | ES_AUTOVSCROLL |
  225. WS_BORDER | WS_VSCROLL | WS_TABSTOP , rect, this, IDC_RIGHT, NULL);
  226. // m_Right.SetBackgroundColor(FALSE,RGB(255,255,193));
  227. // set the subtitle
  228. BITMAP bmstr;
  229. if(m_Prefixe.LoadBitmap(MAKEINTRESOURCE(IDB_RAD1)))
  230. {
  231. m_hPrefixe=LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_RAD1));
  232. m_Prefixe.GetBitmap(&bmstr);
  233. }
  234. pt.x=140;pt.y=140;
  235. sz.cx=250;sz.cy=20;
  236. rect.SetRect(pt.x,pt.y,pt.x+sz.cx,pt.y+sz.cy);
  237. // m_Prefixe.LoadBitmap(IDB_RAD1);
  238. // m_hPrefixe=LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_RAD1));
  239. // m_Subtitle.Create(NULL, WS_CHILD|WS_VISIBLE, rect, GetDlgItem(IDC_TAB), IDC_SUBTITLE);
  240. // m_Subtitle.SetFont(&font, TRUE);
  241. // m_Left.SetBackgroundColor(FALSE,RGB(255,255,193));
  242. m_Pat2.LoadBitmap(MAKEINTRESOURCE(IDB_PAT2));
  243. m_Pat3.LoadBitmap(MAKEINTRESOURCE(IDB_PAT3));
  244. m_BrushPat2.CreatePatternBrush(&m_Pat2);
  245. m_BrushPat3.CreatePatternBrush(&m_Pat3);
  246. long newBrush = myBrush.CreatePatternBrush(&m_Bmp);
  247. // HWND lefthwnd=m_Left.GetSafeHwnd();
  248. // long s = SetClassLong(lefthwnd, GCL_HBRBACKGROUND, newBrush);
  249. // DeleteObject((HBRUSH)SetClassLong(lefthwnd, GCL_HBRBACKGROUND, (LONG)CreateSolidBrush(RGB(255,255,193))));
  250. // rect.SetRect(0,50,102,dictHeight-5);
  251. // ::InvalidateRect(m_Left, &rect, TRUE);
  252. hMyCur=AfxGetApp()->LoadCursor(IDC_MYCUR);
  253. hMyCurTop=AfxGetApp()->LoadStandardCursor(IDC_ARROW);
  254. // load the bitmaps roman, greek
  255. if(m_Roman.LoadBitmap(MAKEINTRESOURCE(IDB_ROMAN)))
  256. {
  257. h_Roman=LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_ROMAN));
  258. m_Roman.GetBitmap(&rostruct);
  259. bitPt_ro.x=5;
  260. bitPt_ro.y=70;
  261. bitSize_ro.cy=rostruct.bmHeight;
  262. bitSize_ro.cx=rostruct.bmWidth;
  263. }
  264. if(m_Greek.LoadBitmap(MAKEINTRESOURCE(IDB_GREEK)))
  265. {
  266. h_Greek=LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_GREEK));
  267. m_Greek.GetBitmap(&grstruct);
  268. bitPt_gr.x=5;
  269. bitPt_gr.y=70;
  270. bitSize_gr.cy=grstruct.bmHeight;
  271. bitSize_gr.cx=grstruct.bmWidth;
  272. }
  273. // FlyOver
  274. m_tool.Create(this); 
  275. m_tool.AddTool(GetDlgItem(IDC_BUTONABOUT),"About"); 
  276. m_tool.AddTool(GetDlgItem(IDC_BUTONCLOSE),"Close"); 
  277. m_tool.AddTool(GetDlgItem(IDC_BUTONHELP),"Help"); 
  278. m_tool.Activate(TRUE);
  279. CHARFORMAT2 cf;
  280. cf.yHeight=220; //font x 20
  281. cf.dwMask=CFM_SIZE|CFM_BOLD|CFM_COLOR|CFM_FACE;
  282. cf.dwEffects=CFE_BOLD;
  283. cf.crTextColor=RGB(255,0,0);
  284. strcpy (cf.szFaceName, "arial") ;
  285. m_Left.SetDefaultCharFormat(cf);
  286. m_Right.GetDefaultCharFormat(cfr);
  287. cfr.yHeight=160; //font x 20
  288. cfr.dwMask=cfr.dwMask|CFM_SIZE|CFM_BOLD|CFM_FACE;
  289. cfr.dwEffects=CFE_BOLD;
  290. strcpy (cfr.szFaceName, "arial") ;
  291. m_Right.SetDefaultCharFormat(cfr);
  292. m_Right.GetDefaultCharFormat(cfr);
  293. // m_Left.SetBackgroundColor(FALSE,RGB(255,255,0));
  294. ::SendMessage(m_Left,  EM_SETEVENTMASK, 0,ENM_MOUSEEVENTS|ENM_SCROLLEVENTS|ENM_KEYEVENTS);
  295. ::SendMessage(m_Right, EM_SETEVENTMASK, 0,ENM_SCROLLEVENTS|ENM_KEYEVENTS);
  296. ::SendMessage(m_Top, EM_SETEVENTMASK, 0,ENM_MOUSEEVENTS);
  297. readTopic();//initializare tabele
  298. readPS(&m_Left, prefix, nr_prefix);//afisare prefixe
  299. Invalidate();
  300. m_Top.EnableWindow(FALSE);
  301. // this->SetWindowPos(&wndTopMost, 1, 2, 3, 4, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
  302.     
  303. /*
  304.      * create an IDirectDraw2 interface
  305.      */
  306. ddrval = DirectDrawCreate( NULL, &lpDD, NULL );
  307.     if( ddrval != DD_OK )
  308.         return FALSE;
  309. iDDSurfaceDesc.dwSize = sizeof(DDSURFACEDESC);
  310.     ddrval = lpDD->GetDisplayMode(&iDDSurfaceDesc);
  311. if( ddrval != DD_OK )
  312.         return FALSE;
  313. DWORD h = iDDSurfaceDesc.dwHeight;
  314. DWORD w = iDDSurfaceDesc.dwWidth;
  315. DWORD c = iDDSurfaceDesc.ddpfPixelFormat.dwRGBBitCount;
  316. if(h!=480 || w!=640 || c!=8)
  317. {
  318. AfxMessageBox("This program requires 640x480 resolution and 256 colors");
  319. /* ddrval = lpDD->SetCooperativeLevel(m_hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN);
  320. if( ddrval != DD_OK )
  321. return FALSE;
  322. ddrval = lpDD->SetDisplayMode(640, 480, 8);//640x480, 256 clrs
  323. if( ddrval != DD_OK )
  324. return FALSE;
  325. ddrval = lpDD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL);
  326. if( ddrval != DD_OK )
  327. return FALSE;
  328. //recenter
  329. cxScreen=GetSystemMetrics(SM_CXSCREEN);
  330. cyScreen=GetSystemMetrics(SM_CYSCREEN);
  331. dictLength=crect.Width();
  332. dictHeight=crect.Height();
  333. if(dictLength!=559&&dictHeight!=282)
  334. {
  335. dictLength=559;
  336. dictHeight=282;
  337. }
  338. this->SetWindowPos(NULL,(cxScreen-dictLength)/2,(cyScreen-dictHeight)/2,dictLength,dictHeight,SWP_SHOWWINDOW);
  339. */ }
  340. else return TRUE;
  341. return TRUE;
  342. }
  343. void read(pCRichEditCtrl m_ctrl, CString str)
  344. {
  345. CFileException e;
  346. CFile file;
  347. int l;
  348. if(!file.Open(str, CFile::modeRead, &e))
  349. {
  350. file.Close();
  351. m_ctrl->SetWindowText("Eroare de deschidere");
  352. }
  353. else 
  354. {
  355. l=file.GetLength();
  356. lungime=l;
  357. pbuf = new char[l];
  358. for (int i=0; i<l; i++)
  359. {
  360. pbuf[i]=' ';
  361. }
  362. pbuf[l] ='';
  363. file.Read(pbuf,l);
  364. m_ctrl->SetWindowText(pbuf);
  365. }
  366. }
  367. void readPS(pCRichEditCtrl m_ctrl, Ctopic * ct, int nrtop)
  368. {
  369. char * pchar;
  370. int i;
  371. tabactiv = ct;
  372. nractiv = nrtop;
  373. pbufer = new char[nrtop*MAXTEXT];
  374. for (i=0; i<nrtop*MAXTEXT; i++)
  375. {
  376. pbufer[i]=' ';
  377. }
  378. pbufer[nrtop*MAXTEXT] ='';
  379. for (i = 0, pchar=pbufer; i < nrtop; i++)
  380. {
  381. int j = sprintf(pchar,"%sn", ct->nume);
  382. pchar=pbufer+strlen(pbufer);
  383. ct+=1;
  384. }
  385. sprintf(pchar, " n");
  386. lungime = strlen(pbufer);
  387. m_ctrl->SetWindowText(pbufer);
  388. }
  389. void readRTF(CString str)
  390. {
  391. CFileException e;
  392. CFile file;
  393. int l;
  394. char * pb;
  395. if(!file.Open(str, CFile::modeRead, &e))
  396. {
  397. file.Close();
  398. AfxMessageBox("Eroare de deschidere a fisierului");
  399. }
  400. else 
  401. {
  402. l=file.GetLength();
  403. lungime=l;
  404. pb = new char[l];
  405. for (int i=0; i<l; i++)
  406. {
  407. pb[i]=' ';
  408. }
  409. pb[l] ='';
  410. file.Read(pb,l);
  411. }
  412. }
  413. BOOL CDictionaryDlg::OnEraseBkgnd(CDC* pDC)
  414. {
  415. int nColor;
  416. if(m_Tab)
  417. {
  418. nColor = m_Tab.GetCurSel();
  419. switch(nColor)
  420. {
  421. case 0:
  422. CDialog::OnEraseBkgnd(pDC);
  423. if(m_Left)
  424. {
  425. m_Left.GetClientRect(rect);
  426. rect.SetRect(0,50,102,dictHeight-5);
  427. pDC->FillRect(rect, &m_BrushPat2);
  428. rect.SetRect(0, 0, dictLength-5, 25);
  429. pDC->FillRect(rect, &m_BrushPat3);
  430. }
  431. if(m_Right)
  432. {
  433. m_Right.GetClientRect(rect);
  434. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  435. pDC->FillRect(rect, &myBrush);
  436. }
  437. return TRUE;
  438. case 1:
  439. CDialog::OnEraseBkgnd(pDC);
  440. if(m_Right)
  441. {
  442. m_Right.GetClientRect(rect);
  443. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  444. pDC->FillRect(rect, &myBrush);
  445. rect.SetRect(0, 0, dictLength-5, 25);
  446. pDC->FillRect(rect, &m_BrushPat3);
  447. }
  448. return TRUE;
  449. case 2:
  450. CDialog::OnEraseBkgnd(pDC);
  451. if(m_Right)
  452. {
  453. m_Right.GetClientRect(rect);
  454. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  455. pDC->FillRect(rect, &myBrush);
  456. rect.SetRect(0, 0, dictLength-5, 25);
  457. pDC->FillRect(rect, &m_BrushPat3);
  458. }
  459. return TRUE;
  460. case 3:
  461. CDialog::OnEraseBkgnd(pDC);
  462. if(m_Left)
  463. {
  464. m_Left.GetClientRect(rect);
  465. rect.SetRect(0,50,102,dictHeight-5);
  466. pDC->FillRect(rect, &m_BrushPat2);
  467. rect.SetRect(0, 0, dictLength-5, 25);
  468. pDC->FillRect(rect, &m_BrushPat3);
  469. }
  470. if(m_Right)
  471. {
  472. m_Right.GetClientRect(rect);
  473. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  474. pDC->FillRect(rect, &myBrush);
  475. }
  476. return TRUE;
  477. case 4:
  478. CDialog::OnEraseBkgnd(pDC);
  479. if(m_Right)
  480. {
  481. m_Right.GetClientRect(rect);
  482. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  483. pDC->FillRect(rect, &myBrush);
  484. rect.SetRect(0, 0, dictLength-5, 25);
  485. pDC->FillRect(rect, &m_BrushPat3);
  486. }
  487. return TRUE;
  488. case 5:
  489. CDialog::OnEraseBkgnd(pDC);
  490. if(m_Right)
  491. {
  492. m_Right.GetClientRect(rect);
  493. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  494. pDC->FillRect(rect, &myBrush);
  495. rect.SetRect(0, 0, dictLength-5, 25);
  496. pDC->FillRect(rect, &m_BrushPat3);
  497. }
  498. return TRUE;
  499. }
  500. if(m_Edit)
  501. {
  502. CDialog::OnEraseBkgnd(pDC);
  503. m_Right.GetClientRect(rect);
  504. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  505. pDC->FillRect(rect, &myBrush);
  506. rect.SetRect(0, 0, dictLength-5, 25);
  507. pDC->FillRect(rect, &m_BrushPat3);
  508. return TRUE;
  509. }
  510. if(right_is_big)
  511. {
  512. CDialog::OnEraseBkgnd(pDC);
  513. m_Right.GetClientRect(rect);
  514. rect.SetRect(0,73,dictLength-5,dictHeight-5);
  515. pDC->FillRect(rect, &myBrush);
  516. rect.SetRect(0, 0, dictLength-5, 25);
  517. pDC->FillRect(rect, &m_BrushPat3);
  518. return TRUE;
  519. }
  520. }
  521. return CWnd::OnEraseBkgnd(pDC);
  522. }
  523. void CDictionaryDlg::OnPaint() 
  524. {
  525. // pWnd = GetDlgItem(IDC_RIGHT);
  526. CPaintDC dc(this); //device context for painting
  527. // CDC * pCDC, *pDC;
  528. // pCDC=pWnd->GetDC();
  529. // pDC=m_Left.GetDC();
  530. // rect.SetRect(0,50,102,dictHeight-5);
  531. // pDC->FillRect(rect, &myBrush);
  532. if (IsIconic())
  533. {
  534. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  535. int cxIcon = GetSystemMetrics(SM_CXICON);
  536. int cyIcon = GetSystemMetrics(SM_CYICON);
  537. GetClientRect(&rect);
  538. int x = (rect.Width() - cxIcon + 1) / 2;
  539. int y = (rect.Height() - cyIcon + 1) / 2;
  540. dc.DrawIcon(x, y, m_hIcon);
  541. }
  542. else
  543. {
  544. CDialog::OnPaint();
  545. dc.DrawIcon(0,0,m_hIcon);
  546. dc.DrawState(bitPt, bitSize, m_Bitmap, DST_BITMAP|DSS_NORMAL, NULL);
  547. // rect.SetRect(0,0,dictLength-5, 57);
  548. // dc.FillRect(rect, &m_BrushPat3);
  549. }
  550. }
  551. HCURSOR CDictionaryDlg::OnQueryDragIcon()
  552. {
  553. return (HCURSOR) m_hIcon;
  554. }
  555. void CDictionaryDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult) 
  556. {
  557. int nColor = m_Tab.GetCurSel();
  558. CHARFORMAT2 cf;
  559. switch(nColor)
  560. {
  561. case 0:
  562. if(right_is_big)
  563. {
  564. m_Right.MoveWindow(102,70,dictLength-5,dictHeight-5);
  565. right_is_big=FALSE;
  566. }
  567. if(m_Left)
  568. {
  569. m_Left.DestroyWindow();
  570. CtrlCreate(&m_Left);
  571. }
  572. else
  573. CtrlCreate(&m_Left);
  574. if(m_Static_ro)
  575. m_Static_ro.DestroyWindow();
  576. if(m_Static_gr)
  577. m_Static_gr.DestroyWindow();
  578. cf.yHeight=220; //font x 20
  579. cf.dwMask=CFM_SIZE|CFM_BOLD|CFM_COLOR|CFM_FACE;
  580. cf.dwEffects=CFE_BOLD;
  581. cf.crTextColor=RGB(255,0,0);
  582. strcpy (cf.szFaceName, "arial") ;
  583. // m_Left.SetBackgroundColor(FALSE,RGB(255,255,193));
  584. m_Left.SetDefaultCharFormat(cf);
  585. readPS(&m_Left, prefix, nr_prefix);
  586. rect.SetRect(140,40,390,60);
  587. m_Right.SetWindowText(" ");
  588. m_Top.SetWindowText(" ");
  589. InvalidateRect(&rect);
  590. break;
  591. case 1://latin root
  592. if(right_is_big)
  593. {
  594. m_Right.MoveWindow(102,70,dictLength-107,dictHeight-75);
  595. right_is_big=FALSE;
  596. }
  597. if(m_Left)
  598. m_Left.DestroyWindow();
  599. if(m_Static_ro)
  600. m_Static_ro.DestroyWindow();
  601. if(m_Static_gr)
  602. m_Static_gr.DestroyWindow();
  603. AfisareContext("latin_roots");
  604. m_Right.LineScroll(-m_Right.GetLineCount(), 0);
  605. //draw image
  606. pWnd=this;
  607. rect.SetRect(bitPt_ro.x,bitPt_ro.y,bitPt_ro.x+rostruct.bmWidth,bitPt_ro.y+rostruct.bmHeight);
  608. m_Static_ro.Create(NULL, WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, rect, pWnd);
  609. m_Static_ro.SetBitmap(h_Roman);
  610. break;
  611. case 2://greek roots
  612. if(right_is_big)
  613. {
  614. m_Right.MoveWindow(102,70,dictLength-107,dictHeight-75);
  615. right_is_big=FALSE;
  616. }
  617. if(m_Left)
  618. m_Left.DestroyWindow();
  619. if(m_Static_ro)
  620. m_Static_ro.DestroyWindow();
  621. if(m_Static_gr)
  622. m_Static_gr.DestroyWindow();
  623. AfisareContext("greek_roots");
  624. m_Right.LineScroll(-m_Right.GetLineCount(), 0);
  625. //draw image
  626. //pWnd=GetDlgItem(IDC_TAB);
  627. pWnd=this;
  628. rect.SetRect(bitPt_gr.x,bitPt_gr.y,bitPt_gr.x+grstruct.bmWidth,bitPt_gr.y+grstruct.bmHeight);
  629. m_Static_gr.Create(NULL, WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, rect, pWnd);
  630. m_Static_gr.SetBitmap(h_Greek);
  631. break;
  632. case 3://suffix
  633. if(right_is_big)
  634. {
  635. m_Right.MoveWindow(102,70,dictLength-107,dictHeight-75);
  636. right_is_big=FALSE;
  637. }
  638. if(m_Left)
  639. {
  640. m_Left.DestroyWindow();
  641. CtrlCreate(&m_Left);
  642. }
  643. else
  644. CtrlCreate(&m_Left);
  645. if(m_Static_ro)
  646. m_Static_ro.DestroyWindow();
  647. if(m_Static_gr)
  648. m_Static_gr.DestroyWindow();
  649. cf.yHeight=220; //font x 20
  650. cf.dwMask=CFM_SIZE|CFM_BOLD|CFM_COLOR|CFM_FACE;
  651. cf.dwEffects=CFE_BOLD;
  652. cf.crTextColor=RGB(255,0,0);
  653. strcpy (cf.szFaceName, "arial") ;
  654. m_Left.SetDefaultCharFormat(cf);
  655. // m_Left.SetBackgroundColor(FALSE, RGB(255,255,193));
  656. readPS(&m_Left, sufix, nr_sufix);
  657. m_hPrefixe=LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_ERASE));
  658. rect.SetRect(140,40,390,60);
  659. m_Right.SetWindowText(" ");
  660. m_Top.SetWindowText(" ");
  661. InvalidateRect(&rect);
  662. break;
  663. case 4:
  664. if(right_is_big)
  665. {
  666. m_Right.MoveWindow(102,70,dictLength-107,dictHeight-75);
  667. right_is_big=FALSE;
  668. }
  669. if(m_Left)
  670. m_Left.DestroyWindow();
  671. if(m_Static_ro)
  672. m_Static_ro.DestroyWindow();
  673. if(m_Static_gr)
  674. m_Static_gr.DestroyWindow();
  675. AfisareContext("misfits");
  676. m_Right.LineScroll(-m_Right.GetLineCount(), 0);
  677. break;
  678. case 5:
  679. if(right_is_big)
  680. {
  681. m_Right.MoveWindow(102,70,dictLength-107,dictHeight-75);
  682. right_is_big=FALSE;
  683. }
  684. if(m_Left)
  685. m_Left.DestroyWindow();
  686. if(m_Static_ro)
  687. m_Static_ro.DestroyWindow();
  688. if(m_Static_gr)
  689. m_Static_gr.DestroyWindow();
  690. AfisareContext("confused");
  691. m_Right.LineScroll(-m_Right.GetLineCount(), 0);
  692. break;
  693. case 6:
  694. if(right_is_big)
  695. {
  696. m_Right.MoveWindow(102,70,dictLength-107,dictHeight-75);
  697. right_is_big=FALSE;
  698. }
  699. if(m_Static_ro)
  700. m_Static_ro.DestroyWindow();
  701. if(m_Static_gr)
  702. m_Static_gr.DestroyWindow();
  703. AfisRTF(" ", &m_Right);
  704. AfisRTF(" ", &m_Top);
  705. old_topic=-1;
  706. OnSwitch();
  707. flg_search=TRUE;
  708. if(m_Left)
  709. m_Left.DestroyWindow();
  710. if(!m_Result)
  711. {
  712. rect.SetRect(10,71,90,90);
  713. m_Result.Create(NULL,WS_CHILD|WS_VISIBLE|SS_SUNKEN|SS_CENTER,rect,this,IDC_REZ);
  714. m_Result.SetFont(&font, TRUE);
  715. m_Result.SetWindowText("Results:");
  716. }
  717. break;
  718. }
  719. *pResult = 0;
  720. Invalidate();
  721. }
  722. DWORD CALLBACK EditStreamCallBack(DWORD dwCookie, 
  723. LPBYTE pbBuff, //pointer la bufer de rw
  724. LONG cb, //nr de bytes rw
  725. LONG *pcb)//primeste nr de bytes rw
  726. {
  727. int val;
  728. CString *pstr = (CString *)dwCookie;
  729. val = pstr->GetLength();
  730. if( val < cb )
  731. {
  732. *pcb = val;
  733. memcpy(pbBuff, (LPCSTR)*pstr, *pcb );
  734. pstr->Empty();
  735. }
  736. else
  737. {
  738. *pcb = cb;
  739. memcpy( pbBuff, (LPCSTR)*pstr, *pcb ) ;
  740. *pstr = pstr->Right( val - cb ) ;
  741. }
  742. return 0;
  743. }
  744. DWORD CALLBACK EditStreamCallBackOut(DWORD dwCookie, 
  745. LPBYTE pbBuff, //pointer la bufer de rw
  746. LONG cb, //nr de bytes rw
  747. LONG *pcb)//primeste nr de bytes rw
  748. {
  749. int val;
  750. CString *pstr = (CString *)dwCookie;
  751. val = strlen((const char*)pbBuff);
  752. {
  753. *pcb = val;
  754. *pstr = (LPCSTR)pbBuff;
  755. }
  756. return 0;
  757. }
  758. void CDictionaryDlg::AfisRTF(char * pchar, CRichEditCtrlEx * m_ctrl)
  759. {
  760. CRect cr;
  761. CString stream=pchar;
  762. EDITSTREAM es;
  763. es.dwCookie=(DWORD)&stream;
  764. es.dwError=0;
  765. es.pfnCallback=EditStreamCallBack;
  766. m_ctrl->StreamIn(SF_RTF, es);
  767. Invalidate();
  768. }
  769. void CDictionaryDlg::On_Search()
  770. {
  771. /* first = TRUE;
  772. contor_text = 0;
  773. AfisRTF(" ", &m_Left);
  774. if(m_Edit)
  775. {
  776. m_Edit.GetWindowText(input);
  777. AfxMessageBox(input);
  778. }
  779. else
  780. AfxMessageBox("type a word or a part of it");
  781. find = input;
  782. */
  783. }
  784. //Enter was hit
  785. void CDictionaryDlg::OnOK()
  786. {
  787. BOOL nu_exista;
  788. do
  789. {
  790. if(first || last)
  791. contor_text=0;
  792. nu_exista=contor_text==0;
  793. for(; contor_text<nr_struct ;)
  794. {
  795. if(old_topic!=cautare[contor_text].nr_topica)
  796. {
  797. old_topic=cautare[contor_text].nr_topica;
  798. car_current=0;
  799. last_find=-1;
  800. car_activ=0;
  801. }
  802. if(gasit_text())
  803. {
  804. if(index_stiva < 99)
  805. index_stiva++;
  806. stiva[index_stiva].contor_text = contor_text;
  807. stiva[index_stiva].car_activ = car_activ;
  808. stiva[index_stiva].car_current = car_current;
  809. stiva[index_stiva].last_find = last_find;
  810. stiva[index_stiva].old_topic = old_topic;
  811. nu_exista=FALSE;
  812. AfisareTopica(cautare[contor_text].nr_topica);
  813. car_activ++;
  814. last=FALSE;
  815. break;
  816. }
  817. else
  818. last=TRUE;
  819. car_current+=cautare[contor_text].lungime_text;
  820. contor_text++;
  821. car_activ = 0;
  822. }
  823. first = FALSE;
  824. }
  825. while(last && !nu_exista);
  826. }
  827. void CDictionaryDlg::OnBack()
  828. {
  829. if(m_Edit)
  830. {
  831. if(index_stiva > 0)
  832. {
  833. index_stiva--;
  834. contor_text = stiva[index_stiva].contor_text;
  835. car_activ = stiva[index_stiva].car_activ;
  836. car_current = stiva[index_stiva].car_current;
  837. last_find = stiva[index_stiva].last_find;
  838. old_topic = stiva[index_stiva].old_topic;
  839. AfisareTopica(cautare[contor_text].nr_topica);
  840. car_activ++;
  841. last=FALSE;
  842. }
  843. }
  844. }
  845. BOOL CDictionaryDlg::gasit_text()
  846. {
  847. char * bufer;
  848. char aux;
  849. int i;
  850. int rez;
  851. bufer = new char[cautare[contor_text].lungime_text+1];
  852. f.Seek(cautare[contor_text].adresa_text, CFile::begin);
  853. f.Read(bufer, cautare[contor_text].lungime_text);
  854. OnReadDecript(bufer, cautare[contor_text].lungime_text);
  855. for(i=car_activ, rez=1; i<(cautare[contor_text].lungime_text-(int)strlen(find)+1); i++)
  856. {
  857. aux=bufer[i+strlen(input)];
  858. bufer[i+strlen(input)]=0;
  859. rez = strcmp(&bufer[i], input);
  860. bufer[i+strlen(input)]=aux;
  861. glob=aux;
  862. if(!rez)
  863. {
  864. car_activ=i;
  865. break;
  866. }
  867. }
  868. delete bufer;
  869. return rez==0;
  870. }
  871. void CDictionaryDlg::AfisareTopica(int l)
  872. {
  873. CFile tmp;
  874. FINDTEXTEX fnd;
  875. long find;
  876. BOOL flag=false;
  877. int cod, nrcar, inceput, sfirsit, lung_top;
  878. int nr_linie;
  879. char * title, * unu, * doi, * trei, * total;
  880. // char * pc;
  881. if(l>=2)
  882. l-=2;
  883. if(l >= nr_topica)
  884. AfxMessageBox("Eroare cautare");
  885. else
  886. {
  887. if(l>=0)
  888. {
  889. f.Seek(topica[l].address, CFile::begin);//pozitionare la inceput
  890. f.Read((char*)&cod, sizeof(cod));//citire cod, adresa
  891. OnReadDecript((char*)&cod, sizeof(cod));
  892. f.Read((char*)&nrcar, sizeof(nrcar));
  893. OnReadDecript((char*)&nrcar, sizeof(nrcar));
  894. title = new char[nrcar];
  895. f.Read(title, nrcar);
  896. OnReadDecript(title, nrcar);
  897. for(int s=0, flag=FALSE; s<nrcar; s++)
  898. {
  899. if((title[s]==' ')&&(title[s+1]=='\'))//primul spatiu cu /
  900. {
  901. if(!flag)
  902. inceput=s;//inceputul titlui
  903. flag=TRUE;
  904. }
  905. if(flag==TRUE && title[s]=='n')
  906. {
  907. sfirsit=s;//sfirsitul titlului
  908. break;
  909. }
  910. }
  911. delete title;
  912. f.Seek(topica[l].address+2*sizeof(int), CFile::begin);//pozitionare inceput
  913. title = new char[sfirsit+2];
  914. f.Read(title, sfirsit);
  915. OnReadDecript(title, sfirsit);
  916. title[sfirsit]='}';
  917. title[sfirsit+1]='';
  918. total=new char[sfirsit+lantet+2];
  919. strcpy(total, antet);
  920. strcat(total, title);
  921. /*
  922. tmp.Open("title.txt", CFile::modeCreate|CFile::modeWrite);
  923. tmp.Write(title, strlen(title));
  924. tmp.Close();
  925. tmp.Open("total.txt", CFile::modeCreate|CFile::modeWrite);
  926. tmp.Write(total, strlen(total));
  927. tmp.Close();
  928. */
  929. CDictionaryDlg::AfisRTF(total, &m_Top);
  930. delete title;
  931. delete total;
  932. //end afisare titlu in top richedit
  933. unu = new char[inceput];
  934. f.Seek(topica[l].address+2*sizeof(int), CFile::begin);
  935. f.Read(unu, inceput);//citire chestii pina inainte de titlu;
  936. OnReadDecript(unu, inceput);
  937. unu[inceput]='';
  938. doi = new char[nrcar-sfirsit];
  939. f.Seek(topica[l].address+2*sizeof(int)+sfirsit, CFile::begin);//pozitionare dupa titlu
  940. f.Read(doi, nrcar-sfirsit);
  941. OnReadDecript(doi, nrcar-sfirsit);
  942. doi[nrcar-sfirsit-2*sizeof(int)+1]='}';//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  943. doi[nrcar-sfirsit-2*sizeof(int)+2]='';
  944. trei = new char[nrcar-(sfirsit-inceput)+1+14];
  945. strcpy(trei, unu);
  946. strcat(trei, " \plain\b\fs22");
  947. strcat(trei, doi);
  948. total = new char[lantet+nrcar+14];
  949. strcpy(total, antet);
  950. strcat(total, trei);
  951. m_Right.GetDefaultCharFormat(cfr);
  952. cfr.yHeight=160; //font x 20
  953. cfr.dwMask=cfr.dwMask|CFM_SIZE|CFM_BOLD|CFM_FACE;
  954. cfr.dwEffects=CFE_BOLD;
  955. strcpy (cfr.szFaceName, "arial") ;
  956. m_Right.SetDefaultCharFormat(cfr);
  957. m_Right.GetDefaultCharFormat(cfr);
  958. CDictionaryDlg::AfisRTF(total, &m_Right);
  959. /* tmp.Open("trei.txt", CFile::modeCreate|CFile::modeWrite);
  960. tmp.Write(trei, strlen(trei));
  961. tmp.Close();
  962. tmp.Open("tdoi.txt", CFile::modeCreate|CFile::modeWrite);
  963. tmp.Write(doi, strlen(doi));
  964. tmp.Close();
  965. tmp.Open("tunu.txt", CFile::modeCreate|CFile::modeWrite);
  966. tmp.Write(unu, strlen(unu));
  967. tmp.Close();
  968. */
  969. if(flg_search)
  970. {
  971. lung_top=m_Top.LineLength();
  972. if(car_current+car_activ > lung_top)
  973. {
  974. fnd.lpstrText = (char*)(LPCSTR)input;
  975. fnd.chrg.cpMin = car_current+car_activ-lung_top;
  976. fnd.chrg.cpMax = nrcar;
  977. fnd.chrgText.cpMin = 0;
  978. fnd.chrgText.cpMax = nrcar;
  979. if(last_find > fnd.chrg.cpMin)
  980. fnd.chrg.cpMin = last_find+1;
  981. find = m_Right.FindText(FR_DOWN | FR_MATCHCASE, &fnd);
  982. EDITSTREAM esout;
  983. CString outtext;
  984. esout.dwCookie=(DWORD)&outtext;
  985. esout.dwError=0;
  986. esout.pfnCallback=EditStreamCallBackOut;
  987. m_Right.StreamOut(SF_TEXT, esout);
  988. /*
  989. tmp.Open("search.txt", CFile::modeCreate|CFile::modeWrite);
  990. tmp.Write(outtext, strlen(outtext));
  991. tmp.Close();
  992. */
  993. if(find == -1)
  994. find = car_current+car_activ-lung_top;
  995. last_find = find;
  996. nr_linie = m_Right.LineFromChar(find);
  997. m_Right.LineScroll(nr_linie, 0);
  998. Invalidate();
  999. m_Right.SetSel(find, find+strlen(input));
  1000. }
  1001. else
  1002. {
  1003. fnd.lpstrText = (char*)(LPCSTR)input;
  1004. fnd.chrg.cpMin = car_activ;
  1005. fnd.chrg.cpMax = lung_top;
  1006. if(last_find > fnd.chrg.cpMin)
  1007. fnd.chrg.cpMin = last_find+1;
  1008. find = m_Top.FindText(FR_DOWN | FR_MATCHCASE, &fnd);
  1009. if(find == -1)
  1010. find = car_activ;
  1011. last_find = find;
  1012. m_Top.SetSel(find, find+strlen(input));
  1013. }
  1014. }
  1015. delete trei;
  1016. delete total;
  1017. }
  1018. }
  1019. }
  1020. void CDialog::OnCancel(){}
  1021. void CDictionaryDlg::OnHelp() 
  1022. {
  1023. if(!m_Edit)
  1024. {
  1025. m_Tab.SetCurSel(6);
  1026. if(m_Left)
  1027. m_Left.DestroyWindow();
  1028. m_Right.MoveWindow(0,70,dictLength-5,dictHeight-75);
  1029. right_is_big=TRUE;
  1030. AfisareContext("intro");
  1031. m_Right.LineScroll(-m_Right.GetLineCount(), 0);
  1032. }
  1033. if(m_Static_ro)
  1034. m_Static_ro.DestroyWindow();
  1035. if(m_Static_gr)
  1036. m_Static_gr.DestroyWindow();
  1037. /*
  1038. read(&m_Right, "afi.txt");
  1039. CString stream=pbuf;
  1040. EDITSTREAM es;
  1041. es.dwCookie=(DWORD)&stream;
  1042. es.dwError=0;
  1043. es.pfnCallback=EditStreamCallBack;
  1044. m_Right.StreamIn(SF_RTF,es);
  1045. */
  1046. }
  1047. void CDictionaryDlg::OnAbout() 
  1048. {
  1049. AfxMessageBox("Dictionary ver 1.0", MB_ICONINFORMATION);
  1050. }
  1051. void CDictionaryDlg::OnClose()
  1052. {
  1053. this->DestroyWindow();
  1054. exit(0);
  1055. }
  1056. void CDictionaryDlg::Afisare(int l)
  1057. {
  1058. CFile tmp;
  1059. BOOL flag=false;
  1060. int cod, nrcar, inceput, sfirsit;
  1061. char * title, * unu, * doi, * trei, * total;
  1062. // char * pc;
  1063. if(l >= nractiv)
  1064. AfxMessageBox("Eroare cautare");
  1065. else
  1066. {
  1067. f.Seek(tabactiv[l].address, CFile::begin);//pozitionare la inceput
  1068. f.Read((char*)&cod, sizeof(cod));//citire cod, adresa
  1069. OnReadDecript((char*)&cod, sizeof(cod));
  1070. f.Read((char*)&nrcar, sizeof(nrcar));
  1071. OnReadDecript((char*)&nrcar, sizeof(nrcar));
  1072. title = new char[nrcar];
  1073. f.Read(title, nrcar);
  1074. OnReadDecript(title, nrcar);
  1075. for(int s=0, flag=FALSE; s<nrcar; s++)
  1076. {
  1077. if((title[s]==' ')&&(title[s+1]=='\'))//primul spatiu cu /
  1078. {
  1079. if(!flag)
  1080. inceput=s;//inceputul titlului
  1081. flag=TRUE;
  1082. }
  1083. if(flag==TRUE && title[s]=='n')
  1084. {
  1085. sfirsit=s;//sfirsitul titlului
  1086. break;
  1087. }
  1088. }
  1089. delete title;
  1090. f.Seek(tabactiv[l].address+2*sizeof(int), CFile::begin);//pozitionare inceput
  1091. title = new char[sfirsit+2];
  1092. f.Read(title, sfirsit);
  1093. OnReadDecript(title, sfirsit);
  1094. title[sfirsit]='}';
  1095. title[sfirsit+1]='';
  1096. total=new char[sfirsit+lantet+2];
  1097. strcpy(total, antet);
  1098. strcat(total, title);
  1099. /*
  1100. tmp.Open("title.txt", CFile::modeCreate|CFile::modeWrite);
  1101. tmp.Write(title, strlen(title));
  1102. tmp.Close();
  1103. tmp.Open("total.txt", CFile::modeCreate|CFile::modeWrite);
  1104. tmp.Write(total, strlen(total));
  1105. tmp.Close();
  1106. */
  1107. CDictionaryDlg::AfisRTF(total, &m_Top);
  1108. delete title;
  1109. delete total;
  1110. //end afisare titlu in top richedit
  1111. unu = new char[inceput];
  1112. f.Seek(tabactiv[l].address+2*sizeof(int), CFile::begin);
  1113. f.Read(unu, inceput);//citire chestii pina inainte de titlu;
  1114. OnReadDecript(unu, inceput);
  1115. unu[inceput]='';
  1116. doi = new char[nrcar-sfirsit];
  1117. f.Seek(tabactiv[l].address+2*sizeof(int)+sfirsit, CFile::begin);//pozitionare dupa titlu
  1118. f.Read(doi, nrcar-sfirsit);
  1119. OnReadDecript(doi, nrcar-sfirsit);
  1120. doi[nrcar-sfirsit-2*sizeof(int)+1]='}';//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1121. doi[nrcar-sfirsit-2*sizeof(int)+2]='';
  1122. trei = new char[nrcar-(sfirsit-inceput)+1+14];
  1123. strcpy(trei, unu);
  1124. strcat(trei, " \plain\b\fs22");
  1125. strcat(trei, doi);
  1126. total = new char[lantet+nrcar+14];
  1127. strcpy(total, antet);
  1128. strcat(total, trei);
  1129. m_Right.GetDefaultCharFormat(cfr);
  1130. cfr.yHeight=160; //font x 20
  1131. cfr.dwMask=cfr.dwMask|CFM_SIZE|CFM_BOLD|CFM_FACE;
  1132. cfr.dwEffects=CFE_BOLD;
  1133. strcpy (cfr.szFaceName, "arial") ;
  1134. m_Right.SetDefaultCharFormat(cfr);
  1135. m_Right.GetDefaultCharFormat(cfr);
  1136. CDictionaryDlg::AfisRTF(total, &m_Right);
  1137. /* tmp.Open("total.txt", CFile::modeCreate|CFile::modeWrite);
  1138. tmp.Write(total, strlen(total));
  1139. tmp.Close();
  1140. tmp.Open("trei.txt", CFile::modeCreate|CFile::modeWrite);
  1141. tmp.Write(trei, strlen(trei));
  1142. tmp.Close();
  1143. tmp.Open("tdoi.txt", CFile::modeCreate|CFile::modeWrite);
  1144. tmp.Write(doi, strlen(doi));
  1145. tmp.Close();
  1146. tmp.Open("tunu.txt", CFile::modeCreate|CFile::modeWrite);
  1147. tmp.Write(unu, strlen(unu));
  1148. tmp.Close();
  1149. */
  1150. delete trei;
  1151. delete total;
  1152. }
  1153. }
  1154. void CDictionaryDlg::OnMsgfilterTab(NMHDR* pNMHDR, LRESULT* pResult)
  1155. {
  1156. MSGFILTER *pMsgFilter = reinterpret_cast<MSGFILTER *>(pNMHDR);
  1157. CPoint punct;
  1158. long xPos,yPos;
  1159. CRect tabrect;
  1160. m_Tab.GetItemRect(0, &tabrect);
  1161. if(pMsgFilter->msg==WM_LBUTTONDOWN)
  1162. {
  1163. yPos = HIWORD(pMsgFilter->lParam);
  1164. xPos = LOWORD(pMsgFilter->lParam);
  1165. }
  1166. *pResult = 0;
  1167. }
  1168. void CDictionaryDlg::OnMsgfilterLeft(NMHDR* pNMHDR, LRESULT* pResult)
  1169. {
  1170. MSGFILTER *pMsgFilter = reinterpret_cast<MSGFILTER *>(pNMHDR);
  1171. int i=0,j,k,l;
  1172. CPoint punct;
  1173. char buff[20];
  1174. long xPos,yPos;
  1175. SetCursor(hMyCur);
  1176. if(pMsgFilter->msg==WM_VSCROLL)
  1177. {
  1178. m_Left.GetRect(&rect);
  1179. rect.SetRect(0,50,102,dictHeight-5);
  1180. InvalidateRect(&rect);
  1181. }
  1182. if(pMsgFilter->msg==WM_KEYDOWN)
  1183. {
  1184. m_Left.GetRect(&rect);
  1185. rect.SetRect(0,50,102,dictHeight-5);
  1186. InvalidateRect(&rect);
  1187. }
  1188. if(pMsgFilter->msg==WM_LBUTTONUP)
  1189. {
  1190. yPos = HIWORD(pMsgFilter->lParam);
  1191. xPos = LOWORD(pMsgFilter->lParam);
  1192. for (k=0, j=0, l=-2; k<lungime; k++)
  1193. {
  1194. if(k==0 || (pbufer[k-1]=='n' && k>0))
  1195. {
  1196. l++;
  1197. punct=m_Left.GetCharPos(k);
  1198. if(punct.y > yPos)
  1199. break;
  1200. else 
  1201. j=k;
  1202. }
  1203. }
  1204. if (k>=lungime)
  1205. {
  1206. // AfxMessageBox("Nu s-a gasit cuvintul");
  1207. }
  1208. else 
  1209. {
  1210. for(i=j; i < k && pbufer[i]!='n'; i++)
  1211. buff[i-j]=pbufer[i];
  1212. buff[i-j]=0;
  1213. Afisare(l>=0?l:0);
  1214. }
  1215. if(j<i)
  1216. m_Left.SetSel(j,i);
  1217. }
  1218. *pResult = 0;
  1219. }
  1220. void CDictionaryDlg::OnMsgfilterRight(NMHDR* pNMHDR, LRESULT* pResult)
  1221. {
  1222. MSGFILTER *pMsgFilter = reinterpret_cast<MSGFILTER *>(pNMHDR);
  1223. if(pMsgFilter->msg==WM_VSCROLL)
  1224. {
  1225. m_Right.GetRect(&rect);
  1226. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  1227. InvalidateRect(&rect);
  1228. }
  1229. if(pMsgFilter->msg==WM_KEYDOWN)
  1230. {
  1231. m_Right.GetRect(&rect);
  1232. rect.SetRect(105,73,dictLength-5,dictHeight-5);
  1233. InvalidateRect(&rect);
  1234. }
  1235. *pResult = 0;
  1236. }
  1237. //preluarea textului introdus pt cautare
  1238. void CDictionaryDlg::OnMsgfilterTop(NMHDR* pNMHDR, LRESULT* pResult)
  1239. {
  1240. MSGFILTER *pMsgFilter = reinterpret_cast<MSGFILTER *>(pNMHDR);
  1241. SetCursor(hMyCurTop);
  1242. if(pMsgFilter->msg==WM_KEYUP)
  1243. {
  1244. m_Edit.GetWindowText(input);
  1245. if(oldinput!=input)
  1246. {
  1247. index_stiva=-1;
  1248. first = TRUE;
  1249. }
  1250. oldinput = input;
  1251. }
  1252. *pResult = 0;
  1253. }
  1254. void CDictionaryDlg::OnSwitch()
  1255. {
  1256. if(!m_Left)
  1257. CtrlCreate(&m_Left);
  1258. if(m_Result)
  1259. m_Result.DestroyWindow();
  1260. //envelope
  1261. if(m_Frame && m_Line)
  1262. {
  1263. m_Frame.DestroyWindow();
  1264. m_Line.DestroyWindow();
  1265. }
  1266. else
  1267. {
  1268. pButton = GetDlgItem(IDC_TAB);
  1269. rect.SetRect(3,5,dictLength-285,27);
  1270. m_Frame.Create(NULL,WS_CHILD|WS_VISIBLE|SS_SUNKEN,rect,pButton,IDC_FRAME);
  1271. rect.SetRect(0,51,dictLength-5,52);
  1272. m_Line.Create("NULL",WS_CHILD|WS_VISIBLE|SS_SUNKEN,rect,this,IDC_LINE);
  1273. }
  1274. //static text 
  1275. if(m_tStatic)
  1276. m_tStatic.DestroyWindow();
  1277. else
  1278. {
  1279. pButton = GetDlgItem(IDC_TAB);
  1280. rect.SetRect(10,6,250,26);
  1281. m_tStatic.Create(NULL, WS_CHILD|WS_VISIBLE,rect,pButton,IDC_FUNDAL);
  1282. m_tStatic.SetFont(&font, TRUE);
  1283. m_tStatic.SetWindowText("X       Type a word or a part of it:");
  1284. }
  1285. //edit control for search
  1286. if(m_Edit)
  1287. m_Edit.DestroyWindow();
  1288. else
  1289. {
  1290. pButton = GetDlgItem(IDC_TAB);
  1291. rect.SetRect(260,3,dictLength-5,29);
  1292. m_Edit.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|ES_WANTRETURN, rect, pButton, IDC_TOP);
  1293. m_Edit.SetFont(&font, TRUE);
  1294. m_Edit.SetBackgroundColor(FALSE,RGB(0,255,255));
  1295. m_Edit.SetFocus();
  1296. ::SendMessage(m_Edit, EM_SETEVENTMASK, 0,ENM_KEYEVENTS);
  1297. oldinput="";
  1298. }
  1299. //tab control
  1300. if(m_Tab.GetItemCount()!=0)
  1301. {
  1302. m_Tab.DeleteAllItems();
  1303. m_Tab.MoveWindow(-1,22,dictLength,30);
  1304. }
  1305. else
  1306. {
  1307. m_Tab.MoveWindow(-1,22,dictLength,24);
  1308. m_Tab.SetImageList(&m_hList);
  1309. if(!m_Tab.GetItem(0,&TabCtrlItem))
  1310. {
  1311. for (int i=0; i<7; i++)
  1312. {
  1313. TabCtrlItem.iImage=i;
  1314. m_Tab.InsertItem(i,&TabCtrlItem);
  1315. }
  1316. }
  1317. CHARFORMAT2 cf;
  1318. cf.yHeight=220; //font x 20
  1319. cf.dwMask=CFM_SIZE|CFM_BOLD|CFM_COLOR|CFM_FACE;
  1320. cf.dwEffects=CFE_BOLD;
  1321. cf.crTextColor=RGB(255,0,0);
  1322. strcpy (cf.szFaceName, "arial") ;
  1323. m_Left.SetDefaultCharFormat(cf);
  1324. readPS(&m_Left, prefix, nr_prefix);
  1325. }
  1326. flg_search=FALSE;
  1327. Invalidate();
  1328. }
  1329. void readTopic()
  1330. {
  1331. int cod, dim;
  1332. struct{
  1333. long topici;
  1334. long contexte;
  1335. long prefixe;
  1336. long sufixe;
  1337. long cautare;
  1338. }fine;
  1339. CFileException e;
  1340. if(f.Open("nume.mnt", CFile::modeRead, &e))
  1341. {
  1342. f.Seek(-5*(int)sizeof(long), CFile::end);
  1343. int r = f.Read(&fine.topici,4);
  1344. OnReadDecript((char*)&fine.topici,4);
  1345.   r = f.Read(&fine.contexte,4);
  1346. OnReadDecript((char*)&fine.contexte,4);
  1347. r = f.Read(&fine.prefixe,4);
  1348. OnReadDecript((char*)&fine.prefixe,4);
  1349. r = f.Read(&fine.sufixe,4);
  1350. OnReadDecript((char*)&fine.sufixe,4);
  1351. r = f.Read(&fine.cautare,4);
  1352. OnReadDecript((char*)&fine.cautare,4);
  1353. }
  1354. else
  1355. AfxMessageBox("Eroare deschidere");
  1356. initTabela(&topica, &nr_topica, fine.topici);
  1357. initTabela(&context, &nr_context, fine.contexte);
  1358. initTabela(&prefix, &nr_prefix, fine.prefixe);
  1359. initTabela(&sufix, &nr_sufix, fine.sufixe);
  1360. initTabelaSearch(&cautare, fine.cautare, &nr_struct);
  1361. f.Seek(0L,CFile::begin);
  1362. f.Read((char*)&cod, sizeof(cod));
  1363. OnReadDecript((char*)&cod, sizeof(cod));
  1364. f.Read((char*)&dim, sizeof(dim));
  1365. OnReadDecript((char*)&dim, sizeof(dim));
  1366. antet = new char[dim];
  1367. f.Read(antet, dim - 2*(sizeof(cod)));
  1368. OnReadDecript(antet, dim - 2*(sizeof(cod)));
  1369. lantet=dim-2*(sizeof(cod));
  1370. antet[lantet] = 0;
  1371. }
  1372. void initTabela(Ctopic ** pTopic, int * nr, long offset)
  1373. {
  1374. Ctopic man, *paux;
  1375. WORD dim;
  1376. int i;
  1377. f.Seek(offset, CFile::begin);
  1378. f.Read(&dim, sizeof(int));
  1379. OnReadDecript((char*)&dim, sizeof(int));
  1380. *nr = dim;
  1381. *pTopic = new Ctopic[dim];
  1382. UINT cit = sizeof(man.nume);
  1383. for (i=0, paux=*pTopic; i<dim; i++/*, paux+=sizeof(Ctopic)*/)
  1384. {
  1385. if(f.Read(man.nume, sizeof(man.nume))!=sizeof(man.nume))
  1386. {
  1387. AfxMessageBox("Desincronizare pe citire Ctopic.nume");
  1388. return;
  1389. }
  1390. else
  1391. OnReadDecript(man.nume, sizeof(man.nume));
  1392. if(f.Read((char*)&man.nr, sizeof(man.nr))!=sizeof(man.nr))
  1393. {
  1394. AfxMessageBox("Desincronizare pe citire Ctopic.numar");
  1395. return;
  1396. }
  1397. else
  1398. OnReadDecript((char*)&man.nr, sizeof(man.nr));
  1399. if(f.Read((char*)&man.address, sizeof(man.address))!=sizeof(man.address))
  1400. {
  1401. AfxMessageBox("Desincronizare pe citire Ctopic.adresa");
  1402. return;
  1403. }
  1404. else
  1405. OnReadDecript((char*)&man.address, sizeof(man.address));
  1406. paux[i].nr = man.nr;
  1407. paux[i].address = man.address;
  1408. for (int j =0; j<MAXTEXT; j++)
  1409. paux[i].nume[j] = man.nume[j];
  1410. }
  1411. }
  1412. void initTabelaSearch(Csearch **pCsearch, long offset, int * nr_struct)
  1413. {
  1414. Csearch man, *paux;
  1415. WORD dim;
  1416. int i;
  1417. f.Seek(offset, CFile::begin);
  1418. f.Read(&dim, sizeof(int));
  1419. OnReadDecript((char*)&dim, sizeof(int));
  1420. *nr_struct = dim;
  1421. *pCsearch = new Csearch[dim];
  1422. UINT cit = sizeof(man.nr_topica);
  1423. for (i=0, paux=*pCsearch; i<dim; i++/*, paux+=sizeof(Ctopic)*/)
  1424. {
  1425. if(f.Read((char*)&man.nr_topica, sizeof(man.nr_topica))!=sizeof(man.nr_topica))
  1426. {
  1427. AfxMessageBox("Desincronizare pe citire Csearch.nr_topica");
  1428. return;
  1429. }
  1430. else
  1431. OnReadDecript((char*)&man.nr_topica, sizeof(man.nr_topica));
  1432. if(f.Read((char*)&man.adresa_text, sizeof(man.adresa_text))!=sizeof(man.adresa_text))
  1433. {
  1434. AfxMessageBox("Desincronizare pe citire Csearch.adresa_text");
  1435. return;
  1436. }
  1437. else
  1438. OnReadDecript((char*)&man.adresa_text, sizeof(man.adresa_text));
  1439. if(f.Read((char*)&man.lungime_text, sizeof(man.lungime_text))!=sizeof(man.lungime_text))
  1440. {
  1441. AfxMessageBox("Desincronizare pe citire Csearch.lungime_text");
  1442. return;
  1443. }
  1444. else
  1445. OnReadDecript((char*)&man.lungime_text, sizeof(man.lungime_text));
  1446. paux[i].nr_topica = man.nr_topica;
  1447. paux[i].adresa_text = man.adresa_text;
  1448. paux[i].lungime_text = man.lungime_text;
  1449. }
  1450. }
  1451. //functia de afisare apelata din ctrltab
  1452. void CDictionaryDlg::AfisareContext(CString string)
  1453. {
  1454. Ctopic *top;
  1455. CFile tmp;
  1456. char * title, * total, * unu, * doi, * trei;
  1457. int i,cod,nrcar,inceput,sfirsit;
  1458. tabactiv = context;
  1459. for(i=0, top=context; i<nr_context; i++)
  1460. {
  1461. if(!strcmp(top[i].nume, string))
  1462. break;
  1463. }
  1464. if(i >= nr_context)
  1465. AfxMessageBox("Eroare pe cautare");
  1466. else
  1467. {
  1468. f.Seek(tabactiv[i].address, CFile::begin);
  1469. f.Read((char*)&cod, sizeof(cod));//initializare cod si nrcar
  1470. OnReadDecript((char*)&cod, sizeof(cod));
  1471. f.Read((char*)&nrcar, sizeof(nrcar));
  1472. OnReadDecript((char*)&nrcar, sizeof(nrcar));
  1473. // if(string=="misfits")
  1474. // nrcar=790;
  1475. title = new char[nrcar];
  1476. f.Read(title, nrcar);
  1477. OnReadDecript(title, nrcar);
  1478. /*
  1479. tmp.Open("unu.txt", CFile::modeCreate|CFile::modeWrite);
  1480. tmp.Write(title, strlen(title));
  1481. tmp.Close();
  1482. */
  1483. for(int s=0,flag=FALSE; s<nrcar; s++)
  1484. {
  1485. if((title[s]==' ')&&(title[s+1]=='\'))//primul spatiu cu '_'
  1486. {
  1487. if(!flag)
  1488. inceput=s;//inceputul titlului
  1489. flag=TRUE;
  1490. }
  1491. if(flag==TRUE && title[s]=='M' && title[s+1]=='i')
  1492. {
  1493. sfirsit=s+7;
  1494. break;
  1495. }
  1496. if(flag==TRUE && title[s]=='G' && title[s+1]=='r')
  1497. {
  1498. sfirsit=s+11;
  1499. break;
  1500. }
  1501. if(flag==TRUE && title[s]=='L' && title[s+1]=='a')
  1502. {
  1503. sfirsit=s+11;
  1504. break;
  1505. }
  1506. if(flag==TRUE && title[s]=='W' && title[s+1]=='o')
  1507. {
  1508. sfirsit=s+20;
  1509. break;
  1510. }
  1511. if(flag==TRUE && title[s]=='i' && title[s+1]=='n')
  1512. {
  1513. sfirsit=s+12;
  1514. break;
  1515. }
  1516. }
  1517. delete title;
  1518. f.Seek(tabactiv[i].address+2*sizeof(int), CFile::begin);//pozitionare inceput
  1519. title = new char[sfirsit+2];
  1520. f.Read(title, sfirsit);
  1521. OnReadDecript(title, sfirsit);
  1522. title[sfirsit]='}';
  1523. title[sfirsit+1]='';
  1524. total=new char[sfirsit+lantet+2];
  1525. strcpy(total, antet);
  1526. strcat(total, title);
  1527. /*
  1528. tmp.Open("afis.txt", CFile::modeCreate|CFile::modeWrite);
  1529. tmp.Write(total, strlen(total));
  1530. tmp.Close();
  1531. */
  1532. CDictionaryDlg::AfisRTF(total, &m_Top);
  1533. delete total;
  1534. //********************************************end afisare titlu;
  1535. unu = new char[inceput];
  1536. f.Seek(tabactiv[i].address+2*sizeof(int), CFile::begin);
  1537. f.Read(unu, inceput);//citire chestii pina inainte de titlu;
  1538. OnReadDecript(unu, inceput);
  1539. unu[inceput]='';
  1540. doi = new char[nrcar-sfirsit];
  1541. f.Seek(tabactiv[i].address+2*sizeof(int)+sfirsit, CFile::begin);//pozitionare dupa titlu
  1542. f.Read(doi, nrcar-sfirsit);
  1543. OnReadDecript(doi, nrcar-sfirsit);
  1544. doi[nrcar-sfirsit-2*sizeof(int)+1]='}';
  1545. doi[nrcar-sfirsit-2*sizeof(int)+2]='';
  1546. trei = new char[nrcar-(sfirsit-inceput)+1];
  1547. strcpy(trei, unu);
  1548. strcat(trei, doi);
  1549. total = new char[lantet+nrcar];
  1550. strcpy(total, antet);
  1551. strcat(total, trei);
  1552. m_Right.GetDefaultCharFormat(cfr);
  1553. cfr.yHeight=160; //font x 20
  1554. cfr.dwMask=cfr.dwMask|CFM_SIZE|CFM_BOLD|CFM_FACE;
  1555. cfr.dwEffects=CFE_BOLD;
  1556. strcpy (cfr.szFaceName, "arial") ;
  1557. m_Right.SetDefaultCharFormat(cfr);
  1558. m_Right.GetDefaultCharFormat(cfr);
  1559. CDictionaryDlg::AfisRTF(total, &m_Right);
  1560. /* tmp.Open("afis3.txt", CFile::modeCreate|CFile::modeWrite);
  1561. tmp.Write(trei, strlen(trei));
  1562. tmp.Close();
  1563. tmp.Open("afis2.txt", CFile::modeCreate|CFile::modeWrite);
  1564. tmp.Write(doi, strlen(doi));
  1565. tmp.Close();
  1566. tmp.Open("afis1.txt", CFile::modeCreate|CFile::modeWrite);
  1567. tmp.Write(unu, strlen(unu));
  1568. tmp.Close();
  1569. delete trei;
  1570. delete total;
  1571. */ }
  1572. }
  1573. void CDictionaryDlg::OnLButtonDown(UINT nFlags, CPoint point) 
  1574. {
  1575. /* bIsMoving = FALSE;
  1576. if(point.x>0 && point.x<dictLength && point.y>0 && point.y <20)
  1577. {
  1578. GetCursorPos(&init);
  1579. initx=point.x;
  1580. inity=point.y;
  1581. bIsMoving = TRUE;
  1582. }
  1583. */
  1584. CRect cr, crbig;
  1585. long xPos, yPos;
  1586. CPoint punctst, punctdr, punctSt;
  1587. if(m_tStatic)
  1588. {
  1589. m_tStatic.GetWindowRect(&cr);//L=240; H=20;
  1590. xPos=point.x;
  1591. yPos=point.y;
  1592. this->GetWindowRect(&crbig);
  1593. punctSt = crbig.TopLeft();
  1594. punctst = cr.TopLeft();
  1595. punctdr = cr.BottomRight();
  1596. if(xPos > -punctSt.x+punctst.x && xPos< -punctSt.x+punctdr.x && yPos<-punctSt.y+punctdr.y && yPos>-punctSt.y+punctst.y)
  1597. {
  1598. OnSwitch();
  1599. m_Top.SetWindowText(" ");
  1600. m_Right.SetWindowText(" ");
  1601. Invalidate();
  1602. }
  1603. }
  1604.     PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM( point.x, point.y));
  1605. }
  1606. void CDictionaryDlg::OnMouseMove(UINT nFlags, CPoint point) 
  1607. {
  1608. /* CRect windowsize;
  1609. CPoint mouse_window;
  1610. GetCursorPos(&mouse_window);
  1611. long xPos, yPos;
  1612. if((nFlags & MK_LBUTTON) && bIsMoving)
  1613. {
  1614. xPos=(point.x-initx);
  1615. yPos=(point.y-inity);
  1616. // xPos = (mouse_window.x-init.x);
  1617. // yPos = (mouse_window.y-init.y);
  1618. GetWindowRect(&windowsize);
  1619. MoveWindow(windowsize.left+xPos,
  1620.    windowsize.top+yPos,
  1621.    dictLength,
  1622.    dictHeight, TRUE);
  1623. }
  1624. */
  1625. }
  1626. void OnReadDecript(char * buf, int nrchar)
  1627. {
  1628. int i;
  1629. for(i=0; i<nrchar; i++)
  1630. buf[i] = -buf[i];
  1631. }
  1632. void CDictionaryDlg::CtrlCreate(CRichEditCtrlEx * rich)
  1633. {
  1634. if(!m_Left)
  1635. {
  1636. rect.SetRect(0,50,102,dictHeight-5);
  1637. m_Left.CreateEx(WS_EX_TRANSPARENT, "RICHEDIT20A", "",
  1638. ES_NOHIDESEL|WS_CHILD|WS_VISIBLE|ES_READONLY|
  1639. ES_MULTILINE| ES_AUTOVSCROLL|
  1640. WS_BORDER|WS_VSCROLL|WS_TABSTOP, rect, this, IDC_LEFT, NULL);
  1641. // m_Left.SetBackgroundColor(FALSE,RGB(255,255,193));
  1642. ::SendMessage(m_Left, EM_SETEVENTMASK, 0,ENM_MOUSEEVENTS|ENM_SCROLLEVENTS);
  1643. ::InvalidateRect(m_Left, &rect, TRUE);
  1644. // SetClipboardData (CF_DIB, CopyHandle((HANDLE) pDoc->GetHDIB()) );
  1645. }
  1646. }
  1647. BOOL OnSetCursor( CWnd* pWnd, UINT nHitTest, UINT message )
  1648. {
  1649. return FALSE;
  1650. }
  1651. HBRUSH CDictionaryDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  1652. {
  1653. switch(nCtlColor) {
  1654. /* case CTLCOLOR_STATIC:
  1655. pDC->SetBkMode(TRANSPARENT);
  1656. return HBRUSH(m_HollowBrush);
  1657. case CTLCOLOR_BTN:
  1658. pDC->SetBkMode(TRANSPARENT);
  1659. return HBRUSH(m_HollowBrush);
  1660. */ case CTLCOLOR_EDIT:
  1661. pDC->SetBkMode(TRANSPARENT);
  1662. return HBRUSH(myBrush);
  1663. default:
  1664. break;
  1665. }
  1666. return (CDialog::OnCtlColor(pDC, pWnd, nCtlColor)); 
  1667. // return m_BrushPat3;
  1668. }
  1669. BOOL CDictionaryDlg::PreTranslateMessage(MSG* pMsg) 
  1670. {
  1671. m_tool.RelayEvent(pMsg);
  1672. BOOL ret = ::TranslateAccelerator(GetSafeHwnd(), m_hAccel, pMsg);
  1673. if (!ret)
  1674.        ret = CDialog::PreTranslateMessage(pMsg);
  1675. return ret;
  1676. }
  1677. /*
  1678. void CDictionaryDlg::OnVscrollLeft()
  1679. {
  1680. m_Left.GetRect(rect);
  1681. InvalidateRect(&rect);
  1682. }
  1683. void CDictionaryDlg::OnVscrollRight()
  1684. {
  1685. m_Right.GetRect(rect);
  1686. InvalidateRect(&rect);
  1687. }
  1688. */