|
will1383 wrote:
I just wanted to be sure there were no other tricks out there I didn't know about.
Yeah!
It's better being on the safe side!
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Hy People!
I'm having some problems with memory leaks, maybe somebody can help me
I have an CArray, full of objects with CStrings and when I finish my program lots of memory leaks of type strcore appears on the my debug.
I try to put myvariableString.Empty(); on the destructor of that object, but doesn't solved
The same happens to my CRichEdit control, I do a 'new' and create; on the destructor I do richedit->DestroyWindow() and delete richedit;
But anyway, the following text appear:
my.cpp: {701} client block at 0x002FA608, subtype 0, 64 bytes long.
a CRichEditCtrl object at $002FA608, 64 bytes long
Thanks everybody for the attention,
cheers!
Ricky
|
|
|
|
|
Empty() only makes the string the empty string (""). You have to call "delete" on anything you allocate with "new".
|
|
|
|
|
If you go to line 701 of MY.CPP, you'll see a new statement. Whenever the owner of the CArray object goes away, you'll need a corresponding delete statement.
|
|
|
|
|
I inserted in the registry (HKCR/myappdata/shell/open) the command line to open a file ("c:/programs dir/my app dir/myapp.exe" "%1") from the shell.
Ok, it works, but the working dir is always "c:". I would like to tell Windows that when opening a file from the shell the working dir is "c:/programs dir/my app dir".
A solution could be to write in the code
SetCurrentDir(GetExeDirectory()), but doing so it would be impossible to use another working dir...
Any suggestion?
thanks
|
|
|
|
|
In your app, in the initial Update, get the command line, parse for the .exe (or use the command line parser from CP, make a search about it), get the next string after the exe, here you have the path to your file.
put a SetCurrentDir(str_commandline_file);
You'ra done.
~RaGE();
|
|
|
|
|
I don't need the file path, I want that the working path is the same of the exe.
But I can't encode that in the source code, I must say that to she shell...
|
|
|
|
|
You caught me wrong.
Assume the user, when installing your tool, put it in F:\Apps\Mytool\Tool.exe, and registers your associated files with extension .paolo.
Then, he opens an explorer, doubleclicks on myfile.paolo which is in C:\CurrentFiles.
So your command line, sent from the shell to the code, is :
F:\Apps\Mytool\Tool.exe C:\CurrentFiles\myfile.paolo
So now you can retrieve the exe path, and use SetDirectory()
~RaGE();
|
|
|
|
|
That could be a good solution, but I can't get the full command line...
The variable m_lpCmdLine only contains
"C:\CurrentFiles\myfile.paolo"
without "F:\Apps\Mytool\Tool.exe"
|
|
|
|
|
In InitInstance() :
CString str=GetCommandLine();
In fact, m_lpCmdLine contains only the parameters. Check this in the MSDN for more info, i give you just the remark here :
Remarks:
ANSI console processes written in C can use the argc and argv arguments of the main function to access the command-line arguments. ANSI GUI applications can use the lpCmdLine parameter of the WinMain function to access the command-line string, excluding the program name. The reason that main and WinMain cannot return Unicode strings is that argc, argv, and lpCmdLine use the LPSTR data type for parameters, not the LPTSTR data type. The GetCommandLine function can be used to access Unicode strings, because it uses the LPTSTR data type.
~RaGE();
|
|
|
|
|
Thank you!!!
It was so obvious, that I couldn't find it
|
|
|
|
|
What you want cannot be done. When you associate a file-type with a program, you provide an absolute path to the EXE responsible for it. How else do you think Windows is going to know how to find it? You could, however, get away with just putting the name of the EXE in the registry, and then making sure the EXE can be found via the PATH environment variable. Sloppy, but do-able.
|
|
|
|
|
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.
|
|
|
|