ENIGMA Forums

Contributing to ENIGMA => Function Peer Review => Topic started by: time-killer-games on May 08, 2013, 01:31:06 pm

Title: Splash functions
Post by: time-killer-games on May 08, 2013, 01:31:06 pm
here's the code.


Code: [Select]
  HWND apphwnd;
  HANDLE handle;

    int CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param)
    {
        DWORD pID;
        DWORD TpID = GetWindowThreadProcessId(hwnd, &pID);
            if (TpID == (DWORD)param)
                {
                apphwnd=hwnd;
                return false;
                }
        return true;
    }

    HANDLE StartNewProcess(LPCTSTR program, LPCTSTR args)
            {
                HANDLE hProcess = NULL;
                PROCESS_INFORMATION processInfo;
                STARTUPINFO startupInfo;
                ::ZeroMemory(&startupInfo, sizeof(startupInfo));
                startupInfo.cb = sizeof(startupInfo);
                    if(::CreateProcess(program, (LPTSTR)args,
                                        NULL,  // process security
                                        NULL,  // thread security
                                        FALSE, // no inheritance
                                        0,     // no startup flags
                                        NULL,  // no special environment
                                        NULL,  // default startup directory
                                        &startupInfo,
                                        &processInfo))
                        { /* success */
                        Sleep(5000);//wait for the window of exe application created
                        ::EnumWindows(&EnumWindowsProc, processInfo.dwThreadId);
                        hProcess = processInfo.hProcess;
                        } /* success */
                return hProcess;//Return HANDLE of process.
            }

  int splash_show_program(char *program)
  {
      StartNewProcess(program);
      ::SetParent(apphwnd,m_hWnd)
      ::SetWindowLong(apphwnd, GWL_STYLE, WS_VISIBLE);
      CRect rect;
      GetClientRect(&rect);
      ::MoveWindow(apphwnd, rect.left, rect.top,rect.right, rect.bottom, true);
  }

  int splash_terminate_program()
  {
      TerminateProcess(handle,0);
  }
Title: Re: Splash functions
Post by: Goombert on May 08, 2013, 11:29:40 pm
When I am free if you don't start on bridges then I will get around to it when I can to expose the Window handle and create a proper bridge for the necessary systems.
Please note as well we have discussion ongoing regarding that functions should be placed in side namespace enigma_user {}; as that is the namespace the engine will use for function detection, everything outside the namespaces scope is hidden from the end user.
Title: Re: Splash functions
Post by: time-killer-games on May 09, 2013, 12:14:05 pm
Quite honestly, I have not a clue on how to impliment my code into enigma and I think it would be much better if some one else did the rest.