Search code examples
delphifocusshowdde

How do I bring my window to the front after a DDE event?


On a DDE event my program loads a file in and should pop to the foreground. I was using

show;

It only seems to be working like then when i have hidden the window.

So i added

bringtofront;

Again this worked if it was hidden, closed, minimized or in the icon tray but not if it was open just under another window.

I even tried some hacky stuff like

windowstate:=wsminimized;
windowstate:=wsnormal;

to try force it to show, but to no avail. I know the code is running as i have printouts on either side of this block and there are no conditional statements that it could be stuck in.


Solution

  • Did you try SetForegroundWindow and/or SetActiveWindow? Also see MSDN info on this subject.