|
Sean,
Either way is messy, keeping a copy of the structure in memory or using the control.
Look to continuously call TreeView_GetParent() until it returns NULL. If you use a loop you will need to insert the parent item's text at the beginning of the buffer each time. If you use a recursive function call then you can build the string by appending each item's text on the way back out of the recursive function.
|
|
|
|
|
That's exactly what I'm looking for and using GetParent doesn't sound as messy as a tree comparisson unless of course the control itself doesn't handle it well.
I'd have to do a recursive match either way so I'll let the control do most of the work.
Thanks a million none the less.
Sean
|
|
|
|
|
When I build my bank.cpp file, I get these linking errors. I don't understand these coding errors, I would appreciate any help you could give me.
Linking...
Bank.obj : error LNK2001: unresolved external symbol "public: class Account & __thiscall Customer::getchecking(void)" (?getchecking@Customer@@QAEAAVAccount@@XZ)
Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Account::setbalance(float)" (?setbalance@Account@@QAEXM@Z)
Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Account::setnum(int)" (?setnum@Account@@QAEXH@Z)
Bank.obj : error LNK2001: unresolved external symbol "public: class Account & __thiscall Customer::getsavings(void)" (?getsavings@Customer@@QAEAAVAccount@@XZ)
Bank.obj : error LNK2001: unresolved external symbol "public: void __thiscall Customer::setpin(int)" (?setpin@Customer@@QAEXH@Z)
Bank.obj : error LNK2001: unresolved external symbol "public: __thiscall Customer::Customer(void)" (??0Customer@@QAE@XZ)
Bank.obj : error LNK2001: unresolved external symbol "public: float __thiscall Account::getbalance(void)" (?getbalance@Account@@QAEMXZ)
Bank.obj : error LNK2001: unresolved external symbol "public: int __thiscall Account::getnum(void)" (?getnum@Account@@QAEHXZ)
Bank.obj : error LNK2001: unresolved external symbol "public: int __thiscall Customer::getpin(void)" (?getpin@Customer@@QAEHXZ)
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Bank.exe : fatal error LNK1120: 10 unresolved externals
Error executing link.exe.
Bank.exe - 11 error(s), 0 warning(s)
This is my bank.cpp file.............................
#include "Bank.h"
#include <fstream.h>
Bank::Bank()
{
numcustomers=0;
companyname="";
}
int Bank::getNumcustomers()
{return numcustomers;}
char * Bank::getCompanyname()
{return companyname;}
Customer& Bank::getCustomer(int index)
{ return customers[index];}
void Bank::setNumcustomers(int n)
{ numcustomers=n; }
void Bank::setCompanyname(char * c)
{ companyname =c;}
void Bank::setCustomer(Customer &c,int index)
{customers[index]= c;}
bool Bank::readCustomers()
{
ifstream infile;
infile.open("customers.dat");
if(!infile)
{
return false;
}
else
{ infile>>numcustomers;
int numberpin=0;
int cksavnumber=0;
float savckbalance=0.00f;
customers = new Customer[numcustomers];
for(int x1=0;x1<=numcustomers;x1++)
{
infile>>numberpin;
infile>>cksavnumber;
infile>>savckbalance;
customers [x1].setpin(numberpin);
customers[x1].getsavings().setnum(cksavnumber);
customers[x1].getsavings().setbalance(savckbalance);
infile>>cksavnumber;
infile>>savckbalance;
customers[x1].getchecking().setnum(cksavnumber);
customers[x1].getchecking().setbalance(savckbalance);
}
infile.close();
}
return true;
}
bool Bank::writeCustomers()
{
ofstream outfile;
outfile.open("newcustomers.dat");
if(!outfile)
{
return false;
}
else
{ outfile<<numcustomers;
for(int="" x1="0;x1<=numcustomers;x1++)
" {
="" outfile="" <<="" customers="" [x1].getpin()="" "\t";
="" outfile<<customers="" [x1].getsavings().getnum()<<="" [x1].getsavings().getbalance()<<="" [x1].getchecking().getnum()<<="" [x1].getchecking().getbalance()<<="" endl;
="" }
="" outfile.close();
="" return="" true;
="" }
int="" bank::checkpin(int="" pin)
{="" for="" (int="" x1<="numcustomers;" x1++)
="" {="" if="" (customers[x1].getpin()="=pin)
" x1;
="" -1;
}
int="" bank::menu()
{="" int="" choice="1;
" cout<<"withdraw";
="" cout<<"deposit";
="" cout<<"transfer";
="" cout<<"display="" balances";
="" cout<<"exit";
="" choice;
}
bool="" bank::withdraw(float="" amount,account="" a)=""
{
if(amount="">a.getbalance())
{
return false;
}
else
{ a.setbalance(a.getbalance()- amount);
return true;
}
}
void Bank::deposit(float amount,Account a)
{a.setbalance(a.getbalance()+ amount);}
bool Bank::transfer(float amount,Account s,Account c)
{
int targetaccount=0;
do
{
cout<<"From which account"<<endl;
cout<<"1-checking"<<endl;
cout<<"2-saving"<<endl;
cin>>targetaccount;
if ((targetaccount!=1)&&(targetaccount !=2))
cout<<"INVALID Choice"<<endl<<endl;
} while="" ((targetaccount!="1)&&(targetaccount" !="2));
if(targetaccount==1)
{"
if="" (amount="">c.getbalance())
return false;
}
else
{
c.setbalance(c.getbalance()-amount);
s.setbalance(s.getbalance()+amount);
}
if(targetaccount==2)
{
if (amount>s.getbalance())
return false;
}
else
{
c.setbalance(c.getbalance()+amount);
s.setbalance(s.getbalance()-amount);
}
return true;
}
void Bank::displayBalance(int index)
{
cout<<"This is your savings account balance: $ "<<customers[index].getsavings().getbalance()<<endl;
cout<<"this="" is="" your="" checking="" account="" balance:="" $="" "<<customers[index].getchecking().getbalance()<<endl;
=""
}
account.cpp="" .........................................
#include="" "account.h"
account::account()
{
="" num="0;
" type="0;
" balance="0.00f;
}
Account::Account(int" n,int="" t,float="" b)
{
="" account::setnum="" (int="" n)
{
="" account::settype="" t)
{
="" account::setbalance(float="" account::getnum()
{
="" return="" num;
}
int="" account::gettype()
{
="" type;
}
float="" account::getbalance()
{
="" balance;
}
my="" void="" main...........................................
#="" include="" <iostream.h="">
# include "account.cpp"
# include "customer.cpp"
# include "bank.cpp"
# include <stdlib.h>
int getaccount();
float getamount();
Bank Chase;
Customer clientme;
void main()
{
int index=-1, pin =0, numtries=1;
Chase.setCompanyname("Chase");
if(!Chase.readCustomers())
{ cout<<"Account not in database!"<<endl;
exit(0);
="" }
="" do
="" {="" cout<<"enter="" your="" password:";
="" cin="">>pin;
index=Chase.checkPin(pin);
if((index==-1) && (numtries<=3))
{numtries++;
cout<<"Password incorrect,try again."<<endl;
="" }
="" }="" while="" ((index="=-1)&&(numtries<=3));
"
="" if="" (numtries="">3)
{ cout<<"Transaction denied!, Number of tries exceeded"<<endl;
exit="" (0);
="" }
=""
="" switch="" (chase.menu())
="" {="" case="" 1:
="" if(getaccount()="=1)
" if(chase.withdraw(getamount(),clientme.getchecking()))
="" cout<<"transaction="" successful!"="" <<endl;
="" else
="" cout<<"insufficient="" funds!"<<endl;
="" cout<<"your="" checking="" balance="" is!"<<clientme.getchecking().getbalance()<<endl;
="" if="" (chase.withdraw(getamount(),clientme.getsavings()))
="" successful!"<<endl;
="" savings="" is!"<<clientme.getsavings().getbalance()<<endl;
="" break;
="" 2:
="" {
="" (getaccount()="=1)
" chase.deposit(getamount(),="" clientme.getchecking());
="" is!"<<clientme.getsavings().getbalance()<<endl;="" clientme.getsavings());
="" is"<<clientme.getsavings().getbalance()<<endl;
="" 3:
="" (chase.transfer(getamount(),="" clientme.getchecking(),="" clientme.getsavings()))
="" is="" !"<<clientme.getchecking().getbalance()<<endl;
="" is!"<<clientme.getsavings().getbalance()<<endl;
="" 4:
="" chase.setcustomer(clientme,="" index);
="" chase.displaybalance(index);
="" 5:
="" chase.writecustomers();
="" cout<<"thank="" you="" for="" banking="" with="" chase!!"<<endl;
="" float="" getamount()
="" amount="0.00f;
" cout<<"enter="" of="" transaction:";
="" cin="">>amount;
return amount;
}
int getaccount()
{
int account;
do
{
cout<<"Which account would you like to withdraw from (1-Checking 2-Savings)?:";
cin>>account;
if ((account<1)|| (account>2))
cout<<"account is invalid, Try Again!" <<endl<<endl;
}="" while="" ((account<1)="" ||="" (account="">2));
return account;
}
|
|
|
|
|
The error means that the compiler can see that you've declared your intention to define a function, but cannot see the function definition. Your second include got lost, but if it's stdafx.h, anything before stdafx.h is lost, you need to include it first. Otherwise I'm not sure off the top of my head, but that is what the error means.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
How do i change the size of the split view?
I tried this.
m_splitWnd.GetPane(0,0)->SetWindowPos(NULL,0,0,10,10,SWP_NOMOVE);
m_splitWnd.RecalcLayout();
does'nt seems to work.
Anyone?
|
|
|
|
|
dumb me.
Can be done with SetColumnInfo and SetRowInfo.
Leave this thread here, just in case someone needs it
|
|
|
|
|
How could we have an object (not dynamicall created) of CFormView (and derivatives)? I've tried:
CSomeView someview;
someview.Create(...);
but they give me "An unsupported operation was attempted". Any way for me to create CSomeView manually (explicit call to Create() ) ? Or any suggestion/hack on allowing me to do this?
|
|
|
|
|
Why not just use a dialog box instead?
|
|
|
|
|
To be exact, I want it to be a child (control?) in a (well-known)CSizableControlBar derivative.
|
|
|
|
|
It should not be a problem to create a CFormView
can be seen from this example
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0998/c++0998.htm&nav=/msj/0998/newnav.htm
|
|
|
|
|
hmm... the example doesn't show me how to create a CFormView DIRECTLY... nice article though. thanx
What I want is, the CFormView is not created dynamically under a CSplitterWnd, but I want it to be under a CControlBar... and created (maybe) in OnCreate() of CControlBar by calling CFormView::Create().
|
|
|
|
|
I don't know if this of any help but I use this for create CFormView's on the fly.
<br />
<br />
#define VIEWS_RECALLING_VIEW AFX_IDW_PANE_FIRST + 5<br />
<br />
<br />
m_pRecallingView = new CRecallingView;<br />
AddView(m_pRecallingView, VIEWS_RECALLING_VIEW);<br />
}<br />
<br />
void CCTIReceptionApp::AddView(CView* pView, UINT nID)<br />
{<br />
CDocument* pCurrentDoc = ((CFrameWnd*) m_pMainWnd)->GetActiveDocument();<br />
<br />
CCreateContext newContext;<br />
newContext.m_pNewViewClass = NULL;<br />
newContext.m_pNewDocTemplate = NULL;<br />
newContext.m_pLastView = NULL;<br />
newContext.m_pCurrentFrame = NULL;<br />
newContext.m_pCurrentDoc = pCurrentDoc;<br />
<br />
CRect rect(0,0,0,0);<br />
<br />
char szTemp[64];<br />
<br />
sprintf(szTemp, "ViewList%x", nID);<br />
<br />
pView->Create(NULL, NULL,<br />
(AFX_WS_DEFAULT_VIEW & ~WS_VISIBLE),<br />
rect, m_pMainWnd,<br />
nID, &newContext);<br />
<br />
pView->SendMessage(WM_INITIALUPDATE, 0, 0);<br />
}<br />
<br />
<br />
Michael
Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor
|
|
|
|
|
I have this problem. A class I am using has using namespace std within a included header. My problem is that this class has parameters named "list" (of type string) and "vector" (float[3]) which will cause a class template error.
Rather than rename the parameters or remove 'using namespace', is there something else that I can do?
Thanks
---
|
|
|
|
|
Rather than rename the parameters or remove 'using namespace', is there something else that I can do?
No, but removing using namespace should cause no problems: simply delete this line (which is a big no-no in header files) and prefix every name belonging in the standard library with std:: . It's as simple as this.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Does anyone know of commercially available library that could parse incoming multi-mime HTTP posts?
Thanks,
John
|
|
|
|
|
here is a code snippet that may help you (or not...)
static char cpBoundaryTag[] = "boundary=";
static char cpContentDispTag[] = "Content-Disposition: ";
static char cpContentTypeTag[] = "Content-Type: ";
static char cpNameTag[] = "name=";
static char cpFileNameTag[] = "filename=";
BOOL WorkerThreadObj::ReadMultiPartMessage()
{
m_bIsMultiPartRequest = TRUE;
char caBoundary[256];
char *cpBoundary = strstr(m_pECB->lpszContentType,cpBoundaryTag);
if (cpBoundary)
{
cpBoundary += strlen(cpBoundaryTag);
while (*cpBoundary == ' ')
cpBoundary++;
strncpy(caBoundary,cpBoundary,255);
caBoundary[255] = 0;
cpBoundary = strchr(caBoundary,' ');
if (cpBoundary)
*cpBoundary = 0;
}
else
{
EraseContent();
StartContent();
WriteTitle();
WriteContent("Multipart Boundary String Not Found! ");
EndContent();
return FALSE;
}
BOOL bDeleteReadBuffer = FALSE;
char *cpReadBuffer = m_cpInputBuffer;
int iReqLength = m_pECB->cbTotalBytes;
if (iReqLength >= m_pLightningServer->m_iInputBufferSize)
{
bDeleteReadBuffer = TRUE;
cpReadBuffer = new char[iReqLength+1];
if (!cpReadBuffer)
{
EraseContent();
StartContent();
WriteTitle();
char caBuf[128];
sprintf(caBuf,"Unable To Allocate Memory To Read All %d Bytes of Request!",iReqLength);
WriteContent(caBuf);
EndContent();
return FALSE;
}
}
memcpy(cpReadBuffer,(LPCTSTR)m_pECB->lpbData,m_pECB->cbAvailable);
*(cpReadBuffer + m_pECB->cbAvailable) = 0;
if (m_pECB->cbAvailable < m_pECB->cbTotalBytes)
{
LPSTR cpTarget = cpReadBuffer + m_pECB->cbAvailable;
DWORD cbRemaining = m_pECB->cbTotalBytes - m_pECB->cbAvailable;
DWORD cbRead;
while (cbRemaining > 0)
{
cbRead = cbRemaining;
if (!m_pECB->ReadClient(m_pECB->ConnID,(LPVOID)cpTarget,&cbRead))
{
EraseContent();
StartContent();
WriteTitle();
char caBuf[128];
sprintf(caBuf,"Unable To Read All %d Bytes of Request!Only %d Bytes Were Able To Be Read!",
m_pECB->cbTotalBytes, m_pECB->cbTotalBytes - cbRemaining);
WriteContent(caBuf);
EndContent();
if (bDeleteReadBuffer)
delete [] cpReadBuffer;
return FALSE;
}
if (cbRead == 0)
break;
cpTarget += cbRead;
cbRemaining -= cbRead;
}
}
*(cpReadBuffer + m_pECB->cbTotalBytes) = 0;
// now, find all boundaries and split up contents
MultiPartParam *pParam = NULL;
char *cpDataStartMarker = NULL;
int iBoundaryLen = strlen(caBoundary);
cpBoundary = cpReadBuffer;
char *cpEnd = cpReadBuffer + m_pECB->cbTotalBytes;
do
{
while (*cpBoundary != caBoundary[0] && cpBoundary < (cpEnd-iBoundaryLen))
cpBoundary++;
if (!memcmp(cpBoundary,caBoundary,iBoundaryLen))
{
// found one!
if (cpDataStartMarker && pParam)
{
pParam->m_lContentLength = cpBoundary-cpDataStartMarker-4;
pParam->m_pData = (BYTE *)(new char[pParam->m_lContentLength+1]);
if (!pParam->m_pData)
{
EraseContent();
StartContent();
WriteTitle();
WriteContent(" Unable To Allocate Memory For MultiPart Parameter!");
EndContent();
if (bDeleteReadBuffer)
delete [] cpReadBuffer;
return FALSE;
}
memcpy(pParam->m_pData,cpDataStartMarker,pParam->m_lContentLength);
*(pParam->m_pData+pParam->m_lContentLength) = 0;
cpDataStartMarker = NULL;
}
cpBoundary += iBoundaryLen;
// check for terminating boundary
if (!memcmp(cpBoundary,"--",2))
break;
pParam = new MultiPartParam;
m_oMultiPartParams.AddTail((CObject *)pParam);
cpBoundary += 2; // skip past CR/LF
while (*cpBoundary != '\x0D' && *(cpBoundary+1) != '\x0A')
{
if (!memicmp(cpBoundary,cpContentDispTag,strlen(cpContentDispTag)))
{
cpBoundary += strlen(cpContentDispTag);
char *p = cpBoundary+1;
while (*p != ';' && *p != '\x0D')
p++;
p++;
while (*p == ' ' || *p == '\x0A')
p++;
cpBoundary = p;
}
else if (!memicmp(cpBoundary,cpNameTag,strlen(cpNameTag)))
{
cpBoundary += strlen(cpNameTag);
cpBoundary++; // skip past the qoute
char *p = cpBoundary;
while (*p != '\"')
p++;
*p = 0;
strcpy(pParam->m_caParamName,cpBoundary);
p++;
while (*p != ';' && *p != '\x0D')
p++;
p++;
while (*p == ' ' || *p == '\x0A')
p++;
cpBoundary = p;
}
else if (!memicmp(cpBoundary,cpFileNameTag,strlen(cpFileNameTag)))
{
cpBoundary += strlen(cpFileNameTag);
cpBoundary++; // skip past the qoute
char *p = cpBoundary;
while (*p != '\"')
p++;
*p = 0;
strcpy(pParam->m_caFileName,cpBoundary);
p++;
while (*p != ';' && *p != '\x0D')
p++;
p++;
while (*p == ' ' || *p == '\x0A')
p++;
cpBoundary = p;
}
else if (!memicmp(cpBoundary,cpContentTypeTag,strlen(cpContentTypeTag)))
{
cpBoundary += strlen(cpContentTypeTag);
char *p = cpBoundary+1;
while (*p != ';' && *p != '\x0D')
p++;
*p = 0;
strcpy(pParam->m_caContentType,cpBoundary);
p++;
while (*p == ' ' || *p == '\x0A')
p++;
cpBoundary = p;
}
else
{
char *p = cpBoundary+1;
while (*p != ';' && *p != '\x0D' && *p != ' ')
p++;
p++;
while (*p == ' ' || *p == '\x0A')
p++;
cpBoundary = p;
}
}
cpBoundary += 2;
// mark start for later extract of the data...
cpDataStartMarker = cpBoundary;
}
else
cpBoundary++;
}
while (cpBoundary < (cpEnd-iBoundaryLen));
if (bDeleteReadBuffer)
delete [] cpReadBuffer;
return TRUE;
}
|
|
|
|
|
I'm getting the following errors when I try to compile my code. I think it derives from the line #DEFINE INITGUID...
error C2065: 'GUID_NULL' : undeclared identifier
error C2440: 'default argument' : cannot convert from 'int' to 'const struct _GUID &'
Reason: cannot convert from 'int' to 'const struct _GUID'
No constructor could take the source type, or constructor overload resolution was ambiguous
error C2548: 'AtlAxCreateControlEx' : missing default parameter for parameter 6
error C2440: 'default argument' : cannot convert from 'int' to 'const struct _GUID &'
Reason: cannot convert from 'int' to 'const struct _GUID'
No constructor could take the source type, or constructor overload resolution was ambiguous
DOES ANYONE HAVE ANY SUGGESTIONS ON HOW I COULD HANDLE THIS??? SUGGESTIONS VERY MUCH APPRECIATED.
THANKS
|
|
|
|
|
Hello,
I'm using the following code fragment:
void CGoalsListView::OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVDISPINFO* pDispInfo=(NMLVDISPINFO*)pNMHDR;
CDC* pDC = GetDC();
...
long npixIndent = pDC->GetTextExtent(...).cx;
...
...and the pDC->GetTextExtent(...).cx seems to arbitrarily give different results after using the program for a while. At first, the program runs fine, and after clicking around the UI for a while, it this suddenly switches to another set of values and gives consistently larger (wrong) values.
Does anyone see something obvious here? Is the DC changing on me? I've debugged down to the GetTextExtent arguments and results, but not in to the GetTextExtent function.
thanks!
Jon Paul
|
|
|
|
|
It uses the current font, maybe that is being changed.
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
Jon Paul wrote:
gives consistently larger (wrong) values
Mmmhh ... As far as I know, the CSize structure is made up of two int and not long int... did you try with
int npixIndent = pDC->GetTextExtent(...).cx
This seems naive, but sometimes
Another possibility is that you changed the font size, but if the values are consistently larger , I do not think it is because if that.
~RaGE();
|
|
|
|
|
Thanks for the advice guys. I tried changing my variable to an int but that didn't change anything.
I found that the effect goes in and out every 5 or so attempts to run this code (i.e., 5 or so times with good results, and 5 with erroneous results).
Hmm......... still thinking myself, but any help would be appreciated.
thanks!
Jon Paul
|
|
|
|
|
Hi everybody,
When updating say a static text control frequently the control flickers a lot. For instance when I do this repeatedly:
wndCtrl->SetWindowText(str);
Is there a way to avoid the flickering?
Thx,
/T
|
|
|
|
|
are you do that with in a timer???????
Renjith-The CPian.
|
|
|
|
|
No, I'm reporting the progress of a lengthy process and I'm doing it withing a for loop:
for (int i=0; i<2342323346; i++)
{
DoLengthThing();
wndStaticText->SetWindowText(progress_str);
}
How can I make the static control not to flicker like crazy?
/T
|
|
|
|
|
store a copy of what you are setting the control to and only update the control if the string has changed....
|
|
|
|
|