|
<small><b>bdiamond wrote:</b></small>
<i>ForumVisual C++
Subject:Re: vector problem
Sender:bdiamond
Date:11:19 1 Jun '04
I can #include in the header file for a class I've created, but I can't put a vector declaration in my header file</i>
?? Why not?
You can put in yourheader.h
#include <vector>
using namespace std;
class CFish
{
public:
vector<int> m_nIntVec;
};
and it works quite happly.
<small><b>bdiamond wrote:</b></small>
<i>I figured I needed the stuff from stdafx.h in my header file also</i>
No. Never include stdafx.h in a header. include stdafx.h should always be the first include in a .CPP and any other includes that follow will have stdafx.h already included.
|
|
|
|
|
I forgot the 'using' directive. thanks!!!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
I am getting problem while displaying chart (V.T.Chart Error)
Can anyone let me know why it is comming.
Thanks
|
|
|
|
|
Theme of code:
Draw to Memdc
in OnDraw
Stretch over the clientDc
Save the dc content to the image file
Problem faced
Well this code is executed in starting time i.e. 1-2 turn when the function is called it will display the things drawn on the view. Even when we save bitmap it does save to BMP file (3.6Mb)
After 1-2 turns it makes screen blasnk and the MemDC contains nothing. Even when MemDC is saved as Bitmap file then it makes BMP file of 1*1 pixel and of size 70 bytes.
What can be the problem? My MemDC is member variable of the class.
<br />
<br />
void CMyView:rawWFRDiagram(int Velocity)<br />
{<br />
char cc[10];<br />
int maxdelay = -1;<br />
CPatternDoc *pDoc = GetDocument();<br />
<br />
CSize sizeTotal; <br />
sizeTotal.cx = 590; sizeTotal.cy = 1100;<br />
SetScrollSizes(MM_LOENGLISH, sizeTotal);<br />
<br />
CClientDC ClientDC(this);<br />
OnPrepareDC(&ClientDC);<br />
<br />
ClientDC.SetMapMode(MM_TEXT);<br />
m_WfrBmp -- Member of CMyView of type CBitmap<br />
m_WfrBmp.DeleteObject (); <br />
m_WfrBmp.CreateCompatibleBitmap(&ClientDC, 860, 1100);<br />
MemDC.CreateCompatibleDC(&ClientDC); <br />
CBitmap *pOldBitmap = MemDC.SelectObject(&m_WfrBmp);<br />
MemDC.SetMapMode(MM_TEXT); <br />
MemDC.PatBlt(0, 0, 860, 1100, WHITENESS); <br />
<br />
Draw anything further to the MemDC<br />
<br />
<br />
MemDC.SetMapMode(MM_LOENGLISH);<br />
if(ClientDC.StretchBlt(50, 0, 860, -1100, &MemDC, 0, 0, 860,<br />
-1100, SRCCOPY) == FALSE)<br />
AfxMessageBox("Failed to draw WFR diagram"); <br />
}<br />
<br />
OnDraw()<br />
{<br />
pDC->StretchBlt(50, 0, 860, -1100, &MemDC, 0, 0, 860, -1100, SRCCOPY);<br />
<br />
}<br />
Help me to solve this problem?
Thanks in advance
Sandeep
Leave your mark wherever you go
|
|
|
|
|
Well in plain words my problem is that i have to draw on the view
and also in the memory device context, which will be used for storing the device context conte to the image file
If you can provide guideline and suggestions then it will be helpful.
NOTE
1.0 I have to keep CDC MemDC ( Memory device context) member of the class so that i can write it in the drawing function and then i can use the same in another function of the class to store it in the image
2.0 In OnDraw i have to render the memdc content on the view. Thats what i was doing? On running the application and trying the drawing function 1-2 times it just draws, but after that it does not draw and same 1*1pixel bitmap
<br />
OnDraw()<br />
{<br />
pDC->StretchBlt(50, 0, 860, -1100, &MemDC, 0, 0, 860, -1100, SRCCOPY);<br />
}
3.0 I want to know that does the following schema is ok?
memdc.createcompatibledc()
bmp.createcompatiblebitmap()
CBitmap *old =memdc.selectobject(bmp);
DO THE DRAWING HERE
memdc.selectobject(old)
another query related to this is that
does this will not effect my memdc.stretchblt in the onDraw.
What i mean is when i select anaother bitmap then does my mainbitmap on which i had drawn still carries the drawing and can i use that for saving as bitmap file?
Would it not affect that bitmap file?
If you can provide the sample code taking above points in consideration than i will be greatfull? Well also point out any mistake.
Leave your mark wherever you go
|
|
|
|
|
You having a 1 X 1 pixel bitmap in your memdc tells me that the bitmap selected into it is the original default bitmap that all memdcs have. You have at some point selected your bitmap out of the memdc.
If I were you, I would make the bitmap (CBitmap or HBITMAP) a member of your class. That way you only have to create it once. Select it into a memdc to draw on it, and select it out again when done. You can then pass that bitmap to your save function.
Remember, it is the bitmap that stores your image, not the DC. The DC is just the means that you use to draw onto a bitmap.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
The following code, which compiles just fine on VC6, apparently causes the VC7.1 (and presumably VC7.0) compiler to wet it's pants. I don't understand why?
#include <string>
class String {
public:
~String() { };
String(){};
String(const String& rhs) {
*this = rhs;
}
String(const std::string& rhs) {
};
};
class Path {
public:
Path() { };
Path( const String& filename );
Path( const Path& filePath );
virtual ~Path() { };
inline Path& operator= ( const Path& path ){
filename_ = path.filename_;
return *this;
}
inline Path& operator= ( const String& filename ) {
filename_ = filename;
return *this;
}
inline operator String () const {
return filename_;
}
inline operator String& () {
return filename_;
}
public:
String filename_;
};
class ConversionClass {
public:
ConversionClass() {
}
String getFileName() {
return filePath_;
}
Path filePath_;
};
int main(int argc, char *argv[])
{
ConversionClass* conversionClass = new ConversionClass();
String s = conversionClass->getFileName();
return 0;
}
The actuall warning/error is:
d:\code\junk\cvt\Conversion_c.cpp(68) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied
while calling the constructor 'String::String(const String &)'
d:\code\junk\cvt\Conversion_c.cpp(13) : see declaration of 'String::String'
Any thoughts, suggestions on how to get rid of this would be most welcome, and I'll be sure to have Bob send you a cookie
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
You could try this
Change
String getFileName()
to
const String& getFileName()
Ant.
|
|
|
|
|
Or probably better
String getFileName()
{
return (String)filePath_;
}
Ant.
|
|
|
|
|
ConversionClass::getFileName() returns a String , but first it has to convert a Path to a String . The rules for overload selection are way too complex for me to memorize, but it looks like the compiler can't choose between Path::operator String() const and Path::operator String&()
I would guess Path::operator String() const should be Path::operator const String() const instead.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
You cannot stop me with paramecium alone!
|
|
|
|
|
I am working with Jim Crafton on the VCF library
and I prepared the test case.
BTW we forgot to initialize filePath_:
ConversionClass() {
filePath_ = Path();
}
From MS help:
"illegal conversion; more than one user-defined conversion has been implicitly applied"
means:
"The compiler did not find an explicit conversion but did find a conversion, which it used."
If this is true, I wonder why we should have a warning.
If we have a chain of implicit conversions. Why we should make them explicit ?
In fact the fix:
String getFileName()
{
return (String)filePath_;
}
works, but I think there should be a way to make this conversion implicit without any warnings.
Otherwise what the conversion operators would be done for ?
And things would get pretty complicated if we should make explicit a chain of implicit conversion.
Both the fixes:
const String& getFileName()
and
inline operator const String2 () const
do not work, used together or not.
And nothing changes if I remove the function:
inline operator String2& () {
return filename_;
}
altogether and try the above fixes.
Should we consider this a MS bug and just eliminate the warning ?
|
|
|
|
|
No no.
Sorry. I tested against my original test case but a macro was altering the results.
Here are the true results:
String getFileName() {
return (String)filePath_;
}
works.
Eliminating the function as:
//inline operator String& () {
// return filename_;
//}
works.
Modifying:
NewString getFileName()
-->
const NewString& getFileName()
works.
Also:
-->
NewString& getFileName()
works.
Modifying
operator String () const
-->
operator const String () const
does not eliminate the warning.
|
|
|
|
|
Thanks a lot for the all answers !
As we could appropriately find a fix of the problem
Cheers,
Marcello
|
|
|
|
|
Hi
I have an application which call functions in a DLL. When debugging I use AfxMessageBox() but I want to use TRACE macro. If debugging I think I can use TRACE macro and it will output to the output window but is that only for my application? If I want the output from functions in my DLL how do I get trace output?
Can I direct my trace output to a file?
|
|
|
|
|
Anonymous wrote:
...is that only for my application?
No, TRACE() outputs to the debug window regardless. The DLL, however, will have to be compiled in debug mode, and the EXE will have to be started via F5.
Anonymous wrote:
Can I direct my trace output to a file?
Not by default. This utility does that, and more.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
In general, trace does nothing in release builds.
However using DbgView from www.sysinternals.com you can view outputs of OutputDebugString (TRACE...)
Are there TRACE calls in the dll?
Check _CrtDbgReport for secod question
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thank you for your help. That program looks very interesting. I have tried to use it with these results:
Running my program in debug but nothing happens. I have set afxTraceEnabled = TRUE; in CMyApp::InitInstance() but I see no output in the output window but I also see no output window in Visual C++ 6.0 anyway. Is there a way to display it while debugging?
I use the DebugView program and nothing happens whether I run my program in debug (F5) or just run it. If I place a call to OutputDebugString(""); though I then get my TRACE calls displayed in the DebugView program. Already it has detected a memory leak so that is good (or bad).
Can you tell me what am I missing?
|
|
|
|
|
Now I have removed the OutputDebugString() call and now when I run (not in debug using F5) the DebugView program displays the TRACE calls only in my application and not from the DLL even though I have TRACE calls in my DLL. It is now that this happens whether I include afxTraceEnabled = TRUE; or not. It is very useful like it is now but I cannot still get any output from my DLL.
|
|
|
|
|
I've tried:
<br />
ShowWindow(SW_SHOW);<br />
ActivateWindow();<br />
SetForegroundWindow();<br />
My window is a derived CDialog.
What's missing ?
|
|
|
|
|
Use SetWindowPos() and the HWND_TOP flag for zorder.
e.g.
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Ant.
|
|
|
|
|
This has no affect
The only thing that changes something is :
SetForegroundWindow();
It makes my window's entry in the task-bar blink, but the window doesn't jump to the foreground.
Perhaps this is privellege related, my call to SetForegroundWindow(); is done in response to a BroadcastSystemMessage with the BSF_ALLOWSFW flag. I don't thinks is the cause though as my window does start blinking...
|
|
|
|
|
Strange!?!
Could you please post a snip of your code where you are using this.
Ant.
|
|
|
|
|
Sender:
Sure, snippet below.
My guess is that my window-style or default-message-handling somehow affects this... But I can't point out exactly what.
<br />
DWORD target = BSM_APPLICATIONS;<br />
BroadcastSystemMessage( BSF_ALLOWSFW | BSF_POSTMESSAGE,<br />
&target,<br />
m_guiMsgId,<br />
0,<br />
0);<br />
<br />
Receiver:
Sure:
<br />
if (IsIconic()) ShowWindow(SW_RESTORE);<br />
SetForegroundWindow();<br />
|
|
|
|
|
OK, how did you call SetWindowPos() when you called it instead of SetForegroundWindow() ?
Ant.
|
|
|
|
|
SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|