|
Hi everybody,
How can I delete a specific record from an array in the Visual C++ environment?
I have an array of object pointers. I want to enter a book title for example from the keyboard and then to have an option of deleting it, from the array. Is this possible?
Regards,
grscot
|
|
|
|
|
First you would need to delete the block of memory that the array element is pointing to. Then you would need to delete the array element itself by moving all elements after the one to be deleted to the left. Let me see if a picture will help:
-----------------<br />
|0|1|2|3|4|5|6|7|<br />
-----------------
If you wanted to remove element #4, elements 5, 6, and 7 would be moved to the left one time, like:
-----------------<br />
|0|1|2|3|5|6|7| |<br />
-----------------
Now you have an empty spot where element #7 used to be. You can either free it up, or leave it so that when another element is added, the memory is already allocated.
|
|
|
|
|
You have to iterate through the array and check the value if it is the same as what the user entered and then assign it NULL.
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Or you can use the MFC CArray wich is a template, that takes care of everything.
#include "Afxtempl.h"
CArray<myobj*,myobj&> arObj;
arObj[n].RemoveAt(index);//it will remove the element and shift to the left
there are plenty of method to do everything you need.
cheers!
Daniel Cespedes Daza
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Cambalindo wrote:
CArray arObj;
This is the correct way of declaring the array
CArray<myObj*,myObj&> arObj;
Daniel Cespedes Daza
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Hi, everyone!
I want to use VC++ to send an Email to someone.
And my application is a console application. (command
line based.) I have searched this site and find all
the sample codes are written in ATL or COM. Well ... I know
nothing about these topic. I simply want to know
where can I find some simple samples which is written
in plain VC++ and a seperate E-Mail sending class?
Thanks in advance,
George
|
|
|
|
|
Look for "CMapi" class it should exist in the codeproject,... if not.. www.google.com
http://www.codeproject.com/internet/cmapi.asp
the latest release....
http://www.naughter.com/cmapi.html
|
|
|
|
|
Thanks, imsniper buddy!
George
|
|
|
|
|
Hi
i have a report style list control within a dialog
the dialog is called from the Main frame, which is a list view
when i click on ok my dialog i want to update the list view
in the main frame with whats in my list view in my dialog
any ideas
ta
si
|
|
|
|
|
Override the CModal method of your CDialog and put a pointer to your listview as a parameter (CDialog::DoModal(stuff, CListView *pListView))
put a CListView *m_pListView; member variable in the CDialog class.
In the DoModal, make m_pListView=pListView;
member parameter of DoModal
This will give you a pointer on your CListView within the CDialog.
Override the CDialog::OnOK() method, and do your update BEFORE the call to CDialog::OnOK(); made in this function (otherwise you'll get your app to crash, since the memeber variables would have already been destroyed.)
You're done.
~RaGE();
|
|
|
|
|
I'm currently developing a program for displaying movie contents on a screen. This means that i could have to change the contents of the graphics up to 60 times per second. Which functions are best suited for this?
Thanks in advance.
-Rune SVendsen
|
|
|
|
|
Can't you use the media player or an active-x control ? is your movie file a custom one or usual avi, mpeg ... ?
~RaGE();
|
|
|
|
|
It's an MPEG2 file, but i'm decoding the file myself.
|
|
|
|
|
Hi,
I am trying to locate the function address (user defined function)once I load the image of my executable. I have gone through the article by Matt Pietrek about the PE file format but still i am unable to work out how one can locate the address of a function in the mapped memory after calling MapAndLoad API or subsequent calls to CreateFileMapping and MapViewOfFile.
Can anyone help in this regard. Has anyone tried to locate the function address this way?
Regards,
Nitin.
|
|
|
|
|
Why not just do a LoadLibraryEx, passing LOAD_LIBRARY_AS_
DATAFILE or DONT_RESOLVE_DLL_REFERENCE flags to prevent it from initializing. Then, you can use the usual GetProcAddress() to look up the address of the function.
|
|
|
|
|
how to restrict a user from accessing contents of the local drives by typing them in the internet explorer address bar..
like if i type c: in internet explorer it opens up the c drive i want to restrict this type of access.
is there any way that i can know what is typed in the url bar and do what i want before navigating.
thanks in advance
qrious
|
|
|
|
|
It depends on the OS. With NT, 2000, and XP, you can restrict what drives, and folders, the current user has access to.
|
|
|
|
|
Hi everyone,
I have a question about XOR painting. I have a window with a bitmap background. Whenever I drag my mouse in the window, I want to highlight the selected area using XOR mode. Of course, I could do that by
::InvertRect(RECT & rect)
However, now I have some other areas that I want to highlight..but with a different color and I still want the background pattern to show under the highlighted rectangle. Is it possible to do an XOR drawing with some bit switched off or something like that. I want the XOR effect, but a different shade.
I hope my problem is clear enough. If anyone has any ides or suggestions, I would really appreciate it.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
hi..
I thing that this function use logical NOT operation!!!
|
|
|
|
|
Hello,
I have problems retrieving the height and width of a formview :
When I call the OnPaint() function, I want to display a picture at a specific position in a formview so I need to know its current size.
What I do to get the size is, in the OnPaint() function :
CRect rect;
this->GetWindowRect(&rect);
int winwidth=rect.Width();
int winheight=rect.Height();
But I get a width and height of zero.
Does anyone know what I did wrong ?
Thanks for your help,
|
|
|
|
|
Try this instead:
CRect ClientRect;
GetClientRect(ClientRect);
This will retrieve the width and the heigth of the client area (so what you need ) !
|
|
|
|
|
Thanks for your help, but it doesn't work either : I still have a width and height of zero with :
CRect rect=new CRect();
GetClientRect(&rect);
int winwidth=rect.Width();
int winheight=rect.Height();
|
|
|
|
|
Have you tried the GetTotalSize() method of the FormView (scrollview implemented)?
|
|
|
|
|
I have a structure like
struct Id {
LPCSTR sId; /* note that this is the first member */
unsigned nId;
};
I'd LOVE to have vc-debugger to display the sId value (in place of {...}) in the watch/this/locals/auto window, like CString does.
I've looked through the sources for CString and haven't quite figured it out.
Deriving from string isn't an option.
Any suggestions?
|
|
|
|
|
Locate the file autoexp.dat - mine (Visual Studio 6) is in the MSDev98\bin directory.
This file contains details of the expansions used when debugging. Open this up, and there is a huge bit at the top telling you how to do your own stuff. Further down you can see the entry for CString.
Hope this helps!
|
|
|
|