|
Did you install the CRT and MFC source code? If so, you can step into the MFC implementation code (so long as you're working with a Debug build) and find what Win32 call is failing. That might give you some more information.
Only thing I can think of, apart maybe from finding some sample code, to see if there's anything you're missing?
|
|
|
|
|
This fails in otherwise working MFC document / view program.
And no I cannot step into the API.
Thanks
|
|
|
|
|
May be GetLastError() can give you some hints. Just add @err,hr to the watch window to get the last error description.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Vaclav_Sal wrote: if(!bmp->CreateBitmapIndirect((BITMAP * ) m_Doc->m_lpBi))
I'm suspicious about that cast - why did you need to cast to a BITMAP*?
Based on the limited info, I have a feeling you're not passing the correct structure...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
As always, you are correct!
BITMAP and BITMAPINFO are definitely different!
Here is my wrong code
if(!m_lpBmpInfo)
{
m_lpBmpInfo = (BITMAPINFO *)( new char[m_vfs]);
((LPBITMAPINFOHEADER)m_lpBmpInfo)->biSize = sizeof BITMAPINFOHEADER;
}
VERIFY(m_lpBmpInfo);
// document bitmap header pointer initialization - do only once in the class
if(!pDocument->m_lpBi)
{
pDocument->m_lpBi = (BITMAP *)( new char[m_vfs]);
((LPBITMAPINFOHEADER)pDocument->m_lpBi)->biSize = sizeof BITMAPINFOHEADER;
}
VERIFY(pDocument->m_lpBi);
As always - the de-reference symbol is shown as -> should be "->"
Now I need to figure out what data is missing from BITMAP. Should be easy.
Thanks Mark
Have a great holidays.
Vaclav
|
|
|
|
|
If you need a HBITMAP from a BITMAPINFO or BITMAPINFOHEADER, you may
want to look into CreateDIBitmap() or CreateDIBSection().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a simple base class that holds id's for use in sorting other classes. It is a non-templated class in an single hpp file ( indexedObject, see below )
class indexedObject
{
public:
indexedObject() : _mID(BAD_DB_ID) {}
indexedObject(dbID id) : _mID(id) {}
~indexedObject();
dbID getID(void);
void setID(dbID id);
bool operator<(const dbID& param) const;
bool operator>(const dbID& param) const;
bool operator==(const dbID& param) const;
bool operator!=(const dbID& param) const;
protected:
dbID _mID;
}; // indexedObject
inline indexedObject::~indexedObject() { _mID = BAD_DB_ID; }
inline dbID indexedObject::getID(void) { return _mID; }
inline void indexedObject::setID(dbID id) { _mID = id; }
inline bool indexedObject::operator<(const dbID& param) const
{
return (_mID < param);
}
inline bool indexedObject::operator>(const dbID& param) const
{
return (_mID > param);
}
inline bool indexedObject::operator==(const dbID& param) const
{
return (_mID == param);
}
inline bool indexedObject::operator!=(const dbID& param) const
{
return (_mID != param);
}
I have a templated class that inherits from the base class.
template <class _Ty> class fwdCurve : public indexedObject, public broadCaster
{
blah blah...
}
When I try to define setID in the derived class
template<class _Ty> void fwdCurve<_Ty>::setID(dbID id)
I get a C2244: indexedObject::setID : unable to match function definition to an existing declaration
I am able to work around this by declaring setID() in the derived class definition and explicitly calling the base class method but why is this happening?
I have VS 2005 with SP1 and hotfix KB930859 installed.
|
|
|
|
|
mjackson11 wrote: When I try to define setID in the derived class
template<class _ty=""> void fwdCurve<_Ty>::setID(dbID id)
I get a C2244: indexedObject::setID : unable to match function definition to an existing declaration
Yes - this is the way C++ works...you need a method declaration in the class before you can define it. The declaration in the base class does not change this.
mjackson11 wrote: I am able to work around this by declaring setID() in the derived class definition and explicitly calling the base class method but why is this happening?
If you just want to call the base classes implementation, then you need no method definition or declaration in the derived class.
What are you actually trying to accomplish?
|
|
|
|
|
Sorry, to be more specific, I tried to implement setID() in the derived class without putting setID in the class declaration. That's when it threw the error. If I define setID in the derived class declaration, when I implement it, it does not call the base class setID method. Seems like the compiler is defining them as two different methods instead of the derived class inhereting.
|
|
|
|
|
mjackson11 wrote: If I define setID in the derived class declaration, when I implement it, it does not call the base class setID method. Seems like the compiler is defining them as two different methods instead of the derived class inhereting.
Yep, that's the way most (if not all) OO languages work. The point is that if you do want to call the base classes method, you can very easily. However, if the language automatically called the base classes methods and you didn't want that to happen, you're stuffed.
Anyway - in conclusion, what you've described is the way C++ is meant to work.
|
|
|
|
|
I wasn't entirely clear about the one case when base class methods are called automatically.
If a base class implements a method and your derived class doesn't declare or define it, then the base class method is automatically called.
Consider this code:
#include <iostream>
class Base
{
public:
void A() { std::cout << "Base::A\n"; }
void B() { std::cout << "Base::A\n"; }
virtual void C() { std::cout << "Base::C\n"; }
};
class Derived : public Base
{
public:
void A() { std::cout << "Derived::A\n"; }
virtual void C() { std::cout << "Derived::C\n"; }
};
void VirtualTest(Base* pBase, const char* objName)
{
std::cout << "Calling pBase->A() with pBase = " << objName << "...\n";
pBase->A();
std::cout << "Calling pBase->C() with pBase = " << objName << "...\n";
pBase->C();
}
int main(int, char**)
{
Base base;
Derived derived;
std::cout << "Calling base.A()...\n";
base.A();
std::cout << "Calling base.B()...\n";
base.B();
VirtualTest(&base, "&base");
std::cout << "Calling derived.A()...\n";
derived.A();
std::cout << "Calling derived.B()...\n";
derived.B();
VirtualTest(&derived, "&derived");
}
You should get this output:
Calling base.A()...
Base::A
Calling base.B()...
Base::A
Calling pBase->A() with pBase = &base...
Base::A
Calling pBase->C() with pBase = &base...
Base::C
Calling derived.A()...
Derived::A
Calling derived.B()...
Base::A
Calling pBase->A() with pBase = &derived...
Base::A
Calling pBase->C() with pBase = &derived...
Derived::C
So - Derived overrides the A() and C() from Base and inherits B() from Base . The difference between overriding virtual and non-virtual methods is demonstrated in VirtualTest - when you have a pointer to base , Base::A() gets called because A() is non-virtual, whereas the implementation of C() that is called depends on the actual type of the object that is pointed to, not the type of the pointer.
|
|
|
|
|
My error, I got myself confused. Everything is working correctly. I had gotten confused with constructors that call the base class constructor. I re-declared everything and explicitly called the base class method.
|
|
|
|
|
In addition to Stuart's replies...
You haven't used "virtual' anywhere, so a method implementation in a derived
class has nothing to do with a base class' method.
Even if you use "virtual", you'd still need to include botht the definition and the
implementation in the derived class, and call the base class method explicitly if desired.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello all
I have the following two lines of code to play an avi file:
mciSendString("open Res\\test.avi type avivideo alias myfile", NULL, 0, NULL);
mciSendString("play myfile", NULL, 0, NULL);
The problem is that it plays the audio but no video is displayed.
I can play the video fine in any media player, but it wont show up in the program, but I know its getting to the file because I can hear the audio.
Any suggestions as to what the problem could be?
Thanks.
Chris
|
|
|
|
|
I believe it might have something to do with not having a "window" to play the video in. It might be simpler to use the MCIWnd functions (I've used them and had no problem in playing videos) compared to sending command strings yourself.
|
|
|
|
|
Yes! I tried that and it works. Once I set up a window to play it in with the MCIWnd functions the video plays in the window.
Thanks alot!
Chris
|
|
|
|
|
Hi
I use coin3d(v2.2) for my project. it work on my desktop bit Ican't use it in my laptop.
I use vs6 and my project use matlab engine too.
the error that I receive is
error signature:
AppName:matlabversion.exe Appver .0.0.0 modname: coind2d.dll
modver .0.0.0 offset:001f29fd
my laptop cpu is AMD(turion64) and my desktop is Intel.
my software and windows are exactly the same.
my graphic card is not installed on my laptop(I only have it's driver in Vista not XP).
I use windows XP.
Regards
|
|
|
|
|
You would probably get a better response on the coin3d support forum.
http://www.coin3d.org/support[^]
Btw... your pseudonym is saagh which is Irish or Scottish Gaelic på norsk skibet/båt == Boat/Ship in english. And the software library your inquiring about was written by a norwegian maritime companyKongsberg SIM[^]. Do you work in the marine industry?
Best Wishes,
-David Delaune
|
|
|
|
|
Saagh is my nickname.
I try coin3d suport forum but I don't get response yet.
I would be glad if you could help me.
Regards
S.A.Ghazvini
|
|
|
|
|
after file selecting from CFileDialog no new records added into log file.
Environment:
- Windows XP SP3, MSVC 6.0
- Dialog-based application
Logic:
- logging in file is Ok (file open+write+close)
- invoke DoModal()
- logging in file isn't performed
(running step by step in debug mode: open+write+close executed without errors and should be performed, but file hasn't new lines)
|
|
|
|
|
Are you sure, the file open/write/close are success? Add err,hr to watch window and check the error code when you step through the code. Well, if you could post the relevant code snippet, it would be more easier to isolate the issue.
Well, how do you open your log file? By just passing the filename? In that case it could be also due to the effect of chdir pitfall[^]. Well, check out that possibility too by opening the file by passing fully qualified path.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Jijo, thanks for reply
For logging I'm using CTextFile class by Johan Rosengren, sorry don't remember url.
The code for write:
BOOL CTextFile::AppendFile( CString& filename, const CString& contents )
{
CFile file;
CFileException feError;
BOOL result = TRUE;
if( file.Open( filename, CFile::modeWrite | CFile::modeCreate, &feError ) ) { // Write the file
file.Write( contents, contents.GetLength() );
file.Close();
}
else { // Set error message
TCHAR errBuff[256];
feError.GetErrorMessage( errBuff, 256 );
m_error = errBuff;
result = FALSE;
}
}
err,hr while Open(): "0xb7 Cannot create a file when that file already exists" doesn't matter - appears in both cases before and after DoModal().
Besides this trouble I have one more. Before selecting file I mount linux partition and unmount it after this. Selected file is copied into windows folder. After that linux partition can't be unmounted.
On the other hand moun/unmount hasn't an influence on logging.
|
|
|
|
|
Igor IP wrote: err,hr while Open(): "0xb7 Cannot create a file when that file already exists"...
What does this have to do with CFileDialog ?
Igor IP wrote: ...appears in both cases before and after DoModal().
How is DoModal() relevant?
If the problem is with opening and/or creating the file, focus on that rather than all the other stuff.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Igor IP wrote: if( file.Open( filename, CFile::modeWrite | CFile::modeCreate, &feError ) ) { // Write the file
If you open the file with just CFile::modeCreate , then it will truncate the content to zero - which can be a reason for your empty log file. Try adding the flag CFile::modeNoTruncate to the existing set of flags.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Sorry, I have got snippet from another function, in my case file used as follows
if( file.Open( filename, CFile::modeWrite | CFile::modeCreate | CFile::modeNoTruncate, &feError ) )
{
file.SeekToEnd();
file.Write( contents, contents.GetLength() );
file.Close();
}
and err,hr shows for
right before Open(): S_OK
Open(): 0xb7
SeekToEnd(): not changed
Write(): not changed
Close(): not changed
I see this in both cases: logging works good from starting program and after invoking CFileDialog::DoModal() no new line added into the file.
|
|
|
|