예제 #1
0
void CTeenSpiritDlg::LoadSettings()
{
	AppSettings* params = PRGAPI()->GetAppSettings();

	WINDOWPLACEMENT pl;
	GetWindowPlacement(&pl);
	int showCmd;
	params->Read(SettingsCategory, _T("CMDSHOW"), showCmd, SW_SHOWNORMAL);
	params->Read(SettingsCategory, _T("LEFT"), (int&) pl.rcNormalPosition.left, 40);
	params->Read(SettingsCategory, _T("TOP"), (int&) pl.rcNormalPosition.top, 25);
	params->Read(SettingsCategory, _T("RIGHT"), (int&) pl.rcNormalPosition.right, 900);
	params->Read(SettingsCategory, _T("BOTTOM"), (int&) pl.rcNormalPosition.bottom, 650);
	//pl.showCmd = SW_SHOWMINIMIZED;
	pl.showCmd = showCmd;
	ModifyStyle(WS_VISIBLE, 0);
	if (showCmd == SW_SHOWMINIMIZED)
	{
		ModifyStyle(WS_VISIBLE, 0);
		SetWindowPlacement(&pl);
		PostMessage(WM_SYSCOMMAND, SC_MINIMIZE);
	}
	else if (showCmd == SW_SHOWMAXIMIZED)
	{
		SetWindowPlacement(&pl);
		ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0);
		MaximizeWindow(pl.rcNormalPosition);

	}
	else
		SetWindowPlacement(&pl);
}
/******************************************************************************
Function Name  :  SetConfigurationData
Input(s)       :  BYTE* pSrcBuffer, UINT unBuffSize
Output         :  HRESULT
Functionality  :  Returns the configuration data
Member of      :  CTSExecutorChildFrame
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  07/04/2011
Modifications  :
Code Tag       :  CS040
******************************************************************************/
HRESULT CTSExecutorChildFrame::SetConfigurationData(BYTE* pSrcBuffer, UINT unBuffSize)
{
    if(unBuffSize != 0)
    {
        vInitialise();
        WINDOWPLACEMENT wndPlacement;
        COPY_DATA_2(&wndPlacement, pSrcBuffer,sizeof(WINDOWPLACEMENT));
        SetWindowPlacement(&wndPlacement);
        INT nCxCur, nCxMin;
        COPY_DATA_2(&nCxCur, pSrcBuffer, sizeof(INT));
        COPY_DATA_2(&nCxMin, pSrcBuffer, sizeof(INT));
        m_omSplitterWnd.SetColumnInfo(0, nCxCur, nCxMin);
        m_omSplitterWnd.RecalcLayout();
        unBuffSize = unBuffSize - sizeof(WINDOWPLACEMENT) - (2*sizeof(INT));
        m_ouTSExecutor.SetConfigurationData(pSrcBuffer, unBuffSize);
        m_odTreeView->GetTreeCtrl().SetCheck(m_hParentTreeItem, m_ouTSExecutor.m_bTestSuiteStatus);
        //Parse The Tree Control;
        INT nCount;
        m_ouTSExecutor.GetTestSetupCount(nCount);

        for(int i = 0; i < nCount; i++)
        {
            bParseTestSetup(i);
        }
    }
    //New File or when Initialising
    else
    {
        vInitialise();
        SetWindowPlacement(&m_sTSDefPlacement);
    }

    return S_OK;
}
예제 #3
0
void RestoreWindowPlacements()
{
	for(auto it = WindowPlacements.begin(); it != WindowPlacements.end(); ++it)
	{
		WINDOWPLACEMENT& placement = it->second;

		// The only thing that change when a monitor is connected or disconnected is the
		// window's "normal position". Everything else remain the same (Z order,
		// maximized/minimized status, focus, etc)"

		// Since the maximized status cannot be catched with SetWinEventHook we have
		// to extract the placement again
		WINDOWPLACEMENT current;
		GetProperWindowPlacement(it->first, &current);

		// No need to restore it if it's already in its correct position
		if(!memcmp(&current, &placement, sizeof(current)))
			continue;

		if(GetWindowTextLength(it->first))
		{
			Log("%S\n", WndText(it->first));
			Log("\tRestore %s to %s\n", current.showCmd == SW_SHOWMINIMIZED ? "minimized" : (current.showCmd == SW_SHOWMAXIMIZED ? "maximized" : ""), PlacementText(placement));
		}

		if(current.showCmd == SW_SHOWMINIMIZED)
		{
			// Restore its minimized position
			placement.showCmd = SW_SHOWMINNOACTIVE;
			placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
			SetWindowPlacement(it->first, &placement);
		}
		else if(current.showCmd == SW_SHOWMAXIMIZED)
		{
			// The window was maximized

			// In order to restore the window on the correct display we have to move it to its normal position first, and then maximize it.
			// If we only maximize it (without moving it first) it will be maximized on the display it's currently on.
			// Before we maximize it we have to show it in its normal state. Otherwise it will retain its size on the new monitor which
			// will be incorrect if the new monitor has a different resolution

			// Restore
			ShowWindowAsync(it->first, SW_SHOWNOACTIVATE);
			// Move
			placement.showCmd = SW_SHOWNOACTIVATE;
			placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
			SetWindowPlacement(it->first, &placement);
			// Maximize
			ShowWindowAsync(it->first, SW_SHOWMAXIMIZED);
		}
		else
		{
			// Restore its normal position
			placement.showCmd = SW_SHOWNOACTIVATE;
			placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
			SetWindowPlacement(it->first, &placement);
		}
	}
}
예제 #4
0
void CMainFrame::ActivateFrame(int nCmdShow) 
{
	
	// TODO: Add your specialized code here and/or call the base class

	if (!m_firstShow)
	{
		
		CString myver;
		CMyCommApp * myApp = (CMyCommApp *)AfxGetApp();
		myver = AfxGetApp()->GetProfileString("Version","VER",myApp->m_AppVersion);
		if(atof(myver)>=atof(myApp->m_AppVersion))
		{
			WINDOWPLACEMENT   WndStatus;  
			CRect   rect;  
			rect.left     = AfxGetApp()->GetProfileInt("Layout","LEFT",100);  
			rect.top      = AfxGetApp()->GetProfileInt("Layout","TOP",100);  
			rect.right    = AfxGetApp()->GetProfileInt("Layout","RIGHT",800);  
			rect.bottom   = AfxGetApp()->GetProfileInt("Layout","BOTTOM",600);  
			WndStatus.rcNormalPosition   =   rect;  
			WndStatus.flags=   AfxGetApp()->GetProfileInt("Layout","FLAG",0);  
			nCmdShow   =   AfxGetApp()->GetProfileInt("Layout","SHOWCMD",SW_SHOW);  
			WndStatus.showCmd   =   nCmdShow;  
			WndStatus.ptMinPosition   =   CPoint(0,0);  
			SetWindowPlacement(&WndStatus); 
		}
		else{
			WINDOWPLACEMENT   WndStatus;  
			CRect   rect;  
			rect.left     = 100;
			rect.top      = 100;
			rect.right    = 800;
			rect.bottom   = 600;
			WndStatus.rcNormalPosition = rect;  
			WndStatus.flags=  0 ;
			WndStatus.showCmd = SW_SHOW;
			WndStatus.ptMinPosition  =  CPoint(0,0);  
			SetWindowPlacement(&WndStatus); 
		}

		//check version
		
		hThread=CreateThread(NULL,
			0,
			(LPTHREAD_START_ROUTINE)ThreadCheckVersion,
			NULL,
			0,
			&ThreadID);
		
        
		m_firstShow = TRUE;
	}
	

	CFrameWnd::ActivateFrame(nCmdShow);
}
예제 #5
0
파일: main.c 프로젝트: pravin/Win7Keys
void DoMove(int direction)
{
    // Get Desktop area
    RECT rc;
    SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
    // Get Active Window
    HWND hwnd = GetForegroundWindow();
    if (hwnd == NULL) {
        return;
    }

    // Get maximized state of window
    WINDOWPLACEMENT wnd;
    wnd.length = sizeof(WINDOWPLACEMENT);
    GetWindowPlacement(hwnd, &wnd);

    // Move it left of right
    int half_width = rc.right/2;
    switch(direction) {
    case VK_LEFT:
        if (wnd.showCmd == SW_SHOWMAXIMIZED) { // If window is maximized, restore it
            wnd.showCmd = SW_RESTORE;
            wnd.flags = WPF_ASYNCWINDOWPLACEMENT;
            wnd.rcNormalPosition.left = rc.left;
            wnd.rcNormalPosition.right = half_width;
            wnd.rcNormalPosition.top = rc.top;
            wnd.rcNormalPosition.bottom = rc.bottom;
            SetWindowPlacement(hwnd, &wnd);
        }
        else {
            MoveWindow(hwnd, rc.left, rc.top, half_width, rc.bottom, TRUE);
        }
        break;
    case VK_RIGHT:
        if (wnd.showCmd == SW_SHOWMAXIMIZED) { // If window is maximized, restore it
            wnd.showCmd = SW_RESTORE;
            wnd.flags = WPF_ASYNCWINDOWPLACEMENT;
            wnd.rcNormalPosition.left = half_width;
            wnd.rcNormalPosition.right = half_width;
            wnd.rcNormalPosition.top = rc.top;
            wnd.rcNormalPosition.bottom = rc.bottom;
            SetWindowPlacement(hwnd, &wnd);
        }
        else {
            MoveWindow(hwnd, half_width, rc.top, half_width, rc.bottom, TRUE);
        }
        break;
    case VK_UP:
        ShowWindowAsync(hwnd, SW_MAXIMIZE);
        break;
    case VK_DOWN:
        ShowWindowAsync(hwnd, SW_MINIMIZE);
        break;
    }
}
void ZLWin32ApplicationWindow::setFullscreen(bool fullscreen) {
	if (fullscreen == myFullScreen) {
		return;
	}
	myFullScreen = fullscreen;

	int style = GetWindowLong(myMainWindow, GWL_STYLE);
	static WINDOWPLACEMENT mainPlacement;
	static WINDOWPLACEMENT toolbarPlacement;
	if (myFullScreen) {
		GetWindowPlacement(myMainWindow, &mainPlacement);
		GetWindowPlacement(myRebar, &toolbarPlacement);
		SetWindowLong(myMainWindow, GWL_STYLE, style & ~WS_CAPTION);
		int cx;
		int cy;
		HDC displayDC = GetDC(0);
		if (displayDC != 0) {
			cx = GetDeviceCaps(displayDC, HORZRES);
			cy = GetDeviceCaps(displayDC, VERTRES);
			ReleaseDC(0, displayDC);
		} else {
			cx = GetSystemMetrics(SM_CXSCREEN);
			cy = GetSystemMetrics(SM_CYSCREEN);
		}
		SetWindowPos(myMainWindow, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW);
		ShowWindow(myMainWindow, SW_SHOWMAXIMIZED);
		ShowWindow(myRebar, SW_HIDE);
		createFloatingToolbar();
		if (myDockWindow != 0) {
			ShowWindow(myDockWindow, SW_SHOWDEFAULT);
			updateFullscreenToolbarSize();
		}
	} else {
		SetWindowLong(myMainWindow, GWL_STYLE, style | WS_CAPTION);
		ShowWindow(myRebar, SW_SHOWNORMAL);
		ShowWindow(myMainWindow, SW_SHOWNORMAL);
		SetWindowPlacement(myMainWindow, &mainPlacement);
		SetWindowPlacement(myRebar, &toolbarPlacement);

		RECT mainRect;
		GetClientRect(myMainWindow, &mainRect);
		RECT rebarRect;
		GetWindowRect(myRebar, &rebarRect);
		MoveWindow(myRebar, 0, 0, mainRect.right - mainRect.left, rebarRect.bottom - rebarRect.top, true);

		destroyFloatingToolbar();
	}
	refresh();
}
예제 #7
0
void CMainFrame::ViewFullScreen(COnStationView *pView)
{
	if (!m_bFullScreen)
	{
		GetWindowPlacement(&m_wplNormal);
		if (!(m_wplNormal.flags&SW_SHOWMAXIMIZED))
		{
			ShowWindow(SW_SHOWMAXIMIZED);
		}
		m_dataView.ShowWindow(SW_HIDE);
		int iMaxX=GetSystemMetrics(SM_CXSCREEN);
		int iMaxY=GetSystemMetrics(SM_CYSCREEN);
		int iTitleBarFudge=GetSystemMetrics(SM_CYMENU)+GetSystemMetrics(SM_CYCAPTION);
		int iBorder=GetSystemMetrics(SM_CYFRAME);
		MoveWindow(-iBorder,-iTitleBarFudge-5,iMaxX+iBorder*2+3,iMaxY+iTitleBarFudge+60,TRUE);
		m_wndToolBar.ShowWindow(SW_HIDE);
		m_wndStatusBar.ShowWindow(SW_HIDE);
		m_wndRuler.ShowWindow(SW_HIDE);
		ShowControlBar(&m_wndToolBarFullScreen,TRUE,TRUE);
		RecalcLayout();
		if (pView!=NULL)
		{
			pView->GetParent()->ShowWindow(SW_SHOWMAXIMIZED);
		}
	}
	else
	{
		CAppSettings *Set=theApp.GetSettings();
		m_dataView.ShowWindow(SW_SHOW);
		m_wndStatusBar.ShowWindow(Set->m_bStatusBar);
		m_wndToolBar.ShowWindow(Set->m_bToolBar);
		ShowControlBar(&m_wndToolBarFullScreen,FALSE,TRUE);
		m_wndRuler.ShowWindow(Set->m_bRuler?SW_SHOW:SW_HIDE);
		//The following code fixes a problem where some stuff
		//didn't redraw properly coming out of full screen mode
		//if we were  maximized.  In particular, the status bar
		//would show up off the bottom of the screen.
		if (m_wplNormal.flags&SW_SHOWMAXIMIZED)
		{
			ShowWindow(SW_SHOWNORMAL);
			RecalcLayout();
			SetWindowPlacement(&m_wplNormal);
		}
		SetWindowPlacement(&m_wplNormal);
		RecalcLayout();
	}
	m_bFullScreen=!m_bFullScreen;
}
예제 #8
0
BOOL CSplashScreen::OnInitDialog()
{
	
#ifdef _DEBUG	//ADDED by fengwen on 2006/11/22 : 调试时不让SplashWnd永远置前,妨碍调试。
	SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
#endif

	HDC hScrDC;						// 屏幕设备描述表
	hScrDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
	
	int xScrn, yScrn;				// 屏幕分辨率

	xScrn = GetDeviceCaps(hScrDC, HORZRES);
	yScrn = GetDeviceCaps(hScrDC, VERTRES);

	CDialog::OnInitDialog();
	
	//InitWindowStyles(this);

	WINDOWPLACEMENT wp;
	GetWindowPlacement(&wp);
	wp.rcNormalPosition.left = 0;
	wp.rcNormalPosition.top = 0;
	wp.rcNormalPosition.right = xScrn;
	wp.rcNormalPosition.bottom = yScrn;

	SetWindowPlacement(&wp);

	return TRUE;
}
예제 #9
0
/*************
 * DESCRIPTION:	load window placement set window
 * INPUT:			system
 * OUTPUT:			-
 *************/
void CMainFrame::InitialShowWindow(UINT nCmdShow)
{
	WINDOWPLACEMENT wp;
	CSize sizeSplitter;
	CRect rect;
	
	((CCamView*)m_wndSplitterH.GetPane(0, 0))->bLockOnSizeRedraw = FALSE;

	if (!ReadWindowPlacement(&wp, &sizeSplitter))
	{
		GetClientRect(rect);
		sizeSplitter.cx = rect.right - 100;
		sizeSplitter.cy = rect.bottom - 130;
	}
	else
	{
		SetWindowPlacement(&wp);
		GetClientRect(rect);
	}

	wp.showCmd = nCmdShow;

	m_wndSplitterH.SetColumnInfo(0, sizeSplitter.cx, 0);
	m_wndSplitterV.SetRowInfo(0, sizeSplitter.cy, 0);
	// do the recalc now, otherwise the Splitter-windows would "forget" it
	m_wndSplitterV.RecalcLayout();
	m_wndSplitterH.RecalcLayout();

	sizeOld.cx = rect.Width();
	sizeOld.cy = rect.Height();

	ShowWindow(wp.showCmd);
}
예제 #10
0
//--------------------------------------------------------------------------------------------------------------//
void CFrmMain::WindowPlacementLoad()
{
	WINDOWPLACEMENT wndpl;

	CXMLParamsHelper XMLParams;
	XMLParams.LoadXMLParams();

	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("MaxPositionX"), &wndpl.ptMaxPosition.x, 0xffff);
	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("MaxPositionY"), &wndpl.ptMaxPosition.y, 0xffff);
	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("MinPositionX"), &wndpl.ptMinPosition.x, 0xffff);
	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("MinPositionY"), &wndpl.ptMinPosition.y, 0xffff);

	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("NormalPositionLeft"), &wndpl.rcNormalPosition.left, 0xffff);
	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("NormalPositionTop"), &wndpl.rcNormalPosition.top, 0xffff);
	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("NormalPositionRight"), &wndpl.rcNormalPosition.right, 0xffff);
	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("NormalPositionBottom"), &wndpl.rcNormalPosition.bottom, 0xffff);

	long nVal = 0xffff;
	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("Flags"), &nVal, 0xffff);
	wndpl.flags = nVal;
	XMLParams.GetXMLLong(SETTINGS_WINDOW_PLACEMENT_KEY, _T("ShowCmd"), &nVal, 0xffff);
	wndpl.showCmd = nVal;

	if(0xffff == wndpl.rcNormalPosition.left
		|| 0xffff == wndpl.rcNormalPosition.top || 0xffff == wndpl.rcNormalPosition.right
		|| 0xffff == wndpl.rcNormalPosition.bottom || 0xffff == wndpl.showCmd)
	{
		return;
	}

	SetWindowPlacement(&wndpl);
}
예제 #11
0
// Initialization helper -- 
//  Loads the Restores data and positions the window in its previously saved state
void cef_main_window::RestoreWindowPlacement(int showCmd)
{
    if (showCmd == SW_MAXIMIZE)
    {
        WINDOWPLACEMENT wp;
        ::ZeroMemory(&wp, sizeof (wp));

        wp.length = sizeof(WINDOWPLACEMENT);

        wp.flags            = 0;
        wp.showCmd          = SW_MAXIMIZE;
        wp.ptMinPosition.x  = -1;
        wp.ptMinPosition.y  = -1;
        wp.ptMaxPosition.x  = -1;
        wp.ptMaxPosition.y  = -1;

        wp.rcNormalPosition.left   = CW_USEDEFAULT;
        wp.rcNormalPosition.top    = CW_USEDEFAULT;
        wp.rcNormalPosition.right  = CW_USEDEFAULT;
        wp.rcNormalPosition.bottom = CW_USEDEFAULT;

        GetRegistryInt(::kWindowPostionFolder, ::kPrefRestoreLeft,   NULL, (int&)wp.rcNormalPosition.left);
        GetRegistryInt(::kWindowPostionFolder, ::kPrefRestoreTop,    NULL, (int&)wp.rcNormalPosition.top);
        GetRegistryInt(::kWindowPostionFolder, ::kPrefRestoreRight,  NULL, (int&)wp.rcNormalPosition.right);
        GetRegistryInt(::kWindowPostionFolder, ::kPrefRestoreBottom, NULL, (int&)wp.rcNormalPosition.bottom);

        // This returns FALSE on failure but not sure what we could do in that case
        SetWindowPlacement(&wp);
    }

    ShowWindow(showCmd);
}
예제 #12
0
	//void winMsgRelease()
	//{
	//	if(customWinProc == daemonProc)
	//	{
	//		Shell_NotifyIcon(NIM_DELETE, &nid);	//资源释放
	//	}
	//}
	void simulateFullScreen(HWND hwnd)
	{
		//方案1
		int ScreenX = GetSystemMetrics(SM_CXSCREEN); //获得全屏的宽
		int ScreenY = GetSystemMetrics(SM_CYSCREEN); //获得全屏的高
		int DialogX = GetSystemMetrics(SM_CXDLGFRAME) - 3; //获得你的窗口左边空白边框的宽度	//-3这个值,不同的系统会不同
		int DialogY = GetSystemMetrics(SM_CYDLGFRAME) + GetSystemMetrics(SM_CYCAPTION);  //获得你的窗口
		WINDOWPLACEMENT newment;
		newment.length = sizeof(WINDOWPLACEMENT);
		newment.flags = WPF_RESTORETOMAXIMIZED;
		newment.showCmd = SW_SHOWMAXIMIZED;

		newment.ptMaxPosition.x = 0;
		newment.ptMaxPosition.y = 0;
		newment.ptMinPosition.x = 0;
		newment.ptMinPosition.y = 0;
		newment.rcNormalPosition.left = -DialogX;      //(0,0)点重合
		newment.rcNormalPosition.top = -DialogY;
		newment.rcNormalPosition.bottom = ScreenX - DialogY; //尺寸一致
		newment.rcNormalPosition.right = ScreenY - DialogX;
		SetWindowPlacement(hwnd, &newment);
		//方案2
		//	SetWindowLongPtr(hwnd, GWL_STYLE, 
		//		WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE);
		//	//MoveWindow(hwnd, 0, 0, windowWidth, windowHeight, TRUE);
		//	setWindowPos(0,0);
	}
예제 #13
0
파일: config.c 프로젝트: alex310110/altdrag
BOOL CALLBACK PropSheetProc(HWND hwnd, UINT msg, LPARAM lParam) {
  if (msg == PSCB_PRECREATE) {
    DLGTEMPLATE *pDlgTemplate = (DLGTEMPLATE*) lParam;
    pDlgTemplate->style |= WS_THICKFRAME;
  }
  else if (msg == PSCB_INITIALIZED) {
    g_cfgwnd = hwnd;
    SetWindowSubclass(g_cfgwnd, PropSheetWinProc, 0, 0);
    UpdateStrings();

    // Set new icon specifically for the taskbar and Alt+Tab, without changing window icon
    HICON taskbar_icon = LoadImage(g_hinst, L"taskbar_icon", IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
    SendMessage(g_cfgwnd, WM_SETICON, ICON_BIG, (LPARAM)taskbar_icon);

    // OK button replaces Cancel button
    SendMessage(g_cfgwnd, PSM_CANCELTOCLOSE, 0, 0);
    HWND cancel = GetDlgItem(g_cfgwnd, IDCANCEL);
    HWND ok = GetDlgItem(g_cfgwnd, IDOK);
    Button_Enable(cancel, TRUE); // Re-enable to enable escape key
    WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) };
    GetWindowPlacement(cancel, &wndpl);
    SetWindowPlacement(ok, &wndpl);
    ShowWindow(cancel, SW_HIDE);

    HWND apply = GetDlgItem(g_cfgwnd, IDAPPLY);
    Button_SetText(apply, L""); // Remove text to remove it's shortcut (Alt+A in English)
  }
}
예제 #14
0
파일: gui.cpp 프로젝트: fishman/virtualdub
void VDUIRestoreWindowPlacementW32(HWND hwnd, const char *name, int nCmdShow) {
	if (!IsZoomed(hwnd) && !IsIconic(hwnd)) {
		VDRegistryAppKey key("Window Placement");
		VDUISavedWindowPlacement sp = {0};

		// Earlier versions only saved a RECT.
		int len = key.getBinaryLength(name);

		if (len > (int)sizeof(VDUISavedWindowPlacement))
			len = sizeof(VDUISavedWindowPlacement);

		if (len >= offsetof(VDUISavedWindowPlacement, mbMaximized) && key.getBinary(name, (char *)&sp, len)) {
			WINDOWPLACEMENT wp = {sizeof(WINDOWPLACEMENT)};

			if (GetWindowPlacement(hwnd, &wp)) {
				wp.length			= sizeof(WINDOWPLACEMENT);
				wp.flags			= 0;
				wp.showCmd			= nCmdShow;
				wp.rcNormalPosition.left = sp.mLeft;
				wp.rcNormalPosition.top = sp.mTop;
				wp.rcNormalPosition.right = sp.mRight;
				wp.rcNormalPosition.bottom = sp.mBottom;

				if ((wp.showCmd == SW_SHOW || wp.showCmd == SW_SHOWNORMAL || wp.showCmd == SW_SHOWDEFAULT) && sp.mbMaximized)
					wp.showCmd = SW_SHOWMAXIMIZED;

				SetWindowPlacement(hwnd, &wp);
			}
		}
	}
}
예제 #15
0
파일: MainFrm.cpp 프로젝트: yeehlin/PMP
void CMainFrame::OnMenuFullscreen()
{
	// TODO: Add your command handler code here

	if(!m_bFullScreen){
		GetWindowPlacement(&m_OldWndPlacement);
		CRect WindowRect;
		GetWindowRect(&WindowRect);
		CRect ClientRect;
		RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery, &ClientRect);
		ClientToScreen(&ClientRect);
		//获取屏幕的分辨率
		int nFullWidth=GetSystemMetrics(SM_CXSCREEN);
		int nFullHeight=GetSystemMetrics(SM_CYSCREEN);
		//将除控制条外的客户区全屏显示到从(0,0)到(nFullWidth, nFullHeight)区域, 将(0,0)和(nFullWidth, nFullHeight)两个点外扩充原窗口和除控制条之外的客户区位置间的差值, 就得到全屏显示的窗口位置
		m_FullScreenRect.left=WindowRect.left-ClientRect.left;
		m_FullScreenRect.top=WindowRect.top-ClientRect.top;
		m_FullScreenRect.right=WindowRect.right-ClientRect.right+nFullWidth;
		m_FullScreenRect.bottom=WindowRect.bottom-ClientRect.bottom+nFullHeight;
		m_bFullScreen=TRUE; //设置全屏显示标志为 TRUE
							//进入全屏显示状态
		WINDOWPLACEMENT wndpl;
		wndpl.length=sizeof(WINDOWPLACEMENT);
		wndpl.flags=0;
		wndpl.showCmd=SW_SHOWNORMAL;
		wndpl.rcNormalPosition=m_FullScreenRect;
		SetWindowPlacement(&wndpl);

	}
}
예제 #16
0
void toggleFullscreen(bool isFullscreen)
{
    MONITORINFO monitorInfo;
    dwStyle = GetWindowLong(hWindow, GWL_STYLE);

    if(isFullscreen)
    {
        if(dwStyle & WS_OVERLAPPEDWINDOW)
        {
            monitorInfo = { sizeof(MONITORINFO) };

            if(GetWindowPlacement(hWindow, &wpPrev) && GetMonitorInfo(MonitorFromWindow(hWindow, MONITORINFOF_PRIMARY), &monitorInfo))
            {
                SetWindowLong(hWindow, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
                SetWindowPos(hWindow, HWND_TOP, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top, SWP_NOZORDER | SWP_FRAMECHANGED);
            }
        }

        ShowCursor(FALSE);
    }
    else
    {
        SetWindowLong(hWindow, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
        SetWindowPlacement(hWindow, &wpPrev);
        SetWindowPos(hWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED);
        ShowCursor(TRUE);
    }
}
예제 #17
0
void ToggleFullscreen(HWND Window, WINDOWPLACEMENT &WindowPosition)
{
	// This follows Raymond Chen's prescription
	// for fullscreen toggling, see:
	// http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx

	DWORD Style = GetWindowLongW(Window, GWL_STYLE);
	if (Style & WS_OVERLAPPEDWINDOW)
	{
		MONITORINFO MonitorInfo = { sizeof(MonitorInfo) };
		if (GetWindowPlacement(Window, &WindowPosition) &&
			GetMonitorInfoW(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
		{
			SetWindowLongW(Window, GWL_STYLE, Style & ~WS_OVERLAPPEDWINDOW);
			SetWindowPos(Window, HWND_TOP,
				MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
				MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
				MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
				SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
		}
	}
	else
	{
		SetWindowLongW(Window, GWL_STYLE, Style | WS_OVERLAPPEDWINDOW);
		SetWindowPlacement(Window, &WindowPosition);
		SetWindowPos(Window, 0, 0, 0, 0, 0,
			SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
			SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
	}
}
예제 #18
0
void cleanUp()
{
    if(isFullscreen)
    {
        dwStyle = GetWindowLong(hWindow, GWL_STYLE);
        SetWindowLong(hWindow, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
        SetWindowPlacement(hWindow, &wpPrev);
        SetWindowPos(hWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED);
        ShowCursor(TRUE);
    }

    renderer->waitForIdle();
    renderer->destroySynchronizations();
    renderer->destroyCommandBuffers();
    renderer->destroyVertexBuffer();
    renderer->destroyCommandPool();
    renderer->destroyFrameBuffers();
    renderer->destroyGraphicsPipline();
    renderer->destroyRenderPass();
    // renderer->destoryDepthStencilImage();
    renderer->destroySwapchainImageViews();
    renderer->destroySwapchain();
    renderer->destroyDevice();

    destroyPlatformSpecificSurface();

    delete renderer;

    destroyPlatformSpecificWindow();
}
예제 #19
0
/*******************************************************************************
  Function Name  : vLoadDataFromStore
  Input(s)       : -
  Output         : -
  Functionality  : Loads the Bus stats dialog Configuration date from store.
  Member of      : CBusStatisticsDlg
  Author(s)      : Arunkumar K
  Date Created   : 07-04-2011
  Modifications  : ArunKumar K, 08-04-2011,
                   Updated for loop MAX index to m_nChannelCount+1 instead of
                   sm_sBusSerializationData.m_nColumnCount.
*******************************************************************************/
void CBusStatisticsDlg::vLoadDataFromStore()
{
    if(sm_sBusSerializationData.m_bIsDirty)
    {
        SetWindowPlacement(&sm_sBusSerializationData.m_sBusStatsDlgCoOrd);
        //Reading column Header Positions.
        CHeaderCtrl* pHeaderCtrl = m_omStatList.GetHeaderCtrl();

        if (pHeaderCtrl != NULL)
        {
            if(sm_sBusSerializationData.m_nColumnCount != (UINT)(m_nChannelCount + 1))
            {
                sm_sBusSerializationData.vLoadDefaults();
            }

            for (int i = 0 ; i < m_nChannelCount+1 ; i++)
            {
                m_omStatList.MakeColumnVisible(i, sm_sBusSerializationData.m_arrbColumnVisible[i]);
                m_omStatList.SetColumnWidth(i, sm_sBusSerializationData.m_arrnColWidth[i]);
            }

            m_omStatList.SetColumnOrderArray(sm_sBusSerializationData.m_nColumnCount , (LPINT)sm_sBusSerializationData.m_arrnOrder);
        }
    }
}
예제 #20
0
/*******************************************************************************
  Function Name  : SetConfigData
  Input(s)       : pvDataStream
  Output         : -
  Functionality  : Sets the Bus stats dialog Configuration from Byte Array.
  Member of      : CBusStatisticsDlg
  Author(s)      : Arunkumar K
  Date Created   : 25-08-2010
  Modifications  :
*******************************************************************************/
HRESULT CBusStatisticsDlg::SetConfigData(BYTE* pvDataStream)
{
    BYTE* pByteSrc = NULL;
    pByteSrc = pvDataStream;

    if (pByteSrc != NULL)
    {
        //Reading Version.
        BYTE byVer = 0;
        COPY_DATA_2(&byVer, pByteSrc, sizeof(BYTE));
        UINT nSize= 0;
        //Reading Buffer Size.
        COPY_DATA_2(&nSize, pByteSrc, sizeof(UINT));

        if ((byVer == BUS_STATS_DLG_VERSION) && (nSize > 0))
        {
            //Reading column Header Positions.
            CHeaderCtrl* pHeaderCtrl = m_omStatList.GetHeaderCtrl();

            if (pHeaderCtrl != NULL)
            {
                int  nColumnCount=0;
                //Reading column count.
                COPY_DATA_2(&nColumnCount, pByteSrc, sizeof(UINT));

                //Saved channel count is same as current channel count.
                if(nColumnCount==m_nChannelCount+1)
                {
                    LPINT pnOrder = (LPINT) malloc(nColumnCount*sizeof(int));

                    for (int i = 0 ; i < nColumnCount; i++)
                    {
                        COPY_DATA_2(&pnOrder[i], pByteSrc, sizeof(int));
                        bool bColumnVisible = false;
                        //Reading visibility
                        COPY_DATA_2(&bColumnVisible, pByteSrc, sizeof(bool));
                        m_omStatList.MakeColumnVisible(i, bColumnVisible);
                        INT nColWidth = 0;
                        //Reading width
                        COPY_DATA_2(&nColWidth, pByteSrc, sizeof(int));
                        m_omStatList.SetColumnWidth(i, nColWidth);
                    }

                    m_omStatList.SetColumnOrderArray(nColumnCount, pnOrder);
                    free(pnOrder);
                }
                else //Saved channel count differs from current channel count.
                {
                    vLoadDefaultValues();
                }
            }

            WINDOWPLACEMENT sMsgWndPlacement;
            COPY_DATA_2(&sMsgWndPlacement, pByteSrc, sizeof(WINDOWPLACEMENT));
            SetWindowPlacement(&sMsgWndPlacement);
        }
    }

    return S_OK;
}
예제 #21
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : lpCreateStruct - 
// Output : int
//-----------------------------------------------------------------------------
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
	{
		return(-1);
	}

	//
	// The splitter gets its layout from the registry.
	//
	if (bUsingSplitter)
	{
		CString str = APP()->GetProfileString("Splitter", "WindowPlacement", "");
		if (!str.IsEmpty())
		{
			WINDOWPLACEMENT wp;
			wp.length = sizeof(wp);
			wp.flags = 0;
			sscanf(str, "(%d %d) (%d %d) (%d %d %d %d) %d", &wp.ptMaxPosition.x, &wp.ptMaxPosition.y, &wp.ptMinPosition.x, &wp.ptMinPosition.y, &wp.rcNormalPosition.bottom, &wp.rcNormalPosition.left, &wp.rcNormalPosition.right, &wp.rcNormalPosition.top, &wp.showCmd);

			if (wp.showCmd == SW_SHOWMAXIMIZED)
			{
				PostMessage(WM_SYSCOMMAND, SC_MAXIMIZE);
			}
			else
			{
				SetWindowPlacement(&wp);
			}
		}
	}

	return(0);
}
예제 #22
0
void CWindowBase::Init(UINT uID, LONG cx, LONG cy)
{
	m_uID = uID;

	YCIni clIni( SBL_STR_INI_EXTRACTDATA );
	clIni.SetSection( m_uID );

	RECT rc;
	SetRect(&rc, 0, 0, cx, cy);
	POINT pt = GetCenterPt(rc);

	clIni.SetKey( _T("Left") );
	clIni.ReadDec( &pt.x );
	clIni.SetKey( _T("Top") );
	clIni.ReadDec( &pt.y );
	clIni.SetKey( _T("Width") );
	clIni.ReadDec( &cx );
	clIni.SetKey( _T("Height") );
	clIni.ReadDec( &cy );

	WINDOWPLACEMENT wndpl;

	memset(&wndpl, 0, sizeof(WINDOWPLACEMENT));

	wndpl.length = sizeof(WINDOWPLACEMENT);
	wndpl.showCmd = SW_HIDE;

	SetRect(&wndpl.rcNormalPosition, pt.x, pt.y, pt.x + cx, pt.y + cy);
	SetWindowPlacement(m_hWnd, &wndpl);

	clIni.SetKey( _T("showCmd") );
	clIni.ReadDec<UINT>( &wndpl.showCmd, SW_SHOWNORMAL );

	ShowWindow( m_hWnd, wndpl.showCmd );
}
예제 #23
0
void RestoreWindowPlacement(HWND hWnd, int showCmd)
{
	if (!hWnd)
		return;

	// If window is maximized, set the "restore" window position
	if (showCmd == SW_MAXIMIZE)
	{
		WINDOWPLACEMENT wp;
		wp.length = sizeof(WINDOWPLACEMENT);

		wp.flags	= 0;
		wp.showCmd	= SW_MAXIMIZE;
		wp.ptMinPosition.x	= -1;
		wp.ptMinPosition.y	= -1;
		wp.ptMaxPosition.x	= -1;
		wp.ptMaxPosition.y	= -1;

		wp.rcNormalPosition.left	= CW_USEDEFAULT;
		wp.rcNormalPosition.top		= CW_USEDEFAULT;
		wp.rcNormalPosition.right	= CW_USEDEFAULT;
		wp.rcNormalPosition.bottom	= CW_USEDEFAULT;

		GetRegistryInt(PREF_WINPOS_FOLDER, PREF_RESTORE_LEFT,	NULL, (int&)wp.rcNormalPosition.left);
		GetRegistryInt(PREF_WINPOS_FOLDER, PREF_RESTORE_TOP,	NULL, (int&)wp.rcNormalPosition.top);
		GetRegistryInt(PREF_WINPOS_FOLDER, PREF_RESTORE_RIGHT,	NULL, (int&)wp.rcNormalPosition.right);
		GetRegistryInt(PREF_WINPOS_FOLDER, PREF_RESTORE_BOTTOM,	NULL, (int&)wp.rcNormalPosition.bottom);

		// This returns an error code, but not sure what we could do on an error
		SetWindowPlacement(hWnd, &wp);
	}

	ShowWindow(hWnd, showCmd);
}
예제 #24
0
void Win32Window::SetFullScreen(bool fullscreen)
{
	if(this->fullscreen == fullscreen) return;
	this->fullscreen = fullscreen;
	if(fullscreen)
	{
		// remember window placement before going fullscreen
		LONG_PTR styles = GetWindowLongPtr(hWnd, GWL_STYLE);
		preFullScreenPlacement.length = sizeof(preFullScreenPlacement);
		GetWindowPlacement(hWnd, &preFullScreenPlacement);
		// remove window frame
		SetWindowLongPtr(hWnd, GWL_STYLE, (styles & (~WS_OVERLAPPEDWINDOW)) | WS_POPUP);
		// if window is maximized already, restore it first
		// otherwise Windows will not maximize it over whole screen
		if(styles & WS_MAXIMIZE) ShowWindowAsync(hWnd, SW_RESTORE);
		// maximize window
		ShowWindowAsync(hWnd, SW_MAXIMIZE);
	}
	else
	{
		// bring window frame back
		SetWindowLongPtr(hWnd, GWL_STYLE, (GetWindowLongPtr(hWnd, GWL_STYLE) & (~WS_POPUP)) | WS_OVERLAPPEDWINDOW);
		// restore window placement
		SetWindowPlacement(hWnd, &preFullScreenPlacement);
	}
}
예제 #25
0
파일: kguimingw.cpp 프로젝트: CarlHuff/kgui
void kGUISystemMINGW::SetWindowPos(int x,int y)
{
	WINDOWPLACEMENT    wp;
	int w,h;

    wp.length = sizeof wp;

    if ( GetWindowPlacement(m_hWnd,&wp) )
	{
		w=wp.rcNormalPosition.right-wp.rcNormalPosition.left;
		h=wp.rcNormalPosition.bottom-wp.rcNormalPosition.top;

		/* clip */
		if((x+w)<25)
			x=25-w;
		else if(x>(GetSystemMetrics(SM_CXSCREEN)-25))
			x=GetSystemMetrics(SM_CXSCREEN)-25;
		if(y<0)
			y=0;
		else if(y>(GetSystemMetrics(SM_CYSCREEN)-25))
			y=GetSystemMetrics(SM_CYSCREEN)-25;

		wp.rcNormalPosition.left=x;
		wp.rcNormalPosition.top=y;
		wp.rcNormalPosition.right=x+w;
		wp.rcNormalPosition.bottom=y+h;
		SetWindowPlacement(m_hWnd,&wp);
	}
}
예제 #26
0
// Thank you Raymond Chen!!
void Win32FullscreenToggle(HWND window)
{
    DWORD style = GetWindowLong(window, GWL_STYLE);
    if (style & WS_OVERLAPPEDWINDOW)
    {
        MONITORINFO monitorInfo = { sizeof(monitorInfo) };
        if (GetWindowPlacement(window, &globalWindowPos) &&
            GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY), &monitorInfo))
        {//NOT BITWISE OPERATOR
            SetWindowLong(window, GWL_STYLE, style & ~WS_OVERLAPPEDWINDOW);
            SetWindowPos(window, HWND_TOP,
                         monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top,
                         monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left,
                         monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top,
                         SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
        }
    }
    else
    {
        SetWindowLong(window, GWL_STYLE, style | WS_OVERLAPPEDWINDOW);
        SetWindowPlacement(window, &globalWindowPos);
        SetWindowPos(window, NULL, 0, 0, 0, 0,
                     SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
                     SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
    }
}
예제 #27
0
void CExtResizableDialog::LoadWindowRect(
	bool bForceHideWindow // = false
	)
{
	CString data;
	WINDOWPLACEMENT wp;

	data = AfxGetApp()->GetProfileString(m_sSection, m_sEntry);
	
	if (data.IsEmpty())	// never saved before
		return;
	
	ZeroMemory(&wp, sizeof(WINDOWPLACEMENT));
	wp.length = sizeof(WINDOWPLACEMENT);
	GetWindowPlacement(&wp);

RECT& rc = wp.rcNormalPosition;	// alias

	if (_stscanf(data, PROFILE_FMT, &rc.left, &rc.top,
		&rc.right, &rc.bottom, &wp.showCmd, &wp.flags) == 6)
	{
		if( bForceHideWindow )
			wp.showCmd = SW_HIDE;
		SetWindowPlacement(&wp);
	}
	ArrangeLayout();
}
예제 #28
0
void CResizableSheet::LoadWindowRect()
{
	CString data;
	WINDOWPLACEMENT wp;
	int page;

	data = AfxGetApp()->GetProfileString(m_sSection, m_sEntry);
	
	if (data.IsEmpty())	// never saved before
		return;
	
	ZeroMemory(&wp, sizeof(WINDOWPLACEMENT));
	wp.length = sizeof(WINDOWPLACEMENT);

	RECT& rc = wp.rcNormalPosition;	// alias

	if (_stscanf_s(data, PROFILE_FMT, &rc.left, &rc.top,
		&rc.right, &rc.bottom, &wp.showCmd, &wp.flags, &page) == 7)
	{
		SetWindowPlacement(&wp);
		if (m_bSavePage)
		{
			SetActivePage(page);
			ArrangeLayout();	// needs refresh
		}
	}
}
예제 #29
0
BOOL CSplitterFrame::Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle , const RECT& rect , CMDIFrameWnd* pParentWnd , CCreateContext* pContext ) {
  /* recréer control tabs */
  this_app->NewTabs();

  // Enlever bordure fenêtre, et mettre en plein écran (pas de fenêtre dans la fenêtre!!)
  dwStyle&=(~(WS_MINIMIZEBOX|WS_BORDER|WS_CAPTION|WS_OVERLAPPED|WS_OVERLAPPEDWINDOW));
  dwStyle|=(WS_MAXIMIZE);
  int r=CMDIChildWnd::Create(lpszClassName,lpszWindowName,dwStyle ,rect ,pParentWnd ,pContext );
  if (r) {
    // Mettre en maximisé
    WINDOWPLACEMENT pl;
    RECT rc;
    rc.top=0;
    rc.left=0;
    rc.bottom=200;
    rc.right=400;
    pl.length=sizeof(pl);
    pl.flags=WPF_RESTORETOMAXIMIZED;
    pl.showCmd=SW_SHOWMAXIMIZED;
    pl.rcNormalPosition=rc;
    SetWindowPlacement(&pl);
  }

  // iconification
  iconifie=false;
  icnd.cbSize=sizeof(NOTIFYICONDATA);
  icnd.uID=0;              // euhh id=0
  icnd.uFlags=NIF_ICON|NIF_TIP|NIF_MESSAGE;
  icnd.uCallbackMessage=wm_IcnRest;  // notre callback
  icnd.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);

  // Retourner résultat
  return r;
}
예제 #30
0
파일: main.c 프로젝트: Jasu/HashTWM
void RestoreWindow(HWND hwnd)
{
  WINDOWPLACEMENT placement = { sizeof(WINDOWPLACEMENT) };
  GetWindowPlacement(hwnd, &placement);
  placement.showCmd = SW_RESTORE;
  SetWindowPlacement(hwnd, &placement);
}