|
It works for me as shown.
You should only get that error if the compiler doesn't know
the BankAccount when the class is referenced. Without seeing
the exact code that's not failing, I don't know
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How to save image in sqlserver with VC++6?
adamichopirgashthersjavanmigardad
|
|
|
|
|
How are you accessing the database? C++ framework? APIs?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
To save images in datbase Sql Sever introduced new Datatype BLOB.
You need to search for manipulation of BLOB in VC6.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Hello to all, and thanks for helping.
My question is something like this:
Say I have a function in a base class that prints the value of two of it's members.
Now I go and create a derived class from the base class the has one more member on top of the two it inherits from the base.
and lets say the function name is show().
How, from the implementation of the derived do I call the implemetation from the base, to save code duplicating?????
class base
{
int a;
int b;
void show(){cout << a << b;}
};
class derived
{
int c;
void show()
{
....;
cout << c;
}
};
what goes instead of the ....; line???
again thanks for your help
|
|
|
|
|
gizmokaka wrote: what goes instead of the ....; line???
base::show();
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
I did that before and it didn't work for some weird reason so I did this->base::show()
and now that I tried again after you said, it did work.
Funny how things work (probably wrote bad syntax before).
Any way on the same note.
How do I call the base constructor from the derived c'tor?
if:
class base
{
base(int a, int b)
{
x = a;
y = b;
}
};
class derived
{
derived(int a, int b, int c):z(c)
{
how to call base c'tor with a and b ????
or maybe it's also done in the initialization list???
}
};
|
|
|
|
|
gizmokaka wrote: maybe it's also done in the initialization list???
This guess is right.
gizmokaka wrote: derived(int a, int b, int c):z(c)
change the above line to
derived(int a, int b, int c):base(a,b), z(c)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
thanks man, it is more simple then I could have imagined yet I needed the pointing finger.
You really helped me, thank a lot again.
have a great night
|
|
|
|
|
I will give a vote on your help.
But I just encountered one more thing I wanna ask you.
I have a class with privates.
I create a new class and define a function in it to accept a pointer to a type of the
first class, and threw it, access the privates of that class.
in order to achieve that I wanna declare it as friend function in the first class.
How is that done?
How do I declare a member method of one class as a friend in another???
|
|
|
|
|
The simplest way is to declare the entire new class as friend of the old one, for instance
class B;
class A
{
friend class B;
int i;
public:
A():i(0){}
};
class B
{
public:
void changeA(A * pA){ pA->i=5;}
};
void main()
{
A a;
B b;
b.changeA(&a);
}
Unfortunately, while declaring friend an ordinary (i.e. global scope) function works fine, you cannot declare friend a method of a class still not declared (as B in my sample, that has, when A is declared, only a deferred declaration), see http://msdn2.microsoft.com/en-us/library/172fs28y(vs.71).aspx[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Hi All,
I've been looking for postings on this problem and have discovered I'm not alone, but no one seems to know the answer.
I have a legacy app I need to make run on Vista. It is using an MFC CListCtrl in report view. Whenever I mouse click (left or right) in the list control I get a default "bing" sound. The problem does not happen on XP.
Any thoughts?
Thanks!
Anthony
|
|
|
|
|
|
Thanks for the tip... but this won't work because when you override the default behaviour you literally override the default behaviour. Something as simple as highlighting will stop working. I can go down this route but I really don't want to have to write all the basic functionality for a list control because MS somehow added a beep. I'll consider this as a method of last resort.
|
|
|
|
|
I have found the solution to the problem myself...
Under sounds in Vista, if the entry "Select" has ever been given a sound file to play and then set back to empty the control will bing. The only easy fix I can see at this point is to assign an empty sound file to that entry. That will elliminate the problem.
I'd suggest this is a bug in Vista.
Anthony
|
|
|
|
|
In my VC6++ source, I'm building a sql string and I run into a problem when a field or string contains an apostrophe or single quote. The single quote in the CString object causes an improper termination of the SQL string syntax. Is there a way around this?
For example:
int iVendorID = 1;<br />
<br />
CString csVendorName = _T("Matt's Hobby Shop");<br />
<br />
CString csSQL = _T("");<br />
<br />
csSQL.Format(_T("Update tblVendorList Set VendorDescription='%s' where VendorID=%d"), csVendorName, iVendorID);
During execution, the sql statement becomes
Update tblVendorList Set VendorDescription='Matt's Hobby Shop' where VendorID=1
And things get ugly because it wants to set VendorDescription to 'Matt' and it has no idea what s Hobby Shop means.
|
|
|
|
|
in SQL, you must type a double simple quote if within a string...
CString csVendorName = _T("Matt''s Hobby Shop");
but the best is ever to use Parametrized Queries...
|
|
|
|
|
littleGreenDude wrote: CString csVendorName = _T("Matt's Hobby Shop");
How about:
CString csVendorName = _T("Matt''s Hobby Shop");
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have a barcode scanner which can emulate a Com Port (i.e. in the Device Manager it appears as a Com Port and I can communicate to it via HyperTerminal). How can I programmatically determine which Com Port (COM1, COM2, COM3, ..., etc) has been assigned to my scanner? If I look in the Device Manager there is some additional information available:
Metrologic USB Scanner (COM4)
Can I retrieve this additional descriptive information somehow from my C++ application? Thanks you in advance for any help.
|
|
|
|
|
The way to do this is to scan the available serial ports and then send a command to the deivce or something that will produce a known response. When you get the response, you have the device. Check if the Mfg. gives you a SDK to work with or they update the registry with useful information. Check the CP projects for a serial port scanner. I think Paul Discalia (sp?) did one a long time ago.
|
|
|
|
|
Thanks for your suggestion. I was unable to locate the serial port example by Paul, but I found another example that does exactly what I would like to do:
http://www.naughter.com/enumser.html[^]
The function CEnumerateSerial::UsingSetupAPI2 reads the entries in the Device Manager so I get the descriptive name of my barcode scanner and can thus locate the correct com port without having to actually communicate over it.
|
|
|
|
|
PJ Naughter is the guy I was thinking of, not Paul.
Sorry about that.
|
|
|
|
|
I have an application which allows users to create documents that could potentially contain a lot of fonts, brushes and pens. In order to keep GDI handle usage to a minimum I was planning to implement some form of shared GDI object pool (as many of the GDI objects used by these documents will be the same) but before I did I thought it worth asking if anyone here has come across anything similar before. I am using MFC FWIW.
Thanks in advance.
|
|
|
|
|
Rob Caldecott wrote: asking if anyone here has come across anything similar before
Yes I have implemented and seen libraries for object pools. I believe they are fairly common. In fact there is C++ template based article for one here on code project which one finds with a simple Google search[^].
|
|
|
|
|
I derived my class from CListBox called CMyListBox.
then I write the virtual function MeasureItem to change the height of items.
In my main dialog CMyDialog, construct a CMyListBox object.
CMyListBox m_ctlBox;
and in the CMyDialog::OnInitDialog
<br />
DDX_Control(pDX, BOXID, m_ctlBox);<br />
CMyDialog::OnInitDialog()<br />
{<br />
m_ctlBox.ModifyStyle(0, LBS_OWNERDRAWFIXED);<br />
}<br />
but it has no affect. The height doesn't change at all. But it executes fine.
Then I've tried comment the code m_ctlBox.ModifyStyle(0, LBS_OWNERDRAWFIXED);
And in the resource editor, I change the property of the ListBox with OwnerDraw to OwnerDrawFixed, then I got compilation assertion error.
What do I miss? And Why do I get the assertion error?But I don't want to create the CMyListBox on the fly at all, cause If I create it on the fly, I can't adjust its position and size.
And in the book «Programming with MFC 2nd», I program as the book shows, it works fine.
First, in the CMyListBox use the PreCreateWindowClass to add the style with LBS_OWNERDRAWFIXED OR LBS_OWNERDRAWVARIABLE.
Second, in the virtual MeasureItem function to change the height.
Third, But you should in the CMyDialog::OnInitDialog to create the CMyListBox on the fly, it should use CMyListBox.Create to create the ListBox, otherwise the CMyListBox::PreCreateWindowClass would not be called to initialize the style with LBS_OWNERDRAWFIXED.
|
|
|
|