|
vasu wrote:
The SetItemText() method is returning true, but the treeitem is not updated and it is NULL
In this case, you have probably set the text for the wrong item ... check if the handle (childItem in your code) is really the good one. Be careful to the difference between Item index and handle.
~RaGE();
|
|
|
|
|
Hello,
First of all, I want to sorry about my terrible English.
Next, please show me the way to get the information of the printer.
Ex: When the user print his/her document (or anything else), my program catches this event and determining the total of printed pages for calculating cost.
If applicable, please give me the VC++ source code.
Thank you very much.
|
|
|
|
|
What kind of info do you want? Some information is harder to get then others.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
I only want the total of printed pages.
Ex: My program will start automatically every time Windows loads. During the Windows session, when user print his/her documents, my program will show the total of printed pages and the total cost of them.
Here is an output example:
Print time: 12:22:00
Document: letter.doc
Cost per page: 5
Total page(s): 3
Total cost: 15
|
|
|
|
|
ok, I'm working in win32 here, no MFC, when trying to create a listview control in a class I get the following err:
First-chance exception in pool.exe (COMCTL32.DLL): 0xC0000005: Access Violation.
Now, this err is on Win98 with IE 5.01
the code works fine on WinXP with IE6
it errs right on CreateWindowEx().
I tried just starting a new win32 app and cutting n pasting the code to create the listview n it works fine on that Win98. So my question is what could be the problem, is it the class?
|
|
|
|
|
|
I do call InitCommonControlsEx already, thats why it works when I try it outside of the class and why I don't get why it'd be causing that err.
|
|
|
|
|
does anyone code on Win98 anymore?
after hours trying to pinpoint the problem I found this: if I set the handle of the parent in CreateWindowEx() to that of a window created in a class it fails, setting the handle of a global parent works ok, so is this a known problem on 98?
CreateWindowEx(....., CWinA::hWnd,...) fails
CreateWindowEx(....., ghWnd,...) is ok
and yes, CwinA::hWnd is a static public member of the class, so I'm at a loss as to the problem, I'm looking for any ideas here ppl
|
|
|
|
|
in OnInitDialog, SetClipboardViewer() crash my app only in release mode
any ideas ?
thanks
|
|
|
|
|
adara wrote:
in OnInitDialog, SetClipboardViewer() crash my app only in release mode
any ideas ?
How did you find out that it was SetClipboardViewer() ? The function returns NULL when it fails, but usually does not crash the app, unless you are doing something related to it just after. So I´m wondering ... Could you post a code sample about how you use it ?
~RaGE();
|
|
|
|
|
It seems that when I add to a TreeControl (Win32 SDK not MFC) the pszString item I add is not the same was what I put in (eg. Put in text and get back a large string of hi-ascii).
I insert into the tree thusly:
<br />
TVINSERTSTRUCT tvs;<br />
TVITEM tvi;<br />
HTREEITEM last;<br />
<br />
tvs.hInsertAfter = TVI_LAST;<br />
tvi.mask = TVIF_TEXT;<br />
<br />
tvi.pszText = "Test Item #1";<br />
tvs.hParent = TVI_ROOT;<br />
tvs.item = tvi;<br />
last = TreeView_InsertItem(GetDlgItem(MainWindow,IDC_TREE),&tvs);<br />
To retrieve I handle the WM_NOTIFY message when the event is TVN_SELCHANGED.
<br />
case WM_NOTIFY: <br />
node = (LPNMTREEVIEW)lParam;<br />
if(node->hdr.code == TVN_SELCHANGED) {<br />
MessageBox(MainWindow,(char *)node->itemNew.pszText,"Selection CHANGED!",0);<br />
}<br />
break;<br />
In the debugger node->itemNew.pszText is high ascii garbage and no where near the "Test #1" item I put in. The book I have and the docs I've found so far all use the TreeControl by comparing the selected item to a list of the items added which is no good for me because I'm trying to build up the entire path from each selected tree item (like a file path). This occurs with multiple items in the tree control as well.
Any suggestions or ideas on where I have gone wrong would be greatly appricated.
Sean
|
|
|
|
|
Rule #1 of the list/tree control structs is: always init them to zero. You'd be surprised how much havoc is wrought if you don't do that.
TVINSERTSTRUCT tvs = {0};
TVITEM tvi = {0};
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Unfortunately, even with that problem still occurs. :L
Sean
|
|
|
|
|
NullStream wrote:
In the debugger node->itemNew.pszText is high ascii garbage and no where near the "Test #1" item I put in
That must be because you are simply not looking at the good item. I do not know enough about non MFC app to be of a great help, but try to see if the lines
node = (LPNMTREEVIEW)lParam;
if(node->hdr.code == TVN_SELCHANGED) {
MessageBox(MainWindow,(char *)node->itemNew.pszText,"Selection CHANGED!",0);
}
really refers to the correct item.
~RaGE();
|
|
|
|
|
I would suggest that where you have gone wrong is to assume the pszText member of itemNew is valid, it isnt. See the MSDN Library topic for TVN_SELCHANGED.
Try it like this:
if(node->hdr.code == TVN_SELCHANGED) {
node->itemNew.mask |= TVIF_TEXT;
TreeView_GetItem(GetDlgItem(MainWindow,IDC_TREE),&node->itemNew);
MessageBox(MainWindow,(char *)node->itemNew.pszText,"Selection CHANGED!",0);
}
|
|
|
|
|
Ok. That seem to do it and according to the help file I ended up with:
<br />
HWND ctrl = GetDlgItem(MainWindow,IDC_TREE);<br />
char buffer[1024];<br />
memset(buffer,0,1024);<br />
if(ctrl == NULL)<br />
MessageBox(MainWindow,"GET TREE","Selection CHANGED!",0);<br />
node->itemNew.mask |= TVIF_TEXT;<br />
node->itemNew.pszText = buffer;<br />
node->itemNew.cchTextMax = 1024;<br />
if(TreeView_GetItem(ctrl,&node->itemNew))<br />
MessageBox(MainWindow,(char *)node->itemNew.pszText,"Selection CHANGED!",0);<br />
This works fine but it seems from the Help files regarding TVITEM suggest than I can only "tell" if an item has a child. Is there a way to use the control itself to follow the lineage of the selected item? For arguments sake let's just say i'm trying to implement a file browser (not the case but the same idea). If I choose a file I need to build up the entire path based on the selection back to through the parents to the root. Do I have to "already know" the structure of the tree already? Having two copies (one in the tree control itself and the other in my program) of the same tree in memory seems to be a waste and terribly inefficient which is why I'm trying to just use the data in the treecontrol instead of building a tree data structure in memory which is replicated to the treecontrol.
Man that's wierdly stated hopefully I'm making some sort of sense here.
Sean
|
|
|
|
|
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.
|
|
|
|