|
Hello Braulio, that Word Automation thing must be a real pain in the ass. I know close to nothing about the subject, but from the similar code I've seen on the net, maybe you should try calling WindowState(wdWindowStateNormal) on oDoc before doing the same with m_app . If what I'm saying is absolute nonsense, please accept my apologies
Good luck!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hola Joaquin !, Gracias por la info !
The thing was to call activate and SetWindowState before any SetTop or Left or... ( and... sh*t I forgot a SetTop(0)... in the code somewhere... ).
But anyway Automation and Office thing is a real pain in the ass... we are having a lot of problems here with that ( it´s a nightmare when you try to run the same things with 97 or 2000, and for some stuff... it´s like... well Word do what you want....).
Thanks again and Seeya !
Braulio
|
|
|
|
|
can anyone give some advice how to debug a service running on win2k. i tried this thing adding a debugger value to the registry key
"Image File Execution Option"
but i didn`t get it to run in the debugger at all.
What is the value I have to add to this key if I want to use the VC++ Debugger ?
CU Mario ///
---------------------------------
www.klangwerker.de
Look out for free Win32
Serial Communication Module
for VC++ or Borland C++ Builder
---------------------------------
|
|
|
|
|
When I want to step into a service, I use the task manager. Select the service .exe and click Debug from the context menu.
Hope this helps,
Bill
|
|
|
|
|
Does realloc free memory if it fails?
according to msdn HeapReAlloc does not free memory and the original pointer/handle are still valid.
char* pTemp = (char*)realloc(m_pMem, 100); }
testing the function with either try/catch or NULL return to indicate a failure, would the following be acceptable?
m_pMem = pTemp;
I'm assuming this works with HeapReAlloc() but i can't find anything that says realloc does the same...?
TIA
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
as i remember, realloc stamps on your pointer if it fails, so yeh i used to do something like
//orig mem
pMem=malloc(42);
...
//need more?
pTry=realloc(pMem,142);
if (pTry)
{
pMem=pTry;
}
else
{
MessageBox(0,"no more mem, but i'll bash on regardless",0,0);
// but pMem is still valid (unless instead of 142 you sent zero!)
}
|
|
|
|
|
the temp return is working i just wanted to know if maybe i was seeing things and if it's really acceptable.
But if you've done it and it worked and it's working for, then i guess it must work.
None of the examples i've seen show testing the return of realloc/HeapReAlloc so i dunno what i'm suppose to think.
if anything they all
if(!ret) AfxMessageBox(" ")
not exactly the direction i want
Thanx again! and for the speedy response
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
realloc returns a void pointer to the reallocated (and possibly moved) memory block. The return value is NULL if the size is zero and the buffer argument is not NULL, or if there is not enough available memory to expand the block to the given size. In the first case, the original block is freed. In the second, the original block is unchanged.
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
So realloc could be used as a substitute for free..? I did not know that...cool
So it is acceptable to do what i was doing and Brandy has suggested is possible...?
store the return in a temp and copy the temp to the original if successful...?
Thanx again
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
Yup What is Brandy wrote is right.
But don't understand why to use ralloc to free the memory? lol
And HeapReAlloc() is called inside realloc()
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
hi guys,
i am trying to load the data of a file which is 100MB large in to a List Control. But during the loading Procedure the app does not respond anymore. If i use i a file which is not so large, it works fine. How can i solve the prob ?
I am using CStdioFile
Best Regards
Sonu
|
|
|
|
|
i don't know of any restriction on bytes or items in a list control, but there probably is one, unintended perhaps.
do you really want all that stuff in one list? it's not gonna be much use for navigation. if you just want the data available to your app, store it in some other structure (e.g. write a list class) or if you want the user to be able to browse it, perhaps a tree view control (include component MS Forms 2)?
hope that is some help.
|
|
|
|
|
To make a different thread and load the file inside this thread. Here is an example:
This is the loading thread function:
UINT LoadFileFunc(LPVOID lParam)
{
CListCtrl* pCtrl = (CListCtrl*)lParam;
CString csLine;
while(f.ReadString(csLine)){
pCtrl->InsertItem(pCtrl->GetItemsCount(), csLine);
}
}
And below the code from OnInitDialog() function (or any other function you want to start loading file)
...
AfxBeginThread(LoadFileFunc, &m_wndYourListCtrl);
...
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
The above 2 messages are good suggestions, and definitely things to think about.
However, I've also come across this and one reason it took so long for me was because it was sorting on every AddString(). Uncheck the "Sort" box in the properties and see if that improves performance a little.
J
|
|
|
|
|
I draw my bitmap (OnDraw function) in my CScrollView derived class using StretchBlt function... I want to avoid flickering when resizing and scrolling view..
Can anybody help me?
|
|
|
|
|
did you handle the WM_ERASEBKGND - Message?
BOOL CMyView::OnEraseBkgnd(CDC* pDC)
{
return true;
}
(i had several problems doing this with ScrollViews.. but maybe you achieve this)
have a nice one
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
try double-buffering
www.klangwerker.de/developer/english/double_buf.htm
(Didn`t I see this post on www.codeguru.com )
CU Mario ///
---------------------------------
www.klangwerker.de
Look out for free Win32
Serial Communication Module
for VC++ or Borland C++ Builder
---------------------------------
|
|
|
|
|
Yep, take a look at a class called CMemDC, maybe this class can help you ( you can find that here or in CodeGuru).
HTH
Braulio
|
|
|
|
|
I've never used new and delete, but figured i'd give it a try cuz they seem easier to work with and are often recommended.
CHAR* m_pBuffer; //private member
SetSize(nSize) { m_pBuffer = new CHAR[nSize]; }
~CMyClass()
{ delete [] m_pBuffer; }
I call Set Size twice but if i call it more than once and run in debug mode i get memory leaks detected!!!
Can you not dynamically resize the m_pBuff more than once...?
Help please
TIA
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
For every new you must have a delete, because new allocates memory.
If you call SetSize() twice you will have two new, but only one delete in the destructor, hence the memory leak. If you have Stroustrups C++ programming language 3rd ed., I suggest you read chapter 6.2.6.
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
I have Bruce Eckel Thinking in C++
I did read up a little on new and delete, turns out my misunderstanding was as simple as not knowing, realloc doesn't have an equivalent new/delete operator.
new and delete are used for dynamic creation and destruction of objects on the heap, but not reallocation.
I guess i have to resort to malloc/realloc and free.
Thanx again!
have a day!
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
Have you considered using std::vector instead of new char[...] ? It has a number of advantanges over your method:- Automatic cleanup (no memory leaks).
- Improved consistency: you get the number of elements by calling
size() on the vector, with new /delete it is up to the programmer to record the size elsewhere and get this information in sync with the buffer. -
realloc -like functionality (vector::resize ). - You can still have a pointer to raw memory if needed for compatibility with other functions (just pass
&v[0] ). Once you get accostumed to std::vector s and other STL containers, you'll never want to get back to raw memory management!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
So i've heard and yes I certainly have, but for the time being i'm keeping with what i have and i'll see what comes of it.
I'm actually doing something quite similar with templates, designed from the ground up.
Call me stupid, but i enjoy playing with things that aren't broke;P
p.s-I've heard and read little of these vectors, so correct me if i'm wrong, but basically there templates with automatic reallocation as needed. Magically index any location and whola it's available..?
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
So i've heard and yes I certainly have, but for the time being i'm keeping with what i have and i'll see what comes of it.
Believe me, the learning curve for STL is not that steep, and the payoff is worth the effort. Consider this: As soon as you start using objects with nontrivial constructors and want to have arrays of them, then you will no longer be able to use malloc and have to resort to either new /delete or STL containers (that's where you are now). What's the point of mastering the intricacies of manual memory management when STL does the job for you? After all it's just about learning one of two methodologies, and the second is by far the most profitable.
I'm actually doing something quite similar with templates, designed from the ground up.
Call me stupid, but i enjoy playing with things that aren't broke;P
I think playing with these things is an excellent way to learn the language. When it comes to writing production code, though, it is better to rely on standard libraries.
p.s-I've heard and read little of these vectors, so correct me if i'm wrong, but basically there templates with automatic reallocation as needed. Magically index any location and whola it's available..?
No, for vectors you have to indicate resizing explicitly. Other STL containers called maps work sort of like you say. Hey, type "STL tutorial" on your web searcher and enter STL paradise! You will not regret having done it
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'll certainly consider looking into using STL.
Thinking in C++ by Bruce Eckel introduced me to templates using the vector as an example. His vector basically has magical indexing. You specify the index location and it there.
I've noticed the STL version of vectors requires explicit resizing. Honestly, i think i prefer Bruce's idea of magic indexing...sounds easier, just set and delete...It's like VB
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|