|
myparam was corrupted and that caused the assert.
Thank you for your kind help.
RichS
|
|
|
|
|
Assert signals a runtime problem, like access to memory through NULL pointer. Your casts do not have anything to do with it. You can remove them and simply call your function like this:
function(myparam)
Look at the stack after assert - you'll be able to see where exactly problem is.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt }
H2,H3,H4,H5 { color: #ff9900; font-weight: bold; }
H2 { font-size: 13pt; }
H3 { font-size: 12pt; }
H4 { font-size: 10pt; color: black; }
PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono;
WHITE-SPACE: pre; }
CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
I am fairly new to Visual C++ Programming but I have experience in C. I want to display the content of a string in a string. Printf("Welcome %s.", name); , in C, I did it like this but in Visual C++, I have a string m_strWelcome and I want to display m_strName in it like above. How?
// JS Paquet
cout << "Thank you all" << endl;
|
|
|
|
|
i dunno if this is the best way since im a newbie too.. but heres how i've been doing it so far
CString strTemp;
CString strName("dzgraphics.com");
strTemp.Format("I really like %s",strName);
AfxMessageBox(strTemp);
-dz
|
|
|
|
|
CString has this nice method called Format() that works just like sprintf() :
CString strName = "Josh";
CString strWelcome;
strWelcome.Format("Welcome %s.", strName);
Or you could do:
CString strName = "Josh";
CString strWelcome = "Welcome " + strName + '.';
Your preference
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
If you're using a string class like the STL string or MFC CString you can use the overloaded operators to concatenate two strings, i.e. m_strWelcome = _T("Welcome ") + m_strName. The MFC CString class does provide a Format() function which works similar to printf() to format a string.
Justin Neville
|
|
|
|
|
I'm not suer if the other posts answered your question. They discuss formatting, but not printing.
Assuming m_strWelcome is a CString...
Printf("Welcome %s.", LPCSTR(m_strWelcome));,
Good luck.,
Bill
|
|
|
|
|
Thanks all, but the one that I used and that seemed to work well was:
CString strName = "Josh";
CString strWelcome = "Welcome " + strName + '.';
// JS Paquet
cout << "Thank you all" << endl;
|
|
|
|
|
Ok, this has been bugging me for months, and i'm getting sick of it.
I have several dialog templates with icon controls on them. These are print dialogs, and the icons are used for the collation indicator (you know, little overlapping pages...), so they are not a standard size; i check Center Image to ensure the image is not stretched. By holding down the alt key, i can resize the control to be large enough to display the icon correctly, however each time i open the template for editing, it resets to 32x32, and i have to resize it again; more than once i've been in a hurry and forgot to do this. If i assign an icon to the control initially, it is compressed into 32x32 on load, and even if the control is resized, it never looks right
So, is there any way, in VS6, to keep the dialog editor from resizing an icon control automatically?
Thanks!
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
does anyone know how to display line numbers . . . I couldn't find anything in the help menus . . .
thanks,
tim
---------------------------------------
Tim Booher
|
|
|
|
|
Are you referring to the __LINE__ macro?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The current line is displayed on the status bar, i don't think there's a way to display them on each line though (if that's what you were asking).
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
I've seen some addin editors that will do it.
Good Luck,
Bill
|
|
|
|
|
Has anyone tried to write an application that uses the performance counters in Windows NT, 2k or xp? I am interested in doing some network monitoring on remote nodes. I found some information on MSDN but no samples.. Does anyone have any sample code of how to use these counters?
Thanks,
Rob Jones
|
|
|
|
|
|
Thanks Tomasz I'll take a look at that.
Rob
|
|
|
|
|
Do you know which function fills rect faster ?
e.g.:
CPaint dc(this);
CRect rect;
GetClientRect(rect);
// a)
dc.FillSolidRect(&rect,RGB(255,0,0));
// b)
CBrush brush(RGB(255,0,0));
CBrush * pOld = dc.SelectObject(&brush);
dc.PalBlt(0,0,rect.Width(),rect.Height(),PATCOPY);
dc.SelectObject(pOld);
Wiizi
|
|
|
|
|
If you look into MFC sources, you'll find that FillSolidRect internally calls ::ExtTextOut. This is probably speed optimization, so chances are that FillSolidRect may be faster.
I don't believe that difference will be visible when you just want to paint client rectangle. This could become significant with thousands of rects.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
If you look into MFC sources, you'll find that FillSolidRect internally calls ::ExtTextOut. This is probably speed optimization, so chances are that FillSolidRect may be faster.
That floored me the first time I saw it in MFC. I wonder which is faster if you already have a brush sitting around. (Being that the ::ExtTextOut method doesn't require you to create a temp brush.)
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
|
LOL, sounds like you are trying to depress the user.
"I see a red door and I want it painted black. No colours anymore, I want them to turn black."
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Just looked in the google archives, it seems that even though PatBlt is VERY fast, selecting the brush into the DC can be very slow and thus makes the ::ExtTextOut the winner.
Interesting stuff.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
To make it even more interesting, starting with 2K you can use SetDCBrushColor, which is probably quite fast (compared to Create/SelectBrush).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
oooooo, another learn something new every day.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi I have a problem
When I call this function below, I get this error:
"Too few parameters. Expected 1."
What am I doing wrong here?
Here is the function:
void CMyTreeView::FillProducts()
{
CProductSet *pSet = &(GetDocument()->m_productSet);
pSet->m_strFilter = "[Categories].[CategoryID] = [Products].[CategoryID]";
if (pSet->IsOpen())
{
pSet->Close();
}
pSet->Open();
if (pSet->IsBOF())
return;
pSet->MoveFirst();
while (!pSet->IsEOF())
{
HTREEITEM hProductNode = FindNode(NULL, pSet->m_CategoryName);
InsertNode(pSet->m_ProductName, hProductNode);
pSet->MoveNext();
}
}
Here is the CProductSet:
void CProductSet::DoFieldExchange(CFieldExchange* pFX)
{
//{{AFX_FIELD_MAP(CProductSet)
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Long(pFX, _T("[Categories].[CategoryID]"), m_CategoryID);
RFX_Text(pFX, _T("[CategoryName]"), m_CategoryName);
RFX_Long(pFX, _T("[ProductID]"), m_ProductID);
RFX_Text(pFX, _T("[ProductName]"), m_ProductName);
RFX_Text(pFX, _T("[ProductDescription]"), m_ProductDescription);
RFX_Long(pFX, _T("[Products].[CategoryID]"), m_CategoryID2);
RFX_Text(pFX, _T("[SerialNumber]"), m_SerialNumber);
RFX_Text(pFX, _T("[UnitSellingPrice]"), m_UnitSellingPrice);
RFX_Text(pFX, _T("[UnitCostPrice]"), m_UnitCostPrice);
RFX_Long(pFX, _T("[ReorderLevel]"), m_ReorderLevel);
RFX_Long(pFX, _T("[UnitsInStock]"), m_UnitsInStock);
RFX_Long(pFX, _T("[SupplierID]"), m_SupplierID);
//}}AFX_FIELD_MAP
pFX->SetFieldType(CFieldExchange::param);
RFX_Text(pFX, "ProductNameParam", m_ProductNameparam);
}
|
|
|
|
|