|
let me try and give an answer to (1). I beleive you need to look for (and there are plenty around) a SingleInstance Class to add to your application. When the app initialises it creates an instance of the Single Instance Class, which creates a system wide Mutex. If you attempt to start a second copy of the program, it runs through the same code, but the Mutex already exists - so it fires a 'bring to foreground' event.
There are some good single-instance classes around, I'll try and find the one I use and post back.
Does that sound like it answers (partially perhaps) your 1st question ?
update - this is once such case CSingleInstance - Single Instance Apps[^] Im not sure if its the one I use - I also use minimise to tray, and when the user attempts to start another copy it reactivates it from the tray ..
'g'
|
|
|
|
|
Ans 1:
Check the article Limiting an application to a single Instance - the MFC way[^]
Ans 2:
There are some other ways to notify other application that your application is running, like creating a name Mutex. Also you can find out whether your process is running or not by enumerating process, or trying to find your window using the "FindWindow" function. How ever I think Mutex is the easiest way.
|
|
|
|
|
Dan Senior wrote: How can I design a program where if the user clicks on the icon while the program is already running, the spawned copy will recognize that the program is already running and transfer control to a particular routine in the original instance?
See Avoiding multiple instances of an application[^] by Dr. Joseph Newcomer.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Thank you... I will look into these ideas, they seem to be what I am looking for as far as not opening the application twice. I will have to play around and see if I can do these and still read the command line parameters passed in... so if I drag a file into the icon it will recognize the file and add it to the queue in the instance that is already running.
As far as #2 with the COM object, I may be able to extend the concepts from #1 to cover #2 as well, I will have to experiment and see what I can do. I still need to see how to make a COM object, most of what I have looked up is just about using COM objects, not about being a COM object.
-Dan
|
|
|
|
|
Maybe uneeded ideas but
- if the users would drag the file to your program instead of doubleclicking on it, you would not have the problem of multiple copies. Then the file is made known to your program by a drop-interface.
- if you could make a small program that copies file(s) to a folder you could use winAPI- functions findfirstchangenotification()/FindNextChangeNotification() to watch this folder with another program. Your basic commands then could also be transfered as files to the folder by the small program, and you could check then if the file(s)/commands sent are processed (because the other program moves them to another folder after processing). When not processed within time the other program is not running (or just too slow) but everything is queued..
That's what came in my mind reading your questions...
Rozis
|
|
|
|
|
Actually, the original draft for this program was very similar to that... it was going to be a macro in Visual Basic Script that would run in the AS/400 client window... and the original way it was going to work was that Excel would generate the file (via Visual Basic for Applications) and copy it into a specific directory. In the meantime, the AS/400 VB script program would cycle through checking for the existence of files (they would be named like file1, file2, etc. but there would also be a particular filename the user could save a text file as and drag into the folder and it would look for that too). When it would see a file, it would process it and then move into a "finished" folder and add to a log that it did it and then move back to looking for the next file in sequence and if there wasn't a #2 or #3, etc. it would go up to about five past where it was and then start over at 1.
When I was working on designing the actual scripting language, I quickly realized that the program was blossoming into something that would be unweildy to run in BASIC, so I moved to C++ and a whole world of options opened up. When I started thinking how does a regular application work, I decided I want to try these other methods in addition. (It might still do the directory scan thing too.) Plus, having a stand-alone program frees up Excel and the AS/400 window because currently I do have Excel pushing into the AS/400 but I can't use either system until it is done.
I will start by first just having a FILE/OPEN or right-click on the queue and choose add... but in thinking ahead because changing structure sometimes requires rewriting the whole program, I'd like to have an idea of how to structure from the beginning so that I don't have to rework the program.
Good ideas, though... I will play with what I have seen so far and if I can have six or seven ways of opening the file, all the more useful for anyone who will be using it later. I just want to make it easy to pick up and use.
|
|
|
|
|
hello i tried to link this two file:
#include<list.h>
template <class T>class hash{
public:
list<int> *l;
int m,n;//k is the entry and m is number of slots and n is the size of our array
hash(){
l=new list<T>[n];
n=m=0;
}
hash(int n1,int m1){
n=n1;
m=m1;
l=new list<T>[n];
}
int hashfunct(T k){
return k % m;
}
void print_hash (){
for(int i=0;i<n;i++)
while(!l[i].empty()){
cout<<"l["<<i<<"]="<<l[i].front()<<" ";
l[i].pop_front();
cout<<endl;
}
}
list<T>* add_to_hash(T k){
int key=h.hashfunct(k);
l[key].push_front(k);
return l;
}
};
and the main program:
#include<iostream>
#include<stdlib.h>
#include "/home/sajad/src/ds/test/hashfunctions/hash.h "
using namespace std;
int main(){
int n;
int m;
cout<<"please enter n(number of entries):"<<endl;
cin>>n;
cout<<"please enter m(the dividisor number,must be near n):"<<endl;
cin>>m;
int a[n];
for(int i=0;i<n;i++)
a[i]=0;
hash<int>h(n,m);
cout<<"please enter n numbers:"<<endl;
for(int i=0;i<n;i++){
cin>>a[i];
h.add_to_hash(a[i]);
}
cout<<"after hashing:"<<endl;
h.print_hash();
return 0;
}
the address of hash.h is completely true but i face this error:
[sajad@sajad hashfunctions]$ g++ my\ hashing.cpp
my hashing.cpp:4:57: error: /home/sajad/src/ds/test/hashfunctions/hash.h : No such file or directory
my hashing.cpp: In function ‘int main()’:
my hashing.cpp:16: error: ‘hash’ was not declared in this scope
my hashing.cpp:16: error: expected primary-expression before ‘int’
my hashing.cpp:16: error: expected ‘;’ before ‘int’
my hashing.cpp:20: error: ‘h’ was not declared in this scope
my hashing.cpp:23: error: ‘h’ was not declared in this scope
[sajad@sajad hashfunctions]$
can anyine help me?
thnx.
|
|
|
|
|
Well, the error message is actually very clear:
the path
/home/sajad/src/ds/test/hashfunctions/hash.h
is wrong.
BTW Why don't you use relative paths?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i also used #include "hash.h" but yet this takes error!!!
modified on Friday, January 8, 2010 3:58 AM
|
|
|
|
|
If the path is wrong then it is wrong (and the preprocessor cannot include the header file).
Go to the folder containing the header file and type pwd (I'm assuming you're developing for a Linux or Unix machine) to see the correct path.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
[sajad@sajad hashfunctions]$ pwd
/home/sajad/src/ds/test/hashfunctions
that this is the last location in the file header.
|
|
|
|
|
khomeyni wrote: #include "/home/sajad/src/ds/test/hashfunctions/hash.h "
I see an extra space at the end of the string...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
oh ... excuse me ,i test it with devcpp and it does not have any error with it!!!
thanx.
|
|
|
|
|
i am looking for for this code.
if you have it, please share.
|
|
|
|
|
Would you please stop asking for full code ? Please read the posting guidelines and try to start by yourself. Once you are stuck, come back with a specific question.
Besides, your question as it this now doesn't make any sense...
|
|
|
|
|
Please ask of google for full code not us.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Yesterday you were asking "can you define polygon?" and now you are asking for that?
I would suggest you to go back to school, and restart the whole mathe contents.
BTW, if you want us to make your homework... you should considering hiring someone and pay his/her salary. Otherwise you are not going to get any other "full code" from people here.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
*
**
* *
* *
* *
OOOOOOOOOOOOOOOOOOOOOOOO######
O #######
O ########
O #########
O ##########
OOOOOOOOOOOOOOOOOOO###########
* *
* *
**************
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Nice ASCII art
|
|
|
|
|
Agree with cedric
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Use GPC - General Polygon Clipper.
-Saurabh
|
|
|
|
|
thank you all of you.
i try myself to finish my homework now.
my teacher only gave some guides to do.
i am begin to solve another home work.
beside , i am a math student , not computer programming student.
|
|
|
|
|
Hi,
In my coding i initialized null to CString.Im comoaring NULL character to that string.But it returns wrong value.See my code.
CString ExeMonFile=_T("");
int NoExeMonFile=1;
if(strcmp(ExeMonFile,"")!=0)
NoExeMonFile=0;
By debugging the NoExeMonFile became 0.
Then i found that ExeMonFile is initialized to some other text.How its possible.
I declared ExeMonFile Globally.
Im using VS2008.Whats the betterway to initialize CString .
Anu
|
|
|
|
|
Anu_Bala wrote: CString ExeMonFile=_T("");
You dont need to intilalize CString , the constructor of CString will take of this. By default it will set the CString to an empty string.
Anu_Bala wrote: if(strcmp(ExeMonFile,"")!=0)
The best way to check wheather a CString is empty or not is to use the IsEmpty() function of CString .
|
|
|
|
|
But in my applcaiton in default it will assign to some "BL001" not only for this CString.
Whatever CString im using in this applcation all are initialized to this "BL001".
Just i converted VC++6.0 to VS2008.
After that only this problem arised.
Anu
|
|
|
|