Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/teraterm/clipboar.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3902 - (hide annotations) (download) (as text)
Thu May 20 22:40:51 2010 UTC (13 years, 10 months ago) by maya
File MIME type: text/x-csrc
File size: 15663 byte(s)
ConfirmChangePaste の確認ダイアログ表示中にクリップボードがロックされたままにならないようにした。
1 maya 3227 /* Tera Term
2     Copyright(C) 1994-1998 T. Teranishi
3     All rights reserved. */
4    
5     /* TERATERM.EXE, Clipboard routines */
6     #include "teraterm.h"
7     #include "tttypes.h"
8     #include "vtdisp.h"
9     #include <string.h>
10     #include <stdlib.h>
11     #include <stdio.h>
12 yutakapon 3635 #include <commctrl.h>
13 maya 3227
14     #include "ttwinman.h"
15     #include "ttcommon.h"
16    
17     #include "clipboar.h"
18     #include "tt_res.h"
19    
20     // for clipboard copy
21     static HGLOBAL CBCopyHandle = NULL;
22     static PCHAR CBCopyPtr = NULL;
23    
24 doda 3872 #define CB_BRACKET_NONE 0
25     #define CB_BRACKET_START 1
26     #define CB_BRACKET_END 2
27 maya 3227 // for clipboard paste
28     static HGLOBAL CBMemHandle = NULL;
29     static PCHAR CBMemPtr = NULL;
30     static LONG CBMemPtr2 = 0;
31     static BOOL CBAddCR = FALSE;
32 doda 3896 static int CBBracketed = CB_BRACKET_NONE;
33 maya 3227 static BYTE CBByte;
34     static BOOL CBRetrySend;
35     static BOOL CBRetryEcho;
36     static BOOL CBSendCR;
37     static BOOL CBDDE;
38    
39     static HFONT DlgClipboardFont;
40    
41     PCHAR CBOpen(LONG MemSize)
42     {
43 maya 3393 if (MemSize==0) {
44     return (NULL);
45     }
46     if (CBCopyHandle!=NULL) {
47     return (NULL);
48     }
49     CBCopyPtr = NULL;
50     CBCopyHandle = GlobalAlloc(GMEM_MOVEABLE, MemSize);
51     if (CBCopyHandle == NULL) {
52     MessageBeep(0);
53     }
54     else {
55     CBCopyPtr = GlobalLock(CBCopyHandle);
56     if (CBCopyPtr == NULL) {
57     GlobalFree(CBCopyHandle);
58     CBCopyHandle = NULL;
59     MessageBeep(0);
60     }
61     }
62     return (CBCopyPtr);
63 maya 3227 }
64    
65     void CBClose()
66     {
67 maya 3393 BOOL Empty;
68     if (CBCopyHandle==NULL) {
69     return;
70     }
71 maya 3227
72 maya 3393 Empty = FALSE;
73     if (CBCopyPtr!=NULL) {
74     Empty = (CBCopyPtr[0]==0);
75     }
76 maya 3227
77 maya 3393 GlobalUnlock(CBCopyHandle);
78     CBCopyPtr = NULL;
79 maya 3227
80 maya 3393 if (OpenClipboard(HVTWin)) {
81     EmptyClipboard();
82     if (! Empty) {
83     SetClipboardData(CF_TEXT, CBCopyHandle);
84     }
85     CloseClipboard();
86     }
87     CBCopyHandle = NULL;
88 maya 3227 }
89    
90 doda 3872 void CBStartPaste(HWND HWin, BOOL AddCR, BOOL Bracketed,
91 maya 3393 int BuffSize, PCHAR DataPtr, int DataSize)
92 maya 3227 //
93     // DataPtr and DataSize are used only for DDE
94     // For clipboard, BuffSize should be 0
95     // DataSize should be <= BuffSize
96     {
97 maya 3393 UINT Cf;
98 maya 3227
99 maya 3393 if (! cv.Ready) {
100     return;
101     }
102     if (TalkStatus!=IdTalkKeyb) {
103     return;
104     }
105 maya 3227
106 maya 3393 CBAddCR = AddCR;
107 doda 3872 if (Bracketed) {
108     CBBracketed = CB_BRACKET_START;
109     }
110 maya 3227
111 maya 3393 if (BuffSize==0) { // for clipboar
112     if (IsClipboardFormatAvailable(CF_TEXT)) {
113     Cf = CF_TEXT;
114     }
115     else if (IsClipboardFormatAvailable(CF_OEMTEXT)) {
116     Cf = CF_OEMTEXT;
117     }
118     else {
119     return;
120     }
121     }
122 maya 3227
123 maya 3393 CBMemHandle = NULL;
124     CBMemPtr = NULL;
125     CBMemPtr2 = 0;
126     CBDDE = FALSE;
127     if (BuffSize==0) { //clipboard
128     if (OpenClipboard(HWin)) {
129     CBMemHandle = GetClipboardData(Cf);
130     }
131     if (CBMemHandle!=NULL) {
132     TalkStatus=IdTalkCB;
133     }
134     }
135     else { // dde
136     CBMemHandle = GlobalAlloc(GHND,BuffSize);
137     if (CBMemHandle != NULL) {
138     CBDDE = TRUE;
139     CBMemPtr = GlobalLock(CBMemHandle);
140     if (CBMemPtr != NULL) {
141     memcpy(CBMemPtr,DataPtr,DataSize);
142     GlobalUnlock(CBMemHandle);
143     CBMemPtr=NULL;
144     TalkStatus=IdTalkCB;
145     }
146     }
147     }
148     CBRetrySend = FALSE;
149     CBRetryEcho = FALSE;
150     CBSendCR = FALSE;
151     if (TalkStatus != IdTalkCB) {
152     CBEndPaste();
153     }
154 maya 3227 }
155    
156     // �����������N���b�v�{�[�h������DDE�f�[�^���[�������������B
157     //
158     // CBMemHandle�n���h�����O���[�o�������������A�����������I�������������A
159     // �����N���b�v�{�[�h������DDE�f�[�^�������������������������i�j�����������\�������j�B
160     // �����A�f�[�^���� null-terminate �����������������O�����������������A�������f�[�^����
161     // �����������B
162     // (2006.11.6 yutaka)
163     void CBSend()
164     {
165 maya 3393 int c;
166     BOOL EndFlag;
167 doda 3688 static DWORD lastcr;
168 doda 3872 static char BracketStart[] = "\033[200~";
169     static char BracketEnd[] = "\033[201~";
170     static int BracketPtr = 0;
171 doda 3688 DWORD now;
172 maya 3227
173 maya 3393 if (CBMemHandle==NULL) {
174     return;
175     }
176 maya 3227
177 doda 3688 now = GetTickCount();
178 doda 3691 if (now - lastcr < (DWORD)ts.PasteDelayPerLine) {
179 doda 3688 return;
180     }
181    
182 maya 3393 if (CBRetrySend) {
183     CBRetryEcho = (ts.LocalEcho>0);
184     c = CommTextOut(&cv,(PCHAR)&CBByte,1);
185     CBRetrySend = (c==0);
186     if (CBRetrySend) {
187     return;
188     }
189     }
190 maya 3227
191 maya 3393 if (CBRetryEcho) {
192     c = CommTextEcho(&cv,(PCHAR)&CBByte,1);
193     CBRetryEcho = (c==0);
194     if (CBRetryEcho) {
195     return;
196     }
197     }
198 maya 3227
199 maya 3393 CBMemPtr = GlobalLock(CBMemHandle);
200     if (CBMemPtr==NULL) {
201     return;
202     }
203 maya 3227
204 maya 3393 do {
205     if (CBSendCR && (CBMemPtr[CBMemPtr2]==0x0a)) {
206     CBMemPtr2++;
207     // added PasteDelayPerLine (2009.4.12 maya)
208 doda 3690 if (ts.PasteDelayPerLine > 0) {
209     lastcr = now;
210     CBSendCR = FALSE;
211     SetTimer(HVTWin, IdPasteDelayTimer, ts.PasteDelayPerLine, NULL);
212     break;
213     }
214 maya 3393 }
215    
216     EndFlag = (CBMemPtr[CBMemPtr2]==0);
217 doda 3872 if (CBBracketed == CB_BRACKET_START) {
218     CBByte = BracketStart[BracketPtr++];
219     if (BracketPtr >= sizeof(BracketStart) - 1) {
220     CBBracketed = CB_BRACKET_END;
221     BracketPtr = 0;
222     }
223     }
224     else if (! EndFlag) {
225 maya 3393 CBByte = CBMemPtr[CBMemPtr2];
226     CBMemPtr2++;
227 maya 3227 // Decoding characters which are encoded by MACRO
228     // to support NUL character sending
229     //
230     // [encoded character] --> [decoded character]
231     // 01 01 --> 00
232     // 01 02 --> 01
233 maya 3393 if (CBByte==0x01) { /* 0x01 from MACRO */
234     CBByte = CBMemPtr[CBMemPtr2];
235     CBMemPtr2++;
236     CBByte = CBByte - 1; // character just after 0x01
237     }
238     }
239     else if (CBAddCR) {
240     EndFlag = FALSE;
241     CBAddCR = FALSE;
242     CBByte = 0x0d;
243     }
244 doda 3872 else if (CBBracketed == CB_BRACKET_END) {
245     EndFlag = FALSE;
246     CBByte = BracketEnd[BracketPtr++];
247     if (BracketPtr >= sizeof(BracketEnd) - 1) {
248     CBBracketed = CB_BRACKET_NONE;
249     BracketPtr = 0;
250     }
251     }
252 maya 3393 else {
253     CBEndPaste();
254     return;
255     }
256 maya 3227
257 maya 3393 if (! EndFlag) {
258     c = CommTextOut(&cv,(PCHAR)&CBByte,1);
259     CBSendCR = (CBByte==0x0D);
260     CBRetrySend = (c==0);
261     if ((! CBRetrySend) &&
262     (ts.LocalEcho>0)) {
263     c = CommTextEcho(&cv,(PCHAR)&CBByte,1);
264     CBRetryEcho = (c==0);
265     }
266     }
267     else {
268     c=0;
269     }
270     }
271     while (c>0);
272 maya 3227
273 maya 3393 if (CBMemPtr!=NULL) {
274     GlobalUnlock(CBMemHandle);
275     CBMemPtr=NULL;
276     }
277 maya 3227 }
278    
279     void CBEndPaste()
280     {
281 maya 3393 TalkStatus = IdTalkKeyb;
282 maya 3227
283 maya 3393 if (CBMemHandle!=NULL) {
284     if (CBMemPtr!=NULL) {
285     GlobalUnlock(CBMemHandle);
286     }
287     if (CBDDE) {
288     GlobalFree(CBMemHandle);
289     }
290     }
291     if (!CBDDE) {
292     CloseClipboard();
293     }
294 maya 3227
295 maya 3393 CBDDE = FALSE;
296     CBMemHandle = NULL;
297     CBMemPtr = NULL;
298     CBMemPtr2 = 0;
299     CBAddCR = FALSE;
300 maya 3227 }
301    
302    
303     static char *ClipboardPtr = NULL;
304     static int PasteCanceled = 0;
305    
306     static LRESULT CALLBACK OnClipboardDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
307     {
308     LOGFONT logfont;
309     HFONT font;
310     char uimsg[MAX_UIMSG];
311     //char *p;
312     POINT p;
313     RECT rc_dsk, rc_dlg;
314     int dlg_height, dlg_width;
315     OSVERSIONINFO osvi;
316 maya 3902 static int ok2right, edit2ok, edit2bottom;
317     RECT rc_edit, rc_ok, rc_cancel;
318 yutakapon 3635 // for status bar
319     static HWND hStatus = NULL;
320 maya 3641 static init_width, init_height;
321 maya 3227
322     switch (msg) {
323     case WM_INITDIALOG:
324     #if 0
325     for (p = ClipboardPtr; *p ; p++) {
326     char buf[20];
327     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%02x ", *p);
328     OutputDebugString(buf);
329     }
330     #endif
331    
332     font = (HFONT)SendMessage(hDlgWnd, WM_GETFONT, 0, 0);
333     GetObject(font, sizeof(LOGFONT), &logfont);
334     if (get_lang_font("DLG_TAHOMA_FONT", hDlgWnd, &logfont, &DlgClipboardFont, ts.UILanguageFile)) {
335     SendDlgItemMessage(hDlgWnd, IDC_EDIT, WM_SETFONT, (WPARAM)DlgClipboardFont, MAKELPARAM(TRUE,0));
336     SendDlgItemMessage(hDlgWnd, IDOK, WM_SETFONT, (WPARAM)DlgClipboardFont, MAKELPARAM(TRUE,0));
337     SendDlgItemMessage(hDlgWnd, IDCANCEL, WM_SETFONT, (WPARAM)DlgClipboardFont, MAKELPARAM(TRUE,0));
338     }
339     else {
340     DlgClipboardFont = NULL;
341     }
342    
343     GetWindowText(hDlgWnd, uimsg, sizeof(uimsg));
344     get_lang_msg("DLG_CLIPBOARD_TITLE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
345     SetWindowText(hDlgWnd, ts.UIMsg);
346     GetDlgItemText(hDlgWnd, IDCANCEL, uimsg, sizeof(uimsg));
347     get_lang_msg("BTN_CANCEL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
348     SetDlgItemText(hDlgWnd, IDCANCEL, ts.UIMsg);
349     GetDlgItemText(hDlgWnd, IDOK, uimsg, sizeof(uimsg));
350     get_lang_msg("BTN_OK", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
351     SetDlgItemText(hDlgWnd, IDOK, ts.UIMsg);
352    
353     SendMessage(GetDlgItem(hDlgWnd, IDC_EDIT), WM_SETTEXT, 0, (LPARAM)ClipboardPtr);
354    
355     DispConvScreenToWin(CursorX, CursorY, &p.x, &p.y);
356     ClientToScreen(HVTWin, &p);
357    
358     // �L�����b�g���������������o���������������\���t����������
359     // �m�F�E�C���h�E�����������������\���������������������B
360     // �E�C���h�E���������o������������������ (2008.4.24 maya)
361     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
362     GetVersionEx(&osvi);
363 maya 3509 if ( (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 4) ||
364     (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && osvi.dwMinorVersion < 10) ) {
365     // NT4.0, 95 ���}���`���j�^API��������
366 maya 3227 SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_dsk, 0);
367     }
368     else {
369     HMONITOR hm;
370     POINT pt;
371     MONITORINFO mi;
372    
373     pt.x = p.x;
374     pt.y = p.y;
375     hm = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
376    
377     mi.cbSize = sizeof(MONITORINFO);
378     GetMonitorInfo(hm, &mi);
379     rc_dsk = mi.rcWork;
380     }
381     GetWindowRect(hDlgWnd, &rc_dlg);
382     dlg_height = rc_dlg.bottom-rc_dlg.top;
383     dlg_width = rc_dlg.right-rc_dlg.left;
384     if (p.y < rc_dsk.top) {
385     p.y = rc_dsk.top;
386     }
387     else if (p.y + dlg_height > rc_dsk.bottom) {
388     p.y = rc_dsk.bottom - dlg_height;
389     }
390     if (p.x < rc_dsk.left) {
391     p.x = rc_dsk.left;
392     }
393     else if (p.x + dlg_width > rc_dsk.right) {
394     p.x = rc_dsk.right - dlg_width;
395     }
396    
397     SetWindowPos(hDlgWnd, NULL, p.x, p.y,
398     0, 0, SWP_NOSIZE | SWP_NOZORDER);
399    
400 maya 3641 // �_�C�A���O�������T�C�Y������
401     GetWindowRect(hDlgWnd, &rc_dlg);
402     init_width = rc_dlg.right - rc_dlg.left;
403     init_height = rc_dlg.bottom - rc_dlg.top;
404    
405 maya 3227 // �����T�C�Y�����K�v���l���v�Z
406     GetClientRect(hDlgWnd, &rc_dlg);
407     GetWindowRect(GetDlgItem(hDlgWnd, IDC_EDIT), &rc_edit);
408     GetWindowRect(GetDlgItem(hDlgWnd, IDOK), &rc_ok);
409    
410     p.x = rc_dlg.right;
411     p.y = rc_dlg.bottom;
412     ClientToScreen(hDlgWnd, &p);
413     ok2right = p.x - rc_ok.left;
414 maya 3902 edit2bottom = p.y - rc_edit.bottom;
415 maya 3227 edit2ok = rc_ok.left - rc_edit.right;
416    
417     // �T�C�Y������
418     SetWindowPos(hDlgWnd, NULL, 0, 0,
419     ts.PasteDialogSize.cx, ts.PasteDialogSize.cy,
420     SWP_NOZORDER | SWP_NOMOVE);
421    
422 yutakapon 3635 // ���T�C�Y�A�C�R�����E�����\���������������A�X�e�[�^�X�o�[���t�����B
423     InitCommonControls();
424     hStatus = CreateStatusWindow(
425     WS_CHILD | WS_VISIBLE |
426     CCS_BOTTOM | SBARS_SIZEGRIP, NULL, hDlgWnd, 1);
427    
428 maya 3227 return TRUE;
429    
430     case WM_COMMAND:
431     switch (LOWORD(wp)) {
432     case IDOK:
433     {
434     int len = SendMessage(GetDlgItem(hDlgWnd, IDC_EDIT), WM_GETTEXTLENGTH, 0, 0);
435     HGLOBAL hMem;
436     char *buf;
437    
438 maya 3902 if (OpenClipboard(hDlgWnd) != 0) {
439     hMem = GlobalAlloc(GMEM_MOVEABLE, len + 1);
440     buf = GlobalLock(hMem);
441     SendMessage(GetDlgItem(hDlgWnd, IDC_EDIT), WM_GETTEXT, len + 1, (LPARAM)buf);
442     GlobalUnlock(hMem);
443 maya 3227
444 maya 3902 EmptyClipboard();
445     SetClipboardData(CF_TEXT, hMem);
446     CloseClipboard();
447     // hMem���N���b�v�{�[�h�������������������A�j�����������������B
448     }
449 maya 3227
450     if (DlgClipboardFont != NULL) {
451     DeleteObject(DlgClipboardFont);
452     }
453    
454 yutakapon 3635 DestroyWindow(hStatus);
455 maya 3227 EndDialog(hDlgWnd, IDOK);
456     }
457     break;
458    
459     case IDCANCEL:
460     PasteCanceled = 1;
461    
462     if (DlgClipboardFont != NULL) {
463     DeleteObject(DlgClipboardFont);
464     }
465    
466 yutakapon 3635 DestroyWindow(hStatus);
467 maya 3227 EndDialog(hDlgWnd, IDCANCEL);
468     break;
469    
470     default:
471     return FALSE;
472     }
473    
474     #if 0
475     case WM_CLOSE:
476     PasteCanceled = 1;
477     EndDialog(hDlgWnd, 0);
478     return TRUE;
479     #endif
480    
481     case WM_SIZE:
482     {
483     // ���z�u
484     POINT p;
485     int dlg_w, dlg_h;
486    
487     GetClientRect(hDlgWnd, &rc_dlg);
488     dlg_w = rc_dlg.right;
489     dlg_h = rc_dlg.bottom;
490    
491     GetWindowRect(GetDlgItem(hDlgWnd, IDC_EDIT), &rc_edit);
492     GetWindowRect(GetDlgItem(hDlgWnd, IDOK), &rc_ok);
493     GetWindowRect(GetDlgItem(hDlgWnd, IDCANCEL), &rc_cancel);
494    
495     // OK
496     p.x = rc_ok.left;
497     p.y = rc_ok.top;
498     ScreenToClient(hDlgWnd, &p);
499     SetWindowPos(GetDlgItem(hDlgWnd, IDOK), 0,
500     dlg_w - ok2right, p.y, 0, 0,
501     SWP_NOSIZE | SWP_NOZORDER);
502    
503     // CANCEL
504     p.x = rc_cancel.left;
505     p.y = rc_cancel.top;
506     ScreenToClient(hDlgWnd, &p);
507     SetWindowPos(GetDlgItem(hDlgWnd, IDCANCEL), 0,
508     dlg_w - ok2right, p.y, 0, 0,
509     SWP_NOSIZE | SWP_NOZORDER);
510    
511     // EDIT
512     p.x = rc_edit.left;
513     p.y = rc_edit.top;
514     ScreenToClient(hDlgWnd, &p);
515     SetWindowPos(GetDlgItem(hDlgWnd, IDC_EDIT), 0,
516 maya 3902 0, 0, dlg_w - p.x - edit2ok - ok2right, dlg_h - p.y - edit2bottom,
517 maya 3227 SWP_NOMOVE | SWP_NOZORDER);
518    
519     // �T�C�Y������
520     GetWindowRect(hDlgWnd, &rc_dlg);
521     ts.PasteDialogSize.cx = rc_dlg.right - rc_dlg.left;
522     ts.PasteDialogSize.cy = rc_dlg.bottom - rc_dlg.top;
523 yutakapon 3635
524     // status bar
525     SendMessage(hStatus , msg , wp , lp);
526 maya 3227 }
527     return TRUE;
528    
529 maya 3641 case WM_GETMINMAXINFO:
530     {
531     // �_�C�A���O�������T�C�Y����������������������������
532     LPMINMAXINFO lpmmi;
533     lpmmi = (LPMINMAXINFO)lp;
534     lpmmi->ptMinTrackSize.x = init_width;
535     lpmmi->ptMinTrackSize.y = init_height;
536     }
537     return FALSE;
538    
539 maya 3227 default:
540     return FALSE;
541     }
542     return TRUE;
543     }
544    
545 yutakapon 3535 // �t�@�C�������`���������������Atext���������������������B
546     static int search_clipboard(char *filename, char *text)
547     {
548     int ret = 0; // no hit
549     FILE *fp = NULL;
550     char buf[256];
551     int len;
552    
553     if (filename == NULL || filename[0] == '\0')
554     goto error;
555    
556     fp = fopen(filename, "r");
557     if (fp == NULL)
558     goto error;
559    
560     // TODO: ���s��256byte�������������������l��
561     while (fgets(buf, sizeof(buf), fp) != NULL) {
562     len = strlen(buf);
563     if (buf[len - 1] == '\n')
564     buf[len - 1] = '\0';
565     if (buf[0] == '\0')
566     continue;
567     if (strstr(text, buf)) { // hit
568     ret = 1;
569     break;
570     }
571     }
572    
573     error:
574     if (fp)
575     fclose(fp);
576    
577     return (ret);
578     }
579    
580    
581 maya 3227 //
582     // �N���b�v�{�[�h�����s�R�[�h�����������������A�m�F�_�C�A���O���\�������B
583     // �N���b�v�{�[�h�����X�����\�B
584     //
585     // return 0: Cancel
586     // 1: Paste OK
587     //
588     // (2008.2.3 yutaka)
589     //
590     int CBStartPasteConfirmChange(HWND HWin)
591     {
592     UINT Cf;
593     HANDLE hText;
594     char *pText;
595     int pos;
596     int ret = 0;
597 yutakapon 3535 int confirm = 0;
598 maya 3227
599     if (ts.ConfirmChangePaste == 0)
600     return 1;
601    
602     if (! cv.Ready)
603     goto error;
604     if (TalkStatus!=IdTalkKeyb)
605     goto error;
606    
607     if (IsClipboardFormatAvailable(CF_TEXT))
608     Cf = CF_TEXT;
609     else if (IsClipboardFormatAvailable(CF_OEMTEXT))
610     Cf = CF_OEMTEXT;
611     else
612     goto error;
613    
614     if (!OpenClipboard(HWin))
615     goto error;
616    
617     hText = GetClipboardData(Cf);
618    
619     if (hText != NULL) {
620     pText = (char *)GlobalLock(hText);
621     pos = strcspn(pText, "\r\n"); // ���s����������������
622     if (pText[pos] != '\0') {
623 yutakapon 3535 confirm = 1;
624    
625     } else {
626     // �������T�[�`����
627     if (search_clipboard(ts.ConfirmChangePasteStringFile, pText)) {
628     confirm = 1;
629     }
630    
631     }
632    
633     if (confirm) {
634 maya 3902 ClipboardPtr = (char *)calloc(sizeof(char), strlen(pText)+1);
635     memcpy(ClipboardPtr, pText, strlen(pText));
636     GlobalUnlock(hText);
637     CloseClipboard();
638 maya 3227 PasteCanceled = 0;
639     ret = DialogBox(hInst, MAKEINTRESOURCE(IDD_CLIPBOARD_DIALOG),
640 maya 3902 HVTWin, (DLGPROC)OnClipboardDlgProc);
641     free(ClipboardPtr);
642 maya 3227 if (ret == 0 || ret == -1) {
643     ret = GetLastError();
644     }
645    
646     if (PasteCanceled) {
647     ret = 0;
648     goto error;
649     }
650    
651     }
652 maya 3902 else {
653     GlobalUnlock(hText);
654     CloseClipboard();
655     }
656 maya 3227
657     ret = 1;
658    
659     }
660    
661     error:
662     return (ret);
663     }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26