|
@Rage
ok if i create my own process for this, how can I the Excelfile I want to?
If I start it the same way with ShellExecute It would be the same effect. Excel would start in an own process but not in the one i've created for it
|
|
|
|
|
Set the lpCommandLine member of the CreateProcess call to the filename that you want to open.
onwards and upwards...
|
|
|
|
|
Anonymous wrote:
If I start it the same way with ShellExecute It would be the same effect. Excel would start in an own process but not in the one i've created for it
What do you mean ? With CreateProcess , *you* start the excel process. The last parameter of create process, which is a PROCESS_INFORMATION struct, contains the process handle and the starting thrad handle. Use ExitProcess() on the process handle, and you're done.
~RaGE();
|
|
|
|
|
hi,
i am newbie to STL.
i want to know if i have a list for storing struct. after i insert a struct in it, it will store the reference or make of in the list?
my worry is memory leakage if i don't remove the struct properly after remove it from the list.
list<control> ctrllist;
void addtolist()
{
control a;
a.id=1; a.value=10;
ctrllist.push_back(a);
}
void removelist()
{
// how to remove from list properly?
//ctrllist.remove(???)???
}
any help?
thanks,
jim
|
|
|
|
|
the code should like this!
list<<control>> ctrllist;
void addtolist()
{
control a;
a.id=1; a.value=10;
ctrllist.push_back(a);
}
void removelist()
{
// how to remove from list properly?
// ctrllist.remove(???)???
}
|
|
|
|
|
You can use pop_back to remove the last-inserted element of a list. Also take into account that all elements remaining inside a list will get destroyed when the list itself is destroyed, so you don't have to worry about leaks in this respect.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
my case is that the list will be alive when the program is running. and, the record into list will add and remove during program running. so, i need the record delete immediately after i remove from the list.
why i concern this because i used CList in mfc b4, which need to delete the element(struct)'s pointer manually after you remove it from the list. so, i want to make sure whether i need to do such procedure with STL's list or not...
pls comments!
jim
|
|
|
|
|
You must carefully distinguish between storing objects or pointers to objects. In the first case, pop_back is all that it takes to prevent leaks. In the second case, it is your responsibility to delete manually the pointer, as in this piece of code:
list<control *> ctrllist;
void addtolist()
{
control* a=new control;
a->id=1; a->value=10;
ctrllist.push_back(a);
}
void removelist()
{
if(ctrllist.empty())return;
control* a=ctrllist.back();
ctrllist.pop_back();
delete a;
}
Your first snippet of code seems to imply that what you're storing are actual objects instead of pointers, so you shouldn't need to worry about these issues.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi I have some code written for a serial port class. Now I want to access the same serial port object from a number of different dialogues etc within my program. So I guess the best way to do this is by making the object global at the start of the application? Or is there another way? Also where do I put the decleration for a global variable in an MDI app?
Any suggestions much appreciated
Andy
|
|
|
|
|
other way would be to modify the constructors. Add a pointer to of Object.
|
|
|
|
|
could you explain in more detail?
Andy
|
|
|
|
|
create an own class that handles your actions with the serial port.
Start the Dialog, SDI or MDI. Create a Member of Your SerialPortClass in the Maindialog.
If you start an other Window add an pointer to your dialog class into the window constructor. Now you have acces to the members of the dialog
|
|
|
|
|
Put it in the Application class, then refer to it via theApp->member _variable.
Elaine
The tigress is here
|
|
|
|
|
nice one cheers
I get a bit stuck sometimes with the doc/view structure, coming from C/embedded stuff where I just have main!
Andy
|
|
|
|
|
Hi Friends,
I haven't tried VC++.Net till now..but out of curiosity i would like to know, what would be the significant difference in vc++.net over vc++6.0
I am basically a system programmer mainly use VC++ for creating DLL's and test applications to test the hardware...Can anybody throw light how vc++.net has the compatibility ratio with the vc++6.0 is concerned in various domains such as:
System software( accessing file, device, doing file operations,multithreading, synchronisation)
Data base access
Com applications
and any others..
Thanks,
Shiva P
|
|
|
|
|
I have never used VC .NET either but this topic has been discussed here so many times. I don't want to offend you but instead of waiting for replies you might want to search the threads of this forum which are related to your topic.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
VC++.NET is a compiler which helps you write both managed code(.net) and unmanaged code(normal c++/mfc stuff) or combine both.
You can get obvious benefits if you move to VC7 or VC7.1 and continue developing your usual applications (mfc/win32/com) simply because it is a better compiler and there are some updations to both MFC/ATL libraries.
The .net part of VC++.NET lets you write .net applications with "Managed C++". Its an extension to C++ that has additional keywords which help in developing managed applications.
Since you are from a vc++/embedded background, I don't see much benefits moving towards .NET for realtime applications(I assume the nature of these apps will be more like displaying realtime charts and stuff similar to that).
If you want to port your apps from vc6 to vc7, they are not binary compatible and there are some breaking changes. So you need to compile your app in vc7 and fix those errors to move on.
- Kannan
|
|
|
|
|
I have had a lot of problems porting to VC7 because of changes in the compiler. In most cases I gave up and still use VC6. This is because I have about 200K lines in 4 dlls that need ported and there are several hundred errors introduced with the new compiler. I guess if I spend a week or two I could get my stuff to compile in both compilers but I am too busy to do this.
[EDIT]
Most of this code fits into the everything else category.
[/EDIT]
John
|
|
|
|
|
Hi !
In my application, I'm using a function to which I have to give a pointer to a text file (FILE*), and the function will write its results in it.
But I don't want the results to be put into a text file, but into a char buffer that I declared myself before calling the function.
Is it possible to emulate a FILE* so that I give to the function what is needed, but the function writes into my char buffer ?
Thank you for your help !
Jerome
|
|
|
|
|
Jerome Conus wrote:
Is it possible to emulate a FILE* so that I give to the function what is needed, but the function writes into my char buffer ?
No. Not if the function requires a FILE* .
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
If you modified the code to use CFile objects instead of FILE *, you could substitite the CMemFile object when needed. So, just change the function(s) like this:
void SomeFunc(CFile *pFile /* FILE *fp*/)
{
// fread(cpSomeBuf,1,512,fp);
pFile->Read(cpSomeBuf,512);
// fwrite(cpSomeBuf,1,strlen(cpSomeBuf),fp);
pFile->Write(cpSomeBuf,strlen(cpSomeBuf));
// fclose(fp);
pFile->Close();
}
onwards and upwards...
|
|
|
|
|
Yes I'm aware of that. I was going to mention that except that from his wording I assumed that he couldn't change the function, hence my reply.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi!,
I am using windows hook to trap the menu select throught the system.I am using WH_GETMESSAGE type of hook.
The WM_COMMAND message is sent when the user selects a command item from a menu.I am getting this message when I select menu item from applications like notepad,windows explorer,internet explorer,acrobat;but I am not getting message if the menu item of any MS-Office application is selected.
Regards
Anshu
|
|
|
|
|
MS Office does not use the standard Windows menu system. It implements its own version which operates without WM_COMMAND messages.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thanks!
any solution for that? i want to catch the menu click of ms-office applications.how to do it?
|
|
|
|