Click here to Skip to main content
15,895,256 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWindows GINA Pin
Lim Bio Liong21-May-03 21:43
Lim Bio Liong21-May-03 21:43 
GeneralDifficult - Owner data in CListCtrl - Pin
JensB21-May-03 20:22
JensB21-May-03 20:22 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
Rage21-May-03 21:12
professionalRage21-May-03 21:12 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
JensB21-May-03 21:28
JensB21-May-03 21:28 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
JensB21-May-03 22:05
JensB21-May-03 22:05 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
Rage21-May-03 22:15
professionalRage21-May-03 22:15 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
Rage21-May-03 22:06
professionalRage21-May-03 22:06 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
JensB21-May-03 22:16
JensB21-May-03 22:16 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
JensB21-May-03 22:30
JensB21-May-03 22:30 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
Rage21-May-03 22:35
professionalRage21-May-03 22:35 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
Rage21-May-03 22:30
professionalRage21-May-03 22:30 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
JensB21-May-03 22:44
JensB21-May-03 22:44 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
JensB21-May-03 22:59
JensB21-May-03 22:59 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
Rage21-May-03 23:06
professionalRage21-May-03 23:06 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
JensB21-May-03 23:12
JensB21-May-03 23:12 
GeneralRe: Difficult - Owner data in CListCtrl - Pin
Rage21-May-03 23:24
professionalRage21-May-03 23:24 
GeneralFast User Switching Pin
Alex Korchemniy21-May-03 19:38
Alex Korchemniy21-May-03 19:38 
GeneralRe: Fast User Switching Pin
Neville Franks22-May-03 0:01
Neville Franks22-May-03 0:01 
Questionhow to delete a file ? Pin
thacdo21-May-03 17:25
thacdo21-May-03 17:25 
AnswerRe: how to delete a file ? Pin
Chris Richardson21-May-03 17:32
Chris Richardson21-May-03 17:32 
AnswerRe: how to delete a file ? Pin
AnkushChopra23-May-03 2:20
AnkushChopra23-May-03 2:20 
QuestionCopy a string to clipboard ? Pin
_skidrow_vn_21-May-03 14:21
_skidrow_vn_21-May-03 14:21 
I have a string, such as "Hello World!"
I want copy it to clipboard, so that, after that, when I right click in a word process application ( such as: NotePad, WordPad, Word...), there is a "paste" menu command show for me to paste that string "Hello World!"

My code is wrong (GlobalUnlock) but I dont know how to fix it (I am following code in MSDN sample)

thanks!

//lpszString = "Wednesday, 21 May 2003 --- 08:21:07 PM"<br />
BOOL CopyToClipBoard(LPSTR lpszString)<br />
{<br />
	LPTSTR  lptstrCopy; <br />
	HGLOBAL hglbCopy; <br />
	INT cch; 		<br />
<br />
	OpenClipboard(hWnd);<br />
	EmptyClipboard(); <br />
<br />
	cch=strlen(lpszString);<br />
	hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (cch + 1) * sizeof(TCHAR)); <br />
	if (hglbCopy == NULL) <br />
	{ <br />
        	CloseClipboard(); <br />
		MessageBox(hWnd,"errror on GlobalAlloc()","Error",MB_ICONERROR);<br />
       		return FALSE; <br />
	}  <br />
<br />
	// Lock the handle and copy the text to the buffer.  <br />
	lptstrCopy = (LPTSTR)GlobalLock(hglbCopy); <br />
	memcpy(lptstrCopy, lpszString, cch * sizeof(TCHAR)); <br />
	lptstrCopy[cch] = (TCHAR) 0;    // null character <br />
<br />
<br />
	if(!GlobalUnlock(hglbCopy)) //>>>>>>>ERROR >>>>>>>:eek:	{<br />
		MessageBox(hWnd,"errror on GlobalUnlock()","Error",MB_ICONERROR);<br />
		return FALSE;  <br />
	}<br />
<br />
    	// Place the handle on the clipboard.  <br />
	if(!SetClipboardData(CF_TEXT, hglbCopy))<br />
	{<br />
		MessageBox(hWnd,"errror on SetClipboardData()","Error",MB_ICONERROR);<br />
		return FALSE; <br />
	}<br />
<br />
	if(!CloseClipboard())<br />
	{<br />
		MessageBox(hWnd,"errror on CloseClipboard()","Error",MB_ICONERROR);<br />
		return FALSE;  <br />
	}  <br />
<br />
	return TRUE;<br />
}

AnswerRe: Copy a string to clipboard ? Pin
Dave Bryant21-May-03 15:29
Dave Bryant21-May-03 15:29 
GeneralRe: Copy a string to clipboard ? Pin
_skidrow_vn_22-May-03 10:48
_skidrow_vn_22-May-03 10:48 
AnswerRe: Copy a string to clipboard ? Pin
valikac21-May-03 19:32
valikac21-May-03 19:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.