|
FredrickNorge wrote: #include <assert.h>
#include <Windows.h>
#include <io.h>
#include <fcntl.h> /* Needed only for _O_RDWR definition */
#include <share.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <fstream>
Why don't you have these in the stdafx.h file?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
FredrickNorge wrote: vs2005, when i want to debug my mfc app with #include fstream
FredrickNorge wrote: 1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xdebug(32)
Generally speaking, in a MFC/VS2005 project of Debug configuration, the version of operator new being invoked is:
"afxmem.cpp" line 59,
void* __cdecl operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
{
return ::operator new(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
}
And then "afxmem.cpp" line 393,
void* __cdecl operator new(size_t nSize, int nType, LPCSTR lpszFileName, int nLine)
{
#ifdef _AFX_NO_DEBUG_CRT
UNUSED_ALWAYS(nType);
UNUSED_ALWAYS(lpszFileName);
UNUSED_ALWAYS(nLine);
return ::operator new(nSize);
#else
void* pResult;
#ifdef _AFXDLL
_PNH pfnNewHandler = _pfnUninitialized;
#endif
for (;;)
{
pResult = _malloc_dbg(nSize, nType, lpszFileName, nLine);
if (pResult != NULL)
return pResult;
#ifdef _AFXDLL
if (pfnNewHandler == _pfnUninitialized)
{
AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
pfnNewHandler = pState->m_pfnNewHandler;
}
if (pfnNewHandler == NULL || (*pfnNewHandler)(nSize) == 0)
break;
#else
if (_afxNewHandler == NULL || (*_afxNewHandler)(nSize) == 0)
break;
#endif
}
return pResult;
#endif
}
Maxwell Chen
-- modified at 14:01 Tuesday 18th July, 2006
|
|
|
|
|
ok i tried to overide the calls, no luck .
What ive done for now though, is commented the verry brief code that actualy use fstream when i debug, and uncomment it for the final release. Works ok for now...
|
|
|
|
|
For this kind of problem, sometimes looking at the compilation log message may help. For example when you have such compilation output message as below:
Compiling ...
stdafx.cpp
test1.cpp
test2.cpp
test3.cpp
e:\wrkshp\test3.cpp(102) : error Cxxxx: blah blah blah
test4.cpp
test5.cpp
Test - 1 error(s), 0 warning(s)
Then you may try to back trace those existing definitions by looking at the included headers (and the related compilation units) in the last compilation (eg: test3.cpp) unit wherein errors are found.
Maxwell Chen
|
|
|
|
|
will do, thanks for all the inputt Maxwell Chen
|
|
|
|
|
Does anyone out there have any suggestiosn on what it the best way to move existing (unmanaged) C++ code into CLR? is it best to port it to C# or is it easier to convert it into "managed" C++ so that the classes becomes available in other languages?
Anil Gurnani
Bear Stearns
|
|
|
|
|
One purpose of MC++ ( C++/CLI ) is the easy porting of C++ code to .NET
|
|
|
|
|
I am building a customized CFileDialog and I have a couple of questions.
1) How do I clear the filename history of the CFileDialog. When my application comes up and I click on the folder to bring up the dialog, the history box is full of files even though I have not entered anything yet. I would like to clear it out prior to creating the CFileDialog.
2) How do I implement the help file for the
Z.K.
|
|
|
|
|
Z.K. wrote: 1) How do I clear the filename history of the CFileDialog. When my application comes up and I click on the folder to bring up the dialog, the history box is full of files even though I have not entered anything yet. I would like to clear it out prior to creating the CFileDialog.
The entries are stored in the registry.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Can someone explain to me how I get my dialog to repaint itself after I draw text on it via the CDC::TextOut command?
Here is my code that I am using for drawing the text.....
CFont Smaller_font;
Smaller_font.CreateFont(40,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,ANSI_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DECORATIVE, "Arial");
def_font = dc.SelectObject(&Smaller_font);
dc.SetTextColor(COLORREF RGB(0,0,0));
dc.TextOut(150, 130, "Thank you.");
Smaller_font.DeleteObject();
This draws the "Thanks you" where I tell it, but if I have the program running and another window covers up the "Thank you." that I just drew, it erases it from my dialog. I am thinking that it is not forcing the repaint command somehow, but I am not sure how to force it.
Please help....
|
|
|
|
|
do your painting in the dialog's OnPaint member function.
Do the chickens have large talons?
|
|
|
|
|
Where is this code ? is in the OnPaint function of the dialog ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
No, it's not in the OnPaint function.
I am drawing text on the screen at different parts of the program, after the user clicks certain buttons.
|
|
|
|
|
Well, that's your problem. When the user clicks to trigger a draw, you need to modify some state data in your object. The OnPaint should then interpret what that data means, and provide an up-to-date set of paint operations.
To trigger the repaint, invalidate your window.
Steve S
Developer for hire
|
|
|
|
|
I think I understand what you mean, but let me check.
In the OnPaint() command of my dlg class, I need to have it check to see if, say a boolean value is true? If so, then do what?
Also, what do you mean by... "To trigger the repaint, invalidate your window"
|
|
|
|
|
why you dont use these function in wm_paint
whitesky
|
|
|
|
|
what do you mean by this?
I have tried...
PostMessage(WMPAINT,0,0), but that didn't work either.
|
|
|
|
|
Move your drawing logic to the handler for the WM_PAINT message. Windows will send this message to your dialog when necessary.
To force a repaint (uncommon), call Invalidate() .
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
No You can declare WM_PAINT in your program and insert your functions to it(use form dc)
whitesky
|
|
|
|
|
Like Chris said you need to move that to the OnPaint message.
void CDialog::OnPaint(...)
{
if (m_bDisplayThankYou)
{
DrawThankYou(pDC);
}
}
|
|
|
|
|
OK,
Here is what I have tried now....
When the user clicks the button to trigger the drawing of text, I set a boolean value to true (RegKeyAvail).
And I also implemented this...
void CMartinPhDDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
if(RegKeyAvail){
dc.SelectObject(&Welcome_font);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(COLORREF RGB(255,0,0));
dc.TextOut(30,30, "WELCOME");
Welcome_font.DeleteObject();
}
if (IsIconic())
{....
However, now the text isn't showing up at all. I know that the OnPaint is being called because I have set breakpoints in there and the functions walks through the dc.TextOut call, but does nothing......
|
|
|
|
|
goodoljosh1980 wrote: dc.SetTextColor(COLORREF RGB(255,0,0));
that compiles?
and, where do you create Welcome_font ?
Do the chickens have large talons?
|
|
|
|
|
Yeah, it compiles...
That is how I set the color of the text I want.
The Welcome_font is a member variable of the main dialog and is created in the
BOOL CMartinPhDDlg::OnInitDialog()
{
CDialog::OnInitDialog();
GetWindowRect(m_rect);
//Hide all diagrams to begin with
top_diagram.ShowWindow(0);
Intro_Stylus_Diagram.ShowWindow(0);
Welcome_font.CreateFont(90, 0, 0, 0,
FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DECORATIVE, "Times New Roman");
|
|
|
|
|
are you calling Invalidate() UpdateWindow() after you set the boolean?
By the way, don't delete the font object in the OnPaint method if it is not being recreated there. You are creating the font object once in your OnInitDialog but then deleting it everytime OnPaint runs.
|
|
|
|
|
I was calling Invalidate() in the OnPaint...
Once I moved it...the text showed up and it doesn't get erased!!!
THANKS TO EVERYONE!
|
|
|
|