0

I have a dilema with my DCEF3 (using Delphi XE3). Let's simply take the cefclient.exe from demo package, since it's not using forms and I didn't really found too much documentation on google, how could I check if there's any process so it can focus the current opened one instead opening a new one.

This is what I'm using in the guiclient demo, where I am using Forms unit.

begin
  Hwnd := FindWindow ('TLoginForm', nil);
  if Hwnd = 0 then
  begin
    Application.Initialize;
    Application.Title := 'Tribul.Net - Game Overview';
    Application.CreateForm(TLoginForm, LoginForm);
    Application.CreateForm(TBrowserForm, BrowserForm);
    Application.Run;
  end else
    SetForegroundWindow(Hwnd);
end.

Any idea on how to do this on this sample of code?

// multi process
  CefSingleProcess := False;
  if not CefLoadLibDefault then Exit;

  try
    wndClass.style         := CS_HREDRAW or CS_VREDRAW;
    wndClass.lpfnWndProc   := @CefWndProc;
    wndClass.cbClsExtra    := 0;
    wndClass.cbWndExtra    := 0;
    wndClass.hInstance     := hInstance;
    wndClass.hIcon         := LoadIcon(0, IDI_APPLICATION);
    wndClass.hCursor       := LoadCursor(0, IDC_ARROW);
    wndClass.hbrBackground := 0;
    wndClass.lpszMenuName  := nil;
    wndClass.lpszClassName := 'tribul';

    RegisterClass(wndClass);

    Window := CreateWindow(
      'tribul',             // window class name
      'Tribul.net - Gods of War',     // window caption
      WS_OVERLAPPEDWINDOW or WS_CLIPCHILDREN,    // window style
      Integer(CW_USEDEFAULT), // initial x position
      Integer(CW_USEDEFAULT), // initial y position
      Integer(CW_USEDEFAULT), // initial x size
      Integer(CW_USEDEFAULT), // initial y size
      0,                      // parent window handle
      0,                      // window menu handle
      hInstance,              // program instance handle
      nil);                   // creation parameters

    ShowWindow(Window, SW_SHOW);
    UpdateWindow(Window);
Eduard
  • 3,395
  • 8
  • 37
  • 62
  • possible duplicate of [How to I ensure only a single instance of my application runs using Delphi XE?](http://stackoverflow.com/questions/5390412/how-to-i-ensure-only-a-single-instance-of-my-application-runs-using-delphi-xe) and http://stackoverflow.com/questions/459554/how-can-i-tell-if-another-instance-of-my-program-is-already-running and http://stackoverflow.com/questions/2432287/easiest-way-to-find-previous-instance-of-an-application and many many more – David Heffernan Nov 08 '13 at 14:46
  • I believe I've even asked this once before long ago, most likely deleted though after realizing it's already been asked many times before. – Jerry Dodge Nov 09 '13 at 13:09

0 Answers0