|
oh.. sorry for the unclear msg.. I want to run the program as soon as it finish compiling and linking.. whereby the program seems to be "automatically" running..
dreamerzz
|
|
|
|
|
Start it within the IDE using Ctrl+F5. That'll compile and link (if necessary), and then run.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
See AppModul.cpp for specific implementation details of _tWinMain.
onwards and upwards...
|
|
|
|
|
Argh... the internet connection failed just when I posted the first answer...
well... lets do it again...
You can do it in three ways:
-> if you don't need to do anything to the GUI you can use the InitInstance function in the main class.
-> if you need to interact with the main frame (the SDI document view container) you can do it in the precreatewindow function in the mainframe class.
-> if you need to interact with the view you can do it in the precreatewindow of the view class.
hope this helps...
|
|
|
|
|
Hi, Thanks for ur help.. i will give it a try and will let u know abt the results..
Thanks a million
dreamerzz
|
|
|
|
|
Hi,
thanks for the help given
dReaMerzZ
|
|
|
|
|
That's ok! has it worked OK?
|
|
|
|
|
Instead of using the void main, I have integrate my 2 MFC to become one.. so it works perfectly fine..
|
|
|
|
|
Sounds like all you want to have is your app start once the linking processs has completed in the DevStudio. Correct? If so, then use the short cut Ctrl+F5 (unless it is mapped somewhere else). This compiles/links and then starts the app.
Larry J. Siddens
|
|
|
|
|
yes that's it. it also have an icon in the toolbar which look a red exclamation mark (next to the compile icon...
TOXCCT >>> GEII power
|
|
|
|
|
dreamerzz wrote:
For a normal Visual C++ program, we have a void main
Strictly speaking, it is int main()
|
|
|
|
|
dreamerzz wrote:
For a normal Visual C++ program, we have a void main
hey man, don't panic, it is not a normal Visual C++ program as he says... We are into a WinMainX()
TOXCCT >>> GEII power
|
|
|
|
|
Hi, id like to write some app using ISAPI. But i dont have Win 2k. I have installed IIS but i dont know if its enough? What else do i need to use ISAPI? Thanks.
|
|
|
|
|
A C compiler, some documentation and a hardy constitution. It is much easier using an App server designed for this purpose, such as this one [^].
onwards and upwards...
|
|
|
|
|
here is a query/problem that I am facing in my work:
We are developing an Windows application. The application is associated with a particular file extension - ".scm" wherein we can open a .scm file in the application either by launching the application and opening the file from File Menu or directly double clicking the .scm file. The app supports multiple document interface.
When user double clicks a .scm file, an instance of the application is started, file name is passed as command line parameter to it and it is opened in the App. Now the problem is every time when user double clicks a file, new instance of the application gets started. If an instance of the application is already running, instead of starting another instance, I want to use the same instance to open the file. In short I want to pass the control to the existing instance of the application.
If anyone has done this or has an idea about how to do this, can u please help me out.
Adi
|
|
|
|
|
In the file extension association, choose "Use DDE" to open files of type SCM.
onwards and upwards...
|
|
|
|
|
hello Basenetman can you clarify little more about the solution you suggested??
|
|
|
|
|
|
Adi Narayana wrote:
If an instance of the application is already running, instead of starting another instance, I want to use the same instance to open the file
See here and here.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
To further expound on the already mentioned single-instance code, you then need to pass the right data to the existing app.
One method I've used in a prodcut is to create a memory-mapped file to store the new filename and then broadcast a registered windows message to all apps. When the existing app sees this message it knows to open the memory-mapped file and read it's contents. Once it does that, it returns a correct response to the message which the app sending the message knows that it's done and can exit immediately.
If you need better details, let me know.
--
Joel Lucsy
|
|
|
|
|
Hello Joel,
thank u very much for the answer.
can u plz give any sample for the concept u explained above?
Thanks
Adi
|
|
|
|
|
Well, after determining that another instance is present, (I use the IsInstancePresent code from one of the articles here), and that you have a command line that you need to pass to the other instance, then do something like:
<br />
DWORD result;<br />
LRESULT ok;<br />
HANDLE fm;<br />
char *buf;<br />
CString fmn;<br />
DWORD pid;<br />
UINT MyProgMsgId;<br />
<br />
MyProgMsgId = RegisterWindowMessage( "MyProgMsg" );<br />
pid = GetCurrentProcessId();<br />
fmn.Format( "MyProg%ld", pid );<br />
fm = CreateFileMapping( (HANDLE)0xffffffff, NULL, PAGE_READWRITE, 0, 8192, fmn );<br />
buf = (char*)MapViewOfFile( fm, FILE_MAP_WRITE, 0, 0, 8192 );<br />
ZeroMemory( buf, 8192 );<br />
strcpy( buf, cmdline );<br />
ok = SendMessageTimeout( HWND_BROADCAST, MyProgMsgId, pid, 0, SMTO_BLOCK|SMTO_ABORTIFHUNG, 20000, &result );<br />
UnmapViewOfFile( buf );<br />
CloseHandle( fm );<br />
Make sure the RegisterWindowMessage happens in both cases (processing the command line and full GUI). Now the MFC gui codes need a line in the message map:
<br />
ON_REGISTERED_MESSAGE(theApp.MyProgMsgId,OnMyProgMsg)<br />
and the code handler will look something like:
<br />
LRESULT CRePlotDlg::OnMyProgMsg( WPARAM w, LPARAM l )<br />
{<br />
CString fmn, str;<br />
HANDLE fm;<br />
char *buf;<br />
<br />
fmn.Format( "MyProg%ld", w );<br />
fm = OpenFileMapping( FILE_MAP_WRITE, FALSE, fmn );<br />
buf = (char*)MapViewOfFile( fm, FILE_MAP_WRITE, 0, 0, 8192 );<br />
str = buf;<br />
UnmapViewOfFile( buf );<br />
CloseHandle( fm );<br />
ReplyMessage( TRUE );<br />
<br />
HandleURL( str );<br />
<br />
return TRUE;<br />
}<br />
Note that this is just an example and you'll have to make sure that certain variables belong to the right things, but it should give you a good starting point. If you need further explanation on anything, let me know.
--
Joel Lucsy
|
|
|
|
|
You could also store the window handle of your application's first instance in the memory map, then you don't have to broadcast the message, you can do a post message directly to the appropriate window instead.
|
|
|
|
|
In my case, the memory-map is not left open. It's only used to transfer data. By the time I need to use the MM, I already know the window handle.
The broadcast seems to work just fine, no delays or any other problems. Is there a good reason not to use it?
--
Joel Lucsy
|
|
|
|
|
I have a lot of the following in my code:
list.erase (remove_if (list.begin (), list.end (), ToDelete ()), list.end ());
Which just removes entries, if the predicate is met. Trying to be a bit smart, I tried wrapping this up in a nice little template to make it look nicer:
template<class Input, class Predicate><br />
void erase_if (Input input, Predicate p)<br />
{<br />
input.erase (remove_if (input.begin (), input.end (), p), input.end ());<br />
}
All looks great, only it doesnt remove any entries and I cant figure out why. It's probably something obvious, so any ideas?
|
|
|
|