|
I have a function show where I have the
following statements:
cout<
|
|
|
|
|
Try to send the fileout as an argument to your function
void parint (offstream &fileout,char *string)
{
fileout<
|
|
|
|
|
Also, you should consider writing an operator << for your class ( I presume all this data is in a class ), then you can just stream the whole lot to any stream type you like, in one go.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am just learning C++ can you give me an example how to do this?
|
|
|
|
|
I've written articles here on the CP site on how to do this, so search the site for iostream and look for my name as author.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am googling around "what is a callback function" and sort of have gotten the general idea. I've been doing some MFC for a year or so, but havent yet seen it used. I'd appreciate some links to more info on what these are exactly and when they are used since obviously I havent run into a situation where I needed one....
Thanks,
ns
|
|
|
|
|
Callback functions are used in Win32 APIs (eg: during printing). MFC provides more formal callbacks in the form of handlers that you can override, eg: CWnd::OnSize() which is called by the framework when the size of the window has changed.
In OO code, callbacks are usually implemented using the Observer pattern, where your custom code (the callback) is executed when an event of interest occurs.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ah! That I can relate to. I hadnt made the connection....
Day off tomorrow!
|
|
|
|
|
Enumeration (e.g., EnumFontFamilies() ) functions make use of callback functions.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks!
The five birds riddle in your sig: is the answer "none" because the ones that didnt fly off got shot or something? Just curious.
Thanks,
ns
|
|
|
|
|
How to change a cell proporties(color for example) into excel file with c++? I use odbc for write into the file but i search to change cell color. I'm use MFC(sorry for my poor english).
Ths Jérôme
|
|
|
|
|
you cannot change properties, appearence of an Excel sheet by using ODBC. Office automation is what you will need.
If you decide to switch to Office automation than you will have all the formatting capabilities that you have when manually editing an Excel sheet, and of course you can also feed your sheet with data as well.
Search MSDN for samples.
Bunburry
|
|
|
|
|
Hi,
I pop up a window with my application, using:
<br />
<br />
<br />
CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CTaskViewSplitFrame );<br />
CObject* pObject = pRuntimeClass->CreateObject();<br />
pTaskViewSplitFrame = (CTaskViewSplitFrame *)(pObject);<br />
pTaskViewSplitFrame->LoadFrame(IDR_TASK_VIEW_SPLIT_FRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, pParent,NULL);<br />
pTaskViewSplitFrame->ShowWindow(SW_SHOWNORMAL);<br />
Everything works fine but if at the end of my application I want to close this window I will probably use delete or pTaskViewSplitFrame->CloseWindow and the window is already closed by the user I will get an exception.
The problem is that the pointer is not really NULL but 0xdddd or something like that so I can't verify it...
Any solution ?
Shay
|
|
|
|
|
what about putting delete this; in the dtor?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
If I put delete this is the destructor, it will fail since PostNCDestroy does it by default.
the problem is not deleting the window, the problem is how to know weather the window deleted itself (after the user closed it) or weather it's open...
If I try pWindow->IsWindowOpen() but pWindow is already deleted, I am dead in the water....
Shay
|
|
|
|
|
Shay Harel wrote:
If I try pWindow->IsWindowOpen() but pWindow is already deleted, I am dead in the water....
Will this work:
if (NULL != pWindow)
{
if (pWindow->IsWindowOpen())
...
}
This ensures that a NULL pointer is not dereferenced.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
The problem is that when the user close the window for me, pWindow is not turning to NULL (0x000000) it may turn to 0xddddd or anything else....
ha !
|
|
|
|
|
Well, After I thought about it again, I saw what you mean..
And it actually worked (The NULL as the first operand)
Thanks
|
|
|
|
|
Shay Harel wrote:
The problem is that the pointer is not really NULL but 0xdddd...
Which indicates freed memory. However, that value is subject to change.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Well,
I can't count on it to be always 0xddddd... this is unprofessional.
I am sure my problem is less complecated that I described it.
Basicall, if I pop up a window with a pointer and go on, how do I check if this window is either open/close/destroyed ?
Shay
|
|
|
|
|
I take it you have a derived CWnd or CSplitterWnd class you are using. How about overriding the default handlers so, that each of them sets a boolean before calling the base class ?
<span style='cpp-keyword'>class</span> CMyDerivedWnd : <span style='cpp-keyword'>public</span> CWnd
{
...
RESULT Create(PARAMS)
{
<span style='cpp-keyword'>this</span>->bIsCreated = TRUE;
<span style='cpp-keyword'>return</span> CWnd::Create(PARAMS);
}
...
<span style='cpp-keyword'>private</span>:
BOOL bIsCreated;
BOOL bIsOpen;
BOOL bIsDestroyed;
}
This, of course, assumes that you've marked the base class as virtual. I am unsure whether the original Create functions are virtual in the CWnd class (why wouldn't they be ? Ask MS)..
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thank you but I found another way to do it:
Shay Harel wrote:
If I try pWindow->IsWindowOpen() but pWindow is already deleted, I am dead in the water....
Will this work:
if (NULL != pWindow){ if (pWindow->IsWindowOpen()) ...}
This ensures that a NULL pointer is not dereferenced.
|
|
|
|
|
My application contains skins which changed by user. Procedure of change occurs as follows:
::OnChangeSkin()
{
if (NULL != m_rgnWindow)
{
::DeleteObject(m_rgnWindow);
m_rgnWindow = NULL;
}
m_rgnWindow = GetRegionFromFile(...);
SetWindowRgn(m_rgnWindow, TRUE);
}
For any paint to call a following method
::OnDisplayWindow()
{
...
::FrameRgn(hMemDC, m_rgnWindow, hBrush, 1, 1);
...
::SelectClipRgn(hMemDC, m_rgnWindow);
::BitBlt();
::SelectClipRgn(hMemDC, NULL);
...
}
In the places specified as "//Error" BoundsChecker finds out a mistake
In what a mistake?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
I had this same problem with CPen - I think it applies to any GDIObject. The object doesn't seem to be completely destroyed. In addition, you should be careful to separate the freeing of resources verses the actual deletion of the object, although Microsoft tries to make them the same with the questionable practice of self deleting functions. I can't be more helpful without seeing more code.
J.
----------------------------
|
|
|
|
|
Hi Everyone,
I'm having problems using messagebox
There is a parameter defined with messagebox, called MB_SERVICE_NOTIFICATION.
I use this parameter in my code:
MessageBox(NULL, "some text", "error", MB_SETFOREGROUND + MB_SERVICE_NOTIFICATION);
But i'm getting a compiler error, MB_SERVICE_NOTIFICATION : Undeclared identifier.
I went on the msdn that describes using messagebox, and it says that i should define _WIN32_WINNT.
So i did, and my preprocessor definition looks like: #define _WIN32_WINNT = 0x0400
I'm still getting the undeclared identifier error message, can someone please help me??? i'm looking at this problem for several hours without any luck.
Thank you in advance
Rico
|
|
|
|