Exemple #1
0
void MainWnd::OnSizing(UINT fwSide, LPRECT pRect)
{	// the OnSizing event only occurs in windowed mode
	CWnd::OnSizing(fwSide, pRect);

	// pause sound to prevent low sound buffers
	if( emulating ) {
		soundPause();
	}

	// maintain minimal window size
	RECT size = { 0, 0, theApp.sizeX, theApp.sizeY };
	AdjustWindowRectEx(
		&size,
		WS_POPUP | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
		FALSE,
		0 );
	MENUBARINFO mbi;
	mbi.cbSize = sizeof(MENUBARINFO);
	GetMenuBarInfo( this->GetSafeHwnd(), OBJID_MENU, 0, &mbi );
	const LONG menuHeight = mbi.rcBar.bottom - mbi.rcBar.top + 1;
	// +1 because of that white line, wherever it comes from
	const LONG width = size.right - size.left;
	const LONG height = size.bottom - size.top + menuHeight;
	if( ( pRect->right - pRect->left ) < width ) {
		pRect->right = pRect->left + width;
	}
	if( ( pRect->bottom - pRect->top ) < height ) {
		pRect->bottom = pRect->top + height;
	}
}
Exemple #2
0
LRESULT CWindow::OnKeyDown(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (wParam)
    {
    case VK_ESCAPE:
        SendMessageA(hWnd, WM_COMMAND, ID_EXIT, 0);
        break;

    case VK_F1:
        SendMessageA(hWnd, WM_COMMAND, ID_ABOUT, 0);
        break;

    case VK_APPS:
        {
            RECT rcClient;
            MENUBARINFO mbi = { sizeof(mbi) };

            GetMenuBarInfo(hWnd, OBJID_MENU, 1, &mbi);
            GetClientRect(hWnd, &rcClient);
            lParam = ((rcClient.right - rcClient.left) / 2 - (mbi.rcBar.right - mbi.rcBar.left)) 
                | (((rcClient.bottom - rcClient.top) / 2 - (mbi.rcBar.bottom - mbi.rcBar.top)) << 16);
            OnRButtonUp(hWnd, uMsg, wParam, lParam);
        }
        break;
    }

    return ERROR_SUCCESS;
}
Exemple #3
0
SIZE NewGUI_GetWindowContentSize(HWND hWnd)
{
	SIZE sz;
	ZeroMemory(&sz, sizeof(SIZE));

	if(hWnd == NULL) { ASSERT(FALSE); return sz; }

	RECT rect;
	ZeroMemory(&rect, sizeof(RECT));
	if(GetClientRect(hWnd, &rect) != FALSE)
	{
		sz.cx = rect.right;
		sz.cy = rect.bottom;
	}
	if((sz.cx <= 0) || (sz.cy <= 0)) { ASSERT(FALSE); return sz; }

	MENUBARINFO mbi;
	ZeroMemory(&mbi, sizeof(MENUBARINFO));
	mbi.cbSize = sizeof(MENUBARINFO);
	if(GetMenuBarInfo(hWnd, OBJID_MENU, 0, &mbi) != FALSE)
	{
		if(mbi.hMenu != NULL)
		{
			const int dx = mbi.rcBar.right - mbi.rcBar.left;
			const int dy = mbi.rcBar.bottom - mbi.rcBar.top;

			if(dx >= dy) sz.cy += dy; // Horizontal menu bar
			else sz.cx += dx; // Vertical menu bar
		}
	}

	return sz;
}
Exemple #4
0
bool COwnerVstEditor::SetSize(int contentWidth, int contentHeight)
//----------------------------------------------------------------
{
	if(contentWidth < 0 || contentHeight < 0 || !m_hWnd)
	{
		return false;
	}

	CRect rcWnd, rcClient;

	// Get border / menu size.
	GetWindowRect(&rcWnd);
	GetClientRect(&rcClient);

	MENUBARINFO mbi;
	MemsetZero(mbi);
	mbi.cbSize = sizeof(mbi);
	GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
	int menuHeight = mbi.rcBar.bottom - mbi.rcBar.top;

	// Preliminary setup, which might have to be adjusted for small (narrow) plugin GUIs again,
	// since the menu might be two lines high...
	const int windowWidth = rcWnd.Width() - rcClient.Width() + contentWidth;
	const int windowHeight = rcWnd.Height() - rcClient.Height() + contentHeight;
	SetWindowPos(NULL, 0, 0,
		windowWidth, windowHeight,
		SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
	m_plugWindow.SetWindowPos(NULL, 0, 0,
		contentWidth, contentHeight,
		SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);

	// Check if the height of the menu bar has changed.
	GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);

	const int menuHeightDiff = (mbi.rcBar.bottom - mbi.rcBar.top) - menuHeight;

	if(menuHeightDiff != 0)
	{
		// Menu height changed, resize window so that the whole content area can be viewed again.
		SetWindowPos(NULL, 0, 0,
			windowWidth, windowHeight + menuHeightDiff,
			SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
	}

	return true;
}
Exemple #5
0
	bool UpdateMenuActive() {
		MENUBARINFO info;
		memset(&info, 0, sizeof(info));
		info.cbSize = sizeof(info);
		if (GetMenuBarInfo(MainWindow::GetHWND(), OBJID_MENU, 0, &info) != 0) {
			menuActive = info.fBarFocused != FALSE;
		}
		return menuActive;
	}
Exemple #6
0
	bool UpdateMenuActive() {
		MENUBARINFO info;
		memset(&info, 0, sizeof(info));
		info.cbSize = sizeof(info);
		if (GetMenuBarInfo(MainWindow::GetHWND(), OBJID_MENU, 0, &info) != 0) {
			menuActive = info.fBarFocused != FALSE;
		} else {
			// In fullscreen mode, we remove the menu
			menuActive = false;
		}
		return menuActive;
	}
Exemple #7
0
void WINCLASS::setClientSize(int width, int height)
{
	int xborder, yborder;
	int ymenu, ymenunew;
	int ycaption;

	MENUBARINFO mbi;

	RECT wndRect;
	int finalx, finaly;

	/* Get the size of the border */
	xborder = GetSystemMetrics(SM_CXSIZEFRAME);
	yborder = GetSystemMetrics(SM_CYSIZEFRAME);
	
	/* Get the size of the menu bar */
	ZeroMemory(&mbi, sizeof(mbi));
	mbi.cbSize = sizeof(mbi);
	GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
	ymenu = (mbi.rcBar.bottom - mbi.rcBar.top + 1);

	/* Get the size of the caption bar */
	ycaption = GetSystemMetrics(SM_CYCAPTION);

	/* Finally, resize the window */
	GetWindowRect(hwnd, &wndRect);
	finalx = (xborder + width + xborder);
	finaly = (ycaption + yborder + ymenu + height + yborder);
	MoveWindow(hwnd, wndRect.left, wndRect.top, finalx, finaly, TRUE);

	/* Oops, we also need to check if the height */
	/* of the menu bar has changed after the resize */
	ZeroMemory(&mbi, sizeof(mbi));
	mbi.cbSize = sizeof(mbi);
	GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
	ymenunew = (mbi.rcBar.bottom - mbi.rcBar.top + 1);

	if(ymenunew != ymenu)
		MoveWindow(hwnd, wndRect.left, wndRect.top, finalx, (finaly + (ymenunew - ymenu)), TRUE);
}
// Enforce that the menu has our background color otherwise it 
//  uses the system default color for the menu bar which looks funny
void cef_dark_window::EnforceMenuBackground()
{
    MENUBARINFO mbi = {0};
    mbi.cbSize = sizeof(mbi);
    
    GetMenuBarInfo(OBJID_MENU, 0, &mbi);

    MENUINFO mi = {0};
    mi.cbSize = sizeof(mi);
    mi.fMask = MIM_BACKGROUND;

    ::GetMenuInfo(mbi.hMenu, &mi);
    
    if (mi.hbrBack != mBackgroundBrush) {
        mi.hbrBack = mBackgroundBrush;
        ::SetMenuInfo(mbi.hMenu, &mi);
    }
}
	JNIEXPORT jboolean JNICALL OS_NATIVE(_1getMenuBarOrItemBounds)(JNIEnv *env, jclass that, JHANDLE jshell, jint jitemIndex, jintArray jbounds) {
		HWND hwnd = (HWND)unwrap_pointer(env, jshell);
		MENUBARINFO info;
		info.cbSize = sizeof(MENUBARINFO);
		if (GetMenuBarInfo(hwnd, OBJID_MENU, jitemIndex, &info)) {
			// prepare buffer
			jsize boundsSize = env->GetArrayLength(jbounds);
			jint *bounds = new jint [boundsSize * sizeof(jint)];
			*(bounds + 0) = info.rcBar.left;
			*(bounds + 1) = info.rcBar.right;
			*(bounds + 2) = info.rcBar.top;
			*(bounds + 3) = info.rcBar.bottom;
			// copy dimensions into java array
			env->SetIntArrayRegion(jbounds, 0, boundsSize, bounds);
			delete []bounds;
			return JNI_TRUE;
		}
		return JNI_FALSE;
	}
/* It is up to the caller to delete the bitmap returned by this method. */
void Explorerplusplus::GetTabLivePreviewBitmap(int iTabId,TabPreviewInfo_t *ptpi)
{
	HDC hdcTab;
	HDC hdcTabSrc;
	HBITMAP hbmTab;
	HBITMAP hbmTabPrev;
	Gdiplus::Color color(0,0,0);
	MENUBARINFO mbi;
	POINT pt;
	BOOL bVisible;
	RECT rcTab;

	HWND hTab = m_hListView[iTabId];

	hdcTab = GetDC(hTab);
	hdcTabSrc = CreateCompatibleDC(hdcTab);

	GetClientRect(hTab,&rcTab);

	Gdiplus::Bitmap bi(GetRectWidth(&rcTab),GetRectHeight(&rcTab),PixelFormat32bppARGB);
	bi.GetHBITMAP(color,&hbmTab);

	hbmTabPrev = (HBITMAP)SelectObject(hdcTabSrc,hbmTab);

	bVisible = IsWindowVisible(hTab);

	if(!bVisible)
	{
		ShowWindow(hTab,SW_SHOW);
	}

	PrintWindow(hTab,hdcTabSrc,PW_CLIENTONLY);

	if(!bVisible)
	{
		ShowWindow(hTab,SW_HIDE);
	}

	SetStretchBltMode(hdcTabSrc,HALFTONE);
	SetBrushOrgEx(hdcTabSrc,0,0,&pt);
	StretchBlt(hdcTabSrc,0,0,GetRectWidth(&rcTab),GetRectHeight(&rcTab),hdcTabSrc,
		0,0,GetRectWidth(&rcTab),GetRectHeight(&rcTab),SRCCOPY);

	MapWindowPoints(hTab,m_hContainer,(LPPOINT)&rcTab,2);

	mbi.cbSize	 = sizeof(mbi);
	GetMenuBarInfo(m_hContainer,OBJID_MENU,0,&mbi);

	/* The operating system will automatically
	draw the main window. Therefore, we'll just shift
	the tab into it's proper position. */
	ptpi->ptOrigin.x = rcTab.left;

	/* Need to include the menu bar in the offset. */
	ptpi->ptOrigin.y = rcTab.top + mbi.rcBar.bottom - mbi.rcBar.top;

	ptpi->hbm = hbmTab;
	ptpi->iTabId = iTabId;

	SelectObject(hdcTabSrc,hbmTabPrev);
	DeleteDC(hdcTabSrc);
	ReleaseDC(hTab,hdcTab);
}
void VBA::updateWindowSize(int value)
{
  regSetDwordValue("video", value);

  if(value == VIDEO_OTHER) {
    regSetDwordValue("fsWidth", fsWidth);
    regSetDwordValue("fsHeight", fsHeight);
    regSetDwordValue("fsColorDepth", fsColorDepth);
  }

  if(((value >= VIDEO_320x240) &&
      (videoOption != value)) ||
     (videoOption >= VIDEO_320x240 &&
      value <= VIDEO_4X) ||
     fsForceChange) {
    fsForceChange = false;
    changingVideoSize = true;
	if( videoOption <= VIDEO_4X ) {
		lastWindowed = (VIDEO_SIZE)videoOption; // save for when leaving full screen
	} else {
		lastFullscreen = (VIDEO_SIZE)videoOption; // save for when using quick switch to fullscreen
	}
    shutdownDisplay();
    if(input) {
      delete input;
      input = NULL;
    }
    m_pMainWnd->DragAcceptFiles(FALSE);
    CWnd *pWnd = m_pMainWnd;
    m_pMainWnd = NULL;
    pWnd->DestroyWindow();
    delete pWnd;
    videoOption = value;
    if(!initDisplay()) {
      if(videoOption == VIDEO_320x240 ||
         videoOption == VIDEO_640x480 ||
         videoOption == VIDEO_800x600 ||
         videoOption == VIDEO_1024x768 ||
         videoOption == VIDEO_1280x1024 ||
         videoOption == VIDEO_OTHER) {
        regSetDwordValue("video", VIDEO_1X);
      }
      changingVideoSize = false;
      AfxPostQuitMessage(0);
      return;
    }
    if(!initInput()) {
      changingVideoSize = false;
      AfxPostQuitMessage(0);
      return;
    }
    input->checkKeys();


    changingVideoSize = FALSE;
    updateWindowSize(videoOption);
    return;
  }

  sizeX = 240;
  sizeY = 160;

  videoOption = value;

  surfaceSizeX = sizeX;
  surfaceSizeY = sizeY;

  switch(videoOption) {
  case VIDEO_1X:
    surfaceSizeX = sizeX;
    surfaceSizeY = sizeY;
    break;
  case VIDEO_2X:
    surfaceSizeX = sizeX * 2;
    surfaceSizeY = sizeY * 2;
    break;
  case VIDEO_3X:
    surfaceSizeX = sizeX * 3;
    surfaceSizeY = sizeY * 3;
    break;
  case VIDEO_4X:
    surfaceSizeX = sizeX * 4;
    surfaceSizeY = sizeY * 4;
    break;
  case VIDEO_320x240:
  case VIDEO_640x480:
  case VIDEO_800x600:
  case VIDEO_1024x768:
  case VIDEO_1280x1024:
  case VIDEO_OTHER:
    {
      int scaleX = 1;
      int scaleY = 1;
      scaleX = (fsWidth / sizeX);
      scaleY = (fsHeight / sizeY);
      int min = scaleX < scaleY ? scaleX : scaleY;
      if(maxScale)
        min = min > maxScale ? maxScale : min;
      surfaceSizeX = min * sizeX;
      surfaceSizeY = min * sizeY;
      if(fullScreenStretch) {
        surfaceSizeX = fsWidth;
        surfaceSizeY = fsHeight;
      }
    }
    break;
  }

  rect.right = sizeX;
  rect.bottom = sizeY;

  int winSizeX = sizeX;
  int winSizeY = sizeY;

  if(videoOption <= VIDEO_4X) {
    dest.left = 0;
    dest.top = 0;
    dest.right = surfaceSizeX;
    dest.bottom = surfaceSizeY;

    DWORD style = WS_POPUP | WS_VISIBLE;

    style |= WS_OVERLAPPEDWINDOW;

    AdjustWindowRectEx(&dest, style, TRUE, 0); //WS_EX_TOPMOST);

    winSizeX = dest.right-dest.left;
    winSizeY = dest.bottom-dest.top;

      m_pMainWnd->SetWindowPos(0, //HWND_TOPMOST,
                               windowPositionX,
                               windowPositionY,
                               winSizeX,
                               winSizeY,
                               SWP_NOMOVE | SWP_SHOWWINDOW);

	  // content of old seperate 'winCheckMenuBarInfo' function:
      MENUBARINFO info;
      info.cbSize = sizeof(MENUBARINFO);
	  GetMenuBarInfo( theApp.m_pMainWnd->GetSafeHwnd(), OBJID_MENU, 0, &info );
      int menuHeight = GetSystemMetrics(SM_CYMENU); // includes white line
      if((info.rcBar.bottom - info.rcBar.top) > menuHeight) // check for double height menu
	  {
        winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1;
        m_pMainWnd->SetWindowPos(
                                        0, //HWND_TOPMOST,
                                        theApp.windowPositionX,
                                        theApp.windowPositionY,
                                        winSizeX,
                                        winSizeY,
                                        SWP_NOMOVE | SWP_SHOWWINDOW);
      }
  }

  adjustDestRect();

  if(display)
    display->resize(theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top);

  m_pMainWnd->RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
}
Exemple #12
0
void WINCLASS::sizingMsg(WPARAM wParam, LPARAM lParam, BOOL keepRatio)
{
	RECT *rect = (RECT*)lParam;

	int _minWidth, _minHeight;

	int xborder, yborder;
	int ymenu, ymenunew;
	int ycaption;

	MENUBARINFO mbi;

	/* Get the size of the border */
	xborder = GetSystemMetrics(SM_CXSIZEFRAME);
	yborder = GetSystemMetrics(SM_CYSIZEFRAME);
	
	/* Get the size of the menu bar */
	ZeroMemory(&mbi, sizeof(mbi));
	mbi.cbSize = sizeof(mbi);
	GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
	ymenu = (mbi.rcBar.bottom - mbi.rcBar.top + 1);

	/* Get the size of the caption bar */
	ycaption = GetSystemMetrics(SM_CYCAPTION);

	/* Calculate the minimum size in pixels */
	_minWidth = (xborder + minWidth + xborder);
	_minHeight = (ycaption + yborder + ymenu + minHeight + yborder);

	/* Clamp the size to the minimum size (256x384) */
	rect->right = (rect->left + std::max(_minWidth, (int)(rect->right - rect->left)));
	rect->bottom = (rect->top + std::max(_minHeight, (int)(rect->bottom - rect->top)));

	/* Apply the ratio stuff */
	if(keepRatio)
	{
		switch(wParam)
		{
		case WMSZ_LEFT:
		case WMSZ_RIGHT:
		case WMSZ_TOPLEFT:
		case WMSZ_TOPRIGHT:
		case WMSZ_BOTTOMLEFT:
		case WMSZ_BOTTOMRIGHT:
			{
				float ratio = ((rect->right - rect->left - xborder - xborder) / (float)minWidth);
				rect->bottom = (rect->top + ycaption + yborder + ymenu + (minHeight * ratio) + yborder);
			}
			break;
				
		case WMSZ_TOP:
		case WMSZ_BOTTOM:
			{
				float ratio = ((rect->bottom - rect->top - ycaption - yborder - ymenu - yborder) / (float)minHeight);
				rect->right = (rect->left + xborder + (minWidth * ratio) + xborder);
			}
			break;
		}
	}

	/* Check if the height of the menu has changed during the resize */
	ZeroMemory(&mbi, sizeof(mbi));
	mbi.cbSize = sizeof(mbi);
	GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi);
	ymenunew = (mbi.rcBar.bottom - mbi.rcBar.top + 1);

	if(ymenunew != ymenu)
		rect->bottom += (ymenunew - ymenu);
}