Пример #1
0
void CDialogTrustDB::OnCancel()
    {
    ::EndDialog(GetWindow(), IDCANCEL); 
    }
CEGUI::Window*
CFileSystemDialogImp::GetWindowImp( void )
{GUCE_TRACE;

    return static_cast< CEGUI::Window* >( GetWindow()->GetImplementationPtr() );
}
Пример #3
0
BOOL CRunTestsSheet::OnInitDialog() 
{
  if(!m_bHideTarget){
    m_prop.Add(_T("Platform"),m_strTarget);
  }
  m_prop.Add(_T("Active timeout"),m_nTimeout);
  m_prop.Add(_T("Download timeout"),m_nDownloadTimeout);
  m_prop.Add(_T("Active timeout type"),m_nTimeoutType);
  m_prop.Add(_T("Download timeout type"),m_nDownloadTimeoutType);
  m_prop.Add(_T("Remote"),m_bRemote);
  m_prop.Add(_T("Serial"),m_bSerial);
  m_prop.Add(_T("Port"),m_strPort);
  m_prop.Add(_T("Baud"),m_nBaud);
  m_prop.Add(_T("Local TCPIP Host"),m_strLocalTCPIPHost);
  m_prop.Add(_T("Local TCPIP Port"),m_nLocalTCPIPPort);
  m_prop.Add(_T("Reset Type"),m_nReset);
  m_prop.Add(_T("Reset String"),m_strReset);
  m_prop.Add(_T("Resource Host"),m_strResourceHost);
  m_prop.Add(_T("Resource Port"),m_nResourcePort);
  m_prop.Add(_T("Remote Host"),m_strRemoteHost);
  m_prop.Add(_T("Remote Port"),m_nRemotePort);
  m_prop.Add(_T("Recurse"),executionpage.m_bRecurse);
  //m_prop.Add(_T("Loadfromdir"),executionpage.m_strLoaddir);
  m_prop.Add(_T("Farmed"),m_bFarmed);
  m_prop.Add(_T("Extension"),executionpage.m_strExtension);
  
  CeCosTrace::SetOutput(TestOutputCallback,this);
  CeCosTrace::SetError (TestOutputCallback,this);
  
  // m_psh can only be used to set the small icon.  Set the large one here.
  m_psh.hIcon=AfxGetApp()->LoadIcon(IDR_TT_MAINFRAME);
  //sheet.m_psh.dwFlags|=PSH_USEHICON/*|PSH_HASHELP*/;
  if(m_psh.hIcon){
    SetIcon(m_psh.hIcon,FALSE);
    SetIcon(m_psh.hIcon,TRUE);
  }
  GetWindowRect(m_rcPrev);
#ifdef _DEBUG
  CeCosTrace::EnableTracing(CeCosTrace::TRACE_LEVEL_TRACE);
#endif
  CeCosTrace::SetInteractive(true);
  
  if(m_pInitFunc){
    m_pInitFunc(&m_prop,false);
  }
  
  GetDlgItem(IDCANCEL)->SetWindowText(_T("&Close"));
  
  m_nTestsToComplete=0;
  BOOL bResult = CeCosPropertySheet::OnInitDialog();
  SetDlgItemText(IDOK,_T("&Run"));
  SetDlgItemText(ID_APPLY_NOW,_T("&Properties"));
  GetDlgItem(ID_APPLY_NOW)->EnableWindow(TRUE);
  GetDlgItem(IDCANCEL)->EnableWindow(TRUE); // required for modeless case
  
  SetActivePage(&outputpage);
  SetActivePage(&summarypage);
  SetActivePage(&executionpage);
 	
  if(m_pInitFunc){
    m_pInitFunc(&m_prop,false);
    outputpage.UpdateData(FALSE);
    summarypage.UpdateData(FALSE);
    executionpage.UpdateData(FALSE);
  }
  /*
  CString strCaption = _T("Output");
  TC_ITEM tcItem;
  tcItem.mask = TCIF_TEXT;
  tcItem.pszText = (LPTSTR)((LPCTSTR)strCaption);
  GetTabControl()->SetItem(2, &tcItem );
  strCaption=_T("Summary");
  GetTabControl()->SetItem(3, &tcItem );
  */
  // Allow resizing
  
  // WS_OVERLAPPEDWINDOW would preclude caption bar help button
  ModifyStyle(0,WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME ,0);
  
  CRect rect;
  GetWindowRect(rect);
  m_rcPrev=rect;
  
  m_cxMin=rect.Width();
  m_cyMin=rect.Height();
  
  m_bAllowResizing=true;
  
  WINDOWPLACEMENT wndpl;
  if (5==_stscanf(m_strPlacement,_T("%d %d %d %d %d"),&rect.left,&rect.top,&rect.right,&rect.bottom,&wndpl.showCmd)){
    CRect rcMax;
    SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)(RECT *)rcMax, 0);
    
    if(rect.Width()<100 || rect.Height()<100 || rect.Width()>rcMax.Width() || rect.Height()>rcMax.Height()){
      rect=CFrameWnd::rectDefault;
    }
    
    wndpl.length = sizeof(WINDOWPLACEMENT);
    wndpl.flags = 0;
    
    wndpl.ptMinPosition = CPoint(0, 0);
    wndpl.ptMaxPosition =CPoint(-::GetSystemMetrics(SM_CXBORDER),-::GetSystemMetrics(SM_CYBORDER));
    wndpl.rcNormalPosition = rect;
    
    // sets window's position and iconized/maximized status
    SetWindowPlacement(&wndpl);
  }
  
  // Hack: force an initial sizing (without which the tab control is badly sized)
  m_rcOffset.left=m_rcOffset.right=m_rcOffset.top=0;
  
  m_rcOffset.bottom=m_bModal?50:-50;
  MoveWindow(GetTabControl(),Stretch);
  for(int i=0;i<GetPageCount();i++){
    MoveWindow(GetPage(i),Stretch);
  }
#ifdef _DEBUG
    for(CWnd *p=GetWindow(GW_CHILD);p;p=p->GetWindow(GW_HWNDNEXT)){
      TCHAR buf[256];
      ::GetClassName(p->m_hWnd,buf,sizeof buf);
      TRACE(_T("Window %x id=%d class=%s\n"),p,p->GetDlgCtrlID(),buf);
    }
#endif
  for(i=0;i<sizeof(arIds)/sizeof(arIds[0]);i++){
    CWnd *pWnd=GetDlgItem(arIds[i]);
    if(pWnd){
      MoveWindow(pWnd,BottomRight);
      pWnd->ShowWindow(SW_SHOW); // necessary in the modeless case
    } else {
      TRACE(_T("Failed to find window id=%x\n"),arIds[i]);
    }
  }

  // hack to lay buttons out correctly in application case
  if(this==AfxGetMainWnd()){
    CRect rect1,rect2;
    GetDlgItem(IDOK)->GetWindowRect(rect1);
    GetDlgItem(IDCANCEL)->GetWindowRect(rect2);
    CRect rect(rect1);
    rect.left-=(rect2.left-rect1.left);
    rect.right-=(rect2.right-rect1.right);
    ScreenToClient(rect);
    GetDlgItem(ID_APPLY_NOW)->MoveWindow(rect);
    GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_SHOW);
  }

  if(!m_bModal){
    SetTimer(0,100,0);
  }
  BringWindowToTop();
  return bResult;
}
Пример #4
0
HWND
InternalCreateDialog(HINSTANCE hInst, LPSTR lpDlg,
                     HWND hWnd, DLGPROC lpFunc, LPARAM lParam)
{
    DIALOGDATA *dp = (DIALOGDATA *) lpDlg;
    CONTROLDATA *cp;
    HWND  	hDlg;
    int     i;
    HWND    hCtl;
    HWND    hFirst = 0,hFirstButton;
    int	X,Y;
    HFONT	hFont = (HFONT)0;
    HFONT	ctlFont;
    DWORD	dwBaseUnits;
    DWORD	dwRet;
    WORD	wDialogWidth, wDialogHeight;
    WORD	wDlgCode;
    int	nWidth, nHeight;
    int	nXBorder = 0, nYBorder = 0;
    int	cyCaption;
    LOGFONT LogFont;
    BOOL	bVisible;
    DWORD	dwStyle;
#if 0
    HDC hDC;
    HCURSOR	hCursOld, hCursHourGlass;
#endif

    dwBaseUnits = GetDialogFontUnits(hFont);
    wDialogWidth  = LOWORD(dwBaseUnits);
    wDialogHeight = HIWORD(dwBaseUnits);

    dwStyle = dp->lStyle;
    /* force WS_POPUP style for top-level dialogs */
    if (!(dwStyle & WS_CHILD))
        dwStyle |= WS_POPUP;

    if (dwStyle & DS_SETFONT  &&
            dp->szFaceName != NULL  && strlen(dp->szFaceName)) {

        memset((LPVOID)&LogFont,0,sizeof(LOGFONT));

        /* dp->wPointSize is defined as the typographical point size,*/
        /*  it must be converted to the logical font size.  */
#if 0
        LogFont.lfHeight = -1 * MulDiv(dp->wPointSize,
                                       GetDeviceCaps (hDC, LOGPIXELSY), 72);
#else
        /* dp->wPointSize is NOT a typographical point size.  It is
         * the font height in dialog base units.  It was misnamed.
         */
        LogFont.lfHeight = (dp->wPointSize * wDialogHeight / 8);
#endif
        LogFont.lfWeight = 700;
        strcpy(LogFont.lfFaceName,dp->szFaceName);

        hFont = CreateFontIndirect(&LogFont);
    }

    /* NOTE:
     *	 the coordinates here are from the resource file
     * 	 we should not change them here, but in Windows.c.
     * 	 this was converted from a straight muliply then
     * 	 divide, to MulDiv, this will round up both the x,y
     *	 and the width.
     */
    X       = MulDiv(dp->x,wDialogWidth,4);
    Y       = MulDiv(dp->y,wDialogHeight,8);
    nWidth  = MulDiv(dp->cx,wDialogWidth,4);
    nHeight = MulDiv(dp->cy,wDialogHeight,8);


    /* final window size and coordinates should be adjusted by */
    /* border and caption size depending on the style	   */

    if (dwStyle & WS_DLGFRAME) {
        nXBorder = GetSystemMetrics(SM_CXDLGFRAME);
        nYBorder = GetSystemMetrics(SM_CYDLGFRAME);
    }
    else if (dwStyle & WS_BORDER) {
        nXBorder = GetSystemMetrics(SM_CXBORDER);
        nYBorder = GetSystemMetrics(SM_CYBORDER);
    }
    if (dwStyle & WS_THICKFRAME) {
        nXBorder = GetSystemMetrics(SM_CXFRAME);
        nYBorder = GetSystemMetrics(SM_CYFRAME);
    }
    X -= nXBorder;
    Y -= nYBorder;
    nWidth += 2*nXBorder;
    nHeight += 2*nYBorder;
    if ((dwStyle & WS_CAPTION) == WS_CAPTION) {
        cyCaption = GetSystemMetrics(SM_CYCAPTION);
        Y -= cyCaption;
        nHeight += cyCaption;
    }

    if (dwStyle & WS_VISIBLE) {
        bVisible = TRUE;
        dwStyle &= ~WS_VISIBLE;
    }
    else
        bVisible = FALSE;

    hDlg = CreateWindow(
               (!HIWORD(dp->szClassName) || !strlen(dp->szClassName))?
               TWIN_DIALOGCLASS:dp->szClassName,
               (HIWORD(dp->szCaption) && strlen(dp->szCaption))?
               dp->szCaption:" ",
               dwStyle,
               X,Y,nWidth,nHeight,
               hWnd,
               (HMENU)0,
               (hInst)?hInst:
               (hWnd?GetWindowInstance(hWnd):0),
               NULL
           );

    if(hDlg == 0) {
        return 0;
    }

    /*
     * The following code was removed because it needlessly leaves
     * an hour glass on all of the applications windows while the dialog
     * box is up.  Another call to SetCursor() was also commented out
     * at the end of this function.
     */
#if 0
    hCursHourGlass = LoadCursor((HINSTANCE)0, IDC_WAIT);
    hCursOld       = SetCursor(hCursHourGlass);
#endif

    SetWF(hDlg,WFDIALOGWINDOW);
    SetWindowWord(hDlg,DWW_STATUS,0);
    SetWindowWord(hDlg,DWW_PARENT,hWnd);
    SetWindowLong(hDlg,DWL_DLGPROC,(LONG)lpFunc);
    SetWindowLong(hDlg,DWL_LPARAM,lParam);
    SetWindowWord(hDlg,DWW_DEFID,(WORD)0L);
    if (hFont)
        SendMessage(hDlg, WM_SETFONT, (WPARAM)hFont,
                    (LPARAM)MAKELONG(FALSE,0));

    for(i=0,cp=dp->controlinfo; i<(int)(dp->bNumberOfItems); i++,cp++) {

        hCtl = CreateWindow(
                   cp->szClass?cp->szClass:"STATIC",
                   ((!cp->szClass || !lstrcmpi(cp->szClass,"STATIC"))
                    && ((cp->lStyle & 0xf) == SS_ICON))?
                   NULL:cp->szText,
                   cp->lStyle,
                   (int)(cp->x*wDialogWidth)/4,
                   (int)(cp->y*wDialogHeight)/8,
                   (int)(cp->cx*wDialogWidth)/4,
                   (int)(cp->cy*wDialogHeight)/8,
                   hDlg,
                   cp->wID,
                   hWnd?GetWindowInstance(hWnd):hInst,
                   NULL
               );
        if(!hFirst && (cp->lStyle & WS_TABSTOP))
            hFirst = hCtl;

        if ((!cp->szClass || !lstrcmpi(cp->szClass,"STATIC")) &&
                ((cp->lStyle & 0xf) == SS_ICON)) {
            /* icon for the SS_ICON control comes from the same place,
            as dialog template, note, only send message if we
            actually have one */
            if(cp->szText)
                SendMessage(hCtl,
                            STM_SETICON,
                            (WPARAM)LoadIcon(hInst,cp->szText),
                            (LPARAM)0);
        }

        /* if a dialog class font was specified, and the control */
        /* has not done a WM_SETFONT, then set this font.        */
        if(hFont) {
            ctlFont = (HFONT)SendMessage(hCtl, WM_GETFONT, 0, 0);
            if(ctlFont == 0)
                SendMessage( hCtl, WM_SETFONT, (WPARAM)hFont,
                             (LPARAM)MAKELONG(FALSE,0) );
        }
    }

    dwRet =  SendMessage(hDlg,WM_INITDIALOG,(WPARAM)hFirst,lParam);

    for (hCtl = GetWindow(hDlg,GW_CHILD),hFirstButton = 0; hCtl;
            hCtl = GetWindow(hCtl,GW_HWNDNEXTSIB)) {
        wDlgCode = (WORD)SendMessage(hCtl,WM_GETDLGCODE,0,0L);
        if (wDlgCode & DLGC_DEFPUSHBUTTON)
            break;
        if ((wDlgCode & DLGC_UNDEFPUSHBUTTON) && (hFirstButton == 0))
            hFirstButton = hCtl;
    }
    if (hCtl != 0)
        SetWindowWord(hDlg,DWW_DEFID,GetWindowID(hCtl));
    else if (hFirstButton != 0)
        SetWindowWord(hDlg,DWW_DEFID,GetWindowID(hFirstButton));
    else
        SetWindowWord(hDlg,DWW_DEFID,0);

    if (dwRet) {
        DlgSetFocus(hFirst);

        if ((WORD)SendMessage(hFirst,WM_GETDLGCODE,0,0L) &
                DLGC_HASSETSEL)
            Edit_SetSel(hFirst, 0, -1);
    }

    hCtl = GetFocus();

    if(hCtl == 0) {
        hCtl = GetFirstDlgTabItem(hDlg);
        if(hCtl) {
            DlgSetFocus(hCtl);

            if ((WORD)SendMessage(hCtl,WM_GETDLGCODE,0,0L) &
                    DLGC_HASSETSEL)
                Edit_SetSel(hCtl, 0, -1);
        }
    }

    if (bVisible) {
        ShowWindow(hDlg,SW_SHOWNORMAL);
    }

    if (bVisible) {
        UpdateWindow(hDlg);
    }

#ifdef CURSORWARPING
    /* this will warp the cursor to the default button */
    /* it only should be activated by a user preference */
    /* and not automatically */
    {
        HWND hWnd;
        int     width ,height;
        RECT rcDlg;

        hWnd = hCtl;
        GetWindowRect(hWnd,&rcDlg);
        width = (rcDlg.left + rcDlg.right)/2;
        height = (rcDlg.bottom + rcDlg.top)/2;
        SetCursorPos(width,height);
    }
#endif

    /* SetCursor(hCursOld); */
    return hDlg;
}
Пример #5
0
    bool OnButtonTeleport()
    {
        ImodelIGC* pDestination = (ImodelIGC*)(m_plistPaneDestinations->GetSelection());
        IstationIGC* pstation = NULL;

        if (pDestination == NULL || trekClient.MyMission() == NULL 
            || trekClient.GetShip()->GetCluster() != NULL)
            return true;


        if (pDestination->GetObjectType() == OT_ship)
        {
            // if this is a ship, try boarding it.
            IshipIGC* pship;
            CastTo(pship, pDestination);

            if (trekClient.GetShip()->GetParentShip() != NULL)
            {
                trekClient.DisembarkAndBoard(pship);
            }
            else
            {
                trekClient.BoardShip(pship);
            }
            trekClient.PlaySoundEffect(personalJumpSound);
        }
        else
        {
            // try teleporting to that station
            IstationIGC* pstation;
            CastTo(pstation, pDestination);

            if (trekClient.GetShip()->GetParentShip() != NULL)
            {
                // if they are already there, just get off of the ship
                if (pstation == trekClient.GetShip()->GetParentShip()->GetStation())
                {
                    trekClient.BoardShip(NULL);
                }
                else
                {
                    trekClient.DisembarkAndTeleport(pstation);
                }
            }
            else
            {
                if (pstation != trekClient.GetShip()->GetStation())
                {
                    trekClient.SetMessageType(BaseClient::c_mtGuaranteed);
                    BEGIN_PFM_CREATE(trekClient.m_fm, pfmDocked, C, DOCKED)
                    END_PFM_CREATE

                    pfmDocked->stationID = pstation->GetObjectID();

                    trekClient.StartLockDown(
                        "Teleporting to " + ZString(pstation->GetName()) + "....", 
                        BaseClient::lockdownTeleporting);
                }
            }
        }

        // dismiss the teleport pane.
        GetWindow()->TurnOffOverlayFlags(ofTeleportPane);

        return true;
    }
Пример #6
0
static void
FreeWindow(HWND hWnd)
{
    HWND hWndFree,hWndFreeNext;
    HWND32 hWnd32;
    DWORD dwClassStyle;

    if (!(hWnd32 = GETHWND32(hWnd)))
	return;

    hWndFree = hWnd32->hWndChild;
    while (hWndFree) {
	hWndFreeNext = GetWindow(hWndFree,GW_HWNDNEXTSIB);
	FreeWindow(hWndFree);
	hWndFree = hWndFreeNext;
    }

    if (hWnd == GetActiveWindow()) {
	if (hWnd32->hWndOwner)
	    SetActiveWindow(hWnd32->hWndOwner);
	else
	    SetActiveWindow(TWIN_FindAnotherOverlapped(hWnd));
    }

    if (hWnd == GetFocus())
	SetFocus(0);
    if (hWnd == GetCapture())
	ReleaseCapture();

    if (!(hWnd32->dwStyle & WS_CHILD))
	if (hWnd32->hMenu) {
	    if (IsMenu(hWnd32->hMenu))
		DestroyMenu(hWnd32->hMenu);
	}
    if (hWnd32->hSysMenu) {
	if (IsMenu(hWnd32->hSysMenu))
	    DestroyMenu(hWnd32->hSysMenu);
    }

    /* NOTE: this used to be after releasing OWN/CLASS DC, but */
    /* at least one app does a GetDC(hWnd) during the NCDESTROY*/
    /* so, don't release it until after. The GetDC code needs  */
    /* the DC to maintain the hardware DC, (read gc for X11)   */

    /* send the last message to this window */
    SendMessage(hWnd,WM_NCDESTROY,0,0);

    /* get rid of DCs that may still be gotten */
    dwClassStyle = GetClassStyle(hWnd);
    if ((dwClassStyle & CS_OWNDC) && hWnd32->hDC)
	TWIN_GdiDestroyDC(hWnd32->hDC);

    if (!(hWnd32->dwStyle & WS_CHILD))
	/* physically destroy the window */
	DRVCALL_WINDOWS(PWSH_DESTROYWINDOW,0L,0L,
			WIN_GETDRVDATA(Get32WindowFrame(hWnd32)));

    if (hWnd32->UpdateRegion)
	DRVCALL_REGIONS(PRH_DESTROYREGION,hWnd32->UpdateRegion,0,0);

    LockClass(hWnd32->hWindowClass32,FALSE);

    SendMessage(Get32WindowFrame(hWnd32),WM_NCDESTROY,0,0L);
    FREEHWND(Get32WindowFrame(hWnd32));

    if (hWnd32->hWndHZScroll) {
	SendMessage(hWnd32->hWndHZScroll,WM_DESTROY,0,0L);
	FREEHWND(hWnd32->hWndHZScroll);
    }
    if (hWnd32->hWndVTScroll) {
	SendMessage(hWnd32->hWndVTScroll,WM_DESTROY,0,0L);
	FREEHWND(hWnd32->hWndVTScroll);
    }

    RELEASEWININFO(hWnd32);
    TWIN_FlushWindowMessages(hWnd);
    FREEHWND(hWnd);
}
Пример #7
0
/** \brief Message Handling Callback.
 * This handles all callbacks to the remote view window.
 */
void RemoteIconView::HandleMessage( Message* pcMessage )
{
	switch( pcMessage->GetCode() )
	{
		case M_REMOTE_DIRLISTING:
		{
			if( !m_bUpdatePending ) {
				DEBUG( "RemoteIconView: Got REMOTE_DIRLISTING while no dirlisting is pending!\n" );
				return;
			}
			
			String zPath;
			if( pcMessage->FindString( "path", &zPath ) != 0 ) {
				DEBUG( "RemoteIconView: Got REMOTE_DIRLISTING without path!\n" );
				return;
			}
			if( zPath != m_zPath ) {
				DEBUG( "RemoteIconView: Got REMOTE_DIRLISTING with wrong path %s! Expecting %s.\n", zPath.c_str(), m_zPath.c_str() );
				return;
			}
			
			std::vector< RemoteNode >* pacNodes;
			/* The Server creates an array of RemoteNodes and passes us the pointer. We should delete it when done. */
			if( pcMessage->FindPointer( "list", (void**)&pacNodes ) ) {
				DEBUG( "RemoteIconView: Got REMOTE_DIRLISTING without pointer to data!\n" );
				return;
			}
			
			bool bInitial;
			if( pcMessage->FindBool( "initial", &bInitial ) != 0 ) bInitial = false;
			
			bool bFinal;
			if( pcMessage->FindBool( "final", &bFinal ) != 0 ) bFinal = false;
			
			SetContents( pacNodes, bInitial, bFinal );
			if( pacNodes ) delete( pacNodes );
		
			break;
		}
		/* Messages from the context menu */
		case M_REMOTE_RENAME:
		{
			/* Check that only one icon is selected & get the selected icon */
			uint nSelectedIcon = -1;
			uint nNumSelected = 0;
			for( uint i = 0; i < GetIconCount(); i++ ) {
				if( GetIconSelected( i ) ) {
					nSelectedIcon = i;
					nNumSelected++;
				}
			}
			if( nNumSelected != 1 ) {
				DEBUG( "RemoteView: Got M_REMOTE_RENAME while %i icons are selected!\n", nNumSelected );
				break;
			}
			RemoteIconData* pcData = (RemoteIconData*)GetIconData( nSelectedIcon );

			/* Display rename dialog */
			Window* pcDialog = new RenameRequester( pcData->m_cNode.m_zPath, this );
			pcDialog->CenterInWindow( GetWindow() );
			pcDialog->Show();
			pcDialog->MakeFocus( true );
			break;
		}
		case M_REMOTE_DELETE:
		{
			/* Save a list of the selected files */
			std::vector< RemoteNode >* pacDeleteList = new std::vector< RemoteNode >;
			for( uint i = 0; i < GetIconCount(); i++ ) {
				if( GetIconSelected( i ) ) {
					pacDeleteList->push_back( ((RemoteIconData*)GetIconData( i ))->m_cNode );
				}
			}
			if( pacDeleteList->size() == 0 ) {
				DEBUG( "RemoteView: Got M_REMOTE_DELETE while no icons are selected!\n" );
				delete( pacDeleteList );
				break;
			}

			/* Display confirmation dialog */
			Window* pcDialog = new DeleteConfirmDialog( pacDeleteList, this );
			pcDialog->CenterInWindow( GetWindow() );
			pcDialog->Show();
			pcDialog->MakeFocus( true );
			break;			
		}
		case M_REMOTE_MKDIR:
		{
			Window* pcDialog = new MkDirRequester( m_zPath, this );
			pcDialog->CenterInWindow( GetWindow() );
			pcDialog->Show();
			pcDialog->MakeFocus( true );
			break;
		}
		case M_DELETE_CONFIRMED:
		{
			std::vector< RemoteNode >* pacDeleteList = NULL;
			pcMessage->FindPointer( "files", (void**)&pacDeleteList );
			if( m_pcServer == NULL ) {	/* Just in case */
				DEBUG( "RemoteView: Got M_DELETE_CONFIRMED while m_pcServer == NULL!\n" );
				delete( pacDeleteList );
				break;
			}
			while( !pacDeleteList->empty() ) {
				RemoteNode* pcNode = &pacDeleteList->back();
				if( pcNode->m_bIsDir ) {
//					DEBUG( "RemoteView: calling RemoveRemoteDir( %s )\n", pcNode->m_zPath.c_str() );
					m_pcServer->RemoveRemoteDir( pcNode->m_zPath );
				} else {
//					DEBUG( "RemoteView: calling DeleteRemote( '%s' )\n", pcNode->m_zPath.c_str() );
					m_pcServer->DeleteRemoteFile( pcNode->m_zPath );
				}
				pacDeleteList->pop_back();
			}
			delete( pacDeleteList );
			Update();
			break;
		}
		case M_MKDIR_CONFIRMED:
		{
			String zPath;
			pcMessage->FindString( "remotepath", &zPath );
			if( m_pcServer == NULL ) {
				DEBUG( "RemoteView: Got M_MKDIR_CONFIRMED while m_pcServer == NULL!\n" );
				break;
			}
			m_pcServer->CreateRemoteDir( zPath );
			Update();
			break;
		}
		case M_RENAME_CONFIRMED:
		{
			String zOldPath, zNewPath;
			pcMessage->FindString( "old_path", &zOldPath );
			pcMessage->FindString( "new_path", &zNewPath );
			if( m_pcServer == NULL ) {
				DEBUG( "RemoteView: Got M_RENAME_CONFIRMED while m_pcServer == NULL!\n" );
				break;
			}
			m_pcServer->MoveRemote( zOldPath, zNewPath );
			Update();
			break;
		}
		default:
		{
			IconView::HandleMessage( pcMessage );
		}
	}
}
Пример #8
0
static char* SSLGiveSRPClientPassword(SSL *s, void *arg)
{
    LOG(INFO) << "SSLGiveSRPClientPassword " << GetWindow("ServerBrowser/Password")->getText();
    return BUF_strdup(GetWindow("ServerBrowser/Password")->getText().c_str());
}
nsresult
sbWindowWatcher::CallWithWindow_Proxy(const nsAString&           aWindowType,
                                  sbICallWithWindowCallback* aCallback,
                                  bool                     aWait)
{
  // Validate arguments.
  NS_ENSURE_ARG_POINTER(aCallback);

  // Function variables.
  nsresult rv;

  // If not on main thread, call back through a proxy.
  if (!SB_IsMainThread(mThreadManager)) {
    nsRefPtr<sbRunnable_<nsresult>> job =
      new sbRunnableMethod3_<nsresult,sbWindowWatcher,
      const nsAString&,sbICallWithWindowCallback*,bool>(
          *this,&sbWindowWatcher::CallWithWindow_Proxy,
          aWindowType,aCallback,aWait);
    // Call back through the proxy.  Wait for window if specified to do so.
    rv = NS_OK;
    while (1) {
      // Call the proxied window watcher.  Exit loop on success or if not
      // waiting.
      NS_DispatchToMainThread(job);
      rv = job->Wait();
      if (NS_SUCCEEDED(rv) || !aWait)
        break;
      if (rv != NS_ERROR_NOT_AVAILABLE)
        NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);

      // Wait for a window if none available.
      rv = WaitForWindow(aWindowType);
      NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
    }
    NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);

    return NS_OK;
  }

  // Operate within the monitor.
  mozilla::ReentrantMonitorAutoEnter autoMonitor(mMonitor);

  // Check if window is already available.
  nsCOMPtr<nsIDOMWindow> window;
  rv = GetWindow(aWindowType, getter_AddRefs(window));
  NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);

  // If a window is available or this instance is shutting down, call the
  // callback.  Otherwise, place the call with window information on the call
  // with window list.
  if (window || mIsShuttingDown) {
    aCallback->HandleWindowCallback(window);
  } else {
    // If specified to wait and the window is not available, return a not
    // available error indication instead of enqueuing onto the call with window
    // list.
    if (aWait)
      return NS_ERROR_NOT_AVAILABLE;

    // Place the call with window information on the call with window list.
    CallWithWindowInfo callWithWindowInfo;
    callWithWindowInfo.windowType = aWindowType;
    callWithWindowInfo.callback = aCallback;
    mCallWithWindowList.AppendElement(callWithWindowInfo);
  }

  return NS_OK;
}
Пример #10
0
void RefreshWindowList(HWND hwndCombobox, ConfigDialogData &configData)
{
    SendMessage(hwndCombobox, CB_RESETCONTENT, 0, 0);
    configData.ClearData();

    HWND hwndCurrent = GetWindow(GetDesktopWindow(), GW_CHILD);
    do
    {
        if(IsWindowVisible(hwndCurrent))
        {
            RECT clientRect;
            GetClientRect(hwndCurrent, &clientRect);

            HWND hwndParent = GetParent(hwndCurrent);

            DWORD exStyles = (DWORD)GetWindowLongPtr(hwndCurrent, GWL_EXSTYLE);
            DWORD styles = (DWORD)GetWindowLongPtr(hwndCurrent, GWL_STYLE);

            if( (exStyles & WS_EX_TOOLWINDOW) == 0 && (styles & WS_CHILD) == 0 /*&& hwndParent == NULL*/)
            {
                String strWindowName;
                strWindowName.SetLength(GetWindowTextLength(hwndCurrent));
                GetWindowText(hwndCurrent, strWindowName, strWindowName.Length()+1);

                bool b64bit = false;

                //-------

                DWORD processID;
                GetWindowThreadProcessId(hwndCurrent, &processID);
                if(processID == GetCurrentProcessId())
                    continue;

                TCHAR fileName[MAX_PATH+1];
                scpy(fileName, TEXT("unknown"));

                HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, processID);
                if(hProcess)
                {
                    DWORD dwSize = MAX_PATH;
                    QueryFullProcessImageName(hProcess, 0, fileName, &dwSize);
                }
                else
                {
                    hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processID);
                    if(hProcess)
                    {
                        CloseHandle(hProcess);
                    }

                    continue;
                }

                //-------

                String strFileName = fileName;
                strFileName.FindReplace(TEXT("\\"), TEXT("/"));

                String strText;
                strText << TEXT("[") << GetPathFileName(strFileName);
                strText << (b64bit ? TEXT("*64") : TEXT("*32"));
                strText << TEXT("]: ") << strWindowName;

                int id = (int)SendMessage(hwndCombobox, CB_ADDSTRING, 0, (LPARAM)strText.Array());
                SendMessage(hwndCombobox, CB_SETITEMDATA, id, (LPARAM)hwndCurrent);

                String strClassName;
                strClassName.SetLength(256);
                GetClassName(hwndCurrent, strClassName.Array(), 255);
                strClassName.SetLength(slen(strClassName));

                WindowInfo &info    = *configData.windowData.CreateNew();
                info.strClass       = strClassName;
                info.strProcess     = fileName;
            }
        }
    } while (hwndCurrent = GetNextWindow(hwndCurrent, GW_HWNDNEXT));
}
Пример #11
0
INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct UrlSendData* dat = (struct UrlSendData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL);
		Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history"));
		Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu"));

		SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, 450, 0);
		dat = (struct UrlSendData*)mir_alloc(sizeof(struct UrlSendData));
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
		dat->hContact = lParam;
		dat->hAckEvent = NULL;
		dat->hSendId = NULL;
		dat->sendBuffer = NULL;

		WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact);
		{
			TCHAR *str = pcli->pfnGetContactDisplayName(dat->hContact, 0);
			SetDlgItemText(hwndDlg, IDC_NAME, str);
		}

		GetOpenBrowserUrls(hwndDlg, GetDlgItem(hwndDlg, IDC_URLS));
		SendDlgItemMessage(hwndDlg, IDC_URLS, CB_SETCURSEL, 0, 0);
		if (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0))SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_URLS, CBN_SELCHANGE), 0);
		EnableWindow(GetDlgItem(hwndDlg, IDOK), (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0) == CB_ERR)?FALSE:TRUE);
		Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "send");
		mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MESSAGE), SendEditSubclassProc);
		mir_subclassWindow( GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), SendEditSubclassProc);

		// From message dlg
		if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0))
			ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);

		SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0);
		// From message dlg end
		return TRUE;

	case WM_DDE_DATA:
	case WM_DDE_ACK:
		return DdeMessage(hwndDlg, msg, wParam, lParam);

	case WM_TIMER:
		if (wParam == 0) {
			//ICQ sendurl timed out
			KillTimer(hwndDlg, 0);
			MessageBox(hwndDlg, TranslateT("Send timed out"), _T(""), MB_OK);
			EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
			EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), TRUE);
			SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, FALSE, 0);
		}
		break;

	case WM_MEASUREITEM:
		return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);

	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
			if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) {
				char *szProto = GetContactProto(dat->hContact);
				if (szProto) {
					HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
					if (hIcon) {
						DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
						DestroyIcon(hIcon);
		}	}	}	}
		return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);

	case DM_UPDATETITLE:
		sttUpdateTitle(hwndDlg, dat->hContact);
		break;

	case WM_COMMAND:
		if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact))
			break;

		switch (LOWORD(wParam)) {
		case IDOK:
			{
				char *body, *url;
				int bodySize, urlSize;

				urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1;
				url = (char*)mir_alloc(urlSize);
				GetDlgItemTextA(hwndDlg, IDC_URLS, url, urlSize);
				if (url[0] == 0) {
					mir_free(url);
					break;
				}
				bodySize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE))+1;
				body = (char*)mir_alloc(bodySize);
				GetDlgItemTextA(hwndDlg, IDC_MESSAGE, body, bodySize);

				dat->sendBuffer = (char*)mir_realloc(dat->sendBuffer, lstrlenA(url)+lstrlenA(body)+2);
				lstrcpyA(dat->sendBuffer, url);
				lstrcpyA(dat->sendBuffer+lstrlenA(url)+1, body);
				dat->hAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT);
				dat->hSendId = (HANDLE)CallContactService(dat->hContact, PSS_URL, 0, (LPARAM)dat->sendBuffer);
				mir_free(url);
				mir_free(body);

				//create a timeout timer
				SetTimer(hwndDlg, 0, TIMEOUT_URLSEND, NULL);
				EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), FALSE);
				SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, TRUE, 0);

				return TRUE;
			}

		case IDCANCEL:
			DestroyWindow(hwndDlg);
			return TRUE;

		case IDC_URLS:
			if (HIWORD(wParam) == CBN_SELCHANGE) {
				int i, urlSize;
				char *title;
				i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0);
				title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0);
				SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title);
				urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0);
				EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0));
			}
			else if (HIWORD(wParam) == CBN_EDITCHANGE) {
				int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS));
				EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0));
			}
			break;
		case IDC_USERMENU:
			{
				RECT rc;
				HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
				GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc);
				TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
				DestroyMenu(hMenu);
			}
			break;

		case IDC_HISTORY:
			CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0);
			break;

		case IDC_DETAILS:
			CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0);
			break;

		case IDC_ADD:
			ADDCONTACTSTRUCT acs = {0};
			acs.hContact = dat->hContact;
			acs.handleType = HANDLE_CONTACT;
			acs.szProto = 0;
			CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);

			if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0))
				ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
		}
		break;

	case HM_EVENTSENT:
		{
			ACKDATA *ack = (ACKDATA*)lParam;
			if (ack->hProcess != dat->hSendId) break;
			if (ack->hContact != dat->hContact) break;
			if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break;

			DBEVENTINFO dbei = { sizeof(dbei) };
			dbei.eventType = EVENTTYPE_URL;
			dbei.flags = DBEF_SENT;
			dbei.szModule = GetContactProto(dat->hContact);
			dbei.timestamp = time(NULL);
			dbei.cbBlob = (DWORD)(strlen(dat->sendBuffer)+strlen(dat->sendBuffer+strlen(dat->sendBuffer)+1)+2);
			dbei.pBlob = (PBYTE)dat->sendBuffer;
			db_event_add(dat->hContact, &dbei);
			KillTimer(hwndDlg, 0);
			DestroyWindow(hwndDlg);
		}
		break;

	case WM_DESTROY:
		Window_FreeIcon_IcoLib(hwndDlg);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY);
		Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU);

		WindowList_Remove(hUrlWindowList, hwndDlg);
		if (dat->hAckEvent) UnhookEvent(dat->hAckEvent);
		if (dat->sendBuffer != NULL) mir_free(dat->sendBuffer);
		mir_free(dat);
		Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "send");

		for (int i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--)
			mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0));
		break;
	}

	return FALSE;
}
Пример #12
0
bool CMPCVideoDecSettingsWnd::OnActivate()
{
	DWORD	dwStyle = WS_VISIBLE|WS_CHILD|WS_BORDER;
	int		nPosY	= 10;
	GUID*	DxvaGui = NULL;

#if defined(REGISTER_FILTER) | INCLUDE_MPC_VIDEO_DECODER
	m_grpFFMpeg.Create (ResStr (IDS_VDF_FFSETTINGS), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (10,  nPosY, 330, nPosY+150), this, IDC_STATIC);

	#if defined(REGISTER_FILTER) | INTERNAL_DECODER_H264
	// Decoding threads
	nPosY += VERTICAL_SPACING;
	m_txtThreadNumber.Create (ResStr (IDS_VDF_THREADNUMBER), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING,  nPosY, 190, nPosY+15), this, IDC_STATIC);
	m_cbThreadNumber.Create  (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (200,  nPosY-4, 260, nPosY+90), this, IDC_PP_THREAD_NUMBER);
	m_cbThreadNumber.AddString (_T("1"));
	m_cbThreadNumber.AddString (_T("2"));
	m_cbThreadNumber.AddString (_T("3"));
	m_cbThreadNumber.AddString (_T("4"));
	m_cbThreadNumber.AddString (_T("5"));
	m_cbThreadNumber.AddString (_T("6"));
	m_cbThreadNumber.AddString (_T("7"));
	m_cbThreadNumber.AddString (_T("8"));

	// H264 deblocking mode
	nPosY += VERTICAL_SPACING;
	m_txtDiscardMode.Create (ResStr (IDS_VDF_SKIPDEBLOCK), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING,  nPosY, 190, nPosY+15), this, IDC_STATIC);
	m_cbDiscardMode.Create  (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (200,  nPosY-4, 315, nPosY+90), this, IDC_PP_DISCARD_MODE);
	m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_NONE));
	m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_DEFAULT));
	m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_NONREF));
	m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_BIDIR));
	m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_NONKFRM));
	m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_ALL));
	#endif
	
	// Error recognition
	nPosY += VERTICAL_SPACING;
	m_txtErrorRecognition.Create (ResStr (IDS_VDF_ERROR_RECOGNITION), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING,  nPosY, 190, nPosY+15), this, IDC_STATIC);
	m_cbErrorRecognition.Create  (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (200,  nPosY-4, 315, nPosY+90), this, IDC_PP_DISCARD_MODE);
	m_cbErrorRecognition.AddString (ResStr (IDS_VDF_ERR_CAREFUL));
	m_cbErrorRecognition.AddString (ResStr (IDS_VDF_ERR_COMPLIANT));
	m_cbErrorRecognition.AddString (ResStr (IDS_VDF_ERR_AGGRESSIVE));
	m_cbErrorRecognition.AddString (ResStr (IDS_VDF_ERR_VERYAGGRESSIVE));

	// IDCT Algo
	nPosY += VERTICAL_SPACING;
	m_txtIDCTAlgo.Create (ResStr (IDS_VDF_IDCT_ALGO), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING,  nPosY, 190, nPosY+15), this, IDC_STATIC);
	m_cbIDCTAlgo.Create  (WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_VSCROLL, CRect (200,  nPosY-4, 315, nPosY+90), this, IDC_PP_DISCARD_MODE);
	m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_AUTO));
	m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_LIBMPG2));
	m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_SIMPLE_MMX));
	m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_XVID));
	m_cbIDCTAlgo.AddString (ResStr (IDS_VDF_IDCT_SIMPLE));

	nPosY += VERTICAL_SPACING;
	m_cbARMode.Create (ResStr (IDS_VDF_AR_MODE), WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX|BS_LEFTTEXT, CRect (LEFT_SPACING,  nPosY, 315, nPosY+15), this, IDC_PP_AR);
	m_cbARMode.SetCheck(FALSE);

	nPosY = 170;
#endif

	m_grpDXVA.Create   (ResStr (IDS_VDF_DXVA_SETTING),   WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (10, nPosY, 330, nPosY+110), this, IDC_STATIC);

	// DXVA mode
	nPosY += VERTICAL_SPACING;
	m_txtDXVAMode.Create (ResStr (IDS_VDF_DXVA_MODE), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING,  nPosY, 120, nPosY+15), this, IDC_STATIC);
	m_edtDXVAMode.Create (WS_CHILD|WS_VISIBLE|WS_DISABLED, CRect (120,  nPosY, 315, nPosY+20), this, 0);

	// Video card description
	nPosY += VERTICAL_SPACING;
	m_txtVideoCardDescription.Create (ResStr (IDS_VDF_VIDEOCARD), WS_VISIBLE|WS_CHILD, CRect (LEFT_SPACING,  nPosY, 120, nPosY+15), this, IDC_STATIC);
	m_edtVideoCardDescription.Create (WS_CHILD|WS_VISIBLE|WS_DISABLED, CRect (120,  nPosY, 315, nPosY+20), this, 0);
	m_edtVideoCardDescription.SetWindowText (m_pMDF->GetVideoCardDescription());
	
	
	DxvaGui = m_pMDF->GetDXVADecoderGuid();
	if (DxvaGui != NULL)
	{
		CString DXVAMode = GetDXVAMode (DxvaGui);
		m_edtDXVAMode.SetWindowText (/*GetDXVAMode (DxvaGui)*/DXVAMode);
	}
	else
	{
		m_txtDXVAMode.ShowWindow (SW_HIDE);
		m_edtDXVAMode.ShowWindow (SW_HIDE);
	}

	for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
		pWnd->SetFont(&m_font, FALSE);

	#if defined(REGISTER_FILTER) | INCLUDE_MPC_VIDEO_DECODER
	if (m_pMDF)
	{
		#if defined(REGISTER_FILTER) | INTERNAL_DECODER_H264
		m_cbThreadNumber.SetCurSel		(m_pMDF->GetThreadNumber() - 1);
		m_cbDiscardMode.SetCurSel		(FindDiscardIndex (m_pMDF->GetDiscardMode()));
		#endif
		m_cbErrorRecognition.SetCurSel	(m_pMDF->GetErrorRecognition()-1);
		m_cbIDCTAlgo.SetCurSel			(m_pMDF->GetIDCTAlgo());

		m_cbARMode.SetCheck(m_pMDF->GetARMode());
	}
	#endif

	return true;
}
Пример #13
0
void CDialogTrustDB::OnInitDialog()
    {
    //
    // Initialize our internals
    //
    if (Init() != S_OK)
        return;

    //
    // Set the state of our commercial checkbox per the current registry setting
    // 
    ::SendMessage(
        WindowOf(IDC_TRUSTCOMMERCIAL),
        BM_SETCHECK, 
        (m_pdb->AreCommercialPublishersTrusted()==S_OK) ? BST_CHECKED : BST_UNCHECKED,
        0L);

    //
    // If we are a property sheet, then hide the OK & Cancel buttons and
    // make the banter wider
    //
    if (m_fPropertySheet)
        {
        RECT rcBanter, rcOk;
        GetWindowRect(WindowOf(IDC_BANTER), &rcBanter);     // get in screen coords
        GetWindowRect(WindowOf(IDOK      ), &rcOk);         // get in screen coords
        ::SetWindowPos(WindowOf(IDC_BANTER), NULL, 
            0, 0, Width(rcBanter) + (rcOk.right - rcBanter.right), Height(rcBanter), 
            SWP_NOMOVE | SWP_NOZORDER);

        ::ShowWindow(WindowOf(IDOK),     SW_HIDE);
        ::ShowWindow(WindowOf(IDCANCEL), SW_HIDE);
        }
    else
        {
        //
        // We are the modal dialog variation. Center ourselves in our
        // parent window
        //
	    RECT rcParent, rcMe;
        ::GetWindowRect(m_hWndParent,  &rcParent);
	    ::GetWindowRect(GetWindow(), &rcMe);

        POINT ptParent = Center(rcParent);
        POINT ptMe     = Center(rcMe);
        POINT pt;
        pt.x = ptParent.x - ptMe.x + rcMe.left;
        pt.y = ptParent.y - ptMe.y + rcMe.top;

	    ::SetWindowPos
            (
            GetWindow(), 
            NULL,
            pt.x,
            pt.y,
            0,
            0,
            SWP_NOZORDER | SWP_NOSIZE
            );

        //
        // Make sure we're on the screen
        //
        EnsureOnScreen(GetWindow());
        }

    //
    // Populate our list box
    //
    RefreshTrustList();

    }
Пример #14
0
HWND CDialogTrustDB::WindowOf(UINT id)
// Return the HWND of this control of ours
    {
    return ::GetDlgItem(GetWindow(), id);
    }
bool
DateValidator::TransferFromWindow()
{
    JEWEL_ASSERT (GetWindow()->IsKindOf(CLASSINFO(TextCtrl)));
    return true;
}
Пример #16
0
/*
 * @implemented
 */
HWND
WINAPI
DECLSPEC_HOTPATCH
CreateWindowExW(DWORD dwExStyle,
                LPCWSTR lpClassName,
                LPCWSTR lpWindowName,
                DWORD dwStyle,
                int x,
                int y,
                int nWidth,
                int nHeight,
                HWND hWndParent,
                HMENU hMenu,
                HINSTANCE hInstance,
                LPVOID lpParam)
{
    MDICREATESTRUCTW mdi;
    HWND hwnd;

    if (!RegisterDefaultClasses)
    {
       ERR("CreateWindowExW RegisterSystemControls\n");
       RegisterSystemControls();
    }

    if (dwExStyle & WS_EX_MDICHILD)
    {
        POINT mPos[2];
        UINT id = 0;
        HWND top_child;
        PWND pWndParent;

        pWndParent = ValidateHwnd(hWndParent);

        if (!pWndParent) return NULL;

        if (pWndParent->fnid != FNID_MDICLIENT)
        {
           WARN("WS_EX_MDICHILD, but parent %p is not MDIClient\n", hWndParent);
           return NULL;
        }

        /* lpParams of WM_[NC]CREATE is different for MDI children.
        * MDICREATESTRUCT members have the originally passed values.
        */
        mdi.szClass = lpClassName;
        mdi.szTitle = lpWindowName;
        mdi.hOwner = hInstance;
        mdi.x = x;
        mdi.y = y;
        mdi.cx = nWidth;
        mdi.cy = nHeight;
        mdi.style = dwStyle;
        mdi.lParam = (LPARAM)lpParam;

        lpParam = (LPVOID)&mdi;

        if (pWndParent->style & MDIS_ALLCHILDSTYLES)
        {
            if (dwStyle & WS_POPUP)
            {
                WARN("WS_POPUP with MDIS_ALLCHILDSTYLES is not allowed\n");
                return(0);
            }
            dwStyle |= (WS_CHILD | WS_CLIPSIBLINGS);
        }
        else
        {
            dwStyle &= ~WS_POPUP;
            dwStyle |= (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION |
                WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
        }

        top_child = GetWindow(hWndParent, GW_CHILD);

        if (top_child)
        {
            /* Restore current maximized child */
            if((dwStyle & WS_VISIBLE) && IsZoomed(top_child))
            {
                TRACE("Restoring current maximized child %p\n", top_child);
                SendMessageW( top_child, WM_SETREDRAW, FALSE, 0 );
                ShowWindow(top_child, SW_RESTORE);
                SendMessageW( top_child, WM_SETREDRAW, TRUE, 0 );
            }
        }

        MDI_CalcDefaultChildPos(hWndParent, -1, mPos, 0, &id);

        if (!(dwStyle & WS_POPUP)) hMenu = UlongToHandle(id);

        if (dwStyle & (WS_CHILD | WS_POPUP))
        {
            if (x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
            {
                x = mPos[0].x;
                y = mPos[0].y;
            }
            if (nWidth == CW_USEDEFAULT || nWidth == CW_USEDEFAULT16 || !nWidth)
                nWidth = mPos[1].x;
            if (nHeight == CW_USEDEFAULT || nHeight == CW_USEDEFAULT16 || !nHeight)
                nHeight = mPos[1].y;
        }
    }

    hwnd = User32CreateWindowEx(dwExStyle,
                                (LPCSTR) lpClassName,
                                (LPCSTR) lpWindowName,
                                dwStyle,
                                x,
                                y,
                                nWidth,
                                nHeight,
                                hWndParent,
                                hMenu,
                                hInstance,
                                lpParam,
                                0);
    return hwnd;
}
Пример #17
0
void
RowFormWidget::UpdateLayout()
{
  PixelRect current_rect = GetWindow()->GetClientRect();
  const unsigned total_width = current_rect.right - current_rect.left;
  const unsigned total_height = current_rect.bottom - current_rect.top;
  current_rect.bottom = current_rect.top;

  const bool expert = UIGlobals::GetDialogSettings().expert;

  /* first row traversal: count the number of "elastic" rows and
     determine the minimum total height */
  unsigned min_height = 0;
  unsigned n_elastic = 0;
  unsigned caption_width = 0;

  for (const auto &i : rows) {
    if (!i.IsAvailable(expert))
      continue;

    min_height += i.GetMinimumHeight(vertical);
    if (i.IsElastic(vertical))
      ++n_elastic;

    if (!vertical && i.type == Row::Type::EDIT) {
      unsigned cw = i.GetControl().GetRecommendedCaptionWidth();
      if (cw > caption_width)
        caption_width = cw;
    }
  }

  if (!vertical && caption_width * 3 > total_width * 2)
    caption_width = total_width * 2 / 3;

  /* how much excess height in addition to the minimum height? */
  unsigned excess_height = min_height < total_height
    ? total_height - min_height
    : 0;

  /* second row traversal: now move and resize the rows */
  for (auto &i : rows) {
    if (!i.IsAvailable(expert)) {
      if (i.type == Row::Type::WIDGET)
        i.GetWidget().Hide();
      else if (i.type != Row::Type::DUMMY)
        i.GetWindow().Hide();

      continue;
    }

    /* determine this row's height */
    UPixelScalar height = i.GetMinimumHeight(vertical);
    if (excess_height > 0 && i.IsElastic(vertical)) {
      assert(n_elastic > 0);

      /* distribute excess height among all elastic rows */
      unsigned grow_height = excess_height / n_elastic;
      if (grow_height > 0) {
        height += grow_height;
        const UPixelScalar max_height = i.GetMaximumHeight(vertical);
        if (height > max_height) {
          /* never grow beyond declared maximum height */
          height = max_height;
          grow_height = max_height - height;
        }

        excess_height -= grow_height;
      }

      --n_elastic;
    }

    if (i.type == Row::Type::WIDGET) {
      Widget &widget = i.GetWidget();

      /* TODO: visible check - hard to implement without remembering
         the control position, because Widget::Show() wants a
         PixelRect parameter */

      NextControlRect(current_rect, height);

      if (!i.initialised) {
        i.initialised = true;
        widget.Initialise(*(ContainerWindow *)GetWindow(), current_rect);
      }

      if (!i.prepared) {
        i.prepared = true;
        widget.Prepare(*(ContainerWindow *)GetWindow(), current_rect);
      }

      widget.Show(current_rect);
      continue;
    }

    Window &window = i.GetWindow();

    if (i.visible)
      window.Show();

    if (i.type == Row::Type::EDIT &&
        i.GetControl().HasCaption()) {
      if (vertical)
        i.GetControl().SetCaptionWidth(-1);
      else if (caption_width > 0)
        i.GetControl().SetCaptionWidth(caption_width);
    }

    /* finally move and resize */
    NextControlRect(current_rect, height);
    window.Move(current_rect);
  }

  assert(excess_height == 0 || n_elastic == 0);
}
Пример #18
0
void CBadTrustDialog::OnInitDialog()
    {
    //
    // Get the background brush for our edit controls
    //
    m_hbrBackground = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));

    // Load the icon
    LPSTR idi;
    switch (m_rrn.hrValid)
        {
    case HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND):
    case TRUST_E_NOSIGNATURE:
        idi = IDI_EXCLAMATION;
        break;
    default:
        idi = IDI_HAND;
        break;
        }
    HICON hicon = LoadIcon(NULL, idi);
    ::SendDlgItemMessage(m_hWnd, IDC_BADTRUSTICON, STM_SETICON, (WPARAM)hicon, (LPARAM)0);

    // Set the window title
		{
		TCHAR sz[128];
        WideCharToMultiByte(CP_ACP, 0, m_rrn.wszDialogTitle, -1, (LPSTR)sz, 128, NULL, NULL);
		::SetWindowText(GetWindow(), sz);
		}

    // Set the banter text
    int cchBanter2;
        {
        const int cchMax = INTERNET_MAX_URL_LENGTH+64;
        TCHAR sz[cchMax];

        // Set the top level banter
        ::LoadString(hinst, IDS_BADTRUSTBANTER1, &sz[0], cchMax);
        ::SetWindowText(WindowOf(IDC_BADTRUSTBANTER1), &sz[0]);

        // Set the program name
            {
            //
            // The 'program' name we see can in fact often be a full URL. URLs
            // can be very long, up to 1024 or so.
            //
            if (m_rrn.wszProgramName)
                {
                WideCharToMultiByte(CP_ACP, 0, m_rrn.wszProgramName, -1, &sz[0], cchMax, NULL, NULL);
                }
            else
                ::LoadString(hinst, IDS_UNKNOWNPROGRAM, &sz[0], cchMax);

            TCHAR szF[cchMax];
            ::FormatMessage(hinst, &szF[0], cchMax, IDS_BADTRUSTBANTER2, &sz[0]);

            ::SetWindowText(WindowOf(IDC_BADTRUSTBANTER2), &szF[0]);
            cchBanter2 = lstrlen(&szF[0]);

            //
            // This control is read-only. Note that the text on the control
            // can be copied using the context menu in the control.
            //
            SendMessage(WindowOf(IDC_BADTRUSTBANTER2), EM_SETREADONLY, (WPARAM)TRUE, 0);
            }

        // Set the trailing banter
        UINT ids;
        switch (m_rrn.hrValid)
            {
        case HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND):
        case TRUST_E_NOSIGNATURE:
            ids = IDS_BADTRUSTBANTER31;
            break;
        case CERT_E_EXPIRED:
        case CERT_E_VALIDIYPERIODNESTING:
            ids = IDS_BADTRUSTBANTER32;
            break;
        case NTE_BAD_SIGNATURE:
            ids = IDS_BADTRUSTBANTER33;
            break;
        default:
            ids = IDS_BADTRUSTBANTER34;
            break;
            }
        ::LoadString(hinst, ids, &sz[0], cchMax);
        ::SetWindowText(WindowOf(IDC_BADTRUSTBANTER3), &sz[0]);

        }

    // Position the controls so that all are visible
        {
        UINT spacing = GetSystemMetrics(SM_CYFIXEDFRAME) * 2;
        RECT rc1, rc2, rc3;
        int h;
        POINT pt;

        //
        // Where on the screen is the client area of the dialog?
        //
        pt.x = 0;
        pt.y = 0;
        ClientToScreen(GetWindow(), &pt);

        //
        // Find first text box location
        //
        GetWindowRect(WindowOf(IDC_BADTRUSTBANTER1), &rc1);

        //
        // Adjust second text box size
        //
        SizeControlToFitText(WindowOf(IDC_BADTRUSTBANTER2));
        //
        // Adjust second text box location
        //
        GetWindowRect(WindowOf(IDC_BADTRUSTBANTER2), &rc2);
        rc2.top    = rc1.bottom + spacing;
        ::SetWindowPos(WindowOf(IDC_BADTRUSTBANTER2), NULL,
            rc2.left - pt.x, rc2.top - pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
        GetWindowRect(WindowOf(IDC_BADTRUSTBANTER2), &rc2);

        //
        // Adjust third text box location
        //
        GetWindowRect(WindowOf(IDC_BADTRUSTBANTER3), &rc3);
        h = Height(rc3);
        rc3.top         = rc2.bottom + spacing;
        rc3.bottom      = rc3.top + h;
        ::SetWindowPos(WindowOf(IDC_BADTRUSTBANTER3), NULL,
            rc3.left - pt.x, rc3.top - pt.y, Width(rc3), Height(rc3), SWP_NOZORDER);

        //
        // Adjust the button locations
        //
        RECT rcOk, rcCancel, rcDetails;
        GetWindowRect(WindowOf(IDOK),        &rcOk);
        GetWindowRect(WindowOf(IDCANCEL),    &rcCancel);
        GetWindowRect(WindowOf(IDC_DETAILS), &rcDetails);
        rcOk.top        = rc3.bottom + spacing;
        rcCancel.top    = rcOk.top;
        rcDetails.top   = rcOk.top;
        ::SetWindowPos(WindowOf(IDOK),        NULL, rcOk.left-pt.x, rcOk.top-pt.y,0,0, SWP_NOZORDER|SWP_NOSIZE);
        ::SetWindowPos(WindowOf(IDCANCEL),    NULL, rcCancel.left-pt.x, rcCancel.top-pt.y,0,0, SWP_NOZORDER|SWP_NOSIZE);
        ::SetWindowPos(WindowOf(IDC_DETAILS), NULL, rcDetails.left-pt.x, rcDetails.top-pt.y,0,0, SWP_NOZORDER|SWP_NOSIZE);
        GetWindowRect(WindowOf(IDOK),        &rcOk);
        GetWindowRect(WindowOf(IDCANCEL),    &rcCancel);
        GetWindowRect(WindowOf(IDC_DETAILS), &rcDetails);

        //
        // Adjust the overall dialog box size
        //
        RECT rcMe;
	    ::GetWindowRect(GetWindow(), &rcMe);            // screen coords	
        rcMe.bottom = rcOk.bottom + spacing + GetSystemMetrics(SM_CYFIXEDFRAME);
        ::SetWindowPos(GetWindow(), NULL, 0,0,Width(rcMe),Height(rcMe), SWP_NOZORDER | SWP_NOMOVE);

        //
        // Center ourselves in the parent window
        //
        HWND hwndParent = ::GetParent(GetWindow());
	    if (hwndParent == NULL)
		    hwndParent = ::GetDesktopWindow();
	    RECT rcParent;
	    ::GetWindowRect(GetWindow(), &rcMe);            // screen coords	
        ::GetWindowRect(hwndParent,  &rcParent);        // screen coords

        POINT ptParent = Center(rcParent);
        POINT ptMe     = Center(rcMe);
        pt.x = ptParent.x - ptMe.x;
        pt.y = ptParent.y - ptMe.y;

	    ::SetWindowPos
            (
            GetWindow(),
            NULL,
            pt.x,
            pt.y,
            0,
            0,
            SWP_NOZORDER | SWP_NOSIZE
            );
        }

    //
    // Make sure we're on the screen
    //
    EnsureOnScreen(GetWindow());

    //
    // Bring ourselves to the attention of the user
    //
    SetForegroundWindow(GetWindow());
    }
Пример #19
0
BOOL WINAPI
DestroyWindow(HWND hWnd)
{
    HWND32 hWnd32, hWndSib32;
    HWND hWndSibling, hWndAncestor, hWndFocus, hWndTmp, hWndOwner;
    DWORD dwStyle;
    int parent_with_focus;

    if (!(hWnd32 = CHECKHWND32(hWnd))) {
	return FALSE;
    }

#ifdef	LATER
	Send WM_CANCELMODE, if caption is active
	Call RealizeDefaultPalette
	Send WM_PALETTECHANGED to all windows
#endif

    if ((hWnd32->dwStyle & WS_CHILD) &&
	!(hWnd32->dwExStyle & WS_EX_NOPARENTNOTIFY)) {
	hWndAncestor = hWnd;
	do {
	    hWndAncestor = GetParent(hWndAncestor);
	    dwStyle = GetWindowStyle(hWndAncestor);
	    SendMessage(hWndAncestor,WM_PARENTNOTIFY,
		GET_WM_PARENTNOTIFY_MPS(WM_DESTROY,hWnd32->wChildID,hWnd));
	} while (dwStyle & WS_CHILD);
    }
    if (!IsWindow(hWnd))
	return TRUE;

    if (hWnd32->dwStyle & WS_VISIBLE) {
	if (hWnd32->dwStyle & WS_CHILD)
	    ShowWindow(hWnd, SW_HIDE);
	else	/* top-level */
	    SetWindowPos(hWnd,0,0,0,0,0,
		SWP_HIDEWINDOW|SWP_NOACTIVATE|
		SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE);
    }
    if (!IsWindow(hWnd))
	return TRUE;

    if (hWnd32->hWndIconTitle)
	DestroyWindow(hWnd32->hWndIconTitle);

    if (!(hWnd32->dwStyle & WS_CHILD)) {
	hWndSibling = GetWindow(hWnd, GW_HWNDFIRST);
	while (hWndSibling) {
	    /* save the next sibling before this one is destroyed */
	    hWndSib32 = GETHWND32(hWndSibling);
	    hWndTmp = hWndSib32->hWndSibling;
	    hWndOwner = hWndSib32->hWndOwner;
	    RELEASEWININFO(hWndSib32);
	    
	    if (hWndOwner == hWnd)
		DestroyWindow(hWndSibling);
	    if (hWndTmp && !IsWindow(hWndTmp))	/* start all over */
		hWndSibling = GetWindow(hWnd, GW_HWNDFIRST);
	    else
		hWndSibling = hWndTmp;
	}
    }

    /* if focus is held by this window or one of it's descendants,
	revert to the parent */

    parent_with_focus= 0;

    if ((hWndFocus = GetFocus()))
	if (hWndFocus == hWnd || IsChild(hWnd,hWndFocus))
	    if(IsWindow(hWnd)) {
		parent_with_focus= GetParent(hWnd);
		SetFocus(parent_with_focus);
	    }

    /* if we are destroying the frame that has the cursor, reset
	the cursor ownership */
    if (!(hWnd32->dwStyle & WS_CHILD)) {
	if (Get32WindowFrame(hWnd32) == TWIN_GetCursorWindow()) {
	    TWIN_SetCursorWindow((HWND)0);
	    if (parent_with_focus) {
		int n;
		POINT FAR lppt;

		GetCursorPos(&lppt);
		n=SendMessage(parent_with_focus, WM_NCHITTEST,(WPARAM)0, MAKELPARAM(lppt.x,lppt.y));
		SendMessage(parent_with_focus, WM_SETCURSOR, (WPARAM)parent_with_focus, n);
	    }
	}
    }

    SendDestroyMessages(hWnd);
    RemoveFromList(hWnd32);
    RELEASEWININFO(hWnd32);
    FreeWindow(hWnd);
    return TRUE;
}
Пример #20
0
void
RenamePickLabelAction::Execute()
{
    GetWindow()->RenamePickLabel(args.GetStringArg1(), args.GetStringArg2());
}
TEST_F(EntityFixture, PlayerTest) {
    GetInput().assignKey(sf::Keyboard::W, Input::Up);
    GetInput().assignKey(sf::Keyboard::A, Input::Left);
    GetInput().assignKey(sf::Keyboard::S, Input::Down);
    GetInput().assignKey(sf::Keyboard::D, Input::Right);
    GetInput().assignMouseButton(sf::Mouse::Left, Input::Shoot);
    GetInput().setMouseLock(true);
    GetWindow().setMouseCursorVisible(false);

    dot.setFillColor(sf::Color::Red);

    // Add behaviors
    playerUpdater = da::BehaviorPtr(new PlayerUpdater(GetView(), GetInput()));
    GetManager().addBehavior(playerUpdater);
    GetManager().addBehavior(velocitiesUpdater);
    GetManager().addBehavior(walker);
    GetManager().addBehavior(poseUpdater);
    GetManager().addBehavior(xformHistorian);

    // Add spatial
    GetRenderer().registerSpatial<SpriteSpatial>();

    // Create entity
    entity = GetManager().create();
    entity->addAttribute(new da::Transform);
    entity->addAttribute(new da::Depth);

    da::TexturePtr texture = GetContent().load<sf::Texture>("mans.png");
    entity->addAttribute(new Sprite(texture));
    entity->addAttribute(new TransformHistory);
    entity->addAttribute(new Collider);
    entity->addAttribute(new Velocities);

    Poses *poses = new Poses;

    Pose pose(6);
    for (unsigned int j = 0; j < DirectionCount; j++) {
        for (unsigned int i = 0; i < pose.getFrameCount(); i++) {
            Pose::Frame frame = {
                sf::IntRect(i * 16, j * 24, 16, 24),
                sf::Vector2f(8, 20)
            };

            pose.setFrame((CardinalDirection)j, i, frame);
        }
    }
    poses->addPose("walk", pose);

    poses->isLoop = true;
    poses->timePerFrame = sf::seconds(0.25f);
    poses->setPose("walk", 0);
    entity->addAttribute(poses);

    Player *player = new Player;
    player->walkSpeed = 100.f;
    player->viewDistance = 40.f;
    entity->addAttribute(player);

    GetManager().refresh(entity);

    Run(update, emptyHandler, draw);
}
Пример #22
0
BOOL CALLBACK AboutBoxWndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
    {
    static HWND hAbout ;
    char cTmp  [255] ;

    switch (iMsg)
        {
        case WM_INITDIALOG :
            if (! STATE_EnterDialogBox ())
                {
                EndDialog (hwnd, FALSE) ;
                return FALSE ;
                }

            hAbout = GetDlgItem (hwnd, IDD_ABOUT_VERSION) ;

#ifndef KICS
            sprintf (cTmp, "%s %s", THIEF_VER, THIEF_NICK) ;
#endif

#ifdef KICS
            sprintf (cTmp, "%s %s", THIEF_VER, THIEF_KICS_NICK) ;
#endif
			if (LUDENS)
				{
				strncat(cTmp,THIEF_NICK_LUDENS,strlen(THIEF_NICK_LUDENS));
				}

            SetWindowText (hAbout, cTmp) ;

            TOOLBOX_CenterWindow (hwnd, GetWindow (hwnd, GW_OWNER)) ;
            return TRUE ;

        case WM_COMMAND:
            switch (LOWORD (wParam))
                {
                case IDOK :
                case IDCANCEL :
						EndDialog (hwnd, TRUE) ;
						STATE_LeaveDialogBox () ;
						return TRUE ;
				case IDD_CREDITS :
						strcpy(cTmp,TOOLBOX_GetInstDirPath ());
						strcat(cTmp,"\\credits.txt");
						TOOLBOX_OpenNotePad (cTmp);
						break ;
				case IDD_THANKS :
						strcpy(cTmp,TOOLBOX_GetInstDirPath ());
						strcat(cTmp,"\\thanks.txt");
						TOOLBOX_OpenNotePad (cTmp);
						break ;
				case IDD_CHANGES :
						strcpy(cTmp,TOOLBOX_GetInstDirPath ());
						strcat(cTmp,"\\changes.txt");
						TOOLBOX_OpenNotePad (cTmp);
						break ;
				case IDD_LGPL :
						strcpy(cTmp,TOOLBOX_GetInstDirPath ());
						strcat(cTmp,"\\LGPL.txt");
						TOOLBOX_OpenNotePad (cTmp);
						break ;
                }
            break ;
        }
    return FALSE ;
    }
Пример #23
0
 PixelSize GetMinimumSize() const override {
   return GetWindow().GetSize();
 }
Пример #24
0
BOOL CALLBACK ControlKeyBoxWndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
    {
    static int nSel ;
    static HWND hFunction ;
    static int nKey [MAX_CONTROL_KEY] ;

    int nI, nJ, nF ;
    char c, cTmp [2048] ;

    switch (iMsg)
        {
        case WM_INITDIALOG :
            if (! STATE_EnterDialogBox ())
                {
                EndDialog (hwnd, FALSE) ;
                return FALSE ;
                }

            hFunction = GetDlgItem (hwnd, IDD_CONTROL_FUNCTION) ;

            for (nI = 0 ; nI < MAX_CONTROL_KEY ; nI++)
                {
                NewC_Type [nI] = ControlKey.nType [nI] ;

                if ((NewC_Type [nI] < 0) || (NewC_Type [nI] >= MAX_FMENU))
                    {
                    NewC_Type [nI] = FUNCTION_NONE ;
                    }

                if (TOOLBOX_NeedCommandValue (NewC_Type [nI]))
                    {
                    strcpy (NewC_FKey [nI], ControlKey.cFKey [nI]) ;
                    }
                else
                    {
                    strcpy (NewC_FKey [nI], "") ;
                    }
                }

            nJ = 0 ;

            SendDlgItemMessage (hwnd, IDD_CONTROL_LIST, LB_RESETCONTENT, 0, 0) ;
            for (nI = 0 ; nI < MAX_CONTROL_KEY ; nI++)
                {
                if (nI < 26)
                    {
                    c = (char) (nI + 'a') ;
                    if ((c == 'a') || (c == 'c') || (c == 'v') || (c == 'x'))
                        {
                        nKey [nI] = -1 ;
                        }
                    else
                        {
                        nKey [nJ] = nI ;
                        sprintf (cTmp, "%02d. Control %c", nJ + 1, (char) (nI + 'A')) ;
                        SendDlgItemMessage (hwnd, IDD_CONTROL_LIST, LB_ADDSTRING, 0, (LPARAM) cTmp) ;
                        nJ = nJ + 1 ;
                        }
                    }
                else
                    {
                    nKey [nJ] = nI ;
                    sprintf (cTmp, "%02d. Control %c", nJ + 1, (char) ((nI - 26) + '0')) ;
                    SendDlgItemMessage (hwnd, IDD_CONTROL_LIST, LB_ADDSTRING, 0, (LPARAM) cTmp) ;
                    nJ = nJ + 1 ;
                    }
                }
            SendDlgItemMessage (hwnd, IDD_CONTROL_LIST, LB_SETCURSEL, 0, 0) ;

            SendMessage (hFunction, CB_RESETCONTENT, 0, 0) ;
            for (nI = 0 ; nI < MAX_FMENU ; nI++)
                {
                strcpy (cTmp, FString [nI]) ;
                SendMessage (hFunction, CB_ADDSTRING, 0, (LPARAM) cTmp) ;
                }

            nSel = nKey [0] ;

            strcpy (cTmp, FString [NewC_Type [nSel]]) ;
            if (SendMessage (hFunction, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) cTmp) == CB_ERR)
                {
                SendMessage (hFunction, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0) ;
                SendMessage (hFunction, WM_SETTEXT, (WPARAM) 0, (LPARAM) cTmp) ;
                }

            SendDlgItemMessage (hwnd, IDD_CONTROL_COMMAND, WM_SETTEXT, 0, (LPARAM) NewC_FKey [nSel]) ;

            EnableWindow (GetDlgItem (hwnd, IDD_CONTROL_COMMAND), TOOLBOX_NeedCommandValue (NewC_Type [nSel])) ;
            
            TOOLBOX_CenterWindow (hwnd, GetWindow (hwnd, GW_OWNER)) ;
            return TRUE ;

        case WM_COMMAND:
            switch (LOWORD (wParam))
                {
                case IDD_CONTROL_LIST :
                    if (HIWORD (wParam) == LBN_SELCHANGE)
                        {
                        nJ = SendDlgItemMessage (hwnd, IDD_CONTROL_LIST, LB_GETCURSEL, 0, 0) ;
                        nI = nKey [nJ] ;

                        nF = SendMessage (hFunction, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0) ;
                        if (nF == CB_ERR)
                            {
                            NewC_Type [nSel] = FUNCTION_NONE ;
                            }
                        else
                            {
                            NewC_Type [nSel] = nF ;
                            }

                        if (TOOLBOX_NeedCommandValue (NewC_Type [nSel]))
                            {
                            SendDlgItemMessage (hwnd, IDD_CONTROL_COMMAND, WM_GETTEXT, (WPARAM) MAX_CONTROL_KEY_SIZE - 1, (LPARAM) cTmp) ;
                            strcpy (NewC_FKey [nSel], cTmp) ;
                            }
                        else
                            {
                            strcpy (NewC_FKey [nSel], "") ;
                            }

                        strcpy (cTmp, FString [NewC_Type [nI]]) ;
                        if (SendMessage (hFunction, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) cTmp) == CB_ERR)
                            {
                            SendMessage (hFunction, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0) ;
                            SendMessage (hFunction, WM_SETTEXT, (WPARAM) 0, (LPARAM) cTmp) ;
                            }

                        SendDlgItemMessage (hwnd, IDD_CONTROL_COMMAND, WM_SETTEXT, 0, (LPARAM) NewC_FKey [nI]) ;

                        nSel = nI ;
                        EnableWindow (GetDlgItem (hwnd, IDD_CONTROL_COMMAND), TOOLBOX_NeedCommandValue (NewC_Type [nSel])) ;
                        }
                    break ;

                case IDD_CONTROL_FUNCTION :
                    if (HIWORD (wParam) == CBN_SELCHANGE)
                        {
                        nF = SendMessage (hFunction, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0) ;
                        if (nF == CB_ERR)
                            {
                            EnableWindow (GetDlgItem (hwnd, IDD_CONTROL_COMMAND), 0) ;
                            }
                        else
                            {
                            EnableWindow (GetDlgItem (hwnd, IDD_CONTROL_COMMAND), TOOLBOX_NeedCommandValue (nF)) ;
                            }
                        }
                    break ;

                case IDOK :
                    nF = SendMessage (hFunction, CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0) ;
                    if (nF == CB_ERR)
                        {
                        NewC_Type [nSel] = FUNCTION_NONE ;
                        }
                    else
                        {
                        NewC_Type [nSel] = nF ;
                        }

                    if (TOOLBOX_NeedCommandValue (NewC_Type [nSel]))
                        {
                        SendDlgItemMessage (hwnd, IDD_CONTROL_COMMAND, WM_GETTEXT, (WPARAM) MAX_CONTROL_KEY_SIZE - 1, (LPARAM) cTmp) ;
                        strcpy (NewC_FKey [nSel], cTmp) ;
                        }
                    else
                        {
                        strcpy (NewC_FKey [nSel], "") ;
                        }

                    for (nI = 0 ; nI < MAX_CONTROL_KEY ; nI++)
                        {
                        ControlKey.nType [nI] = NewC_Type [nI] ;
                        strcpy (ControlKey.cFKey [nI], NewC_FKey [nI]) ;
                        TOOLBOX_AllTrim (ControlKey.cFKey [nI]) ;

                        if (! TOOLBOX_NeedCommandValue (ControlKey.nType [nI]))
                            {
                            strcpy (ControlKey.cFKey [nI], "") ;
                            }
                        }

                    CONTROLKEY_Adjust () ;
                    EndDialog (hwnd, TRUE) ;
                    STATE_LeaveDialogBox () ;
                    return TRUE ;

                case IDCANCEL :
                    EndDialog (hwnd, FALSE) ;
                    STATE_LeaveDialogBox () ;
                    return TRUE ;

                case IDD_CONTROL_DEFAULT :
                    for (nI = 0 ; nI < MAX_CONTROL_KEY ; nI++)
                        {
                        NewC_Type [nI] = FUNCTION_NONE ;
                        strcpy (NewC_FKey [nI], "") ;
                        }

                    // set CTRL T as maximize telnet console
                    NewC_Type [(int) ('T' - 'A')] = FUNCTION_MAXIMIZE_TELNET ;

                    // set CTRL B as restore telnet console
                    NewC_Type [(int) ('B' - 'A')] = FUNCTION_RESTORE_TELNET ;

                    // set CTRL N as reset board
                    NewC_Type [(int) ('N' - 'A')] = FUNCTION_RESET_BOARD ;

                    // set CTRL F as flip board
                    NewC_Type [(int) ('F' - 'A')] = FUNCTION_FLIP_BOARD ;

                    nJ = SendDlgItemMessage (hwnd, IDD_CONTROL_LIST, LB_GETCURSEL, 0, 0) ;
                    nI = nKey [nJ] ;

                    strcpy (cTmp, FString [NewC_Type [nI]]) ;
                    if (SendMessage (hFunction, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) cTmp) == CB_ERR)
                        {
                        SendMessage (hFunction, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0) ;
                        SendMessage (hFunction, WM_SETTEXT, (WPARAM) 0, (LPARAM) cTmp) ;
                        }

                    SendDlgItemMessage (hwnd, IDD_CONTROL_COMMAND, WM_SETTEXT, 0, (LPARAM) NewC_FKey [nI]) ;

                    nSel = nI ;
                    EnableWindow (GetDlgItem (hwnd, IDD_CONTROL_COMMAND), TOOLBOX_NeedCommandValue (NewC_Type [nSel])) ;
                    return TRUE ;

                case IDD_CONTROL_DEFAULT1 :
                    for (nI = 27 ; nI <= 34 ; nI++)
                        {
                        NewC_Type [nI] = FUNCTION_NONE ;
                        strcpy (NewC_FKey [nI], "") ;
                        }

                    // set CTRL 1 to 8 to restore layout #1 to #8
                    NewC_Type [27] = FUNCTION_RESTORE_LAYOUT1 ;
                    NewC_Type [28] = FUNCTION_RESTORE_LAYOUT2 ;
                    NewC_Type [29] = FUNCTION_RESTORE_LAYOUT3 ;
                    NewC_Type [30] = FUNCTION_RESTORE_LAYOUT4 ;
                    NewC_Type [31] = FUNCTION_RESTORE_LAYOUT5 ;
                    NewC_Type [32] = FUNCTION_RESTORE_LAYOUT6 ;
                    NewC_Type [33] = FUNCTION_RESTORE_LAYOUT7 ;
                    NewC_Type [34] = FUNCTION_RESTORE_LAYOUT8 ;

                    nJ = SendDlgItemMessage (hwnd, IDD_CONTROL_LIST, LB_GETCURSEL, 0, 0) ;
                    nI = nKey [nJ] ;

                    strcpy (cTmp, FString [NewC_Type [nI]]) ;
                    if (SendMessage (hFunction, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) cTmp) == CB_ERR)
                        {
                        SendMessage (hFunction, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0) ;
                        SendMessage (hFunction, WM_SETTEXT, (WPARAM) 0, (LPARAM) cTmp) ;
                        }

                    SendDlgItemMessage (hwnd, IDD_CONTROL_COMMAND, WM_SETTEXT, 0, (LPARAM) NewC_FKey [nI]) ;

                    nSel = nI ;
                    EnableWindow (GetDlgItem (hwnd, IDD_CONTROL_COMMAND), TOOLBOX_NeedCommandValue (NewC_Type [nSel])) ;
                    return TRUE ;
                }
            break ;
        }
    return FALSE ;
    }
Пример #25
0
    bool OnButtonBack()
    {
        GetWindow()->TurnOffOverlayFlags(ofTeleportPane);

        return true;
    }
Пример #26
0
void COXCustomizeShortkeysPage::OnInitDialog()
{
	// must call default implementation
	COXCustomizePage::OnInitDialog();

	// add here initialization code for your demo dialog. Treat it as a
	// normal CDialog::OnInitDialog function

	// separators
	COLORREF clr=::GetSysColor(COLOR_WINDOW);
	m_sepShortkeys.SetTextColor(clr);
	m_sepDescription.SetTextColor(clr);
	m_sepConflict.SetTextColor(clr);
	m_sepCommands.SetTextColor(clr);

	// populate tree
	GetVars();

	// populate table of accelerator contexts
	COXArrAccelTables* pAccelTables=m_shortkeysOrganizer.GetAccelTables();
	ASSERT(pAccelTables!=NULL);
	if(pAccelTables->GetSize()==0)
	{
		// there is no accelerator tables defined for this application
		// as aresult all controls on this dialog must be disabled
		CWnd* pWndChild=GetWindow(GW_CHILD);
		while(pWndChild!=NULL)
		{
			pWndChild->EnableWindow(FALSE);
			pWndChild=pWndChild->GetNextWindow();
		}
		m_bReadOnly=TRUE;
	}
	else
	{
		for(int nIndex=0; nIndex<pAccelTables->GetSize(); nIndex++)
		{
			CString sText=OXDEFAULTACCEL;
			if(pAccelTables->GetAt(nIndex).m_docTemplate!=NULL)
			{
				pAccelTables->GetAt(nIndex).m_docTemplate->
					GetDocString(sText,CDocTemplate::docName);
			}
			m_comboTable.AddString(sText);
		}
	}

	m_nAccelTableIndex=0;

	// layout
	//
	m_LayoutManager.TieChild(&m_treeCommands,OX_LMS_ANY,OX_LMT_SAME);
	m_LayoutManager.TieChild(&m_sepCommands,
		OX_LMS_LEFT|OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(&m_sepDescription,
		OX_LMS_LEFT|OX_LMS_RIGHT|OX_LMS_BOTTOM,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_STATIC_DESCRIPTION,
		OX_LMS_LEFT|OX_LMS_RIGHT|OX_LMS_BOTTOM,OX_LMT_SAME);

	m_LayoutManager.TieChild(IDC_OX_SEPARATOR_SHORTKEYS,OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_STATIC_FOR,OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_COMBO_TABLE,OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_STATIC_CURRENT_KEYS,OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_LIST_SHORTKEYS,
		OX_LMS_RIGHT|OX_LMS_BOTTOM|OX_LMS_TOP,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_BUTTON_ASSIGN,OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_BUTTON_REMOVE,OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_BUTTON_REMOVE_ALL,OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_BUTTON_RESET_ALL,OX_LMS_RIGHT,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_STATIC_NEW_KEY,
		OX_LMS_RIGHT|OX_LMS_BOTTOM,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_HOTKEY_SHORTKEY,
		OX_LMS_RIGHT|OX_LMS_BOTTOM,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_SEPARATOR_CONFLICTS,
		OX_LMS_RIGHT|OX_LMS_BOTTOM,OX_LMT_SAME);
	m_LayoutManager.TieChild(IDC_OX_STATIC_ASSIGNED_TO,
		OX_LMS_RIGHT|OX_LMS_BOTTOM,OX_LMT_SAME);
	//
	///////////////////////////////////////

	UpdateData(FALSE);
	GetShortkeys();
	ShowVars();

	m_bInitialized=TRUE;
}
Пример #27
0
 //------------------------------------------------------------------------------
 void        SwapWeaponAction::Execute (void)
 {
     GetWindow ()->SwapPart(m_equipmentType, m_mount);
 }
Пример #28
0
 // fill task bar with buttons for enumerated top level windows
BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam)
{
	TaskBar* pThis = (TaskBar*)lparam;

	DWORD style = GetWindowStyle(hwnd);
	DWORD ex_style = GetWindowExStyle(hwnd);

	if ((style&WS_VISIBLE) && !(ex_style&WS_EX_TOOLWINDOW) &&
		!GetParent(hwnd) && !GetWindow(hwnd,GW_OWNER)) {
		TCHAR title[BUFFER_LEN];

		if (!GetWindowText(hwnd, title, BUFFER_LEN))
			title[0] = '\0';

		TaskBarMap::iterator found = pThis->_map.find(hwnd);
		int last_id = 0;

		if (found != pThis->_map.end()) {
			last_id = found->second._id;

			if (!last_id)
				found->second._id = pThis->_next_id++;
		} else {
			HBITMAP hbmp;
			HICON hIcon = get_window_icon_small(hwnd);
			BOOL delete_icon = FALSE;

			if (!hIcon) {
				hIcon = LoadIcon(0, IDI_APPLICATION);
				delete_icon = TRUE;
			}

			if (hIcon) {
				hbmp = create_bitmap_from_icon(hIcon, GetSysColorBrush(COLOR_BTNFACE), WindowCanvas(pThis->_htoolbar));
				if (delete_icon)
					DestroyIcon(hIcon); // some icons can be freed, some not - so ignore any error return of DestroyIcon()
			} else
				hbmp = 0;

			TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
			int bmp_idx = SendMessage(pThis->_htoolbar, TB_ADDBITMAP, 1, (LPARAM)&ab);

			TaskBarEntry entry;

			entry._id = pThis->_next_id++;
			entry._hbmp = hbmp;
			entry._bmp_idx = bmp_idx;
			entry._title = title;

			pThis->_map[hwnd] = entry;
			found = pThis->_map.find(hwnd);
		}

		TBBUTTON btn = {-2/*I_IMAGENONE*/, 0, TBSTATE_ENABLED/*|TBSTATE_ELLIPSES*/, BTNS_BUTTON, {0, 0}, 0, 0};
		TaskBarEntry& entry = found->second;

		++entry._used;
		btn.idCommand = entry._id;

		HWND foreground = GetForegroundWindow();
		HWND foreground_owner = GetWindow(foreground, GW_OWNER);

		if (hwnd==foreground || hwnd==foreground_owner) {
			btn.fsState |= TBSTATE_PRESSED|TBSTATE_CHECKED;
			pThis->_last_foreground_wnd = hwnd;
		}

		if (!last_id) {
			 // create new toolbar buttons for new windows
			if (title[0])
				btn.iString = (INT_PTR)title;

			btn.iBitmap = entry._bmp_idx;
			entry._btn_idx = SendMessage(pThis->_htoolbar, TB_BUTTONCOUNT, 0, 0);

			SendMessage(pThis->_htoolbar, TB_INSERTBUTTON, entry._btn_idx, (LPARAM)&btn);

			pThis->ResizeButtons();
		} else {
			 // refresh attributes of existing buttons
			if (btn.fsState != entry._fsState)
				SendMessage(pThis->_htoolbar, TB_SETSTATE, entry._id, MAKELONG(btn.fsState,0));

			if (entry._title != title) {
				TBBUTTONINFO info;

				info.cbSize = sizeof(TBBUTTONINFO);
				info.dwMask = TBIF_TEXT;
				info.pszText = title;

				SendMessage(pThis->_htoolbar, TB_SETBUTTONINFO, entry._id, (LPARAM)&info);

				entry._title = title;
			}
		}

		entry._fsState = btn.fsState;

#ifdef __REACTOS__	// now handled by activating the ARW_HIDE flag with SystemParametersInfo(SPI_SETMINIMIZEDMETRICS)
		 // move minimized windows out of sight
		if (IsIconic(hwnd)) {
			RECT rect;

			GetWindowRect(hwnd, &rect);

			if (rect.bottom > 0)
				SetWindowPos(hwnd, 0, -32000, -32000, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
		}
#endif
	}

	return TRUE;
}
Пример #29
0
/**
 * Tries to switch to the main window of the VM process.
 *
 * @return true if successfully switched and false otherwise.
 */
bool UIVMItem::switchTo()
{
#ifdef Q_WS_MAC
    ULONG64 id = m_machine.ShowConsoleWindow();
#else
    WId id = (WId) m_machine.ShowConsoleWindow();
#endif
    AssertWrapperOk(m_machine);
    if (!m_machine.isOk())
        return false;

    /* winId = 0 it means the console window has already done everything
     * necessary to implement the "show window" semantics. */
    if (id == 0)
        return true;

#if defined (Q_WS_WIN32) || defined (Q_WS_X11)

    return vboxGlobal().activateWindow(id, true);

#elif defined (Q_WS_MAC)
    /*
     * This is just for the case were the other process cannot steal
     * the focus from us. It will send us a PSN so we can try.
     */
    ProcessSerialNumber psn;
    psn.highLongOfPSN = id >> 32;
    psn.lowLongOfPSN = (UInt32)id;
    OSErr rc = ::SetFrontProcess(&psn);
    if (!rc)
        Log(("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
    else
        Log(("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));
    return !rc;

#endif

    return false;

    /// @todo Below is the old method of switching to the console window
    //  based on the process ID of the console process. It should go away
    //  after the new (callback-based) method is fully tested.
#if 0

    if (!canSwitchTo())
        return false;

#if defined (Q_WS_WIN32)

    HWND hwnd = mWinId;

    /* if there are blockers (modal and modeless dialogs, etc), find the
     * topmost one */
    HWND hwndAbove = NULL;
    do
    {
        hwndAbove = GetNextWindow(hwnd, GW_HWNDPREV);
        HWND hwndOwner;
        if (hwndAbove != NULL &&
            ((hwndOwner = GetWindow(hwndAbove, GW_OWNER)) == hwnd ||
             hwndOwner  == hwndAbove))
            hwnd = hwndAbove;
        else
            break;
    }
    while (1);

    /* first, check that the primary window is visible */
    if (IsIconic(mWinId))
        ShowWindow(mWinId, SW_RESTORE);
    else if (!IsWindowVisible(mWinId))
        ShowWindow(mWinId, SW_SHOW);

#if 0
    LogFlowFunc(("mWinId=%08X hwnd=%08X\n", mWinId, hwnd));
#endif

    /* then, activate the topmost in the group */
    AllowSetForegroundWindow(m_pid);
    SetForegroundWindow(hwnd);

    return true;

#elif defined (Q_WS_X11)

    return false;

#elif defined (Q_WS_MAC)

    ProcessSerialNumber psn;
    OSStatus rc = ::GetProcessForPID(m_pid, &psn);
    if (!rc)
    {
        rc = ::SetFrontProcess(&psn);

        if (!rc)
        {
            ShowHideProcess(&psn, true);
            return true;
        }
    }
    return false;

#else

    return false;

#endif

#endif
}
Пример #30
0
void CDialogTrustDB::OnOK()
    {
    OnApplyNow();
    ::EndDialog(GetWindow(), IDOK);
    }