void DUIInit( void ) { InitScreen(); CmdHistory = WndInitHistory(); SrchHistory = WndInitHistory(); InitToolBar(); InitMemWindow(); InitAboutMessage(); InitIOWindow(); InitMenus(); WndInit( LIT_DUI( The_WATCOM_Debugger ) ); _SwitchOff( SW_ERROR_STARTUP ); #if defined(__GUI__) TellWinHandle(); #endif if( WndMain != NULL ) WndSetIcon( WndMain, &MainIcon ); StartTimer(); InitHelp(); InitGadget(); InitPaint(); InitBrowse(); InitFont(); }
BOOL CDlgOpentools::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText("组件编辑 - 类型:" + m_sBaseType + " 名称:" + m_sNodeName); HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON_OPENTOOLS); //SetIcon(hIcon, FALSE); SetIcon(hIcon, TRUE); // TODO: 在此添加额外的初始化 CRect rcArce; SystemParametersInfo(SPI_GETWORKAREA,0,&rcArce,SPIF_SENDCHANGE); int nWorkHeight = rcArce.Height(); int nWorkWidth = rcArce.Width(); // int x = 1120; // int y = 630; // int xStart = (nWorkWidth - x) / 2; // int yStart = (nWorkHeight - y) / 2; // ::SetWindowPos(m_hWnd, NULL, xStart, yStart, x, y, SWP_NOZORDER); // ::SetWindowPos(m_hWnd, NULL, 0, 0, nWorkWidth, nWorkHeight, SWP_NOZORDER); SetWndPos();//设置窗口大小 ////////////////////////////////////////////////////////////////////////// //取窗口句柄 DWORD dwPid = 0; HWND hWnd = 0; m_pSharedMemoryOnlineEdit->GetInfo(&dwPid, &hWnd); //窗口句柄有效,直接返回 if (hWnd != 0 && IsWindow(hWnd)) { m_hWndOpentools = hWnd; m_dProcessId = dwPid; //ShowWindow(SW_SHOWMAXIMIZED); BindWindow(); //发送任务指令 SetTimer(TIMER_SEND_MISSON, 1, NULL); } else { //窗口句柄无效时,从进程中查 HANDLE hProcess = NULL; if (dwPid != 0) { hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwPid); } //若进程无效,重新启动封装环境 if (hProcess == NULL || hProcess == INVALID_HANDLE_VALUE) { m_dProcessId = m_pSharedMemoryOnlineEdit->StartOpenTools(); if (m_dProcessId == 0) { MyClose(IDCANCEL); return TRUE; } InitPaint(); SetTimer(TIMER_FIND_WINDOW, 500, NULL); } else { m_dProcessId = dwPid; CloseHandle(hProcess); HWND hWndFindOpentools = SharedMemoryOnlineEdit::GetMainWindow(m_dProcessId, "组件封装", "HwndWrapper[PeraComponentEditor.exe"); if (hWndFindOpentools && IsWindow(hWndFindOpentools)) { m_hWndOpentools = hWndFindOpentools; //更新共享内存 m_pSharedMemoryOnlineEdit->SetInfo(m_dProcessId, m_hWndOpentools); BindWindow(); //发送任务指令 SetTimer(TIMER_SEND_MISSON, 1, NULL); } else { InitPaint(); SetTimer(TIMER_FIND_WINDOW, 500, NULL); } } } ShowWindow(SW_SHOWMAXIMIZED); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }