|
I wanna add and remove button in runtime
Agh
|
|
|
|
|
See here[^]
maybe it is some helpful to you
|
|
|
|
|
As part of a sort algorithm I am copying the contents of a vector to a local dynamic array (temporarily) prior to sorting them (using a simple algorithm such as bubble sort).
CSentenceList.h
--------------------------------------------
class CSentenceList
{
public:
...
//Properties
unsigned int Size;
vector<string> Sentences; //list of sentences
...
private:
...
//Properties
string* m_tempList; //used for sort
};
CSentenceList.cpp
--------------------------------------------
....
void CSentenceList::sort()
{ m_tempList = new string[Size];
//copy Sentences to m_tempList
for (int iIndex = 0; iIndex = Size; iIndex++)
{m_tempList[iIndex] = Sentences[iIndex];} // ERROR!
Sentences.clear();
// sort the array
...
delete [] m_tempList;
}
However the code breaks during the assignment of the contents of the vector to the dynamic array (memcpy.asm), when trying to read from memory.
Error: Access violation reading location 0xabababab.
I am declaring m_tempList as a string* otherwise I wouldn't be able to create the array using the 'new[]' operator.
Any ideas? Any simpler way to sort?
Jon
|
|
|
|
|
You're sure that Size is the size of hte vector ? Either way, it's redundant, you should be pulling the size from the vector itself.
In any case, you should be using one of the sorting algorithms that come with the stl. Something like
#include <algorithm>
std::sort(Sentences.begin(), Sentences.end());
That's totally from very old and disused memory, but it's along those lines.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Your for loop has problems:
{ m_tempList = new string[Size];<br />
<br />
for (int iIndex = 0; iIndex = Size; iIndex++)<br />
{m_tempList[iIndex] = Sentences[iIndex];}
Since you allocated Size items, the index has a maximum of (Size-1). In the test of your for loop (iIndex = Size), you are setting the value of iIndex to Size instead of testing it for the limit. Your code in the for loop then tries to set the [Size] member to the value - illegal since it onlly has [Size-1] members.
Perhaps you mean:
<br />
for (int iIndex = 0; iIndex < Size; iIndex++)<br />
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
|
A server application i made on PC having Windows XP and Visual Studios 6 is running fine on another windows XP machine (after supplying 4 DLL files). But it is not running on a Windows 2000 professional platform. Any solutions ??
Sid.
|
|
|
|
|
Possibly XP had a library already that you depend on, and 2000 did not ? It would help to find out what the exact problem is.
Also, perhaps you used an API that was new to XP in your code ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Download the Dependency Walker application and run it on your DLL files. If you find a DLL with a function that has an exclamation point by it that means that that dependency is not resolved hence the dll cannot be loaded. This could be why your application is failing.
Deus caritas est
|
|
|
|
|
Use from Dependency Walker.Maybe you use from a service that is in xp and isnt in 2000
|
|
|
|
|
If bring the *.exe which build by VC++ to run in another PC that don't have VC++ is installed, it will show error and can't use this program.
Anybody know, how to solve this problem.
|
|
|
|
|
probably you are missing libraries ...
SkyWalker
|
|
|
|
|
|
If you're running on XP and using VS2005, you need to run the redistributable file which will install them to the correct WinSXS folders. The .manifest file also needs to ship with your app in this case. If you're < VS2005, then files like the MSVCRT and the MFC dll need to be put in the system32 folder of the target machine, if you used MFC and the C runtime ( cancel one or the other as appropriate ), unless you link them into your app, which makes your exe bigger.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
The application program will ask for DLL files when you run it in another PC which does not have Visual Studio installed. Copy the required DLL files from a PC having Visual Studio into the folder which has the application and run it.
Sid.
|
|
|
|
|
WinSXS means this does not work anymore for XP, at least not for VS2005 built programs, AFAIK.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Select static linking for the MFC libraries then they are built into the binary.
Elaine
|
|
|
|
|
Where is this option?
Is it in VC++?
|
|
|
|
|
You've probably found it by now, but it's in your project properties.
|
|
|
|
|
Right click in solution->select property->in Use of MFC select Static
|
|
|
|
|
You should add many ".dll" to the other PC!
If you do that,the problem will be solved!
DaHongying
|
|
|
|
|
I will start to learn win32 and com.Com is a part of win32.right?
I am vague of starting win32 books and com books first?
In fact i don't sure what are the steps for learning win32.I see that most of the tutorials showing win32: learning message dispatch system of windows or to learning what functions included in system32 dlls.
Which roadmap must i follow to learning win32 and com.
I decided that first learning com(I have 3 books) and then win32(ı have 2 books).
Is this right way?
What do you advice me?
|
|
|
|
|
sawerr wrote: Com is a part of win32.right?
No. COM was first called ActiveX and ActiveX didn't even exist when Win32 came along.
sawerr wrote: In fact i don't sure what are the steps for learning win32.
First, get used to pain. Programming Win32 style is a lot harder than MFC, which is itself a lot harder than using C#/Winforms. WPF brings something new to the table, I think it's harder than C#/Winforms
But, if you want to use Win32, by 'Programming Windows' by Charles Petzold. There's not other book half as good.
sawerr wrote: I decided that first learning com(I have 3 books) and then win32(ı have 2 books).
Unless your terminology is strange, that's a weird order. COM is a way of creating dlls that expose an interface which is mainly useful for being able to call stuff without having any idea where it is on the file system ( otherwise, you could just use plain old dlls ), and for exposing an interface through your app ( as Office does, for example ).
What are you trying to learn exactly, and what is your background ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks Christian
I start programming with c and after that i learned c# and.Net well.I see that they are not enough for me for writing low level(i mean orginial) applications.So I started to learn c++ and STL and I finished them.
In fact i know both com and win32 generally.
I am member of safari bookshelf and in my bookshelf there are 5 books and i can not decide to order of reading these books.
1-)COM+ Programming: A Practical Guide Using Visual C++ and ATL
2-)Microsoft Windows 2000 API SuperBible
3-)Win32 System Services: The Heart of Windows® 98 and Windows® 2000
4-)Applying COM+
5-)COM and .NET Component Services
So i want your advices to learning win32-com-mfc with visual c++.If you tell me order of reading these books will very helpful.An other advices will be greatly appreciated
Thanks again
|
|
|
|
|
sawerr wrote: I start programming with c and after that i learned c# and.Net
Wow - C to C# is a big leap. So C# was your first OOP ?
sawerr wrote: I see that they are not enough for me for writing low level(i mean orginial) applications.
I totally disagree. C is indeed hard, but if you learn WinAPI programming instead of MFC, you're basically learning windows in C, that's where it comes from. But, I write 'original' programs in C# that interact with digital cameras, do image processing, video capture, etc.
sawerr wrote: So I started to learn c++ and STL and I finished them.
LOL - I doubt that. No-one finishes learning any language, especially C++ and STL.
sawerr wrote: COM+ Programming: A Practical Guide Using Visual C++ and ATL
COM+ is a superset of COM. That means any COM+ book will teach you more than you need to know to use COM.
sawerr wrote: COM and .NET Component Services
This book is probably mostly about interop.
sawerr wrote: If you tell me order of reading these books will very helpful.An other advices will be greatly appreciated
I would forget Win32 and go straight to MFC. For this, I can't even remember the books I used. I do know the best COM book I read, the one that made me understand it all, was called 'Building lightweight components with ATL' by Jonathan Bates.
I still don't get why you feel the need to learn COM, but if you do, I'd certainly recommend learning MFC first.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|