|
No Problem. I have to agree about the automation docs, I ran into similar problems trying to get some Excel automation running. In fact, I think it was exactly the same problem
|
|
|
|
|
As soon as I have some time (I seriously don't know when) I'll write some tutorials for my web site on all the tough problems I ran into in COM/MFC/OLE/ActiveX programming in the past few months.
My web site contains several tutorials on how to develop 3D video games using the Genesis3D engine but I discovered that more and more programmers are looking for infos and tutorials just about everything.
Anyhow, thanks again. This was really critical for me.
|
|
|
|
|
Does anyone know why this code:
void Cfoobar::Serialize( CArchive &ar )
{
int int_val;
bool bool_val;
...
...
ar >> int_val;
ar >> bool_val;
ar >> (int)bool_val;
...
...
}
throws up compilation errors for the bool variable, even if I cast it into int?
The errors read:
... error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'bool' (or there is no acceptable conversion)
... error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
What obvious point have I missed?
TIA,
Pete
|
|
|
|
|
int nBoolVal;<br />
bool bRealBoolVal;<br />
<br />
ar >> nBoolVal;<br />
bRealBoolVal = (nBoolVal != 0);
As for why? Probably because MFC pre-dates the C++ bool type, so everything is done with BOOL s.
--Mike--
My really out-of-date homepage
"Hey, you wanna go to the Espresso Pump and get sugared up on mochas?"
-- Willow Rosenberg
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Doh!
I guess that's what they call "not seeing the woods for the trees"
I still think it's wierd that >> fails even when you cast the bool. I was under the impression that casting /always/ created the desired type, but apparently not. Maybe it's a bug in VC++
Another wierd thing is that
ar << bool_var;
works fine. Hmm.
Anyway, Thanks a lot,
Pete
|
|
|
|
|
moredip wrote:
I still think it's wierd that >> fails even when you cast the bool. I was under the impression that casting /always/ created the desired type, but apparently not.
The right side of CArchive::operator >> must be an l-value, that is, something that can be assigned to. A cast is not an l-value. (int) boolval does indeed create an object of type int , however that is not an l-value, thus you get the compile error.
And yes, you could probably try casting to an int& , which would make an l-value, but since the underlying object is smaller than an int , the reulting code will blow up or corrupt the stack or something equally Bad.
Moral: Casting is dangerous when you don't understand what happens under the hood. Just because you get rid of the compiler error doesn't mean your code is correct.
--Mike--
My really out-of-date homepage
"Hey, you wanna go to the Espresso Pump and get sugared up on mochas?"
-- Willow Rosenberg
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Ok, that makes sense. I guess I still have a lot to learn!
Thanks a lot for the explaination, I appreciate you taking the time to point out something which is probably trivial to you!
Pete
|
|
|
|
|
Hi group, here's my question.
I have a VFP DLL sending an XML string back to my C program. The XML has an inline schema (which of course means datatypes, widths, fieldnames, etc).
I need to convert this huge string into a multi-dimensional array.
I've tried using the MSXml SDK, and some other cute toys, but nothing is even close to what I need.
If you know a way to extract the information from the schema, as well as the data itself, and throw it into the appropriate array columns (since some columns are left out in the original XML due to NULL values), PLEASE let me know.
Chris Zangarine
Bass-Trigon Software Development Team
|
|
|
|
|
In W2K if you unplug the network cable the tray icon changes to reflect the condition. Anyone have any idea how I can monitor this in my app as well? I tried searching for some info but I must be off target.
|
|
|
|
|
Hey, this article I found on the Usenet may be of help to you.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Just wondering if i could get an opinion for the best case scenerio.
I'm writting a CWnd derived text editor...i know theres many out there already, but it's a challenge and none quite do what i want. Some flicker, others don't even implement shift selections.
I've got most of the drawing code complete, with caret movement etc...however the buffer implementation is what made me think twice about it's deisgn.
I currently use CStringArray each element is it's own line, blah blah...easy enough right?
However I noticed mapping the virtual buffer to the physical output would be a bit of a problem, mouse selctions seem more work than nessecary. So i was wondering
Would a char buff[lines*255] array work better...?
Although, if a line isn't exactly 255 bytes it would waste space and i suppose this is efficient, however it seems to be more easily implemented to the the physical screen...?
To avoid the pit falls of lost mem, i also thought of use one long flat array say 10 000 000 bytes and just adding the CRLF on each return, however for this to work i would have to iterate the entire array each key stroke to keep track of lines right...?
Any suggestions...?
My appologies for being so wordy
TIA
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
Why don't you replace CString s with something like, say CInfiniteString designed along the following lines:
class CInfiniteString
{
public:
CString& GetString(){return str_;};
TCHAR operator[](int n)const
{
if(n<str_.GetSize())return str_[n];
else return _T(" ");
}
private:
CString str_;
}; The idea is that CInfiniteString is as efficient as the encapsulated CString and you can use its operator [] for rendering operations (where it behaves as if having an infinite trail of blanks). Got the idea?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You could have a separate fixed buffer for the line you are currently
editing, eg 1024 bytes.
And when changing lines simply save what is currently in the buffer.
..but why are you doing this in the first place?
why not use the existing edit controls?
|
|
|
|
|
Why am i doing this...?
Cuz I am not a professional programmer I'm someone who simply enjoys the challenges computers give me. Over the years i've self studied many langs, like basic,pascal,assembly,c++,JScript,perl(and other c derivitives...?) and even once had a quick fix for cobol and lisp. I dropped outta<grins> high school in Gr. 10 and found myself pumping gas and soon realized it sucked. basically i'm a VERY un-convetional programmer and somes times like to do things the hard way, just for experience. Money or time is not an issue for my projects, efficiency in code is everything. Sometimes this means re-inventing the wheel and making it better like BASF<smiles> I'm not saying existing controls aren't great, but they don't do what i want.
I'm no expert, but i've looked for ways of using existing windows edit control(CEdit) but couldn't quickly figure out how to increase it's buffer size so i gave up and decided to write my own.
Sorry for the verbose life story, but i'm often asked why re-invent the wheel or don't fix it if it ain't broke...my answer. What fun is that.
Ciao
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
I am seeking information regarding memory allocation. Specifically, about the default C++ memory allocation (that comes with the compiler), how well it works in a multithreaded environment -- or on a server.
I expect that this memory allocation was written 'more for' a client application, where huge numbers of allocations are not necessarily done.
Does anyone out there have good experience with this? What good alternatives are there? I am looking at an advertisement for "SmartHeap from MicroQuill", and their ad says that the compiler-supplied memory management is SLOW SLOW SLOW, and even slower in a multi-processor and multi-threaded environment....
I've had this feeling for a long time that 'just using' the default compiler libraries for memory management is not a good long-term solution. And do any of these have good tools for debugging memory problems?
Any comments out there?
|
|
|
|
|
Hi Peter Weyzen,
Simply put, the default malloc that "new" uses <<sucks>> for multhreading, you could use Hoard alllocator that is appropriate for multithreading/multiprocessing. It has released as LGPL , so you could use the source or the binaries freely , In the web site there are plenty of graphics and reports that demonstrates the gains that this allocator provides.
So here is the link http://www.hoard.org
Hope this helps , regards
Joao Vaz
Joao Vaz
|
|
|
|
|
dear all,
i am using MS Acess database with ODBC in my MFC project.I am creating DSN name through control panel.But i want to create DSN name through programmetically.
please help me.
thanks in advance
anju
|
|
|
|
|
Anju,
I think what you are looking for is how to create a "DSNLess Connection." Click here and search on "DSNLess" to find your answer.
Hth,
~Cliff
P.S. I did a little more checking and here is a link to MSKB article Q167294
Also you will find a lot more reference in MSKB if you search on DSN-Less with the hyphen.
|
|
|
|
|
Have a look at SQLConfigDataSource() in the MSDN library. It worked fine for me.
Alternatively, OLEDB (specifically IDBDataSourceAdmin::CreateDataSource()) looks like it provides similar functionality, but I haven't used it before.
J
|
|
|
|
|
Thanks i got the solution with SQLConfigDataSource.
anju
|
|
|
|
|
Hey!
Some background first: I've written an app that has a plugin system.
Each plugin contains a CDialog. I enumerate all the plugin dll's in a
certain folder and init each one, storing their HMODULE handles and
other information in an array. Each plugin has an item in
the "plugin" menu and a check marks weather the a certain plugin is
activated. All of this works great and I have no problems with it.
The problem comes from when I want to shutdown one of the plugins.
Depending on the order the plugins were loaded, if I shut down
one plugin, it does so properly, but all the others dissapear. The
other plugins don't get shutdown, their HWND becomes NULL and
consequently, their windows vanish.
I've traced the code to the point where this all happens, and
a FreeLibrary() call seems to be the culprit. As soon as that
function is called with the HMODULE of the plugin I want to free,
all the others dissapear. Now I do have functions in each plugin
that free memory and things like that, but as a rule plugins don't
know anything about each other. They should be self-contained ie
one plugin shouldn't be able to affect another. That's why I think
that there might be some weird stuff happening deep down in MFC or
Windows, but I have no idea what.
Any suggestions?
Steve The Plant
|
|
|
|
|
I have a similar type system for one of my apps although I do not dynamically unload them until the app ends.
I would check to see whether its a particular DLL which always causes the problem. Try renaming them so they get loaded in a different order in your app. If the same DLL always causes the problem check to see whether its corrupting memory somehow in your main app.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
|
|
|
|
|
I've done what you suggested, and It doesn't look like its a
particular DLL. I've had them loaded in a different order and the
problem persists.
Here's another explanation of the problem. Let's say my app
loaded four dlls, plugin01 to plugin04. Plugin01 being
the first one loaded, plugin02 the second and so on. If I
shutdown plugin01, then the other three dissapear. But
if I shutdown plugin02, 3 and 4 dissapear but not 1. If I
shutdown plugin03, plugin04 dissapears, but not 1 or 2.
It doesn't matter which plugins get loaded, a loaded plugin
always knocks out the ones loaded after it when shutdown.
It's weird.
I'm only doing one call to FreeLibrary and I'm passing the HMODULE
of the plugin I want to shutdown.
But, if all the plugins are loaded, and I shutdown and restart the
plugins in the reverse order (4, then 3, etc.) the problem dissapears
and I can shutdown and activate plugins at will properly without
affecting others.
Putting breakpoints in the exit functions (DestroyWindow,
ExitInstance, etc.) of the other plugins doesn't work. It
doesn't seem that those functions are called when they accidentally
dissapear.
Steve The Plant
|
|
|
|
|
Do those DLLs do something weird at DLL_PROCESS_ATTACH or DLL_PROCESS_ATTACH time, like loading another libraries?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|