|
Yeah, that seems to work.. Thank you(and Navin)
|
|
|
|
|
You probably need to define a copy constructor for your class.
E.g.,
class test
{
public:
test(const test &src);
CBrush f;
};
test::test(const test &src)
:f(src.f)
{
}
Then try it and see what happens. (Note, just a guess, I didn't actually try to compile this.)
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Objects that can be stored in std:: containers must be copyable, and copies must be equivalent. This isn't the case with CBrush. Even if you arrange a copy constructor such that the object being copied to takes ownership,
test ( const test& t)
{
f.Attach ( t.f.Detach ()) ;
}
you haven't met the 'equivalent' condition since the new object owns the Windows Brush and the old one no longer does. In your example if 't' was initialised with a valid brush after the push_back would no longer own it.
The copy constructor above won't compile because the argument 't' is const and we're trying to modify it with 'Detach', sound familiar?
In these circumstances it is appropriate to store a container of pointers and manage the destruction of the contained pointers manually.
Paul
|
|
|
|
|
Thank you, Paul, that was a good answer.
|
|
|
|
|
Paul Ranson wrote:
In these circumstances it is appropriate to store a container of pointers and manage the destruction of the contained pointers manually.
Or even better, to use some smart pointers, like boost::shared_ptr or Loki::SmartPtr
|
|
|
|
|
Hi all,
I'm having what I consider to be an inexplicable problem printing in my program. I've searched message boards, google, etc.. for the past week and no dice. I have two different "reports" that are displayed in the main window of my SDI app and should be printable. All of the drawing code is contained in OnDraw(), and the program draws the appropriate report based on flags set by button presses. Both reports display fine in Print Preview, but only one will actually print. When i print the other, the printer just spits out a blank page. I've replaced the drawing code in the function to simply display a rectangle in the center of the view for testing, but it still displays fine in print preview, but wont print. The report that is displayed by default is the one that prints okay, so i'm wondering if I need to re-initialize the CDC between prints or something along those lines. Thanks for reading this far, and thanks for any help you can provide.
|
|
|
|
|
Acetate wrote:
i'm wondering if I need to re-initialize the CDC between prints...
Printing the non-working report first will tell you if it's an initialization issue or not.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
True true. Just tried that, and sure enough, its still shooting out a blank page. Thanks for responding.
|
|
|
|
|
I'm sorry I could not be of more help. A lot of times, knowing what the problem is not is just as important as knowing what the problem is.
Thomas Edison said something to the effect of "I have not failed. I've just found 10,000 ways that won't work."
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Do you have both reports in the SDI view or do you switch between the 2 reports? Do you print both reports on 2 pages or only one?
If you do something more complex the MFC classes often won't do as they should. I think that I can say that I have stressed the MFC classes to their limits with the printing in my project...
I would try to implement the CView::OnPrint method and try to draw your content not directly to the print DC but first into a memory DIB which is compatible to the screen. Then you have to have to use StretchDIBits to "copy" the DIB to the printer. My experience is that in general it is not a good idea to do the output directly on the printer with the same drawing code which you use for your screen output. Many printers support only a subset of the GDI functions which you can use to draw on the screen. Often the output looks ugly or you won't have any ouput. Since the PrintPreviw uses a compatible screen DC to draw (the print DC is only used to do the sizing) your output may look good on print preview but not on the printer. But there are also some cases where your output sucks in print preview but looks good on the printer.
If you dont't have experience with DIBs take a look at the MSDN knowledge base article "DIBs and Their Use" from Ron Gery.
So I would do something like this:
<br />
void CReportView::OnPrint(DCD* pDC)<br />
{<br />
OnDraw(&memoryDC);<br />
}<br />
Since I don't know your implementation this is just a hint how I would do it. But I think drawing in a DIB may solve your problem.
|
|
|
|
|
Hey,
I'm glad I'm not the only one who's encountered problems with the MFC printing classes. I appreciate the lengthy response. I switch between the 2 reports in the SDI view, and I print the reports seperately on two different pages. (They are only one page reports as well). I'll take a look at the DIB functions and get up to speed. The only thing is, I don't use any different GDI functions in the two reports, and the first one prints fine. Thanks again for taking the time to help.
|
|
|
|
|
OK, if you use the same GDI functions, than it seems to be an other problem. What are your configurations in the OnBeginPrinting and OnPrepareDC methods? Have you overwritten those methods? Do you modify the CPrintInfo object, e.g. you can set the number of pages to print.
|
|
|
|
|
I've been looking for an easy way to encrypt data with an API function but all I found - e.g DPAPI - use machines & users credentials and so on whereas I only want to provide a password to retreive the original data from any users and any computer.
Any help would be appreciated.
Richard
Tout programme dont la fiabilité dépend de l'homme n'est pas fiable
|
|
|
|
|
|
Hi,
I've got a very weird problem. When my MFC Dialog based app starts it stops after 10 seconds or so. without any reason : no crash message, no error debug message, nothing....
I don't need to do anything (click on a control, edit some text, etc.) it just stops.
If someone had the same kind of problem or knows what it's all about please let me know.
thank.
|
|
|
|
|
could you give us your code written into OnInitDialog() ?
else, what messages does your handler catch ?
TOXCCT >>> GEII power
|
|
|
|
|
<code>
BOOL CFrontEndWin32Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
CheckInstallState();
UpdateText();
#if COMPILE_FOR_AUTORUN
if (e_ISNotInstalled == m_InstallState)
{
char VolumeName[FILENAME_MAX];
char CurrentPath[MAX_PATH];
getcwd(CurrentPath, sizeof(CurrentPath));
CurrentPath[3] = '\0';
if (TRUE == GetVolumeInformation(CurrentPath, VolumeName, sizeof(VolumeName), 0, 0, 0, 0, 0))
{
if (0 != strcmpi(MAIN_INSTALL_DISK_VOLUME_NAME, VolumeName))
{
char Buffer[512];
LoadString(AfxGetResourceHandle(), IDS_INSERT_DISK_ONE, Buffer, sizeof(Buffer));
AfxMessageBox(_T(Buffer), MB_OK);
OnCancel();
}
}
}
#endif // COMPILE_FOR_AUTORUN
return TRUE;
}
BEGIN_MESSAGE_MAP(CFrontEndWin32Dlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_DESTROY()
ON_CBN_SELENDOK(IDC_COMBO_LANGUAGE, OnCbnSelendokComboLanguage)
ON_BN_CLICKED(ID_DISPLAY, OnBnClickedDisplay)
ON_BN_CLICKED(ID_HELP, OnBnClickedHelp)
ON_BN_CLICKED(ID_CONTROLLERS, OnBnClickedControllers)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
</code>
|
|
|
|
|
Well have you set up some recurrsive function that calls every clock tick????
I guess its mostly due to stack overflow. Checkout wheather you have any infinite loop or never ending recurrsive function call.
God is Real, unless declared Integer.
|
|
|
|
|
But if it was an stack overflow i could see it in debug mode !!
another weirdo too : when i run regedit the same thing happens....
|
|
|
|
|
virus beahavior....
already saw something like that.
TOXCCT >>> GEII power
|
|
|
|
|
Humm, I think you should run the anti-virus software.
God is Real, unless declared Integer.
|
|
|
|
|
toxcct, Mr.Prakash,
actually you were left er... right
It seems that a virus is at work in my job's network. Not really harmfull (can really a virus NOT harm you ??) but it took the day to understand that my problem may be was viral, since two other co-workers had the same problem with other apps (regedit and a dictionary software).
It's the first time I get to meet a virus and I still don't understand who can code a virus that close apps....
Anyway, the lesson of the day was : communicate as much as you can
|
|
|
|
|
haust wrote:
actually you were left er... right
not able to get those words rite huh ?
haust wrote:
Not really harmfull
Not harmfull in the senceof not doing any destruction, but it wasted lot of your time and thats what the virus do and if time is money for your company and so also money too.
haust wrote:
I still don't understand who can code a virus that close apps....
Well generally the virus writter wont give away his identity, but he may be sitting rite next to you and smiling every time your application closes.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
I have a SDI with splitters that look like this:
_____________
|......|............|
|View|............|
|Tree|ViewList.| ....(fig. 1)
|......|............|
|......|............|
|____|_______|
and I am trying to make a second View (Frame) with splitters that look like this:
________________
|.....| View 2........|
|.....|___________|
|.....|.....|...........|
|V1..|.....|...........|
|.....|V3..| View 4.| (fig. 2)
|.....|.....|............|
|.....|.....|............|
|___|___|________|
The 1. question: How can I switch between the frames (Views)?
The 2. question: How can I create the 2. frame with splitter to look as shown (fig. 2).
It is important for the first version, that I can switch between to frames. Maybe it is easier to make the second frame like this (no Splitter in a splitter –fig. 3):
_______________
|V 1..| view2.....|
|____|_________|
|View|..............| .... (fig. 3)
| 3...|View 4.....|
|......|..............|
|......|..............|
|____|________|
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, <br />
CCreateContext* pContext) <br />
{<br />
if (!m_wndSplitter.CreateStatic(this,1,2))<br />
{<br />
return FALSE;<br />
}<br />
CRect rect;<br />
GetClientRect(&rect);<br />
CSize sizeTree = rect.Size();<br />
<br />
sizeTree.cx = rect.Width()/4; <br />
<br />
if (!m_wndSplitter.CreateView(PANE_ROW_ZERO, eTreeWinPane, RUNTIME_CLASS(CViewTree),<br />
sizeTree, pContext)|| <br />
(!m_wndSplitter.CreateView(PANE_ROW_ZERO, eListWinPane, RUNTIME_CLASS(CViewList),<br />
CSize(100,100), pContext)))<br />
{ <br />
return FALSE;<br />
}<br />
return TRUE;<br />
}<br />
Must I use OnCreateClient()function, or there is an alternative?
Thanx in advance..
Nadin_Sam
|
|
|
|
|
Dear friends,
What is the equivalent function with MoveFileEx w/ dwFlags=MOVEFILE_REPLACE_EXISTING in Windows 98? MoveFileEx is not suppoted in Windows 98, so I have to use its old version, which is MoveFile. However, MoveFile failed when lpNewFileName already exists. Drop me your advices. Thanks so much.
BRs.
____
Tuan
|
|
|
|