Click here to Skip to main content
16,013,082 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: FlexGrid Sort Pin
29-May-02 15:38
suss29-May-02 15:38 
GeneralCreate form controls at runtime Pin
Aaron Schaefer29-May-02 12:55
Aaron Schaefer29-May-02 12:55 
GeneralRe: Create form controls at runtime Pin
Matt Gullett29-May-02 12:52
Matt Gullett29-May-02 12:52 
GeneralRe: Create form controls at runtime Pin
Aaron Schaefer29-May-02 13:09
Aaron Schaefer29-May-02 13:09 
Generalfstream issues Pin
Alan Chambers29-May-02 10:45
Alan Chambers29-May-02 10:45 
GeneralRe: fstream issues Pin
Joaquín M López Muñoz29-May-02 11:12
Joaquín M López Muñoz29-May-02 11:12 
GeneralRe: fstream issues Pin
Alan Chambers29-May-02 11:21
Alan Chambers29-May-02 11:21 
GeneralProblem converting a CComBSTR to LPCTSTR with CW2CT Pin
JC Gauthier29-May-02 10:24
JC Gauthier29-May-02 10:24 
I have a problem converting a CComBSTR to LPCTSTR with CW2CT. Eveything works fine until my CComBSTR gets around 64 caracters... then the result of the convertion is a long "corrupted" string: "îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþ...."

Please help me ! Cry | :((

-----
See comments between /* */ for more info
-----
LRESULT CListBoxDlg::OnBnClickedBtngetselitems(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	LPCTSTR sTitle;			// Message box title
	int arrSelList[12];		// Message buffer
	TCHAR pszBuf[128] = "";// Message buffer
	int iMaxNum = 12;		// Max number of selected items
	LRESULT iSelCount = 0;	// Total selected items in the list
	LPCTSTR sMsg = 0;		// Message to put in the message box
	CComBSTR bsMessage;		// Message accumulator

	iSelCount = this->SendDlgItemMessage(IDC_AVSCODES, LB_GETSELITEMS, WPARAM(iMaxNum), LPARAM(arrSelList));

	if (iSelCount != LB_ERR) {

		bsMessage.Append("You have selected the fields: ");
		_stprintf(pszBuf, "%li", arrSelList[0]);
		bsMessage.Append(pszBuf);

		for (int i = 1; i < iSelCount; i++) {

			bsMessage.Append(", ");
			_stprintf(pszBuf, "%li", arrSelList[i]);
			bsMessage.Append(pszBuf);
		}
		bsMessage.Append(".");
		/* The following line will fails if bsMessage.m_str contains:
			"You have selected the fields: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11."
		   But will not fail if it bsMessage.m_str contains:
			"You have selected the fields: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10."
			(4 caracter less) but long size is not suppose the cause problems
			with ATL 7.0 compared to ATL 3.0
		*/
		sMsg = CW2CT(bsMessage.m_str);
		/*
		// The following two lines makes it work fine but USES_CONVERSION is not supposed
		// to be needed with ATL 7.0
		USES_CONVERSION;
		sMsg = W2CT(bsMessage.m_str);*/
		sTitle = _T("Selected Items List");
		::MessageBox(this->m_hWnd, sMsg, sTitle, MB_OK);
	}

	return 0;
} 
ompared to ATL 3.0
*/
sMsg = CW2CT(bsMessage.m_str);
/*
// The following two lines makes it work fine but USES_CONVERSION is not supposed
// to be needed with ATL 7.0
USES_CONVERSION;
sMsg = W2CT(bsMessage.m_str);*/
sTitle = _T("Selected Items List");
::MessageBox(this->m_hWnd, sMsg, sTitle, MB_OK);
}

return 0;
}

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
J.-C. Gauthier - http://www.grandmenhir.com/
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
soptest29-May-02 12:25
soptest29-May-02 12:25 
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
JC Gauthier30-May-02 4:27
JC Gauthier30-May-02 4:27 
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
soptest30-May-02 8:36
soptest30-May-02 8:36 
General_popen issue Pin
Stew29-May-02 9:41
Stew29-May-02 9:41 
GeneralRe: _popen issue Pin
Joaquín M López Muñoz29-May-02 9:46
Joaquín M López Muñoz29-May-02 9:46 
GeneralRe: _popen issue Pin
soptest29-May-02 9:56
soptest29-May-02 9:56 
GeneralWeird Keyboard Hooking Issue Pin
John Aldrich29-May-02 9:02
John Aldrich29-May-02 9:02 
GeneralRe: Weird Keyboard Hooking Issue Pin
Joaquín M López Muñoz29-May-02 9:34
Joaquín M López Muñoz29-May-02 9:34 
GeneralI think I got it now Pin
Joaquín M López Muñoz29-May-02 9:40
Joaquín M López Muñoz29-May-02 9:40 
GeneralMeasureItem doesn't get called. Pin
29-May-02 9:07
suss29-May-02 9:07 
GeneralRe: MeasureItem doesn't get called. Pin
Paul M Watt29-May-02 9:22
mentorPaul M Watt29-May-02 9:22 
GeneralRe: MeasureItem doesn't get called. Pin
29-May-02 9:46
suss29-May-02 9:46 
GeneralQuestion Pin
Steve L.29-May-02 9:04
Steve L.29-May-02 9:04 
GeneralRe: Question Pin
Mauricio Ritter29-May-02 9:20
Mauricio Ritter29-May-02 9:20 
GeneralMaximum value of unsigned long Pin
Hoang Le29-May-02 8:54
Hoang Le29-May-02 8:54 
GeneralRe: Maximum value of unsigned long Pin
Joaquín M López Muñoz29-May-02 8:50
Joaquín M López Muñoz29-May-02 8:50 
GeneralRe: Maximum value of unsigned long Pin
Christopher Lord29-May-02 12:49
Christopher Lord29-May-02 12:49 

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.