I'm a bit baffled. I wrote a "single instance" TWinControl
in which the secondary instance of a program passes info to the first instance(such as command tail etc.) and also sends a message to restore the first program instance's main form.
The restore code is:
SendMessage(MainHandle, WM_SYSCOMMAND, SC_RESTORE, 0);
SetForegroundWindow(MainHandle);
The first program instance stores Application.Handle in a memory mapped file that the instance control uses to pass data. (In code prior to what I've shown, I copy the Handle value from the memory mapped file to the local variable "MainInstance".)Here's the part I can't figure out. If I use a component or TWinControl with the above 2 lines, they work perfectly. However, when I convert my TWinControl into an ActiveX Control(.ocx) using the Delphi 5 wizard, I get nadda! It's really strange!! The ActiveX Control method just reflects into the TWinControl code which works if it's not wrapped up in an ActiveX.
I can come up with a work-around but it would be much neater if the .ocx did it all "automatically" instead of through an event handler supplied by the application programmer.
in which the secondary instance of a program passes info to the first instance(such as command tail etc.) and also sends a message to restore the first program instance's main form.
The restore code is:
SendMessage(MainHandle, WM_SYSCOMMAND, SC_RESTORE, 0);
SetForegroundWindow(MainHandle);
The first program instance stores Application.Handle in a memory mapped file that the instance control uses to pass data. (In code prior to what I've shown, I copy the Handle value from the memory mapped file to the local variable "MainInstance".)Here's the part I can't figure out. If I use a component or TWinControl with the above 2 lines, they work perfectly. However, when I convert my TWinControl into an ActiveX Control(.ocx) using the Delphi 5 wizard, I get nadda! It's really strange!! The ActiveX Control method just reflects into the TWinControl code which works if it's not wrapped up in an ActiveX.
I can come up with a work-around but it would be much neater if the .ocx did it all "automatically" instead of through an event handler supplied by the application programmer.