Exemple #1
0
/*******************************************************************************
  Function Name  : OnSize
  Input(s)       : nType - Sizing mode
                   cx - New X value
                   cy - New Y Value
  Output         : -
  Functionality  : This function will be called by the framework during sizing
                   of the window. This function will set the buttons position at
                   the center of the dialog
  Member of      : CTxFunctionsView
  Author(s)      : Raja N
  Date Created   : 26.4.2005
  Modifications  :
*******************************************************************************/
void CTxFunctionsView::OnSize(UINT nType, int cx, int cy)
{
    CFormView::OnSize(nType, cx, cy);
    const double dOffset = 0.75;
    // Get Update Window pointer
    CWnd* pWnd = GetDlgItem( IDC_BTN_UPDATE );
    // If valid
    if( pWnd != NULL )
    {
        CRect omRect;
        // Move the button to center postion
        pWnd->CenterWindow();
        // Now move away from the center
        pWnd->GetWindowRect( &omRect );
        ScreenToClient(&omRect);
        double nWidth = omRect.Width();
        // Shift 75 % of width of the button away from the center
        nWidth *= dOffset;
        omRect.left -= (LONG)nWidth;
        omRect.right -= (LONG)nWidth;
        // Move the window to the new location
        pWnd->MoveWindow(&omRect);
    }

    // Get Close Window pointer
    pWnd = GetDlgItem( IDC_BTN_CLOSE );
    // If valid
    if( pWnd != NULL )
    {
        CRect omRect;
        // Move the button to center postion
        pWnd->CenterWindow();
        // Now move away from the center
        pWnd->GetWindowRect( &omRect );
        ScreenToClient(&omRect);
        double nWidth = omRect.Width();
        // Shift 75 % of width of the button away from the center
        nWidth *= dOffset;
        omRect.left += (LONG)nWidth;
        omRect.right += (LONG)nWidth;
        // Move the window to the new location
        pWnd->MoveWindow(&omRect);
    }
}
Exemple #2
0
//bi.pidRoots was set,only dir and subdir can appear in the dialog.//ParsePidlFromPath convet path to pidroot
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
    if (uMsg==BFFM_INITIALIZED) {
        CWnd *pDlg = CWnd::FromHandle(hwnd);
        pDlg->CenterWindow(CWnd::FromHandle(GetDesktopWindow()));
        pDlg->SetForegroundWindow();
        CString strInitialDir;
        strInitialDir = (LPTSTR)lpData;
        if (!strInitialDir.IsEmpty()) {
            ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData);
        }
    }
    return 0;
}
int CKSFileDialog::DoModal()
{
	ASSERT_VALID(this);
	DWORD nOffset = lstrlen(m_ofn.lpstrFile)+1;
	memset(m_ofn.lpstrFile+nOffset, 0, (m_ofn.nMaxFile-nOffset)*sizeof(TCHAR));

	HWND hWndFocus = ::GetFocus();
	BOOL bEnableParent = FALSE;
	//m_ofn.hwndOwner = PreModal();
	
	CWnd dummy;
	dummy.CreateEx(NULL,AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),NULL,NULL,CRect(0,0,0,0),NULL,NULL);
	dummy.CenterWindow();
	CRect rect;
	dummy.GetWindowRect(rect);
	dummy.SetWindowPos(NULL, rect.left-230, rect.top-180, -1, -1,
		SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);	dummy.ShowWindow(SW_HIDE);
	m_ofn.hwndOwner=dummy.GetSafeHwnd();
	if (m_ofn.hwndOwner==NULL) m_ofn.hwndOwner=PreModal();
	if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner))
	{
		bEnableParent = TRUE;
		::EnableWindow(m_ofn.hwndOwner, FALSE);
	}

	_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
	ASSERT(pThreadState->m_pAlternateWndInit == NULL);

	m_ofn.lpfnHook = NULL;
	m_ofn.lpTemplateName = NULL;
	int nResult;
	if (m_bOpenFileDialog)
		nResult = ::GetOpenFileName(&m_ofn);
	else
		nResult = ::GetSaveFileName(&m_ofn);

	if (nResult)
		ASSERT(pThreadState->m_pAlternateWndInit == NULL);
	pThreadState->m_pAlternateWndInit = NULL;

	// WINBUG: Second part of special case for file open/save dialog.
	if (bEnableParent)
		::EnableWindow(m_ofn.hwndOwner, TRUE);
	if (::IsWindow(hWndFocus))
		::SetFocus(hWndFocus);

	PostModal();
	return nResult ? nResult : IDCANCEL;
}
Exemple #4
0
/*
**  Name: LocSelHookProc
**
**  Description:
**      Hook Procedure for GetFileNameOpen() common dialog box
*/
static UINT CALLBACK 
LocSelHookProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam)
{
    BOOL	rc;
    CWnd	Parent;

    rc=TRUE;
    switch (messg)
    {
	case WM_INITDIALOG:          /* Set Default Values for Entry Fields */
	    Parent.Attach(::GetParent(hDlg));
	    Parent.CenterWindow();
	    Parent.Detach();
	    CommDlg_OpenSave_SetControlText(::GetParent(hDlg), IDOK, "OK");
	    rc=TRUE;
	    break;

	default:
	    rc=FALSE;
	    break;
    }
    return rc;
}
BOOL CThetaGridAdjustmentSimpleOutputDlg::OnInitDialog() 
{
	int i;
	CString T;
	BOOL b;
	CWnd* pWnd;
	CDC* pDC;

	pWnd=this;
	pWnd->CenterWindow();
	if (m_nType==1) pWnd->SetWindowTextW(L"Simple Output - Event's Arguments"); //if dealing with the event's arguments
	else if (m_nType==2) pWnd->SetWindowTextW(L"Simple Output - Complement Clause"); //if dealing with the event's complement clause
	CDialog::OnInitDialog();
	m_bSubjectRaised=FALSE;
	m_strTargetFontName=m_pDoc->GetTargetLanguageFontName(); //used in ChangeFont
	if (HFONT(m_fontTarget)==NULL)        //first time this modeless dialog activated
	{
		//create the fonts that will be used in the combo boxes
		pWnd=&m_datatblInput;
		pDC=pWnd->GetDC();	                    //get a pointer to the device context
		T=m_pDoc->GetSourceLanguageFontName(4);
		b=m_fontArial.CreatePointFont(90,L"Arial",pDC);
		if (b==FALSE) AfxMessageBox(L"Unable to create Arial font.",MB_OK);
		i=m_pDoc->GetTargetLanguageFontSize();
		b=m_fontTarget.CreatePointFont(10*i,m_strTargetFontName,pDC);
		if (b==FALSE) AfxMessageBox(L"Unable to create Target font.",MB_OK);
	}
	SetupTable();
	if (m_nType==2)        //if specifying features for object complement clause
	{
		pWnd=GetDlgItem(IDC_BUTTONFEATURESET);
		pWnd->MoveWindow(12,68,75,22);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CBCGPFileDialog::OnInitDone()
{
	const int iBorderWidth = 20;
	const int iBorderHeight = 40;

	CWnd* pFD = GetParent();
	ASSERT (pFD != NULL);

	CRect rectClient;
	pFD->GetClientRect (rectClient);

	int nNewDlgWidth = rectClient.Width () + iBorderWidth * 2 + m_iExtraWidth;

	if (m_pBmpLogo != NULL)
	{
		BITMAP bmp;
		m_pBmpLogo->GetBitmap (&bmp);

		m_rectLogo = CRect (CPoint (max (0, (nNewDlgWidth - bmp.bmWidth) / 2), 8),
							CSize (bmp.bmWidth, bmp.bmHeight));
		m_iLogoAreaHeight = bmp.bmHeight + 20;
	}

	//---------------------------
	// Adjust parent window size:
	//---------------------------
	pFD->ModifyStyle (WS_THICKFRAME, WS_DLGFRAME | WS_BORDER);
	pFD->ModifyStyleEx (WS_EX_WINDOWEDGE, 0);
	pFD->SetWindowPos (NULL, -1, -1, nNewDlgWidth,
					rectClient.Height () + iBorderHeight * 2 + m_iLogoAreaHeight + m_iExtraHeight,
					SWP_NOMOVE | SWP_NOZORDER  | SWP_NOACTIVATE);

	//-------------------
	// Move all controls:
	//-------------------
	CWnd* pWndChild = pFD->GetWindow (GW_CHILD);
	while (pWndChild != NULL)
	{
		CRect rectCtl;
		pWndChild->GetClientRect (rectCtl);
		pWndChild->MapWindowPoints (pFD, rectCtl);
		pWndChild->SetWindowPos (NULL, 
			rectCtl.left + iBorderWidth, 
			rectCtl.top + iBorderHeight + m_iLogoAreaHeight,
			rectCtl.Width (), rectCtl.Height (), 
			SWP_NOZORDER | SWP_NOACTIVATE);

		pWndChild = pWndChild->GetNextWindow ();
	}

	//------------------------------------------
	// Create new and recent file list controls:
	//------------------------------------------
	CRect rectList (0, 0, 0, 0);
	m_wndNewList.Create (WS_VISIBLE | WS_BORDER | WS_TABSTOP | WS_CHILD | LVS_ICON | LVS_AUTOARRANGE | LVS_SINGLESEL, 
							rectList, pFD, iNewListCtrlId);
	m_wndNewList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	if (m_pImagesNew != NULL)
	{
		m_wndNewList.SetImageList (m_pImagesNew, LVSIL_NORMAL);
	}

	int i = 0;
	for (POSITION pos = m_lstNewItems.GetHeadPosition (); pos != NULL; i ++)
	{
		CNewItemInfo* pInfo = (CNewItemInfo*) m_lstNewItems.GetNext (pos);
		ASSERT_VALID (pInfo);

		m_wndNewList.InsertItem (i, pInfo->m_strName, pInfo->m_iIconIndex);
	}

	m_wndRecentList.Create (WS_TABSTOP | WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT, 
							rectList, pFD, iRecentListCtrlId);
	m_wndRecentList.ModifyStyleEx (0, WS_EX_CLIENTEDGE);

	m_ImagesRecent.Create (	globalData.m_sizeSmallIcon.cx,
							globalData.m_sizeSmallIcon.cy,
							ILC_COLOR, 0, 10);
	m_wndRecentList.SetImageList (&m_ImagesRecent, LVSIL_SMALL);

	{
		CBCGPLocalResource locaRes;

		CString strFile;
		strFile.LoadString (IDS_BCGBARRES_FILE);
		m_wndRecentList.InsertColumn (0, strFile, LVCFMT_LEFT, 100);

		CString strFolder;
		strFolder.LoadString (IDS_BCGBARRES_FOLDER);
		m_wndRecentList.InsertColumn (1, strFolder);
	}

	CRecentFileList* pMRUFiles = 
		((CBCGApp*) AfxGetApp ())->m_pRecentFileList;

	if (pMRUFiles != NULL)
	{
		TCHAR szCurDir [_MAX_PATH + 1];
		::GetCurrentDirectory (_MAX_PATH, szCurDir);

		int nCurDir = lstrlen (szCurDir);
		ASSERT (nCurDir >= 0);

		szCurDir [nCurDir] = _T('\\');
		szCurDir [++ nCurDir] = _T('\0');

		//---------------
		// Add MRU files:
		//---------------
		int iNumOfFiles = 0;	// Actual added to menu
		for (int i = 0; i < pMRUFiles->GetSize (); i ++)
		{
			CString strFile = (*pMRUFiles) [i];
			if (!strFile.IsEmpty ())
			{
				CString strPath;
				CString strName;
				int iImage = -1;

				int iIndex = strFile.ReverseFind (_T('\\'));
				if (iIndex != -1)
				{
					strPath = strFile.Left (iIndex);
					strName = strFile.Mid (iIndex + 1);
				}
				else
				{
					strName = strFile;
				}

				SHFILEINFO  sfi;
				HIMAGELIST himlSmall = (HIMAGELIST) SHGetFileInfo (strFile,
                                       0,
                                       &sfi, 
                                       sizeof(SHFILEINFO), 
                                       SHGFI_SYSICONINDEX | SHGFI_SMALLICON);

				if (himlSmall != NULL)
				{
					CImageList* pImages = CImageList::FromHandle (himlSmall);
					ASSERT (pImages != NULL);

					HICON hIcon = pImages->ExtractIcon (sfi.iIcon);
					iImage = m_ImagesRecent.Add (hIcon);
					if (hIcon != NULL)
					{
						::DestroyIcon (hIcon);
					}
				}

				iIndex = m_wndRecentList.InsertItem (iNumOfFiles ++, strName, iImage);
				m_wndRecentList.SetItemText (iIndex, 1, strPath);

				int iPathWidth = m_wndRecentList.GetStringWidth (strPath) + 20;
				if (iPathWidth > m_wndRecentList.GetColumnWidth (1))
				{
					m_wndRecentList.SetColumnWidth (1, iPathWidth);
				}
			}
		}
	}

	//---------------------
	// Create tabs control:
	//---------------------
	CRect rectTabs;
	pFD->GetClientRect (rectTabs);
	rectTabs.DeflateRect (4, 4);
	rectTabs.top += m_iLogoAreaHeight;

	m_wndTab.Create (CBCGPTabWnd::STYLE_3D, rectTabs, pFD, iTabCtrlId, 
		CBCGPTabWnd::LOCATION_TOP);
	m_wndTab.m_pParent = this;
	m_wndTab.SetActiveTabBoldFont ();

	m_wndTab.SetFont (GetFont ());
	m_wndTab.SetOwner (this);

	m_wndDummy.Create (_T(""), WS_CHILD, CRect (0, 0, 0, 0), this);

	{
		CBCGPLocalResource locaRes;
		CString strTab;

		if (m_bNewPage)
		{
			m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_NEW_FILE, (UINT)-1, FALSE);
		}

		m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_EXISTING, (UINT)-1, FALSE);
		m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_RECENT, (UINT)-1, FALSE);
	}

	pFD->CenterWindow ();
	pFD->SetWindowText (m_strCaption);

	//------------------
	// Set dilaog icons:
	//------------------
	if (m_hIconSmall != NULL)
	{
		pFD->SetIcon (m_hIconSmall, FALSE);
	}

	if (m_hIconBig != NULL)
	{
		pFD->SetIcon (m_hIconBig, TRUE);
	}

	//--------------------------
	// Setup parent window proc:
	//--------------------------
	m_wndProc = (WNDPROC)SetWindowLongPtr(pFD->m_hWnd, GWLP_WNDPROC, 
		(LONG_PTR) CBCGPFileDialog::WindowProcNew);
}
/*******************************************************************************
  Function Name    :  OnInitDialog
  Input(s)         :    -
  Output           :    -
  Functionality    :  Called by the framework to when the dialog control is
                      initialised. The control will be initialised with last
                      used value or default value.
  Member of        :  CDriverInfoDlg
  Friend of        :      -
  Author(s)        :  Raja N
  Date Created     :  07.09.2004
  Modifications    :
*******************************************************************************/
BOOL CDriverInfoDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // Resize the dialog in USB build
    // Pointer to components
    CWnd* pomWnd = nullptr;
    // Hide Copywright message
    pomWnd = GetDlgItem(IDC_STAT_COPYRIGHT);
    if( pomWnd != nullptr )
    {
        //pomWnd->SetWindowText("USB driver from Peak Systems");
        pomWnd->ShowWindow ( SW_HIDE );
        // Invalidate
        pomWnd = nullptr;
    }
    // Store current control rect and dialog rect
    CRect omRect, omWndRect;
    // Get Dialog Size
    GetWindowRect( &omWndRect );
    // Get the Bottom line object
    pomWnd = GetDlgItem( IDC_STAT_LINE3 );
    if( pomWnd != nullptr )
    {
        // Get the position
        pomWnd->GetWindowRect(&omRect);
        omWndRect.bottom = omRect.bottom;
        // Resize the dialog upto botton line
        MoveWindow( omWndRect.left, omWndRect.top, omWndRect.Width(),
                    omWndRect.Height() );
        // Update dialog size
        GetWindowRect( &omWndRect );
        // Invalidate
        pomWnd = nullptr;
    }
    // Offset is 1/4th of dialog size
    int nOffset = omWndRect.Height() / 4;
    // Center the Version Label
    pomWnd = GetDlgItem( IDC_STAT_DRIVER_VERSION );
    if( pomWnd != nullptr )
    {
        int nWidth = 0, nHeight = 0;
        pomWnd->CenterWindow();
        pomWnd->GetWindowRect( omRect );
        ScreenToClient(omRect);

        nWidth = omRect.Width();
        nHeight = omRect.Height();
        // Move the top to First quarter
        omRect.top =  nOffset - nHeight / 2;
        // Move the window to the new position
        pomWnd->MoveWindow( omRect.left, omRect.top, nWidth, nHeight );
        pomWnd = nullptr;
    }

    // Change the position of OK Button
    pomWnd = GetDlgItem ( IDOK );
    if( pomWnd != nullptr )
    {
        // Move the button to the center of the dialog
        pomWnd->CenterWindow();
        pomWnd->GetWindowRect( omRect );
        ScreenToClient(omRect);

        int nWidth = 0, nHeight = 0;
        nWidth = omRect.Width();
        nHeight = omRect.Height();
        // Move it to the thired Quarter
        omRect.top = nOffset * 2 - nHeight / 2;
        // Move the window to its new location
        pomWnd->MoveWindow( omRect.left, omRect.top, nWidth, nHeight, TRUE );
        pomWnd = nullptr;
    }
    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}