bool CASW_Weapon_Sniper_Rifle::ShouldMarineMoveSlow()
{
	return (gpGlobals->curtime < m_fSlowTime) || IsZoomed();
}
//-------------------------------------------------------------------------
bool CWeapon::OnActionModify(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if (IsZoomed() || IsZoomingInOrOut())
		return false;

	if (CanModify() && ((!IsReloading() && !IsBusy()) || AreAnyItemFlagsSet(eIF_Modifying)))
	{
		if (m_fm)
			m_fm->StopFire();

		if (AreAnyItemFlagsSet(eIF_Modifying))
		{
			m_enterModifyAction = 0;
			PlayAction(GetFragmentIds().leave_modify, 0);
			s_dofSpeed = fres(-g_pGameCVars->i_weapon_customisation_transition_time);
			s_dofValue = 1.0f;
			s_focusValue = -1.0f;

			GetScheduler()->TimerAction(g_pGameCVars->i_weapon_customisation_transition_time, CSchedulerAction<ScheduleLayer_Leave>::Create(this), false);

			SetItemFlags( eIF_Transitioning );
			ClearItemFlags( eIF_Modifying );

			GetGameObject()->InvokeRMI(CItem::SvRequestLeaveModify(), CItem::EmptyParams(), eRMI_ToServer);
		}
		else
		{
			gEnv->p3DEngine->SetPostEffectParam("Dof_Active", 1.0f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_UseMask", 0.f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusRange", -1.f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMin", 0.5f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMax", 1.0f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusLimit", 1.5f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMinZ", 0.0f);
			gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMinZScale", 0.0f);

			m_itemLowerMode = eILM_Raised;

			TagState tagState = TAG_STATE_EMPTY;
			m_enterModifyAction = new CItemAction(PP_PlayerAction, GetFragmentIds().enter_modify, tagState);
			PlayFragment(m_enterModifyAction);
			s_dofSpeed = fres(g_pGameCVars->i_weapon_customisation_transition_time);
			s_dofValue = 0.0f;

			SetItemFlags(eIF_Transitioning);

			GetScheduler()->TimerAction(g_pGameCVars->i_weapon_customisation_transition_time, CSchedulerAction<ScheduleLayer_Enter>::Create(this), false);
			
			SetItemFlags(eIF_Modifying);

			CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor());
			if (pPlayer)
			{
				SPlayerStats *pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats());
				assert(pStats);
				pStats->bIgnoreSprinting = true;
			}

			GetGameObject()->InvokeRMI(CItem::SvRequestEnterModify(), CItem::EmptyParams(), eRMI_ToServer);
		}
	}

	return true;
}
Beispiel #3
0
LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam)
{
	switch (uMsg)
	{
	case WM_CREATE:
	{
		//record class for future usage
		LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
		CMainGui * _this = (CMainGui *)lpcs->lpCreateParams;
		SetProp((HWND)hWnd, "Class", _this);

		_this->m_hMainWindow = hWnd;
		_this->CreateStatusBar();

		//Move the Main window to the location last executed from or center the window
		int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2;
		int	Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2;

		g_Settings->LoadDword(UserInterface_MainWindowTop, (uint32_t &)Y);
		g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X);

		_this->SetPos(X, Y);

		_this->ChangeWinSize(640, 480);
	}
	break;
	case WM_SYSCOMMAND:
		switch (wParam) {
		case SC_SCREENSAVE:
		case SC_MONITORPOWER:
		{
			CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
			if (_this &&
				_this->bCPURunning() &&
				!g_Settings->LoadBool(GameRunning_CPU_Paused) &&
				g_Settings->LoadDword(Setting_DisableScrSaver))
			{
				return 0;
			}
		}
		break;
		case SC_MAXIMIZE:
		{
			CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
			if (_this)
			{
				if (_this->RomBrowserVisible())
				{
					_this->RomBrowserMaximize(true);
				}
			}
		}
		break;
		}
		return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam);
		break;
	case WM_MOVE:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");

		if (!_this->m_bMainWindow ||
			!_this->m_Created ||
			_this->m_AttachingMenu ||
			_this->m_MakingVisible ||
			IsIconic((HWND)hWnd) ||
			_this->ShowingRomBrowser())
		{
			break;
		}

		if (IsZoomed((HWND)hWnd))
		{
			if (_this->RomBrowserVisible())
			{
				// save that browser is maximized
			}
			break;
		}

		//get the current position of the window
		RECT WinRect;
		GetWindowRect((HWND)hWnd, &WinRect);

		//save the location of the window
		if (_this->RomBrowserVisible())
		{
			_this->m_SaveRomBrowserPos = true;
			_this->m_SaveRomBrowserTop = WinRect.top;
			_this->m_SaveRomBrowserLeft = WinRect.left;
		}
		else
		{
			_this->m_SaveMainWindowPos = true;
			_this->m_SaveMainWindowTop = WinRect.top;
			_this->m_SaveMainWindowLeft = WinRect.left;
		}
		KillTimer(hWnd, Timer_SetWindowPos);
		SetTimer(hWnd, Timer_SetWindowPos, 1000, NULL);
	}
	if (CGuiSettings::bCPURunning() && g_BaseSystem)
	{
		if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen)
		{
			WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting");
			g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam));
			WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done");
		}
	}
	break;
	case WM_TIMER:
		if (wParam == Timer_SetWindowPos)
		{
			KillTimer(hWnd, Timer_SetWindowPos);
			CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
			_this->SaveWindowLoc();
			break;
		}
		break;
	case WM_SIZE:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		if (_this) { _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam)); }
		if (_this)
		{
			if (wParam == SIZE_MAXIMIZED)
			{
				if (_this->RomBrowserVisible())
				{
					_this->RomBrowserMaximize(true);
				}
			}
			_this->ResizeRomList(LOWORD(lParam), HIWORD(lParam));
		}
		if (_this)
		{
			if (wParam == SIZE_RESTORED && _this->RomBrowserVisible())
			{
				_this->RomBrowserMaximize(false);
			}
		}
	}
	break;
	case WM_NOTIFY:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		if (_this)
		{
			if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam, lParam))
			{
				return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam);
			}
		}
	}
	break;
	case WM_DRAWITEM:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		if (_this)
		{
			if (!_this->RomListDrawItem(wParam, lParam))
			{
				return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam);
			}
		}
	}
	break;
	case WM_PAINT:
	{
		//			CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class");
		//			CN64System * System  = _this->m_System;

		//			if (bCPURunning() && Settings->Load(CPU_Paused)) {
		//				CPlugins * Plugins = System->Plugins();
		//				if (Plugins->Gfx()->DrawScreen) {
		//					Plugins->Gfx()->DrawScreen();
		//				}
		//			}
		ValidateRect((HWND)hWnd, NULL);
	}
	break;
	case WM_KEYUP:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");

		if (_this->m_bMainWindow && bCPURunning())
		{
			if (g_BaseSystem)
			{
				if (g_Plugins && g_Plugins->Control()->WM_KeyUp) {
					g_Plugins->Control()->WM_KeyUp(wParam, lParam);
				}
			}
		}
	}
	break;
	case WM_KEYDOWN:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");

		if (_this->m_bMainWindow && bCPURunning())
		{
			if (g_BaseSystem)
			{
				if (g_Plugins && g_Plugins->Control()->WM_KeyDown)
				{
					g_Plugins->Control()->WM_KeyDown(wParam, lParam);
				}
			}
		}
	}
	break;
	case WM_SETFOCUS:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		if (_this->RomBrowserVisible())
		{
			PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0);
			break;
		}

		if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
		{
			if (g_BaseSystem)
			{
				g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus);
			}
		}
	}
	break;
	case WM_KILLFOCUS:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		if (_this->RomBrowserVisible())
		{
			break;
		}

		if (_this->m_bMainWindow && bCPURunning() && bAutoSleep())
		{
			if (g_BaseSystem)
			{
				g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus);
			}
		}
	}
	break;
	case WM_ACTIVATEAPP:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		DWORD fActive = (BOOL)wParam;

		if (fActive && _this->RomBrowserVisible())
		{
			PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0);
		}
		if (_this->m_bMainWindow && bCPURunning())
		{
			if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen))
			{
				Notify().WindowMode();
				if (bAutoSleep() && g_BaseSystem)
				{
					//System->ExternalEvent(PauseCPU_AppLostActiveDelayed );
				}
				break;
			}
			if (bAutoSleep() || fActive)
			{
				if (g_BaseSystem)
				{
					g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive);
				}
			}
		}
	}
	break;
	case WM_HIDE_CUROSR:
		if (!wParam)
		{
			while (ShowCursor(FALSE) >= 0) { Sleep(0); }
		}
		else
		{
			while (ShowCursor(TRUE) < 0) { Sleep(0); }
		}
		break;
	case WM_MAKE_FOCUS:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		_this->BringToTop();
	}
	break;
	case WM_BORWSER_TOP:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		_this->RomBrowserToTop();
	}
	break;
	case WM_RESET_PLUGIN:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		if (_this->m_ResetInfo != NULL)
		{
			g_Notify->BreakPoint(__FILEW__, __LINE__);
		}
		_this->m_ResetInfo = (RESET_PLUGIN *)lParam;
		_this->m_ResetPlugins = true;
	}
	break;
	case WM_COMMAND:
	{
		CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
		if (_this == NULL) { break; }

		switch (LOWORD(wParam)) {
		case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break;
		case ID_POPUPMENU_ROMDIRECTORY:   _this->SelectRomDir(); break;
		case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break;
		case ID_POPUPMENU_ROMINFORMATION:
		{
			RomInformation Info(_this->CurrentedSelectedRom());
			Info.DisplayInformation(hWnd);
		}
		break;
		case ID_POPUPMENU_EDITSETTINGS:
		case ID_POPUPMENU_EDITCHEATS:
		{
			CN64Rom Rom;
			Rom.LoadN64Image(_this->CurrentedSelectedRom(), true);
			Rom.SaveRomSettingID(true);

			if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
			{
				CSettingConfig SettingConfig(true);
				SettingConfig.Display(hWnd);
			}

			if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
			{
				CCheatsUI * cheatUI = new CCheatsUI;
				g_cheatUI = cheatUI;
				cheatUI->SelectCheats(hWnd, true);
				if (g_cheatUI == cheatUI)
				{
					g_cheatUI = NULL;
				}
			}

			if (g_Rom)
			{
				g_Rom->SaveRomSettingID(false);
			}
			else
			{
				Rom.ClearRomSettingID();
			}
		}
		break;
		default:
			if (_this->m_Menu)
			{
				if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100)
				{
					if (g_Plugins->RSP())
					{
						g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam));
					}
				}
				else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200)
				{
					if (g_Plugins->Gfx())
					{
						WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting");
						g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam));
						WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done");
					}
				}
				else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300)
				{
					if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL)
					{
						CN64Rom Rom;
						if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true))
						{
							break;
						}
						Rom.SaveRomSettingID(true);
						g_Notify->DisplayMessage(0, L"");
						BYTE * RomHeader = Rom.GetRomAddress();
						WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Starting");
						g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader);
						WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Done");
						if (g_Rom)
						{
							g_Rom->SaveRomSettingID(false);
						}
						else
						{
							g_Settings->SaveString(Game_IniKey, "");
						}
					}
				}
				else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam)))
				{
					return true;
				}
			}
		}
	}
	break;
	case WM_DROPFILES:
	{
		char filename[MAX_PATH];

		HDROP hDrop = (HDROP)wParam;
		DragQueryFile(hDrop, 0, filename, sizeof(filename));
		DragFinish(hDrop);

		CN64System::RunFileImage(filename);
	}
	break;
	case WM_DESTROY:
		WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - start");
		{
			CMainGui   * _this = (CMainGui *)GetProp((HWND)hWnd, "Class");
			if (_this->m_bMainWindow)
			{
				Notify().WindowMode();
			}
			_this->m_hMainWindow = NULL;
			WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 1");
			if (_this->m_bMainWindow)
			{
				_this->SaveRomListColoumnInfo();
				WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 2");
				_this->SaveWindowLoc();
			}
		}
		WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 3");
		RemoveProp((HWND)hWnd, "Class");
		WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 4");
		PostQuitMessage(0);
		WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - Done");
		break;
	default:
		return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam);
	}
	return TRUE;
}
Beispiel #4
0
void InitConsole(int FirstInit)
{
    InitRecodeOutTable();

    if (FirstInit)
    {
        CancelIoInProgress = std::make_unique<DECLTYPE(CancelIoInProgress)::element_type>();
        CancelIoInProgress->Open(true);

        DWORD Mode;
        if(!Global->Console->GetMode(Global->Console->GetInputHandle(), Mode))
        {
            HANDLE ConIn = CreateFile(L"CONIN$", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
            SetStdHandle(STD_INPUT_HANDLE, ConIn);
        }
        if(!Global->Console->GetMode(Global->Console->GetOutputHandle(), Mode))
        {
            HANDLE ConOut = CreateFile(L"CONOUT$", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
            SetStdHandle(STD_OUTPUT_HANDLE, ConOut);
            SetStdHandle(STD_ERROR_HANDLE, ConOut);
        }
    }

    Global->Console->SetControlHandler(CtrlHandler, true);
    Global->Console->GetMode(Global->Console->GetInputHandle(),InitialConsoleMode);
    Global->Console->GetTitle(Global->strInitTitle);
    Global->Console->GetWindowRect(InitWindowRect);
    Global->Console->GetSize(InitialSize);
    Global->Console->GetCursorInfo(InitialCursorInfo);

    // размер клавиатурной очереди = 1024 кода клавиши
    if (!KeyQueue)
        KeyQueue = std::make_unique<DECLTYPE(KeyQueue)::element_type>();

    SetFarConsoleMode();

    /* $ 09.04.2002 DJ
       если размер консольного буфера больше размера окна, выставим
       их равными
    */
    if (FirstInit)
    {
        SMALL_RECT WindowRect;
        Global->Console->GetWindowRect(WindowRect);
        Global->Console->GetSize(InitSize);

        if(Global->Opt->WindowMode)
        {
            Global->Console->ResetPosition();
        }
        else
        {
            if (WindowRect.Left || WindowRect.Top || WindowRect.Right != InitSize.X-1 || WindowRect.Bottom != InitSize.Y-1)
            {
                COORD newSize;
                newSize.X = WindowRect.Right - WindowRect.Left + 1;
                newSize.Y = WindowRect.Bottom - WindowRect.Top + 1;
                Global->Console->SetSize(newSize);
                Global->Console->GetSize(InitSize);
            }
        }
        if (IsZoomed(Global->Console->GetWindow()))
            ChangeVideoMode(1);
    }

    GetVideoMode(CurSize);
    Global->ScrBuf->FillBuf();

    Global->ConsoleIcons->setFarIcons();
}
Beispiel #5
0
SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	SDL_Surface *video;
	Uint32 prev_flags;
	DWORD style;
	const DWORD directstyle =
			(WS_POPUP);
	const DWORD windowstyle = 
			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
	const DWORD resizestyle =
			(WS_THICKFRAME|WS_MAXIMIZEBOX);

	
	int x, y;
	BOOL was_visible;
	Uint32 Rmask, Gmask, Bmask;


#ifdef HAVE_OPENGL //maks
	/* Clean up any GL context that may be hanging around */
	if ( current->flags & SDL_OPENGL ) { //maks: close only in video quit to avoid texture lost when go to game mode
		WIN_GL_ShutDown(this);
	}
#endif	
	

#ifdef _USE_POCKET_HAL_

	halWidth = width;
	halHeight = height;

	//Don't use GAPI or PocketHAL with OpenGL
	//Hybrid will show a blank screen
	OpenGAPI(1);	//Can open PocketHAL in Intel 2700G

	//Go to the game, monitor task bar
	HookTaskBar();

	/*if( flags & SDL_FULLSCREEN ) 
	{
		//maks: native resolution only		
		//Causes "Error - not enough memory to execute the game"
		halGetDimensions(&width, &height);
	}*/

	/* Recalculate the bitmasks if necessary */
	if ( bpp == current->format->BitsPerPixel ) 
	{
		video = current;
	} 
	else 
	{
		bpp = 16;		
		
		/* 5-6-5 */
		Rmask = 0x0000f800;
		Gmask = 0x000007e0;
		Bmask = 0x0000001f;	
		
		
		video = SDL_CreateRGBSurface(SDL_SWSURFACE,
					0, 0, bpp, Rmask, Gmask, Bmask, 0);

		if ( video == NULL ) 
		{
			SDL_OutOfMemory();
			return(NULL);
		}
	}
	
#else

	int m_nXPitch, m_nYPitch;
	GXDisplayProperties m_dispProps = GXGetDisplayProperties();

	m_nXPitch = m_dispProps.cbxPitch >> 1;
	m_nYPitch = m_dispProps.cbyPitch >> 1;

	if (m_nXPitch < 0)
	{
		this->hidden->m_nBufferStartOffset = m_nXPitch * (m_dispProps.cxWidth - 1);
	}
	else
	{
		this->hidden->m_nBufferEndOffset = m_nXPitch * (m_dispProps.cxWidth - 1);
	}

	if (m_nYPitch < 0)
	{
		this->hidden->m_nBufferStartOffset += m_nYPitch * (m_dispProps.cyHeight - 1);
	}
	else
	{
		this->hidden->m_nBufferEndOffset += m_nYPitch * (m_dispProps.cyHeight - 1);
	}

	

	
	

	/* Recalculate the bitmasks if necessary */
	if ( bpp == current->format->BitsPerPixel ) 
	{
		video = current;
	} 
	else 
	{
		bpp = m_dispProps.cBPP;		
		
		if(m_dispProps.ffFormat | kfDirect565)
		{
			/* 5-6-5 */
			Rmask = 0x0000f800;
			Gmask = 0x000007e0;
			Bmask = 0x0000001f;
		}
		else if(m_dispProps.ffFormat | kfDirect555)
		{
			/* 5-5-5 */
			Rmask = 0x00007c00;
			Gmask = 0x000003e0;
			Bmask = 0x0000001f;
		}
		else if(m_dispProps.ffFormat | kfDirect888)
		{
			/* 8-8-8 */
			Rmask = 0x00ff0000;
			Gmask = 0x0000ff00;
			Bmask = 0x000000ff;
		}
			
		video = SDL_CreateRGBSurface(SDL_SWSURFACE,
					0, 0, bpp, Rmask, Gmask, Bmask, 0);

		if ( video == NULL ) 
		{
			SDL_OutOfMemory();
			return(NULL);
		}
	}

	if( flags & SDL_FULLSCREEN ) 
	{
		//maks: native resolution only
		width  = m_dispProps.cxWidth;
		height = m_dispProps.cyHeight;
	}
#endif //_USE_POCKET_HAL_


	/* See whether or not we should center the window */
	was_visible = IsWindowVisible(SDL_Window);

	/* Fill in part of the video surface */
	prev_flags = video->flags;
	video->flags = 0;	/* Clear flags */
	video->w = width;
	video->h = height;
	video->pitch = SDL_CalculatePitch(video);

	 /* Stuff to hide that $#!^%#$ WinCE taskbar in fullscreen... */
	if ( flags & SDL_FULLSCREEN ) 
	{
		if ( !(prev_flags & SDL_FULLSCREEN) )
		{
			SHFullScreen(SDL_Window, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);			
			bShowTaskBar = 0;
		}
		video->flags |= SDL_FULLSCREEN;
	} 
	else 
	{
		if ( prev_flags & SDL_FULLSCREEN ) 
		{
			SHFullScreen(SDL_Window, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
			bShowTaskBar = 1;
		}
	}



#ifndef NO_CHANGEDISPLAYSETTINGS
	/* Set fullscreen mode if appropriate */
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		DEVMODE settings;

		memset(&settings, 0, sizeof(DEVMODE));
		settings.dmSize = sizeof(DEVMODE);
		settings.dmBitsPerPel = video->format->BitsPerPixel;
		settings.dmPelsWidth = width;
		settings.dmPelsHeight = height;
		settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
		if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
			video->flags |= SDL_FULLSCREEN;
			SDL_fullscreen_mode = settings;
		}
	}
#endif /* !NO_CHANGEDISPLAYSETTINGS */

	
	

	style = GetWindowLong(SDL_Window, GWL_STYLE);
	style &= ~(resizestyle|WS_MAXIMIZE);

	if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) 
	{
		style &= ~windowstyle;
		style |= directstyle;
	} 
	else 
	{
#ifndef NO_CHANGEDISPLAYSETTINGS
		if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) 
		{
			ChangeDisplaySettings(NULL, 0);
		}
#endif
		if ( flags & SDL_NOFRAME ) 
		{
			style &= ~windowstyle;
			style |= directstyle;
			video->flags |= SDL_NOFRAME;
		} 
		else 
		{
			style &= ~directstyle;
			style |= windowstyle;

			if ( flags & SDL_RESIZABLE ) 
			{
				style |= resizestyle;
				video->flags |= SDL_RESIZABLE;
			}
		}
#if WS_MAXIMIZE
		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif
	}

	/* DJM: Don't piss of anyone who has setup his own window */
	if (!SDL_windowid)
		SetWindowLong(SDL_Window, GWL_STYLE, style);	
	

	/* Resize the window */
	if ( SDL_windowid == NULL ) 
	{
		
		HWND top;
		UINT swp_flags;
		//RECT bounds; //Aways full screen, don't need calculate the bounds

		int realW = width, realH = height, screenW, screenH;

		GetPokcetPCScreenDimensions(&screenW, &screenH);

		if(width > height && screenW < screenH)
		{
			//Rotate
			realW = height;
			realH = width;
		}

		SDL_resizing = 1;
		/*bounds.left = 0;
		bounds.top = 0;
		bounds.right = realW;
		bounds.bottom = realH;
		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0); //If need to use, consider the system screen rotation
		realW = bounds.right-bounds.left;
		realH = bounds.bottom-bounds.top;*/
		x = (screenW-realW)/2;
		y = (screenH-realH)/2;


		//if(x < 0 || y < 0) //maks: to avoid crash when run a 480x640 game in a 240x320 device
		if((realW != screenW && 2*realW != screenW) ||
		   (realH != screenH && 2*realH != screenH)) 
		{
			//maks: Avoid a game running in a different system resolution,
			//but can 240x320 in a 480x640 device
			CloseGAPI();
			return NULL;
		}

	   

		if ( y < 0 ) { /* Cover up title bar for more client area */
			y -= GetSystemMetrics(SM_CYCAPTION)/2;
		}
		swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
		if ( was_visible && !(flags & SDL_FULLSCREEN) ) {
			swp_flags |= SWP_NOMOVE;
		}
		if ( flags & SDL_FULLSCREEN ) {
			top = HWND_TOPMOST;
		} else {
			top = HWND_NOTOPMOST;
		}

		sdlWindowSize.left = x;
		sdlWindowSize.top = y;
		sdlWindowSize.right = realW;
		sdlWindowSize.bottom = realH;

		SetWindowPos(SDL_Window, top, x, y, realW, realH, swp_flags);
		SDL_resizing = 0;
		SetForegroundWindow(SDL_Window);
	}

	/* If not fullscreen, locking is possible, but it doesn't do what 
	   the caller really expects -- if the locked surface is written to,
	   the appropriate portion of the entire screen is modified, not 
	   the application window, as we would like.
	   Note that it is still possible to write directly to display
	   memory, but the application must respect the clip list of
	   the surface.  There might be some odd timing interactions
	   involving clip list updates and background refreshing as
	   Windows moves other windows across our window.
	   We currently don't support this, even though it might be a
	   good idea since BeOS has an implementation of BDirectWindow
	   that does the same thing.  This would be most useful for
	   applications that do complete screen updates every frame.
	    -- Fixme?
	*/


	if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
		/* Necessary if we're going from fullscreen to window */
		#if 0
		if ( video->pixels == NULL ) {
			video->pitch = (width*video->format->BytesPerPixel);
			/* Pitch needs to be QWORD (8-byte) aligned */
			video->pitch = (video->pitch + 7) & ~7;
			video->pixels = (void *)malloc(video->h*video->pitch);
			if ( video->pixels == NULL ) {
				if ( video != current ) {
					SDL_FreeSurface(video);
				}
				SDL_OutOfMemory();
				return(NULL);
			}
		}
		#endif



		
//#if 0 /* FIXME: enable this when SDL consistently reports lost surfaces */
		if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
			video->flags |= SDL_HWSURFACE;
		} else {
			video->flags |= SDL_SWSURFACE;
		}
/*#else
		video->flags |= SDL_SWSURFACE;
#endif*/
		if ( (flags & SDL_RESIZABLE) && !(flags & SDL_NOFRAME) ) {
			video->flags |= SDL_RESIZABLE;
		}
		if ( flags & SDL_NOFRAME ) {
			video->flags |= SDL_NOFRAME;
		}
	} else {
		/* Necessary if we're going from window to fullscreen */
		if ( video->pixels != NULL ) {
			free(video->pixels);
			video->pixels = NULL;
		}
		
		video->flags |= SDL_HWSURFACE;
	}


#ifndef _USE_POCKET_HAL_
	backBuferSize = (this->hidden->m_nBufferEndOffset - this->hidden->m_nBufferStartOffset + 1)*2;
	if(!OpenGAPI((video->flags & SDL_FULLSCREEN)?1:0))
	{
		if ( video != current ) 
		{
			SDL_FreeSurface(video);
		}
		SDL_SetError("Couldn't open GAPI");
		
		return NULL;
	}

	//Go to the game, monitor task bar
	HookTaskBar();

#endif //_USE_POCKET_HAL_

#ifdef HAVE_OPENGL
	/* Set up for OpenGL */
	if ( flags & SDL_OPENGL ) 
	{
		if ( WIN_GL_SetupWindow(this) >= 0 )
		{
			video->flags |= SDL_OPENGL;
		}
	}
#endif

	/* We're live! */
	videoSurface = video;
	return(video);
}
BOOL CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	DWORD ws;
	struct ParentWindowData *dat;
	dat = (struct ParentWindowData *) GetWindowLong(hwndDlg, GWL_USERDATA);
	if (!dat && msg!=WM_INITDIALOG) return FALSE;
	switch (msg) {
	case WM_INITDIALOG:
		{
			struct NewMessageWindowLParam *newData = (struct NewMessageWindowLParam *) lParam;
			dat = (struct ParentWindowData *) malloc(sizeof(struct ParentWindowData));
			dat->foregroundWindow = GetForegroundWindow();
			dat->hContact = newData->hContact;
			dat->nFlash = 0;
			dat->nFlashMax = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_FLASHCOUNT, SRMSGDEFSET_FLASHCOUNT);
			dat->childrenCount = 0;
			dat->children = NULL;
			dat->hwnd = hwndDlg;
			dat->flags = g_dat->flags;// | SMF_SHOWTITLEBAR;
			dat->mouseLBDown = 0;
			dat->windowWasCascaded = 0;
			dat->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwndDlg, NULL, g_hInst, NULL);
			{
				int statwidths[4];
				RECT rc;
				SendMessage(dat->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0);
				GetWindowRect(dat->hwndStatus, &rc);
				/*
				statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH - SB_SENDING_WIDTH;
				statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH - SB_SENDING_WIDTH; //rc.right - rc.left - SB_CHAR_WIDTH;
				statwidths[2] = rc.right - rc.left - SB_TYPING_WIDTH; //rc.right - rc.left - SB_CHAR_WIDTH;
				statwidths[3] = -1;
				SendMessage(dat->hwndStatus, SB_SETPARTS, 4, (LPARAM) statwidths);
				*/
				statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH;
				statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH;
				statwidths[2] = -1;
				SendMessage(dat->hwndStatus, SB_SETPARTS, 3, (LPARAM) statwidths);
			}
			dat->hwndTabs = GetDlgItem(hwndDlg, IDC_TABS);
			dat->hwndActive = NULL;
			SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) dat);
			if (g_dat->hIconList != NULL) {
				TabCtrl_SetImageList(dat->hwndTabs, g_dat->hIconList);
			}
			WindowList_Add(g_dat->hParentWindowList, hwndDlg, 0);
			dat->tabCtrlDat = (struct TabCtrlData *) malloc(sizeof(struct TabCtrlData));
			dat->tabCtrlDat->bDragging = FALSE;
			SetWindowLong(dat->hwndTabs, GWL_USERDATA, (LONG) dat->tabCtrlDat);
			OldTabCtrlProc = (WNDPROC) SetWindowLong(dat->hwndTabs, GWL_WNDPROC, (LONG) TabCtrlProc);
			ws = GetWindowLong(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM);
			if (dat->flags & SMF_TABSATBOTTOM) {
				ws |= TCS_BOTTOM;
			}
			SetWindowLong(dat->hwndTabs, GWL_STYLE, ws);
			ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION);
			if (dat->flags & SMF_SHOWTITLEBAR) {
				ws |= WS_CAPTION;
				SetWindowLong(hwndDlg, GWL_STYLE, ws);
			} else {
				RECT rc;
				SetWindowLong(hwndDlg, GWL_STYLE, ws);
				GetWindowRect(hwndDlg, &rc);
				SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
							 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER  | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
			}
			ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED;
			ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0;
			SetWindowLong(hwndDlg , GWL_EXSTYLE , ws);
			if (dat->flags & SMF_USETRANSPARENCY) {
   				pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA);
//				RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
			}
			//SetWindowPos(dat->hwndTabs, 0, 0, -10, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
			if (!(dat->flags & SMF_SHOWSTATUSBAR)) {
				ShowWindow(dat->hwndStatus, SW_HIDE);
			}
			if (dat->flags & SMF_USETABS) {
				if (ScriverRestoreWindowPosition(hwndDlg, NULL, SRMMMOD, "", 0, SW_HIDE)) {
					SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE  | SWP_HIDEWINDOW);
				}
			} else {
				int savePerContact = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT);
				if (ScriverRestoreWindowPosition(hwndDlg, savePerContact ? dat->hContact : NULL, SRMMMOD, "", 0, SW_HIDE)) {
				//if (Utils_RestoreWindowPosition(GetParent(hwndDlg), savePerContact ? dat->hContact : NULL, SRMMMOD, "")) {
					if (savePerContact) {
						if (ScriverRestoreWindowPosition(hwndDlg, NULL, SRMMMOD, "", RWPF_NOSIZE, SW_HIDE))
					//	if (Utils_RestoreWindowPositionNoMove(GetParent(hwndDlg), NULL, SRMMMOD, ""))
						SetWindowPos(GetParent(hwndDlg), 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE);
					}
					else
						SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE);
				}
				if (!savePerContact && DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_CASCADE, SRMSGDEFSET_CASCADE))
					WindowList_Broadcast(g_dat->hParentWindowList, DM_CASCADENEWWINDOW, (WPARAM) hwndDlg, (LPARAM) & dat->windowWasCascaded);
			}
		}
		return TRUE;
	case WM_GETMINMAXINFO:
	{
		MINMAXINFO *mmi = (MINMAXINFO *) lParam;
		SIZE size;
		if (GetKeyState(VK_CONTROL) & 0x8000) {
			WINDOWPLACEMENT wp;
			RECT rcDesktop;
			wp.length = sizeof(wp);
			GetWindowPlacement(hwndDlg, &wp);
			SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0);
			mmi->ptMaxSize.x = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
			mmi->ptMaxSize.y = rcDesktop.bottom - rcDesktop.top;
			mmi->ptMaxPosition.x = wp.rcNormalPosition.left;
			if(IsIconic(hwndDlg)) {
				mmi->ptMaxPosition.y = rcDesktop.top;
			} else {
				mmi->ptMaxPosition.y = 0;
			}
		}
		GetMinimunWindowSize(dat, &size);
		mmi->ptMinTrackSize.x = size.cx;
		mmi->ptMinTrackSize.y = size.cy;
		return FALSE;
	}

	case WM_SIZE:
		if (wParam == SIZE_MINIMIZED) {
			dat->bMinimized = 1;

		}
		if (IsIconic(hwndDlg))	{
			MoveWindow(dat->hwndActive, dat->childRect.left, dat->childRect.top, dat->childRect.right-dat->childRect.left, dat->childRect.bottom - dat->childRect.top, TRUE);
		} else {
//		}
//		if (!IsIconic(hwndDlg)) {
			int i;
			RECT rc, rcStatus, rcChild, rcWindow;
			SIZE size;
			dat->bMinimized = 0;
			GetClientRect(hwndDlg, &rc);
			GetWindowRect(hwndDlg, &rcWindow);
			rcStatus.top = rcStatus.bottom = 0;
			if (dat->flags & SMF_SHOWSTATUSBAR) {
				int statwidths[4];
				GetWindowRect(dat->hwndStatus, &rcStatus);
				statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH;
				statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH;
				statwidths[2] = -1;
				SendMessage(dat->hwndStatus, SB_SETPARTS, 3, (LPARAM) statwidths);
				SendMessage(dat->hwndStatus, WM_SIZE, 0, 0);
			}
			MoveWindow(dat->hwndTabs, 0, 2, (rc.right - rc.left), (rc.bottom - rc.top) - (rcStatus.bottom - rcStatus.top) - 2,	FALSE);
			RedrawWindow(dat->hwndTabs, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE);
			GetMinimunWindowSize(dat, &size);
			if ((rcWindow.bottom-rcWindow.top) < size.cy || (rcWindow.right-rcWindow.left) < size.cx) {
				if ((rcWindow.bottom-rcWindow.top) < size.cy) {
					rcWindow.bottom = rcWindow.top + size.cy;
				}
				if ((rcWindow.right-rcWindow.left) < size.cx) {
					rcWindow.right = rcWindow.left + size.cx;
				}
				MoveWindow(hwndDlg, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top,	TRUE);
			}
			GetChildWindowRect(dat, &rcChild);
			memcpy(&dat->childRect, &rcChild, sizeof(RECT));
			for (i=0;i<dat->childrenCount;i++) {
				if (dat->children[i] == dat->hwndActive) {
					MoveWindow(dat->children[i], rcChild.left, rcChild.top, rcChild.right-rcChild.left, rcChild.bottom - rcChild.top, TRUE);
					RedrawWindow(GetDlgItem(dat->children[i], IDC_LOG), NULL, NULL, RDW_INVALIDATE);
				}
			}
			if (dat->flags & SMF_SHOWSTATUSBAR) {
				RedrawWindow(dat->hwndStatus, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
			}
		}
		return FALSE;
	case WM_SETFOCUS:
		if (dat->hwndActive != NULL) {
			SetFocus(dat->hwndActive);
		}
		return TRUE;
	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		return TRUE;
	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDCANCEL:
			//DestroyWindow(hwndDlg);
			return TRUE;
		}
	case WM_NOTIFY:
		{
			NMHDR* pNMHDR = (NMHDR*) lParam;
			if (pNMHDR->hwndFrom == dat->hwndTabs) {
				switch (pNMHDR->code) {
				case TCN_SELCHANGE:
					{
						TCITEM tci = {0};
						int iSel = TabCtrl_GetCurSel(dat->hwndTabs);
						tci.mask = TCIF_PARAM;
						if (TabCtrl_GetItem(dat->hwndTabs, iSel, &tci)) {
							struct MessageWindowData * mdat = (struct MessageWindowData *) tci.lParam;
							ActivateChild(dat, mdat->hwnd);
							SetFocus(dat->hwndActive);
						}
					}
					break;
				case NM_RCLICK:
					{
						TCHITTESTINFO thinfo;
						int tabId, x, y;
						GetCursorPos(&thinfo.pt);
						x = thinfo.pt.x;
						y = thinfo.pt.y;
						ScreenToClient(dat->hwndTabs, &thinfo.pt);
						tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo);
						if (tabId != -1) {
							struct MessageWindowData * mwd = GetChildFromTab(dat->hwndTabs, tabId);
							//CallService(MS_USERINFO_SHOWDIALOG, (WPARAM) mwd->hContact, 0);
							HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) mwd->hContact, 0);
							TrackPopupMenu(hMenu, 0, x, y, 0, mwd->hwnd, NULL);
							DestroyMenu(hMenu);
						}
					}
					break;
				}
			} else if (pNMHDR->hwndFrom == dat->hwndStatus)  {
				switch (pNMHDR->code) {
				case NM_CLICK:
					{
						NMMOUSE *nm=(NMMOUSE*)lParam;
						RECT rc;
						SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc);
						if (nm->pt.x >= rc.left)
							SendMessage(dat->hwndActive, DM_SWITCHUNICODE, 0, 0);
					}
				}
				break;
			}
		}
		break;
	case WM_DROPFILES:
		SendMessage(dat->hwndActive, WM_DROPFILES, wParam, lParam);
		break;
	case WM_TIMER:
		if (wParam == TIMERID_FLASHWND) {
			if ((dat->nFlash > dat->nFlashMax)) {// || ((GetActiveWindow() == hwndDlg) && (GetForegroundWindow() == hwndDlg))) {
				KillTimer(hwndDlg, TIMERID_FLASHWND);
				FlashWindow(hwndDlg, FALSE);
			} else if (dat->nFlash < dat->nFlashMax) {
				FlashWindow(hwndDlg, TRUE);
				dat->nFlash++;
			}
		}
		break;
	case WM_CONTEXTMENU:
	{
		if (dat->hwndStatus && dat->hwndStatus == (HWND) wParam) {
			RECT rc;
			POINT pt, pt2;
			GetCursorPos(&pt);
			pt2.x = pt.x;
			pt2.y = pt.y;
			ScreenToClient(dat->hwndStatus, &pt);
			SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc);
			if (pt.x >= rc.left && dat->hwndActive != NULL) {
				int codePage = (int) SendMessage(dat->hwndActive, DM_GETCODEPAGE, 0, 0);
				int i, iSel;
				for(i = 0; i < GetMenuItemCount(g_dat->hMenuANSIEncoding); i++) {
					CheckMenuItem (g_dat->hMenuANSIEncoding, i, MF_BYPOSITION | MF_UNCHECKED);
				}
				if(codePage == CP_ACP) {
					CheckMenuItem(g_dat->hMenuANSIEncoding, 0, MF_BYPOSITION | MF_CHECKED);
				} else {
					CheckMenuItem(g_dat->hMenuANSIEncoding, codePage, MF_BYCOMMAND | MF_CHECKED);
				}
				iSel = TrackPopupMenu(g_dat->hMenuANSIEncoding, TPM_RETURNCMD, pt2.x, pt2.y, 0, hwndDlg, NULL);
				if (iSel >= 500) {
					if (iSel == 500) iSel = CP_ACP;
					SendMessage(dat->hwndActive, DM_SETCODEPAGE, 0, iSel);
				}
			}
			else
				SendMessage(dat->hwndActive, WM_CONTEXTMENU, (WPARAM)hwndDlg, 0);
		}
		break;
	}

	case WM_ACTIVATE:
		if (LOWORD(wParam) == WA_INACTIVE) {
			ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED;
			ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0;
			SetWindowLong(hwndDlg , GWL_EXSTYLE , ws);
			if (dat->flags & SMF_USETRANSPARENCY) {
   				pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA);
//				RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
			}
		}
		if (LOWORD(wParam) != WA_ACTIVE)
			break;
		if (dat->hwndActive == NULL) { // do not set foreground window at all (always stay in the background !)
//			SendMessage(hwndDlg, DM_DEACTIVATE, 0, 0);
		} else {
			PostMessage(hwndDlg, WM_SETFOCUS, 0, 0);
		}
	case WM_MOUSEACTIVATE:
		if (KillTimer(hwndDlg, TIMERID_FLASHWND)) {
			FlashWindow(hwndDlg, FALSE);
			dat->nFlash = 0;
		}
		ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED;
		ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0;
		SetWindowLong(hwndDlg , GWL_EXSTYLE , ws);
		if (dat->flags & SMF_USETRANSPARENCY) {
   			pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->activeAlpha), LWA_ALPHA);
//				RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
		}
		break;
	case WM_LBUTTONDOWN:
		if (!IsZoomed(hwndDlg)) {
			POINT pt;
			GetCursorPos(&pt);
		//	dat->mouseLBDown = 1;
		//	GetCursorPos(&dat->mouseLBDownPos);
			return SendMessage(hwndDlg, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y));
		//	SetCapture(hwndDlg);
			
		}
		break;
	case WM_LBUTTONUP:
		//if (dat->mouseLBDown) {
		//	dat->mouseLBDown = 0;
		//	ReleaseCapture();
		//}
		break;
	case WM_MOUSEMOVE:/*
		if (dat->mouseLBDown) {
			POINT pt;
			RECT  rc;
			GetCursorPos(&pt);
			GetWindowRect(hwndDlg, &rc);
			SetWindowPos(hwndDlg, 0, rc.left - (dat->mouseLBDownPos.x - pt.x), rc.top - (dat->mouseLBDownPos.y - pt.y), 0, 0, SWP_NOZORDER | SWP_NOSIZE);
			dat->mouseLBDownPos = pt;
		}*/
		break;
	case WM_MOVING:
		{
			int snapPixels = 10;
			RECT rcDesktop;
			RECT *pRect = (RECT *)lParam;
			POINT pt;
			SIZE szSize = {pRect->right-pRect->left,pRect->bottom-pRect->top};
			GetCursorPos(&pt);
			SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0);			
			pRect->left = pt.x-dat->mouseLBDownPos.x;
			pRect->top = pt.y-dat->mouseLBDownPos.y;
			pRect->right = pRect->left+szSize.cx;
			pRect->bottom = pRect->top+szSize.cy;				
            if (!(GetAsyncKeyState(VK_CONTROL) & 0x8000)) {
				if(pRect->top < snapPixels && pRect->top > -snapPixels) {
					pRect->top = 0;
					pRect->bottom = szSize.cy;
				}
				if(pRect->left < snapPixels && pRect->left > -snapPixels) {
					pRect->left = 0;
					pRect->right = szSize.cx;
				}
				if(pRect->right < rcDesktop.right+snapPixels && pRect->right > rcDesktop.right-snapPixels) {
					pRect->right = rcDesktop.right;
					pRect->left = rcDesktop.right-szSize.cx;
				}
				if(pRect->bottom < rcDesktop.bottom+snapPixels && pRect->bottom > rcDesktop.bottom-snapPixels) {
					pRect->bottom = rcDesktop.bottom;
					pRect->top = rcDesktop.bottom-szSize.cy;
				}
			}
		}
		break;
	case WM_SYSCOMMAND:
		if ((wParam & 0xFFF0) == SC_MOVE) {
			RECT  rc;
			GetWindowRect(hwndDlg, &rc);
			dat->mouseLBDownPos.x = LOWORD(lParam) - rc.left;
			dat->mouseLBDownPos.y = HIWORD(lParam) - rc.top;
		}
		break;
	case WM_DESTROY:
		{
			g_dat->hParent = NULL;
			SetWindowLong(hwndDlg, GWL_USERDATA, 0);
			WindowList_Remove(g_dat->hParentWindowList, hwndDlg);
			if (dat->children!=NULL) free (dat->children);
			free(dat->tabCtrlDat);
			free(dat);
			if (dat->flags & SMF_USETABS) {
				WINDOWPLACEMENT wp = { 0 };
				wp.length = sizeof(wp);
				GetWindowPlacement(hwndDlg, &wp);
				DBWriteContactSettingDword(NULL, SRMMMOD, "x", wp.rcNormalPosition.left);
				DBWriteContactSettingDword(NULL, SRMMMOD, "y", wp.rcNormalPosition.top);
				DBWriteContactSettingDword(NULL, SRMMMOD, "width", wp.rcNormalPosition.right - wp.rcNormalPosition.left);
				DBWriteContactSettingDword(NULL, SRMMMOD, "height", wp.rcNormalPosition.bottom - wp.rcNormalPosition.top);
			} else {
				WINDOWPLACEMENT wp = { 0 };
				HANDLE hContact;
				if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT))
					hContact = dat->hContact;
				else
					hContact = NULL;
				wp.length = sizeof(wp);
				GetWindowPlacement(hwndDlg, &wp);
				if (!dat->windowWasCascaded) {
					DBWriteContactSettingDword(hContact, SRMMMOD, "x", wp.rcNormalPosition.left);
					DBWriteContactSettingDword(hContact, SRMMMOD, "y", wp.rcNormalPosition.top);
				}
				DBWriteContactSettingDword(hContact, SRMMMOD, "width", wp.rcNormalPosition.right - wp.rcNormalPosition.left);
				DBWriteContactSettingDword(hContact, SRMMMOD, "height", wp.rcNormalPosition.bottom - wp.rcNormalPosition.top);
			}

		}
		break;
	case DM_DEACTIVATE:
		SetForegroundWindow(dat->foregroundWindow);
		break;
	case DM_ERRORDECIDED:
		break;
	case DM_STARTFLASHING:
		if (GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg) {
			dat->nFlash = 0;
			SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL);
		}
		break;
	case DM_REMOVECHILD:
		{
			RemoveChild(dat, (HWND) lParam);
			if (dat->childrenCount != 0) {
				SetFocus(dat->hwndActive);
			} else {
				DestroyWindow(hwndDlg);
			}
		}
		return TRUE;
	case DM_ADDCHILD:
		{
			struct MessageWindowData * mdat = (struct MessageWindowData *) lParam;
			AddChild(dat, mdat);
		}
		return TRUE;
	case DM_ACTIVATECHILD:
		if((HWND) lParam != dat->hwndActive) {
			ActivateChild(dat, (HWND) lParam);
		}
		return TRUE;
	case DM_ACTIVATEPREV:
		ActivatePrevChild(dat, (HWND) lParam);
		SetFocus(dat->hwndActive);
		return TRUE;
	case DM_ACTIVATENEXT:
		ActivateNextChild(dat, (HWND) lParam);
		SetFocus(dat->hwndActive);
		return TRUE;
	case DM_SENDMESSAGE:
		{
			int i;
			for (i=0;i<dat->childrenCount;i++) {
				SendMessage(dat->children[i], DM_SENDMESSAGE, wParam, lParam);
			}
		}
		break;
	case DM_OPTIONSAPPLIED:
		{
			RECT rc;
			dat->flags = g_dat->flags;
			if (!(dat->flags & SMF_SHOWSTATUSBAR)) {
				ShowWindow(dat->hwndStatus, SW_HIDE);
			} else {
				ShowWindow(dat->hwndStatus, SW_SHOW);
			}
			ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION);
			if (dat->flags & SMF_SHOWTITLEBAR) {
				ws |= WS_CAPTION;
			}
			SetWindowLong(hwndDlg, GWL_STYLE, ws);

			ws = GetWindowLong(hwndDlg, GWL_EXSTYLE)& ~WS_EX_LAYERED;
			ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0;
			SetWindowLong(hwndDlg , GWL_EXSTYLE , ws);
			if (dat->flags & SMF_USETRANSPARENCY) {
   				pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA);
//				RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
			}

			ws = GetWindowLong(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM);
			if (dat->flags & SMF_TABSATBOTTOM) {
				ws |= TCS_BOTTOM;
			}
			SetWindowLong(dat->hwndTabs, GWL_STYLE, ws);
			RedrawWindow(dat->hwndTabs, NULL, NULL, RDW_INVALIDATE);
			GetWindowRect(hwndDlg, &rc);
			SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
                        SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
			SendMessage(hwndDlg, WM_SIZE, 0, 0);
			//RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
			break;
		}
	case DM_UPDATETITLE:
		{
			struct MessageWindowData * mdat = (struct MessageWindowData *) lParam;
			TCITEM tci;
			int tabId;
			TCHAR *tContactName;
			if (mdat && mdat->hwnd == dat->hwndActive) {
				TCHAR *newtitle, oldtitle[256];
#if defined ( _UNICODE )
				newtitle = GetWindowTitle(mdat->hContact, mdat->szProto);
#else
				newtitle = GetWindowTitle(mdat->hContact, mdat->szProto);
#endif
				GetWindowText(hwndDlg, oldtitle, sizeof(oldtitle));
				if (lstrcmp(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed
					SetWindowText(hwndDlg, newtitle);
					//SendMessage(hwndDlg, WM_SIZE, 0, 0);
				}
				free(newtitle);
			}
			tabId = GetTabFromHWND(dat, mdat->hwnd);
			tContactName = GetTabName(mdat->hContact);
			tci.mask = TCIF_TEXT;
			tci.pszText = tContactName;
			TabCtrl_SetItem(dat->hwndTabs, tabId, &tci);
			free(tContactName);
			break;
		}
	case DM_UPDATEWINICON:
		{
			struct MessageWindowData * mdat = (struct MessageWindowData *) lParam;
			if (mdat) {
				if (mdat->szProto) {
					int i, icoIdx = 0;
					WORD wStatus;
					char *szProto = mdat->szProto;
					HANDLE hContact = mdat->hContact;
					if (strcmp(mdat->szProto, "MetaContacts") == 0 && DBGetContactSettingByte(NULL,"CLC","Meta",0) == 0) {
						hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(UINT)mdat->hContact, 0);
						if (hContact != NULL) {
							szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(UINT)hContact,0);
						} else {
							hContact = mdat->hContact;
						}
					}
					wStatus = DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE);
					mdat->wStatus = wStatus;
					if (mdat->hwnd == dat->hwndActive) {
						if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_STATUSICON, SRMSGDEFSET_STATUSICON)) {
							if (mdat->showTyping && (g_dat->flags&SMF_SHOWTYPINGWIN)) {
								SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) g_dat->hIcons[SMF_ICON_TYPING]);
							} else if (mdat->showUnread && (GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg)) {
								SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
							} else {
								SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedProtoIcon(szProto, wStatus));
							}
						} else {
							SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
						}
					}
					SendDlgItemMessage(mdat->hwnd, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadSkinnedProtoIcon(szProto, wStatus));
					icoIdx = 0;
					for (i = 0; i < g_dat->protoNum; i++) {
						if (!strcmp(g_dat->protoNames[i], szProto)) {
							icoIdx = wStatus - ID_STATUS_OFFLINE + (ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE + 1) * (i +1) + 2;
							break;
						}
					}
					if (mdat->hwnd != dat->hwndActive) {
						if (mdat->showTyping) {
							icoIdx = 1;
						} else if (mdat->showUnread & 1) {
							icoIdx = 0;
						}
					}
					i = GetTabFromHWND(dat, mdat->hwnd);
					if (i>=0) {
						TCITEM tci;
						tci.mask = TCIF_IMAGE;
						tci.iImage = icoIdx;
						TabCtrl_SetItem(dat->hwndTabs, i, &tci);
					}
				}
			}
			break;
		}
	case DM_UPDATESTATUSBAR:
		break;
	case DM_SWITCHSTATUSBAR:
		dat->flags ^= SMF_SHOWSTATUSBAR;
		if (!(dat->flags & SMF_SHOWSTATUSBAR)) {
			ShowWindow(dat->hwndStatus, SW_HIDE);
		} else {
			ShowWindow(dat->hwndStatus, SW_SHOW);
		}
		SendMessage(hwndDlg, WM_SIZE, 0, 0);
		break;
	case DM_SWITCHTOOLBAR:
		{
			int i;
			dat->flags ^= SMF_SHOWBTNS;
			for (i=0;i<dat->childrenCount;i++) {
				SendMessage(dat->children[i], DM_SWITCHTOOLBAR, 0, 0);
			}
			SendMessage(hwndDlg, WM_SIZE, 0, 0);
		}
		break;
	case DM_SWITCHTITLEBAR:
		{
			RECT rc;
			dat->flags ^= SMF_SHOWTITLEBAR;
			ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION);
			if (dat->flags & SMF_SHOWTITLEBAR) {
				ws |= WS_CAPTION;
			}
			SetWindowLong(hwndDlg, GWL_STYLE, ws);
			GetWindowRect(hwndDlg, &rc);
			SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
                         SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER  | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
//			SendMessage(hwndDlg, WM_SIZE, 0, 0);
			RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
		}
		break;
	case DM_CASCADENEWWINDOW:
		if ((HWND) wParam == hwndDlg)
			break;
		{
			RECT rcThis, rcNew;
			GetWindowRect(hwndDlg, &rcThis);
			GetWindowRect((HWND) wParam, &rcNew);
			if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) {
				int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);
				SetWindowPos((HWND) wParam, 0, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
				*(int *) lParam = 1;
			}
		}
		break;
	//case DM_MESSAGESENDING:
	//	dat->messagesInProgress += wParam ? -1 : 1;
	//	if (dat->messagesInProgress < 0) dat->messagesInProgress = 0;
	//	break;
	}
	return FALSE;
}
Beispiel #7
0
void CWeaponMagazined::StartIdleAnim			()
{
	if(IsZoomed())	m_pHUD->animDisplay(mhud.mhud_idle_aim[Random.randI(mhud.mhud_idle_aim.size())], TRUE);
	else			m_pHUD->animDisplay(mhud.mhud_idle[Random.randI(mhud.mhud_idle.size())], TRUE);
}
// WM_NCHITTEST handler
int cef_dark_window::HandleNcHitTest(LPPOINT ptHit)
{
    RECT rectWindow;
    GetWindowRect(&rectWindow);

    if (!::PtInRect(&rectWindow, *ptHit)) 
        return HTNOWHERE;
    
    RECT rectClient;
    GetClientRect(&rectClient);
    ClientToScreen(&rectClient);

    if (::PtInRect(&rectClient, *ptHit)) 
        return HTCLIENT;

    RECT rectCaption;
    ComputeWindowCaptionRect(rectCaption);
    NonClientToScreen(&rectCaption);

    if (::PtInRect(&rectCaption, *ptHit)) 
        return HTCAPTION;

    RECT rectCloseButton;
    ComputeCloseButtonRect(rectCloseButton);
    NonClientToScreen(&rectCloseButton);

    if (::PtInRect(&rectCloseButton, *ptHit)) 
        return HTCLOSE;

    RECT rectMaximizeButton;
    ComputeMaximizeButtonRect(rectMaximizeButton);
    NonClientToScreen(&rectMaximizeButton);

    if (::PtInRect(&rectMaximizeButton, *ptHit)) 
        return HTMAXBUTTON;

    RECT rectMinimizeButton;
    ComputeMinimizeButtonRect(rectMinimizeButton);
    NonClientToScreen(&rectMinimizeButton);

    if (::PtInRect(&rectMinimizeButton, *ptHit)) 
        return HTMINBUTTON;

    RECT rectSysIcon;
    ComputeWindowIconRect(rectSysIcon);
    NonClientToScreen(&rectSysIcon);

    if (::PtInRect(&rectSysIcon, *ptHit)) 
        return HTSYSMENU;

    if (!IsZoomed()) {

        // Left Border
        if (ptHit->x >= rectWindow.left && ptHit->x <= rectWindow.left + ::GetSystemMetrics (SM_CYFRAME))
        {
            // it's important that we know if the mouse is on a corner so that
            //    the right mouse cursor is displayed
            if (ptHit->y <= rectWindow.top + ::GetSystemMetrics (SM_CYFRAME))
                 return HTTOPLEFT;
 
            if (ptHit->y >= rectWindow.bottom - ::GetSystemMetrics (SM_CYFRAME))
                 return HTBOTTOMLEFT;
 
            return HTLEFT;
        }

        // Right Border
        if (ptHit->x <= rectWindow.right && ptHit->x >= rectWindow.right - ::GetSystemMetrics (SM_CYFRAME)) 
        {
            // it's important that we know if the mouse is on a corner so that
            //    the right mouse cursor is displayed
            if (ptHit->y <= rectWindow.top + ::GetSystemMetrics (SM_CYFRAME))
                return HTTOPRIGHT;
 
            if (ptHit->y >= rectWindow.bottom - ::GetSystemMetrics (SM_CYFRAME))
                return HTBOTTOMRIGHT;
 
            return HTRIGHT;
        }

        // Top and Bottom Borders
        if (ptHit->y <= rectWindow.top + ::GetSystemMetrics (SM_CYFRAME)) 
             return HTTOP;
             
        if (ptHit->y >= rectWindow.bottom - ::GetSystemMetrics (SM_CYFRAME))
             return HTBOTTOM;
    }

    // If it's not in the menu, it's in the caption
    RECT rectMenu;
    ComputeRequiredMenuRect(rectMenu);
    NonClientToScreen(&rectMenu);

    if (::PtInRect(&rectMenu, *ptHit))
        return HTMENU;

    return HTCAPTION;
}
Beispiel #9
0
static BOOL GRPFILE_DoWriteGroupFile(HFILE file, PROGGROUP *group)
{
  CHAR buffer[34];
  HLOCAL hProgram;
  INT    NumProg, Title, Progs, Icons, Extension;
  INT    CurrProg, CurrIcon, nCmdShow, ptr, seqnum;
  DWORD  sizeAnd, sizeXor;
  BOOL   need_extension;
  LPCSTR lpszTitle = LocalLock(group->hName);

  UINT16 checksum;

  GRPFILE_InitChecksum();

  /* Calculate offsets */
  NumProg = 0;
  Icons   = 0;
  Extension = 0;
  need_extension = FALSE;
  hProgram = group->hPrograms;
  while(hProgram)
    {
      PROGRAM *program = LocalLock(hProgram);
      LPCSTR lpszWorkDir = LocalLock(program->hWorkDir);

      NumProg++;
      GRPFILE_CalculateSizes(program, &Icons, &Extension, &sizeAnd, &sizeXor);

      /* Set a flag if an extension is needed */
      if (lpszWorkDir[0] || program->nHotKey ||
	  program->nCmdShow != SW_SHOWNORMAL) need_extension = TRUE;

      hProgram = program->hNext;
    }
  Title      = 34 + NumProg * 2;
  Progs      = Title + strlen(lpszTitle) + 1;
  Icons     += Progs;
  Extension += Icons;

  /* Header */
  buffer[0] = 'P';
  buffer[1] = 'M';
  buffer[2] = 'C';
  buffer[3] = 'C';

  PUT_SHORT(buffer,  4, 0); /* Checksum zero for now, written later */
  PUT_SHORT(buffer,  6, Extension);
  /* Update group->nCmdShow */
  if (IsIconic(group->hWnd))      nCmdShow = SW_SHOWMINIMIZED;
  else if (IsZoomed(group->hWnd)) nCmdShow = SW_SHOWMAXIMIZED;
  else                            nCmdShow = SW_SHOWNORMAL;
  PUT_SHORT(buffer,  8, nCmdShow);
  PUT_SHORT(buffer, 10, group->x);
  PUT_SHORT(buffer, 12, group->y);
  PUT_SHORT(buffer, 14, group->width);
  PUT_SHORT(buffer, 16, group->height);
  PUT_SHORT(buffer, 18, group->iconx);
  PUT_SHORT(buffer, 20, group->icony);
  PUT_SHORT(buffer, 22, Title);
  PUT_SHORT(buffer, 24, 0x0020); /* unknown */
  PUT_SHORT(buffer, 26, 0x0020); /* unknown */
  PUT_SHORT(buffer, 28, 0x0108); /* unknown */
  PUT_SHORT(buffer, 30, 0x0000); /* unknown */
  PUT_SHORT(buffer, 32, NumProg);

  if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 34)) return FALSE;

  /* Program table */
  CurrProg = Progs;
  CurrIcon = Icons;
  hProgram = group->hPrograms;
  while(hProgram)
    {
      PROGRAM *program = LocalLock(hProgram);

      PUT_SHORT(buffer, 0, CurrProg);
      if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 2))
	      return FALSE;

      GRPFILE_CalculateSizes(program, &CurrProg, &CurrIcon, &sizeAnd, &sizeXor);
      hProgram = program->hNext;
    }

  /* Title */
  if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, lpszTitle, strlen(lpszTitle) + 1))
    return FALSE;

  /* Program entries */
  CurrProg = Progs;
  CurrIcon = Icons;
  hProgram = group->hPrograms;
  while(hProgram)
    {
      PROGRAM *program = LocalLock(hProgram);
      LPCSTR Name     = LocalLock(program->hName);
      LPCSTR CmdLine  = LocalLock(program->hCmdLine);
      LPCSTR IconFile = LocalLock(program->hIconFile);
      INT next_prog = CurrProg;
      INT next_icon = CurrIcon;

      GRPFILE_CalculateSizes(program, &next_prog, &next_icon, &sizeAnd, &sizeXor);
      PUT_SHORT(buffer,  0, program->x);
      PUT_SHORT(buffer,  2, program->y);
      PUT_SHORT(buffer,  4, program->nIconIndex);
      PUT_SHORT(buffer,  6, 0x048c);            /* unknown */
      PUT_SHORT(buffer,  8, sizeXor);
      PUT_SHORT(buffer, 10, sizeAnd * 8);
      PUT_SHORT(buffer, 12, CurrIcon);
      PUT_SHORT(buffer, 14, CurrIcon + 12 + sizeAnd);
      PUT_SHORT(buffer, 16, CurrIcon + 12);
      ptr = CurrProg + 24;
      PUT_SHORT(buffer, 18, ptr);
      ptr += strlen(Name) + 1;
      PUT_SHORT(buffer, 20, ptr);
      ptr += strlen(CmdLine) + 1;
      PUT_SHORT(buffer, 22, ptr);

      if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 24) ||
	  (UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, Name, strlen(Name) + 1) ||
	  (UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, CmdLine, strlen(CmdLine) + 1) ||
	  (UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, IconFile, strlen(IconFile) + 1))
	return FALSE;

      CurrProg = next_prog;
      CurrIcon = next_icon;
      hProgram = program->hNext;
    }

  /* Icons */
#if 0  /* FIXME: this is broken anyway */
  hProgram = group->hPrograms;
  while(hProgram)
    {
      PROGRAM *program = LocalLock(hProgram);
      CURSORICONINFO *iconinfo = LocalLock(program->hIcon);
      LPVOID XorBits, AndBits;
      INT sizeXor = iconinfo->nHeight * iconinfo->nWidthBytes;
      INT sizeAnd = iconinfo->nHeight * ((iconinfo->nWidth + 15) / 16 * 2);
      /* DumpIcon16(LocalLock(program->hIcon), 0, &XorBits, &AndBits);*/

      PUT_SHORT(buffer, 0, iconinfo->ptHotSpot.x);
      PUT_SHORT(buffer, 2, iconinfo->ptHotSpot.y);
      PUT_SHORT(buffer, 4, iconinfo->nWidth);
      PUT_SHORT(buffer, 6, iconinfo->nHeight);
      PUT_SHORT(buffer, 8, iconinfo->nWidthBytes);
      buffer[10] = iconinfo->bPlanes;
      buffer[11] = iconinfo->bBitsPerPixel;

      if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 12) ||
	  (UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, AndBits, sizeAnd) ||
	  (UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, XorBits, sizeXor)) return FALSE;

      hProgram = program->hNext;
    }
#endif

  if (need_extension)
    {
      /* write `PMCC' extension */
      PUT_SHORT(buffer, 0, 0x8000);
      PUT_SHORT(buffer, 2, 0xffff);
      PUT_SHORT(buffer, 4, 0x000a);
      buffer[6] = 'P', buffer[7] = 'M';
      buffer[8] = 'C', buffer[9] = 'C';
      if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 10))
	      return FALSE;

      seqnum = 0;
      hProgram = group->hPrograms;
      while(hProgram)
	{
	  PROGRAM *program = LocalLock(hProgram);
	  LPCSTR lpszWorkDir = LocalLock(program->hWorkDir);

	  /* Working directory */
	  if (lpszWorkDir[0])
	    {
	      PUT_SHORT(buffer, 0, 0x8101);
	      PUT_SHORT(buffer, 2, seqnum);
	      PUT_SHORT(buffer, 4, 7 + strlen(lpszWorkDir));
	      if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 6) ||
		  (UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, lpszWorkDir, strlen(lpszWorkDir) + 1))
		return FALSE;
	    }

	  /* Hot key */
	  if (program->nHotKey)
	    {
	      PUT_SHORT(buffer, 0, 0x8102);
	      PUT_SHORT(buffer, 2, seqnum);
	      PUT_SHORT(buffer, 4, 8);
	      PUT_SHORT(buffer, 6, program->nHotKey);
	      if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 8)) return FALSE;
	    }

	  /* Show command */
	  if (program->nCmdShow)
	    {
	      PUT_SHORT(buffer, 0, 0x8103);
	      PUT_SHORT(buffer, 2, seqnum);
	      PUT_SHORT(buffer, 4, 8);
	      PUT_SHORT(buffer, 6, program->nCmdShow);
	      if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 8)) return FALSE;
	    }

	  seqnum++;
	  hProgram = program->hNext;
	}

      /* Write `End' extension */
      PUT_SHORT(buffer, 0, 0xffff);
      PUT_SHORT(buffer, 2, 0xffff);
      PUT_SHORT(buffer, 4, 0x0000);
      if ((UINT)HFILE_ERROR == GRPFILE_WriteWithChecksum(file, buffer, 6)) return FALSE;
    }

  checksum = GRPFILE_GetChecksum();
  _llseek(file, 4, SEEK_SET);
  PUT_SHORT(buffer, 0, checksum);
  _lwrite(file, buffer, 2);

  return TRUE;
}
Beispiel #10
0
    void Update()
    {
        // maintain top/left pos
        CRect rcwnd;
        GetWindowRect(rcwnd);

        // Clear text
        m_wndRTF.SetWindowText(NULL);

        // Stream in new text...
        CComVariant bstr;
        std::string text;
        if(m_vertex)
            m_vertex->GetProperty(PROP_TOOLTIP, bstr);
        if(m_edge)
            m_edge->GetProperty(PROP_TOOLTIP, bstr);
        if (bstr.vt == VT_BSTR)
            text = CW2A(bstr.bstrVal);
        LPCSTR pstrText=text.c_str();
        RtfStream st = { pstrText, 0 }; 
        EDITSTREAM es = { 0 };
        es.dwCookie = (DWORD) &st;
        es.dwError = 0;
        es.pfnCallback = _StreamReadCallback;
        UINT uFormat = pstrText[0]=='{' ? SF_RTF : SF_TEXT;
        m_wndRTF.StreamIn(uFormat, es);

        // Request new layout
        int cx = DEFAULT_WIDTH;
        CRect rc( 0, 0, cx, DEFAULT_HEIGHT);
        m_wndRTF.ResizeClient(cx, DEFAULT_HEIGHT, FALSE);
        m_wndRTF.SetRect(&rc);
        m_wndRTF.RequestResize();
        CRect rcRTF(m_rcRTF);
        CRect rcOrig(m_rcRTF);

        // Resize RTF control until the height changes. This will indicate
        // the minimum/optimal width of the text.
        int iStep = 30;
        while( true ) 
        {
            ATLASSERT(cx>0);
            CRect rc( 0, 0, cx - iStep, DEFAULT_HEIGHT);
            m_wndRTF.ResizeClient(cx - iStep, DEFAULT_HEIGHT, FALSE);
            m_wndRTF.SetRect(&rc);
            m_wndRTF.RequestResize();
            if(rcRTF.Height() != m_rcRTF.Height()) 
            {
                if( iStep <= 1 ) break;
                iStep /= 2;
            }
            else 
            {
                cx -= iStep;
                if( cx <= 0 ) 
                {
                    rcRTF = rcOrig;
                    break;
                }
                rcRTF = m_rcRTF; // Apply better width
            }
        }

        bool notnormal=IsIconic() || IsZoomed();
        m_wndRTF.SetWindowPos(0, &rcRTF, (notnormal?0:SWP_SHOWWINDOW) | SWP_NOACTIVATE | SWP_NOZORDER);
        if(!notnormal)
        {
            DWORD exstyle=GetWndExStyle(0);
            rcwnd.right=rcwnd.left+rcRTF.Width();
            rcwnd.bottom=rcwnd.top+rcRTF.Height();
            ::AdjustWindowRectEx(&rcwnd, GetWndStyle(0), FALSE, exstyle);
            // finally, keep it inside screen bounds
            CRect rcScreen;
            ::SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, 0);
            if(rcwnd.right > rcScreen.right) 
                rcwnd.OffsetRect(-(rcwnd.right-rcScreen.right), 0);
            if(rcwnd.top < rcScreen.top) 
                rcwnd.OffsetRect(0, rcScreen.top-rcwnd.top);

            SetWindowPos(0, rcwnd, SWP_NOZORDER);
        }
    }
Beispiel #11
0
LRESULT APIENTRY ProToolsProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	LONG_PTR				action = 0, command = 0, hitArea = 0, styleChg = 0;
	pLL					currentLink, prevLink;
	RECT				rect,	clientRect, workingAreaRect;
	LONG_PTR				x = 0, y = 0, xFrame, yFrame;
	INT_PTR					mnuItemCount, i;
	HMENU				hMenu;
	BOOL				bFuncReturn;
	LPMINMAXINFO		lpmmi; //01/18/03
	static LONG_PTR			InCommand = 0; // 01/18/03
	POINT				pt; // 01/19/03
	LPWINDOWPOS			lpwp;
	LPNCCALCSIZE_PARAMS	lpcalcsize;
	static HWND			currentChildMaxed = NULL, prevChildMaxed = NULL;
	//char*				minimizedWindows[32];
	char				title[128];
	INT_PTR					n = 0, err = 0;
	INT_PTR					minimizedPerRow; // REB 8/11/08 #16207

	currentLink = NULL;
	prevLink = NULL;

	if (toolBarRestrictions.toolBarOnDeck == 1) { // 01/17/03

		xFrame = GetSystemMetrics(SM_CXSIZEFRAME);
		yFrame = GetSystemMetrics(SM_CYSIZEFRAME);
		// REB 8/11/08 #16207
		minimizedPerRow = ((GetSystemMetrics(SM_CXVIRTUALSCREEN) - (toolBarRestrictions.clientOffsetx + toolBarRestrictions.left + toolBarRestrictions.right)) / GetSystemMetrics(SM_CXMINSPACING));
		//err = GetWindowText(hwnd, title , 128); //**DEBUG**
		switch (uMsg)
		{
			case WM_SYSCOMMAND : //this tells a subsequent WM_GETMINMAXINFO command
				// that it is okay to proceed if we are in the process of a maximize command.
				command = wParam & 0xFFF0;
				if (SC_MAXIMIZE == command) {
					InCommand = IN_SYSCOMMAND_MAX;
					GetWindowRect(hwnd, &toolBarRestrictions.origWindowRect);
					GetWindowRect(windowHandles.MDIhWnd, &rect);
					toolBarRestrictions.clientOffsetx = rect.left;
					toolBarRestrictions.clientOffsety = rect.top;
					currentChildMaxed = hwnd;
					if (IsZoomed(hwnd) == 0){ // REB 8/11/08 #16207
						//minimizePositions[toolBarRestrictions.numMinimized] = 0;		
						err = GetWindowText(hwnd, title , 128);				
						for (n=0; n < SMLBUF; n++) {
							if(strcmp(toolBarRestrictions.minimizedWindows[n], title) == 0){
								strcpy(toolBarRestrictions.minimizedWindows[n], "");
								//break;
							}
						}
					}
				}
				// REB 8/11/08 #16207
				if  (SC_MINIMIZE == command) {
					InCommand = IN_SYSCOMMAND_MIN;
					GetWindowRect(hwnd, &toolBarRestrictions.origWindowRect);
					GetWindowRect(windowHandles.MDIhWnd, &rect);

					//Debug
					//GetWindowRect(windowHandles.MDIs_4DhWnd, &rect);
					//GetWindowRect(windowHandles.fourDhWnd, &rect);
					//End Debug

					toolBarRestrictions.clientOffsetx = rect.left;
					toolBarRestrictions.clientOffsety = rect.top;					
				}

				if (SC_RESTORE == command) { //|| (toolBarRestrictions.appBeingMaxed > 0)) {
					InCommand = IN_SYSCOMMAND_RESTORE;
					if (IsZoomed(hwnd) != 0){ // REB 8/11/08 #16207 Only clear these if we are restoring a window that was already maximized.
						currentChildMaxed = NULL;
						// REB 3/26/10 #22878 Move the previous window back.
						MoveWindow(prevChildMaxed, toolBarRestrictions.previousWindowRect.left, toolBarRestrictions.previousWindowRect.top, (toolBarRestrictions.previousWindowRect.right - toolBarRestrictions.previousWindowRect.left), (toolBarRestrictions.previousWindowRect.bottom - toolBarRestrictions.previousWindowRect.top), 1);
						prevChildMaxed = NULL;
					}else{
						err = GetWindowText(hwnd, title , 128);				
						for (n=0; n < SMLBUF; n++) {
							if(strcmp(toolBarRestrictions.minimizedWindows[n], title) == 0){
								strcpy(toolBarRestrictions.minimizedWindows[n], "");
								//break;
							}
						}
					}
					toolBarRestrictions.appBeingMaxed = 0;
				}
				//if (SC_NEXTWINDOW == command) {
					//toolBarRestrictions.appBeingMaxed = XCHANGING_MAX_WINDOWS;
				//}


				if (SC_CLOSE == command) {
					if (IsZoomed(hwnd) == 0){ // REB 8/11/08 #16207	
						err = GetWindowText(hwnd, title , 128);				
						for (n=0; n < SMLBUF; n++) {
							if(strcmp(toolBarRestrictions.minimizedWindows[n], title) == 0){
								strcpy(toolBarRestrictions.minimizedWindows[n], "");
								//break;
							}
						}
					}
					break;
				};

				break;

			case WM_WINDOWPOSCHANGING :

				lpwp = (LPWINDOWPOS)lParam;

				GetWindowRect(windowHandles.MDIhWnd, &rect);

				if  ((InCommand == IN_SYSCOMMAND_MAX) && (toolBarRestrictions.appWindowState == APP_MAXIMIZED)) {

					lpwp->x = lpwp->x - toolBarRestrictions.clientOffsetx - toolBarRestrictions.left;
					lpwp->y = lpwp->y - toolBarRestrictions.clientOffsety - toolBarRestrictions.top - yFrame;
					lpwp->cx = toolBarRestrictions.origWindowRect.right - toolBarRestrictions.origWindowRect.left;
					lpwp->cy = toolBarRestrictions.origWindowRect.bottom - toolBarRestrictions.origWindowRect.top;
					return 0;
				}
				// REB 8/11/08 #16207
				if  ((InCommand == IN_SYSCOMMAND_MIN) ){  // Minimizing the windows
					err = GetWindowText(hwnd, title , 128);				
					for (n=0; n < SMLBUF; n++) {
						if((strcmp(toolBarRestrictions.minimizedWindows[n], "") == 0) || (strcmp(toolBarRestrictions.minimizedWindows[n], title) == 0)){
							strcpy(toolBarRestrictions.minimizedWindows[n], title);
							break;
						}
					}

					lpwp->x = toolBarRestrictions.clientOffsetx + toolBarRestrictions.left + ((n % minimizedPerRow)  * GetSystemMetrics(SM_CXMINSPACING));
				
					SystemParametersInfo(SPI_GETWORKAREA, 0, &workingAreaRect, 0);
					lpwp->y = workingAreaRect.bottom - yFrame - toolBarRestrictions.clientOffsety - toolBarRestrictions.bottom - (((n  / (minimizedPerRow) ) + 1) * GetSystemMetrics(SM_CYMINSPACING));
					
					return 0;
				}

				if  ((toolBarRestrictions.appBeingMaxed == APP_MAXIMIZING) ||
						 (toolBarRestrictions.appBeingMaxed == APP_RESTORING) ||
						 (toolBarRestrictions.appBeingMaxed == APP_SIZING_W_CHLDMAX)) {
					
					lpwp->x = toolBarRestrictions.left - xFrame;
					lpwp->y = toolBarRestrictions.top - yFrame;
					lpwp->cx = rect.right - rect.left + (2 * xFrame) - toolBarRestrictions.left - toolBarRestrictions.right;
					lpwp->cy = rect.bottom - rect.top + (2 * yFrame) - toolBarRestrictions.top - toolBarRestrictions.bottom;
					return 0;
				}

				if (currentChildMaxed == hwnd) { //(toolBarRestrictions.appBeingMaxed == (LONG_PTR)hwnd) {
					lpwp->x = toolBarRestrictions.left - xFrame;
					lpwp->y = toolBarRestrictions.top - yFrame;
					lpwp->cx = rect.right - rect.left + (2 * xFrame) - toolBarRestrictions.left - toolBarRestrictions.right;
					lpwp->cy = rect.bottom - rect.top + (2 * yFrame) - toolBarRestrictions.top - toolBarRestrictions.bottom;
					return 0;
				}
				break;

			case WM_GETMINMAXINFO :
				if ((InCommand == IN_SYSCOMMAND_MAX) || (toolBarRestrictions.appBeingMaxed > 0) ||
						(currentChildMaxed == hwnd) ) {
						
					lpmmi = (LPMINMAXINFO) lParam;
						
					lpmmi->ptMaxSize.x = lpmmi->ptMaxSize.x - toolBarRestrictions.left - toolBarRestrictions.right;
					lpmmi->ptMaxSize.y = lpmmi->ptMaxSize.y - toolBarRestrictions.top - toolBarRestrictions.bottom;
					lpmmi->ptMaxPosition.x  = - xFrame + toolBarRestrictions.left; // maxPosition x&y seem to be static values -- hmmm!
					lpmmi->ptMaxPosition.y  = - yFrame + toolBarRestrictions.top;
					lpmmi->ptMaxTrackSize.x = lpmmi->ptMaxTrackSize.x - toolBarRestrictions.left - toolBarRestrictions.right;
					lpmmi->ptMaxTrackSize.y = lpmmi->ptMaxTrackSize.y - toolBarRestrictions.top - toolBarRestrictions.bottom;
						
					return 0; // return 0 telling OS that we have processed this command
				} // end if 
				break;

			case WM_NCCALCSIZE :
				if ( ((currentChildMaxed != NULL) || (prevChildMaxed != NULL)) && ((BOOL)wParam == TRUE) ) {
					lpcalcsize = (LPNCCALCSIZE_PARAMS)lParam;
					lpwp = lpcalcsize->lppos;
					rect = lpcalcsize->rgrc[0];
					clientRect = lpcalcsize->rgrc[1];
					toolBarRestrictions.appBeingMaxed = 0; //new
				}
				break;

			case WM_NCACTIVATE :
				if ((currentChildMaxed != NULL) && (currentChildMaxed != hwnd)) {
					//bFuncReturn = IsZoomed(currentChildMaxed);
					// REB 3/26/10 #22878 Here we need to capture the size of the newly activated window before it's resized to the max.
					// This window will become the new original window and we'll save the previous window position to be resized later.
					if (wParam){ 
						toolBarRestrictions.previousWindowRect = toolBarRestrictions.origWindowRect;
						GetWindowRect(hwnd, &toolBarRestrictions.origWindowRect);
						prevChildMaxed = currentChildMaxed;
						currentChildMaxed = hwnd;
					}
					toolBarRestrictions.appBeingMaxed = (LONG_PTR)currentChildMaxed; //was XCHANGING_MAX_WINDOWS
				}
				break;

			case WM_SETFOCUS : // msg received by window getting focus
					//if (prevChildMaxed == (HWND)wParam) { 
					//use the following in lieu of XCHANGING.. to restore all on window change
					//SendMessage((HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0L);
					//use this to keep maxed window when using CRTL-TAB.  But 4D has an ugy bug in window
					//  resize when called from a menu (Bring to Front).
					//toolBarRestrictions.appBeingMaxed = XCHANGING_MAX_WINDOWS;	
				break;


			case WM_SIZE :
					if (toolBarRestrictions.appBeingMaxed != APP_SIZING_W_CHLDMAX) {
						toolBarRestrictions.appBeingMaxed = 0;
					}
					InCommand = 0;
				break;


			case WM_SIZING : 
			case WM_MOVING : // restrict sizing or moving to prevent
				GetClientRect(windowHandles.MDIhWnd, &clientRect);
				//clientRect.right contains width of client area
				//clientRect.bottom contains height of client area
				//convert this rect to screen coordinates for comparison to movingRect
				pt.x = clientRect.left;
				pt.y = clientRect.top;
				ClientToScreen(windowHandles.MDIhWnd, &pt);
				clientRect.left = pt.x;
				clientRect.top = pt.y;
				pt.x = clientRect.right;
				pt.y = clientRect.bottom;
				ClientToScreen(windowHandles.MDIhWnd, &pt);
				clientRect.right = pt.x;
				clientRect.bottom = pt.y;
				
				clientRect.left += toolBarRestrictions.left;
				if (toolBarRestrictions.trackingRestriction == 0) {
					clientRect.top += toolBarRestrictions.top;
				} else {
					clientRect.top += toolBarRestrictions.trackingRestriction;
				}
				clientRect.right -= toolBarRestrictions.right;
				clientRect.bottom -= toolBarRestrictions.bottom;
				ClipCursor(&clientRect);
				break;


			case WM_EXITSIZEMOVE :
				rect.left		= 0;
				rect.top		= 0;
				rect.right	= GetSystemMetrics(SM_CXVIRTUALSCREEN);// REB 6/6/08 #16838 (Fix Provided by Keith White)
				rect.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN);// REB 6/6/08 #16838 (Fix Provided by Keith White)
				ClipCursor(&rect);
				break;
			default :
				if((uMsg!=WM_ERASEBKGND)&&(uMsg!=WM_NCPAINT)&&(uMsg!=WM_PAINT)&&(uMsg!=WM_IME_SETCONTEXT)&&(uMsg!=WM_IME_NOTIFY)&&(uMsg!=WM_SETFOCUS)&&(uMsg!=WM_NCACTIVATE)&&(uMsg!=WM_KILLFOCUS)&&(uMsg!=WM_GETTEXT)){
					break;
				};
		} // end switch (uMsg)
	} // end if (toolBarRestrictions.toolBarOnDeck == 1)



	if (startOfList != NULL) {

		if ((uMsg == WM_SYSCOMMAND) || (uMsg == WM_NCHITTEST) || (uMsg == WM_INITMENU)) {

			if (search_list( &startOfList, &currentLink, &prevLink, LL_hWnd, LL_Restrict, (LONG_PTR *) &hwnd)) {
		
				action = currentLink->dataLong1;

				switch (uMsg)
				{
					case (WM_SYSCOMMAND) :
						command = wParam & 0xFFF0;
						switch (command)
						{
							case (SC_SIZE) :
								if (RW_NO_SIZE == (action & RW_NO_SIZE)) {
									wParam = 0x000F;
								}
								break;

							case (SC_MOVE) :
								if (RW_NO_MOVE == (action & RW_NO_MOVE)) {
									wParam = 0x000F;
								}
								break;

							case (SC_MINIMIZE) :
								if (RW_NO_MIN == (action & RW_NO_MIN)) {
									wParam = 0x000F;
								}
								break;

							case (SC_MAXIMIZE) :
								if (RW_NO_MAX == (action & RW_NO_MAX)) {
									wParam = 0x000F;
								}
								break;
						}  // end switch

						break;

					case (WM_NCHITTEST) :
						if (RW_NO_SIZE == (action & RW_NO_SIZE)) {
							hitArea = DefWindowProc(hwnd, uMsg, wParam, lParam);
							if ((hitArea >= HTLEFT) && (hitArea <= HTBOTTOMRIGHT)) {
								uMsg = HTNOWHERE;
							} else {
								// test for coordinates of lower right 
								GetWindowRect(hwnd, &rect);
								x = LOWORD (lParam);
								y = HIWORD (lParam);
								if ((x <= rect.right) && (x >= (rect.right - 25 )) &&
									(y <= rect.bottom) && (y >= (rect.bottom - 25))) {
									uMsg = HTNOWHERE;
								}
							}
						}
						break;

					case (WM_INITMENU):

						hMenu = GetSystemMenu(hwnd, FALSE);

						if (RW_NO_SIZE == (action & RW_NO_SIZE)) {
							bFuncReturn = EnableMenuItem(hMenu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED);
						}
						if (RW_NO_MOVE == (action & RW_NO_MOVE)) {
							bFuncReturn = EnableMenuItem(hMenu, SC_MOVE, MF_BYCOMMAND | MF_GRAYED);
						}
						if (RW_NO_MIN == (action & RW_NO_MIN)) {
							bFuncReturn = EnableMenuItem(hMenu, SC_MINIMIZE, MF_BYCOMMAND | MF_GRAYED);
						}
						if (RW_NO_MAX == (action & RW_NO_MAX)) {
							bFuncReturn = EnableMenuItem(hMenu, SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED);
						}
						if (RW_NO_NEXT == (action & RW_NO_NEXT)) {
							mnuItemCount = GetMenuItemCount(hMenu);
							for (i = (mnuItemCount - 1); i >= 0; i--)
							{
								if (GetMenuItemID(hMenu, i) == SC_NEXTWINDOW) {
									bFuncReturn = DeleteMenu(hMenu, SC_NEXTWINDOW, MF_BYCOMMAND);
									// is next higher menu item a separator line?
									if (GetMenuItemID(hMenu, i - 1) == 0) {
										bFuncReturn = DeleteMenu(hMenu, i - 1, MF_BYPOSITION);	
									}
								} else if (GetMenuItemID(hMenu, i) == SC_PREVWINDOW) {
									bFuncReturn = DeleteMenu(hMenu, SC_PREVWINDOW, MF_BYCOMMAND);
									// is next higher menu item a separator line?
									if (GetMenuItemID(hMenu, i - 1) == 0) {
										bFuncReturn = DeleteMenu(hMenu, i - 1, MF_BYPOSITION);	
									}
								}
							}
						} // end if (RW_NO_NEXT == (action & RW_NO_NEXT))

						break;

					case (WM_DESTROY) :
						delete_list(&startOfList, LL_hWnd, LL_Restrict, (LONG_PTR *) &hwnd);
						break;

				} // end switch (uMsg)
			} // end if (search_list( &startOfList, &currentLink, &prevLink, LL_hWnd, LL_Restrict, (LONG_PTR *) &hwnd))
		} // end if ((uMsg == WM_SYSCOMMAND) || (uMsg == WM_NCHITTEST) || (uMsg == WM_INITMENU))
	} // end if (startOfList != NULL)
	

	return CallWindowProc(processHandles.wpProToolsOrigProc, hwnd, uMsg, wParam, lParam);

}
Beispiel #12
0
void COFSNcDlg::DrawCaption(CDC &dc,const CRect &m_Rect)
{
	if(m_Rect.Width()==0||m_Rect.Height()==0) return;
	switch(m_CaptionMode)
	{
     case CAP_NONE:
	 case CAP_COLOR:	 
		 {
			 CFont m_font;
			 CBrush m_br;
			 CRect m_TextRect = m_Rect;
			 
			 if(m_bActive)
				 m_br.CreateSolidBrush(m_ActiveColor);
		     else
			     m_br.CreateSolidBrush(m_InactiveColor);

			 dc.FillRect(m_Rect,&m_br);
			 CString str;
			 GetWindowText(str);
			 m_font.Attach(GetStockObject(DEFAULT_GUI_FONT));
			 dc.SelectObject(&m_font);
			 dc.SetTextColor(RGB(255,255,255));
			 dc.SetBkMode(TRANSPARENT);
			 m_TextRect.right -= 80;
			 dc.DrawText(str,(LPRECT)&m_TextRect ,DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS|DT_SINGLELINE);
		 }
		 break;
     case CAP_BITMAP_1:	 		
		 {
			 CDC dcT;
			 dcT.CreateCompatibleDC(&dc);
			 dcT.SelectObject(pActiveBMP);
			 dc.BitBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,SRCCOPY);
		 }
		 break;
     case CAP_BITMAP_1_ZOOM:	 		 
		 {
			 CDC dcT;
			 dcT.CreateCompatibleDC(&dc);
			 dcT.SelectObject(pActiveBMP);
			 dc.StretchBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,m_ActiveBMPSize.cx,m_ActiveBMPSize.cy,SRCCOPY);
//			 dc.BitBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,SRCCOPY);
		 }
		 break;
     case CAP_BITMAP_2:	 		 
		 {
			 CDC dcT;
			 dcT.CreateCompatibleDC(&dc);
			 if(m_bActive)
				 dcT.SelectObject(pActiveBMP);
			 else
                 dcT.SelectObject(pInactiveBMP);    
			 dc.BitBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,SRCCOPY);
		 }
		 break;
     case CAP_BITMAP_2_ZOOM:	 		 
		 {
			 CDC dcT;
			 dcT.CreateCompatibleDC(&dc);
			 if(m_bActive)
			 {
				 dcT.SelectObject(pActiveBMP);
				 dc.StretchBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,m_ActiveBMPSize.cx,m_ActiveBMPSize.cy,SRCCOPY);
			 }
			 else
			 {
                 dcT.SelectObject(pInactiveBMP);    
				 dc.StretchBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,m_InactiveBMPSize.cx,m_InactiveBMPSize.cy,SRCCOPY);
			 }
		 }
		 break;
	}

	DWORD dwStyle = GetStyle();
	CRect m_ButtonRect;
	m_ButtonRect.SetRect(m_Rect.right - CaptionH +2 ,m_Rect.top + 4,
		m_Rect.right - 2,m_Rect.bottom - 2);
	
	if(dwStyle&WS_SYSMENU)
		dc.DrawFrameControl(&m_ButtonRect,DFC_CAPTION,DFCS_CAPTIONCLOSE);
	
	if (dwStyle & WS_MAXIMIZEBOX) 
	{
	   m_ButtonRect-=CPoint(CaptionH-2,0);
       dc.DrawFrameControl(&m_ButtonRect, DFC_CAPTION, IsZoomed()?DFCS_CAPTIONRESTORE:DFCS_CAPTIONMAX);
	}
	
	if (dwStyle & WS_MINIMIZEBOX) 
	{
		m_ButtonRect-=CPoint(CaptionH-2,0);
        dc.DrawFrameControl(&m_ButtonRect, DFC_CAPTION ,DFCS_CAPTIONMIN);
	}

}
Beispiel #13
0
LRESULT WINEXPORT WMainWndProc( HWND hWnd, UINT message,
                                WPARAM wParam, volatile LPARAM lParam )
{
    HMENU           menu;
#if 0
    HWND            win;
#endif
    LRESULT         ret;
    Bool            pass_to_def;
    WAccelEditInfo  *einfo;
    WORD            wp;
    MINMAXINFO      *minmax;
    about_info      ai;

    pass_to_def = TRUE;
    ret = FALSE;
    einfo = (WAccelEditInfo *)GetWindowLong( hWnd, 0 );
    WSetCurrentEditInfo( einfo );

    if( einfo != NULL && einfo->getting_key ) {
        if( WGetKeyPressProc( einfo, message, wParam, lParam ) ) {
            einfo->getting_key = FALSE;
            DestroyWindow( einfo->key_info.text_win );
            ReleaseCapture();
            WHandleChange( einfo );
            pass_to_def = FALSE;
        }
    }

    switch( message ) {
    case WM_ACTIVATE:
        if( GET_WM_ACTIVATE_FACTIVE( wParam, lParam ) &&
            !GET_WM_ACTIVATE_FMINIMIZED( wParam, lParam ) &&
            einfo != NULL && einfo->edit_dlg != (HWND)NULL ) {
            SetFocus( einfo->edit_dlg );
            pass_to_def = FALSE;
        }
        break;

    case WM_INITMENU:
        if( wParam == (WPARAM)GetMenu( hWnd ) ) {
            // set the cut and copy menu items
            ret = SendDlgItemMessage( einfo->edit_dlg, IDM_ACCEDLIST, LB_GETCURSEL, 0, 0 );
            if( ret != LB_ERR ) {
                EnableMenuItem( (HMENU)wParam, IDM_ACC_CUT, MF_ENABLED );
                EnableMenuItem( (HMENU)wParam, IDM_ACC_COPY, MF_ENABLED );
            } else {
                EnableMenuItem( (HMENU)wParam, IDM_ACC_CUT, MF_GRAYED );
                EnableMenuItem( (HMENU)wParam, IDM_ACC_COPY, MF_GRAYED );
            }
            // set the paste menu item
            if( OpenClipboard( hWnd ) ) {
                if( //IsClipboardFormatAvailable( WClipbdFormat ) ||
                    IsClipboardFormatAvailable( WItemClipbdFormat ) ) {
                    EnableMenuItem( (HMENU)wParam, IDM_ACC_PASTE, MF_ENABLED );
                } else {
                    EnableMenuItem( (HMENU)wParam, IDM_ACC_PASTE, MF_GRAYED );
                }
                CloseClipboard();
            }
            ret = FALSE;
        }
        break;

    case WM_CREATE:
        einfo = ((CREATESTRUCT *)lParam)->lpCreateParams;
        SetWindowLong( hWnd, 0, (LONG)einfo );
        break;

    case WM_MENUSELECT:
        if( einfo != NULL ) {
            menu = WGetMenuHandle( einfo );
            WHandleMenuSelect( einfo->wsb, menu, wParam, lParam );
            setLastMenuSelect( einfo, wParam, lParam );
        }
        break;

    case WM_GETMINMAXINFO:
        minmax = (MINMAXINFO *)lParam;
        minmax->ptMinTrackSize.x = appWidth;
        minmax->ptMinTrackSize.y = appHeight;
        break;

    case WM_MOVE:
        if( einfo != NULL ) {
            if( IsZoomed( hWnd ) ) {
                WSetOption( WOptScreenMax, TRUE );
            } else if( !IsIconic( hWnd ) ) {
                WUpdateScreenPosOpt( hWnd );
                WSetOption( WOptScreenMax, FALSE );
            }
        }
        break;

    case WM_SIZE:
        if( einfo != NULL ) {
            if( wParam == SIZE_MAXIMIZED ) {
                WSetOption( WOptScreenMax, TRUE );
            } else if( wParam != SIZE_MINIMIZED ) {
                WUpdateScreenPosOpt( hWnd );
                WSetOption( WOptScreenMax, FALSE );
            }
            WResizeWindows( einfo );
        }
        break;

#if 0
    case WM_ACTIVATE:
        if( GET_WM_ACTIVATE_FACTIVE( wParam, lParam ) != WA_INACTIVE ) {
            einfo = (WAccelEditInfo *)GetWindowLong( hWnd, 0 );
            if( einfo != NULL && einfo->edit_dlg != (HWND)NULL ) {
                SetFocus( einfo->edit_dlg );
            }
            WSetCurrentEditInfo( einfo );
        } else {
            WSetCurrentEditInfo( NULL );
        }
        break;
#endif

    case WM_COMMAND:
        wp = LOWORD( wParam );
        switch( wp ) {
        case IDM_ACC_CLEAR:
            WHandleClear( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_UPDATE:
            SendMessage( einfo->info->parent, ACCEL_PLEASE_SAVEME, 0, (LPARAM)einfo->hndl );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_OPEN:
            pass_to_def = FALSE;
            if( einfo->info->modified ) {
                ret = WQuerySave( einfo, FALSE );
                if( !ret ) {
                    break;
                }
            }
            ret = SendMessage( einfo->info->parent, ACCEL_PLEASE_OPENME, 0,
                               (LPARAM)einfo->hndl );
            ret = FALSE;
            break;

        case IDM_ACC_SAVE:
            WSaveObject( einfo, FALSE, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_SAVEAS:
            WSaveObject( einfo, TRUE, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_SAVEINTO:
            WSaveObject( einfo, TRUE, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_EXIT:
            /* clean up before we exit */
            PostMessage( einfo->win, WM_CLOSE, 0, 0 );
            break;

        case IDM_ACC_PASTE:
            WPasteAccelItem( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_COPY:
        case IDM_ACC_CUT:
            WClipAccelItem( einfo, wp == IDM_ACC_CUT );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_DELETE:
            WDeleteAccelEntry( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_NEWITEM:
            WInsertAccelEntry( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_KEYVALUE:
            WSetStatusByID( einfo->wsb, W_GETTINGKEYS, -1 );
            WHandleGetKeyValue( einfo, einfo->last_menu_select == IDM_ACC_KEYVALUE );
            WSetStatusReadyText( einfo->wsb );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_SYMBOLS:
            handleSymbols( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_LOAD_SYMBOLS:
            handleLoadSymbols( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_SHOWRIBBON:
            menu = WGetMenuHandle( einfo );
            WShowRibbon( einfo, menu );
            pass_to_def = FALSE;
            break;

        case IDM_ACC_MEM_FLAGS:
            WSetStatusByID( einfo->wsb, W_CHANGEACCELMEMFLAGS, -1 );
            einfo->info->modified |= WChangeMemFlags( einfo->win, &einfo->info->MemFlags,
                                                      einfo->info->res_name,
                                                      WGetEditInstance(),
                                                      WAccHelpRoutine );
            pass_to_def = FALSE;
            WSetStatusReadyText( einfo->wsb );
            break;

        case IDM_ACC_RENAME:
            WHandleRename( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_HELP:
            WAccHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_SEARCH:
            WAccHelpSearchRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_ON_HELP:
            WAccHelpOnHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_ACC_ABOUT:
            ai.owner = hWnd;
            ai.inst = WGetEditInstance();
            ai.name = AllocRCString( W_ABOUT_NAME );
            ai.version = banner1p2( _RESEDIT_VERSION_ );
            ai.first_cr_year = AllocRCString( W_ABOUT_COPYRIGHT_YEAR );
            ai.title = AllocRCString( W_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.first_cr_year );
            FreeRCString( ai.title );
            pass_to_def = FALSE;
            break;
        }
        break;

    case WM_DESTROY:
        WWinHelp( hWnd, "resacc.hlp", HELP_QUIT, 0 );
        WCleanup( einfo );
        break;

    case WM_CLOSE:
        ret = TRUE;
        pass_to_def = WHandleWM_CLOSE( einfo, (Bool)wParam );
        wParam = 0;
        break;
    }

    if( pass_to_def ) {
        ret = DefWindowProc( hWnd, message, wParam, lParam );
    }

    return( ret );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFSniperRifle::ItemPostFrame( void )
{
	// If we're lowered, we're not allowed to fire
	if ( m_bLowered )
		return;

	// Get the owning player.
	CTFPlayer *pPlayer = ToTFPlayer( GetOwner() );
	if ( !pPlayer )
		return;

	if ( !CanAttack() )
	{
		if ( IsZoomed() )
		{
			ToggleZoom();
		}
		return;
	}

	HandleZooms();

#ifdef GAME_DLL
	// Update the sniper dot position if we have one
	if ( m_hSniperDot )
	{
		UpdateSniperDot();
	}
#endif

	// Start charging when we're zoomed in, and allowed to fire
	if ( pPlayer->m_Shared.IsJumping() )
	{
		// Unzoom if we're jumping
		if ( IsZoomed() )
		{
			ToggleZoom();
		}

		m_flChargedDamage = 0.0f;
		m_bRezoomAfterShot = false;
	}
	else if ( m_flNextSecondaryAttack <= gpGlobals->curtime )
	{
		// Don't start charging in the time just after a shot before we unzoom to play rack anim.
		if ( pPlayer->m_Shared.InCond( TF_COND_AIMING ) && !m_bRezoomAfterShot )
		{
			m_flChargedDamage = min( m_flChargedDamage + gpGlobals->frametime * TF_WEAPON_SNIPERRIFLE_CHARGE_PER_SEC, TF_WEAPON_SNIPERRIFLE_DAMAGE_MAX );
		}
		else
		{
			m_flChargedDamage = max( 0, m_flChargedDamage - gpGlobals->frametime * TF_WEAPON_SNIPERRIFLE_UNCHARGE_PER_SEC );
		}
	}

	// Fire.
	if ( pPlayer->m_nButtons & IN_ATTACK )
	{
		Fire( pPlayer );
	}

	// Idle.
	if ( !( ( pPlayer->m_nButtons & IN_ATTACK) || ( pPlayer->m_nButtons & IN_ATTACK2 ) ) )
	{
		// No fire buttons down or reloading
		if ( !ReloadOrSwitchWeapons() && ( m_bInReload == false ) )
		{
			WeaponIdle();
		}
	}
}
// WM_NCHITTEST handler
int cef_dark_aero_window::HandleNcHitTest(LPPOINT ptHit)
{
    RECT rectWindow;
    GetWindowRect(&rectWindow);

    if (!::PtInRect(&rectWindow, *ptHit)) 
        return HTNOWHERE;
    
    RECT rectCaption;
    ComputeWindowCaptionRect(rectCaption);
    ClientToScreen(&rectCaption);

    if (::PtInRect(&rectCaption, *ptHit)) 
        return HTCAPTION;

    RECT rectCloseButton;
    ComputeCloseButtonRect(rectCloseButton);
    ClientToScreen(&rectCloseButton);

    if (::PtInRect(&rectCloseButton, *ptHit)) 
        return HTCLOSE;

    RECT rectMaximizeButton;
    ComputeMaximizeButtonRect(rectMaximizeButton);
    ClientToScreen(&rectMaximizeButton);

    if (::PtInRect(&rectMaximizeButton, *ptHit)) 
        return HTMAXBUTTON;

    RECT rectMinimizeButton;
    ComputeMinimizeButtonRect(rectMinimizeButton);
    ClientToScreen(&rectMinimizeButton);

    if (::PtInRect(&rectMinimizeButton, *ptHit)) 
        return HTMINBUTTON;

    RECT rectSysIcon;
    ComputeWindowIconRect(rectSysIcon);
    ClientToScreen(&rectSysIcon);

    if (::PtInRect(&rectSysIcon, *ptHit)) 
        return HTSYSMENU;

    if (!IsZoomed()) {

        // Left Border
        if (ptHit->x >= rectWindow.left && ptHit->x <= rectWindow.left + ::kWindowFrameSize)
        {
            // it's important that we know if the mouse is on a corner so that
            //    the right mouse cursor is displayed
            if (ptHit->y <= rectWindow.top + ::kWindowFrameSize)
                 return HTTOPLEFT;
 
            if (ptHit->y >= rectWindow.bottom - ::kWindowFrameSize)
                 return HTBOTTOMLEFT;
 
            return HTLEFT;
        }

        // Right Border
        if (ptHit->x <= rectWindow.right && ptHit->x >= rectWindow.right - ::kWindowFrameSize) 
        {
            // it's important that we know if the mouse is on a corner so that
            //    the right mouse cursor is displayed
            if (ptHit->y <= rectWindow.top + ::kWindowFrameSize)
                return HTTOPRIGHT;
 
            if (ptHit->y >= rectWindow.bottom - ::kWindowFrameSize)
                return HTBOTTOMRIGHT;
 
            return HTRIGHT;
        }

        // Top and Bottom Borders
        if (ptHit->y <= rectWindow.top + ::kWindowFrameSize) 
             return HTTOP;
             
        if (ptHit->y >= rectWindow.bottom - ::kWindowFrameSize)
             return HTBOTTOM;
    }

    RECT rectMenu;
    ComputeRequiredMenuRect(rectMenu);
    ClientToScreen(&rectMenu);

    if (::PtInRect(&rectMenu, *ptHit))
        return HTMENU;

    // If it's in the menu bar but not actually
    //  on a menu item, then return caption so 
    //  the window can be dragged from the dead space 
    ComputeMenuBarRect(rectMenu);
    ClientToScreen(&rectMenu);
    if (::PtInRect(&rectMenu, *ptHit))
        return HTCAPTION;

    // Aero requires that we return HTNOWHERE
    return HTNOWHERE;
}
Beispiel #16
0
void PrintWindowSettings( FILE * fp ) {
	int ret ;
	RECT r ;
	char buffer[MAX_VALUE_NAME] ;
	
	GetOSInfo( buffer ) ;
	fprintf( fp, "OSVersion=%s\n", buffer ) ;
	
	ret = GetWindowText( MainHwnd, buffer, MAX_VALUE_NAME ) ; buffer[ret]='\0';
	ret = GetWindowTextLength( MainHwnd ) ;
	fprintf( fp, "Title (length)=%s (%d)\n", buffer, ret ) ;
	if( GetWindowRect( MainHwnd, &r ) ) {
		fprintf( fp, "WindowRect.left=%ld\n", r.left ) ;
		fprintf( fp, "WindowRect.right=%ld\n", r.right ) ;
		fprintf( fp, "WindowRect.top=%ld\n", r.top ) ;
		fprintf( fp, "WindowRect.bottom=%ld\n", r.bottom ) ;
		}
	if( GetClientRect( MainHwnd, &r ) ) {
		fprintf( fp, "ClientRect.left=%ld\n", r.left ) ;
		fprintf( fp, "ClientRect.right=%ld\n", r.right ) ;
		fprintf( fp, "ClientRect.top=%ld\n", r.top ) ;
		fprintf( fp, "ClientRect.bottom=%ld\n", r.bottom ) ;
		}
	
	ret = GetWindowModuleFileName( MainHwnd, buffer, MAX_VALUE_NAME ) ; buffer[ret]='\0';
	fprintf( fp, "WindowModuleFileName=%s\n", buffer ) ;
	
	WINDOWINFO wi ;
	wi.cbSize = sizeof( WINDOWINFO ) ;
	if( GetWindowInfo( MainHwnd, &wi ) ) {
		fprintf( fp, "WindowInfo.cbSize=%lu\n", wi.cbSize ) ;
		fprintf( fp, "WindowInfo.rcWindow.left=%ld\n", wi.rcWindow.left ) ;
		fprintf( fp, "WindowInfo.rcWindow.right=%ld\n", wi.rcWindow.right ) ;
		fprintf( fp, "WindowInfo.rcWindow.top=%ld\n", wi.rcWindow.top ) ;
		fprintf( fp, "WindowInfo.rcWindow.bottom=%ld\n", wi.rcWindow.bottom ) ;
		fprintf( fp, "WindowInfo.rcClient.left=%ld\n", wi.rcWindow.left ) ;
		fprintf( fp, "WindowInfo.rcClient.right=%ld\n", wi.rcWindow.right ) ;
		fprintf( fp, "WindowInfo.rcClient.top=%ld\n", wi.rcWindow.top ) ;
		fprintf( fp, "WindowInfo.rcClient.bottom=%ld\n", wi.rcWindow.bottom ) ;
		fprintf( fp, "WindowInfo.dwStyle=%lu\n", wi.dwStyle ) ;
		fprintf( fp, "WindowInfo.dwExStyle=%lu\n", wi.dwExStyle ) ;
		fprintf( fp, "WindowInfo.dwWindowStatus=%lu\n", wi.dwWindowStatus ) ;
		fprintf( fp, "WindowInfo.cxWindowBorders=%u\n", wi.cxWindowBorders ) ;
		fprintf( fp, "WindowInfo.cyWindowBorders=%u\n", wi.cyWindowBorders ) ;
		fprintf( fp, "WindowInfo.wCreatorVersion=%d\n", wi.wCreatorVersion ) ;
		}
	
	WINDOWPLACEMENT wp;
	wp.length=sizeof(WINDOWPLACEMENT) ;
	if( GetWindowPlacement( MainHwnd, &wp ) ) {
		fprintf( fp, "WindowPlacement.length=%u\n", wp.length ) ;
		fprintf( fp, "WindowPlacement.flags=%u\n", wp.flags ) ;
		fprintf( fp, "WindowPlacement.showCmd=%u\n", wp.showCmd ) ;
		fprintf( fp, "WindowPlacement.ptMinPosition.x=%ld\n", wp.ptMinPosition.x ) ;
		fprintf( fp, "WindowPlacement.ptMinPosition.y=%ld\n", wp.ptMinPosition.y ) ;
		fprintf( fp, "WindowPlacement.ptMaxPosition.x=%ld\n", wp.ptMaxPosition.x ) ;
		fprintf( fp, "WindowPlacement.ptMaxPosition.y=%ld\n", wp.ptMaxPosition.y ) ;
		fprintf( fp, "WindowPlacement.rcNormalPosition.left=%ld\n", wp.rcNormalPosition.left ) ;
		fprintf( fp, "WindowPlacement.rcNormalPosition.right=%ld\n", wp.rcNormalPosition.right ) ;
		fprintf( fp, "WindowPlacement.rcNormalPosition.top=%ld\n", wp.rcNormalPosition.top ) ;
		fprintf( fp, "WindowPlacement.rcNormalPosition.bottom=%ld\n", wp.rcNormalPosition.bottom ) ;
		}
	
	fprintf( fp, "IsIconic=%d\n", IsIconic( MainHwnd ) ) ;
	fprintf( fp, "IsWindow=%d\n", IsWindow( MainHwnd ) ) ;
	fprintf( fp, "IsWindowUnicode=%d\n", IsWindowUnicode( MainHwnd ) ) ;
	fprintf( fp, "IsWindowVisible=%d\n", IsWindowVisible( MainHwnd ) ) ;
	fprintf( fp, "IsZoomed=%d\n", IsZoomed( MainHwnd ) ) ;
	}
Beispiel #17
0
bool SkOSWindow::makeFullscreen() {
    if (fFullscreen) {
        return true;
    }
    if (fHGLRC) {
        this->detachGL();
    }
    // This is hacked together from various sources on the web. It can certainly be improved and be
    // made more robust.

    // Save current window/resolution information. We do this in case we ever implement switching
    // back to windowed mode.
    fSavedWindowState.fZoomed = SkToBool(IsZoomed((HWND)fHWND));
    if (fSavedWindowState.fZoomed) {
        SendMessage((HWND)fHWND, WM_SYSCOMMAND, SC_RESTORE, 0);
    }
    fSavedWindowState.fStyle = GetWindowLong((HWND)fHWND, GWL_STYLE);
    fSavedWindowState.fExStyle = GetWindowLong((HWND)fHWND, GWL_EXSTYLE);
    GetWindowRect((HWND)fHWND, &fSavedWindowState.fRect);
    DEVMODE currScreenSettings;
    memset(&currScreenSettings,0,sizeof(currScreenSettings));
    currScreenSettings.dmSize = sizeof(currScreenSettings);
    EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &currScreenSettings);
    fSavedWindowState.fScreenWidth = currScreenSettings.dmPelsWidth;
    fSavedWindowState.fScreenHeight = currScreenSettings.dmPelsHeight;
    fSavedWindowState.fScreenBits = currScreenSettings.dmBitsPerPel;
    fSavedWindowState.fHWND = fHWND;

    // Try different sizes to find an allowed setting? Use ChangeDisplaySettingsEx?
    static const int kWidth = 1280;
    static const int kHeight = 1024;
    DEVMODE newScreenSettings;
    memset(&newScreenSettings, 0, sizeof(newScreenSettings));
    newScreenSettings.dmSize = sizeof(newScreenSettings);
    newScreenSettings.dmPelsWidth    = kWidth;
    newScreenSettings.dmPelsHeight   = kHeight;
    newScreenSettings.dmBitsPerPel   = 32;
    newScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
    if (ChangeDisplaySettings(&newScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
        return false;
    }
    RECT WindowRect;
    WindowRect.left = 0;
    WindowRect.right = kWidth;
    WindowRect.top = 0;
    WindowRect.bottom = kHeight;     
    ShowCursor(FALSE);
    AdjustWindowRectEx(&WindowRect, WS_POPUP, FALSE, WS_EX_APPWINDOW);
    HWND fsHWND = CreateWindowEx(
        WS_EX_APPWINDOW,
        fWinInit.fClass,
        NULL,
        WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP,
        0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top,
        NULL,
        NULL,
        fWinInit.fInstance,
        NULL
    );
    if (!fsHWND) {
        return false;
    }
    // Hide the old window and set the entry in the global mapping for this SkOSWindow to the
    // new HWND.
    ShowWindow((HWND)fHWND, SW_HIDE);
    gHwndToOSWindowMap.remove(fHWND);
    fHWND = fsHWND;
    gHwndToOSWindowMap.set(fHWND, this);
    this->updateSize();

    fFullscreen = true;
    return true;
}
Beispiel #18
0
WINEXPORT LRESULT CALLBACK WMainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    HMENU           menu;
#if 0
    HWND            win;
#endif
    LRESULT         ret;
    bool            pass_to_def;
    WStringEditInfo *einfo;
    WORD            wp;
    MINMAXINFO      *minmax;
    about_info      ai;

    pass_to_def = TRUE;
    ret = FALSE;
    einfo = (WStringEditInfo *)GET_WNDLONGPTR( hWnd, 0 );
    WSetCurrentEditInfo( einfo );

    switch( message ) {
    case WM_ACTIVATE:
        if( GET_WM_ACTIVATE_FACTIVE( wParam, lParam ) &&
            !GET_WM_ACTIVATE_FMINIMIZED( wParam, lParam ) &&
            einfo != NULL && einfo->edit_dlg != (HWND)NULL ) {
            SetFocus( einfo->edit_dlg );
            pass_to_def = FALSE;
        }
        break;

    case WM_INITMENU:
        if( wParam == (WPARAM)GetMenu( hWnd ) ) {
            // set the cut and copy menu items
            if( SendDlgItemMessage( einfo->edit_dlg, IDM_STREDLIST, LB_GETCURSEL, 0, 0 ) != LB_ERR ) {
                EnableMenuItem( (HMENU)wParam, IDM_STR_CUT, MF_ENABLED );
                EnableMenuItem( (HMENU)wParam, IDM_STR_COPY, MF_ENABLED );
                EnableMenuItem( (HMENU)wParam, IDM_STR_MEM_FLAGS, MF_ENABLED );
            } else {
                EnableMenuItem( (HMENU)wParam, IDM_STR_CUT, MF_GRAYED );
                EnableMenuItem( (HMENU)wParam, IDM_STR_COPY, MF_GRAYED );
                EnableMenuItem( (HMENU)wParam, IDM_STR_MEM_FLAGS, MF_GRAYED );
            }
            // set the paste menu item
            if( OpenClipboard( hWnd ) ) {
                if( //IsClipboardFormatAvailable( WClipbdFormat ) ||
                    IsClipboardFormatAvailable( CF_TEXT ) ) {
                    EnableMenuItem( (HMENU)wParam, IDM_STR_PASTE, MF_ENABLED );
                } else {
                    EnableMenuItem( (HMENU)wParam, IDM_STR_PASTE, MF_GRAYED );
                }
                CloseClipboard();
            }
        }
        break;

    case WM_CREATE:
        einfo = ((CREATESTRUCT *)lParam)->lpCreateParams;
        SET_WNDLONGPTR( hWnd, 0, (LONG_PTR)einfo );
        break;

    case WM_MENUSELECT:
        if( einfo != NULL ) {
            menu = WGetMenuHandle( einfo );
            WHandleMenuSelect( einfo->wsb, menu, wParam, lParam );
        }
        break;

    case WM_GETMINMAXINFO:
        minmax = (MINMAXINFO *)lParam;
        minmax->ptMinTrackSize.x = appWidth;
        minmax->ptMinTrackSize.y = appHeight;
        break;

    case WM_MOVE:
        if( einfo != NULL ) {
            if( IsZoomed( hWnd ) ) {
                WSetOption( WOptScreenMax, TRUE );
            } else if( !IsIconic( hWnd ) ) {
                WUpdateScreenPosOpt( hWnd );
                WSetOption( WOptScreenMax, FALSE );
            }
        }
        break;

    case WM_SIZE:
        if( einfo != NULL ) {
            if( wParam == SIZE_MAXIMIZED ) {
                WSetOption( WOptScreenMax, TRUE );
            } else if( wParam != SIZE_MINIMIZED ) {
                WUpdateScreenPosOpt( hWnd );
                WSetOption( WOptScreenMax, FALSE );
            }
            WResizeWindows( einfo );
        }
        break;

    case WM_COMMAND:
        wp = LOWORD(wParam);
        switch( wp ) {
        case IDM_STR_CLEAR:
            WHandleClear( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_STR_UPDATE:
            SendMessage( einfo->info->parent, STRING_PLEASE_SAVEME, 0,
                         (LPARAM)einfo->hndl );
            pass_to_def = FALSE;
            break;

        case IDM_STR_OPEN:
            pass_to_def = FALSE;
            if( einfo->info->modified ) {
                ret = WQuerySave( einfo, FALSE );
                if( !ret ) {
                    break;
                }
            }
            ret = SendMessage( einfo->info->parent, STRING_PLEASE_OPENME, 0,
                               (LPARAM)einfo->hndl );
            ret = FALSE;
            break;

        case IDM_STR_SAVE:
            WSaveObject( einfo, FALSE, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_STR_SAVEAS:
            WSaveObject( einfo, TRUE, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_STR_SAVEINTO:
            WSaveObject( einfo, TRUE, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_STR_EXIT:
            /* clean up before we exit */
            PostMessage( einfo->win, WM_CLOSE, 0, 0 );
            break;

        case IDM_STR_PASTE:
            WPasteStringItem( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_STR_CUT:
        case IDM_STR_COPY:
            WClipStringItem( einfo, wp == IDM_STR_CUT );
            pass_to_def = FALSE;
            break;

        case IDM_STR_DELETE:
            WDeleteStringEntry( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_STR_NEWITEM:
            WInsertStringEntry( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_STR_SYMBOLS:
            handleSymbols( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_STR_LOAD_SYMBOLS:
            handleLoadSymbols( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_STR_SHOWRIBBON:
            menu = WGetMenuHandle( einfo );
            WShowRibbon( einfo, menu );
            pass_to_def = FALSE;
            break;

        case IDM_STR_MEM_FLAGS:
            WHandleMemFlags( einfo );
            pass_to_def = FALSE;
            break;

        case IDM_HELP:
            WStrHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_SEARCH:
            WStrHelpSearchRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_ON_HELP:
            WStrHelpOnHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_STR_ABOUT:
            ai.owner = hWnd;
            ai.inst = WGetEditInstance();
            ai.name = AllocRCString( W_ABOUT_NAME );
            ai.version = AllocRCString( W_ABOUT_VERSION );
            ai.first_cr_year = "2002";
            ai.title = AllocRCString( W_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.version );
            FreeRCString( ai.title );
            pass_to_def = FALSE;
            break;
        }
        break;

    case WM_DESTROY:
        WWinHelp( hWnd, "resstr.hlp", HELP_QUIT, 0 );
        WCleanup( einfo );
        break;

    case WM_CLOSE:
        ret = TRUE;
        pass_to_def = WHandleWM_CLOSE( einfo, wParam != 0 );
        wParam = 0;
        break;
    }

    if( pass_to_def ) {
        ret = DefWindowProc( hWnd, message, wParam, lParam );
    }

    return( ret );
}
Beispiel #19
0
long DoCommand( HWND hWindow, WPARAM wParam, LPARAM lParam )
/***********************************************************************/
{
FNAME szFileName;
LPFRAME lpFrame;
LPOBJECT lpObject, lpBase;
RECT rect, rMask, rTemp, rAll;
HWND hWnd;
STRING szString;
int i, idFileType, x, y, dx, dy;
BOOL fDoZoom, bPrint, fHasZoom;
LPSTR lpszCmdLine;
HGLOBAL hMem;
ITEMID idDataType;
DWORD dwReturn;
int NewShape;
UINT wID;

SoundStartID( wParam, NO/*bLoop*/, NULL/*hInstance*/ );
/*
	WIN16:	ID          = wParam
			ctrl handle = LOWORD(lParam)
			notify code = HIWORD(lParam)

	WIN32:	ID          = LOWORD(wParam)
			ctrl handle = lParam
			notify code = HIWORD(wParam)
*/

#ifdef WIN32
	wID = LOWORD(wParam);
#else
	wID = wParam;
#endif

switch (wID)
	{
	case IDM_EXIT:
	DeactivateTool();
	PostMessage( hWndAstral, WM_CLOSE, 0, 0L);
    Delay (750);
	break;

	case IDM_CLOSE:
	DeactivateTool();
	/* Check to see if the image needs to be saved */
	if ( !ConfirmClose(NO,NO) )
		break;
	CloseImage( NO, lpImage ); // Close the active image
	break;

	case IDM_ABOUT:
	/* Bring up the modal 'About' dialog box */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_ABOUT, DlgAboutProc);
	break;

	case IDM_NEXTPAGE:
	if ( !lpImage )
		break;
	DeactivateTool();
	SendMessage( lpImage->hWnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0L );
	break;

	case IDM_NEW:
	DeactivateTool();
	SoundStartResource( "magic01", NO, NULL );
	AstralCursor( IDC_WAIT );
	New( Control.NewWidth, Control.NewHeight, Control.NewResolution,
		Control.NewDepth );
	AstralCursor( NULL );
	break;

	case IDM_OPEN:
	DeactivateTool();
	/* Bring up the modal 'File Open' box */
	if ( !(dwReturn = DoOpenDlg( hWindow, IDD_OPEN,
		Save.FileType, szFileName, NO )) )
		break;
	idFileType = LOWORD( dwReturn );
	Save.FileType = idFileType;
	PutDefaultInt( "FileType", idFileType - IDN_TIFF );
	AstralImageLoad( idFileType, szFileName, MAYBE, YES );
	break;

	case IDM_ALTOPEN:
	DeactivateTool();
	// Command line sent from a second instance prior to it closing
	/* If the caller passed in a file name, try to load it or print it */
	if ( !(lpszCmdLine = (LPSTR)lParam) )
		break;
	HandleCommandLine( hWindow, lpszCmdLine, &bPrint );
	break;

	case IDM_SAVE:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEAS:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVESPECIAL:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEWALLPAPER:
	DeactivateTool();
	SaveWallpaper( "CRAYOLA", NO/*fTiled*/ );
	break;

	case IDM_REVERT:
	if ( !lpImage )
		break;
	DeactivateTool();
	if ( lpImage->fUntitled ) // If the picture doesn't have a name, get out
		break;
	if ( ImgChanged(lpImage) )
		{
		/* Check to see if its OK to trash changes */
		if ( AstralOKCancel(IDS_OKTOREVERT,
				(LPSTR)lpImage->CurFile) == IDCANCEL )
			break;
		}
	lstrcpy( szFileName, lpImage->CurFile );
	idFileType = lpImage->FileType;
	fDoZoom = IsZoomed(lpImage->hWnd);
	fHasZoom = Window.fHasZoom;
	CloseImage( NO, lpImage ); // Close the active image
	if ( !AstralImageLoad( idFileType, szFileName, fDoZoom, YES ) )
		break;
	break;

	case IDM_RECALLIMAGE0:
	case IDM_RECALLIMAGE1:
	case IDM_RECALLIMAGE2:
	case IDM_RECALLIMAGE3:
	case IDM_RECALLIMAGE4:
	case IDM_RECALLIMAGE5:
	case IDM_RECALLIMAGE6:
	case IDM_RECALLIMAGE7:
	case IDM_RECALLIMAGE8:
	case IDM_RECALLIMAGE9:
	DeactivateTool();
	GetMenuString( GetMenu(hWindow), wID,
		szFileName, sizeof(szFileName), MF_BYCOMMAND );
	i = 0;
	while ( szFileName[i] && szFileName[i] != ' ' )
		i++; // Skip over the numeric id in the string (3. junk.tif)
	lstrcpy(szString, &szFileName[i+1]);
	GetRecallFileName(szString);
	AstralImageLoad( NULL, szString, MAYBE, YES );
	break;

	case IDM_PRINT:
	if ( !lpImage )
		break;
	DeactivateTool();
	AstralCursor( IDC_WAIT );
	DoPrintSizeInits();
	SoundStartResource( "print", YES, NULL );
	PrintFile( hWindow, filename(lpImage->CurFile), YES, lpImage, NULL );
	SoundStop();
	AstralCursor( NULL );
	break;

	case IDM_PRINTSETUP:
	/* Bring up the setup dialog box for the active printer */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PRINTSETUP,
		DlgPrintSetupProc);
	break;

	case IDC_SOUND:
	SoundToggle();
	break;

	case IDM_UNDO:
	if ( !lpImage )
		break;
	DeactivateTool();
	ImgEditUndo(lpImage, YES, NO);
	break;

	case IDM_CUT:
	case IDM_COPY:
	if ( !lpImage )
		break;
	DeactivateTool();

	// Create the clipboard files from the image
	ProgressBegin(1, IDS_PROGCOPY);
	if ( !ImgWriteClipOut( lpImage, NULL, NULL, &rMask, lpImage->DataType ) )
		{
		ProgressEnd();
		Message(IDS_EMEMALLOC);
		break;
		}
	ProgressEnd();

	OpenClipboard(hWindow);
	EmptyClipboard();

	// Passing a NULL data handle in SetClipboardData() means that
	// the data will be requested in a WM_RENDERFORMAT message
	hMem = ConstructObject( lpImage,
		IsRectEmpty(&rMask)? (LPRECT)NULL : (LPRECT)&rMask );
	if ( pOLE )
		{ // Any data put on before Native will become staticly copied
		SetClipboardData( pOLE->cfNative, NULL );
		SetClipboardData( pOLE->cfOwnerLink, hMem );
		}
	SetClipboardData( CF_DIB, NULL );
	if ( Control.DoPicture )
		SetClipboardData( CF_METAFILEPICT, NULL );
	if ( Control.DoBitmap )
		SetClipboardData( CF_BITMAP, NULL );
	SetClipboardData( CF_PALETTE, NULL );
	SetClipboardData( Control.cfImage, NULL );
	if ( pOLE && wID == IDM_COPY && !lpImage->fUntitled )
		{ // ObjectLink is retrieved during a Paste Link...
		SetClipboardData( pOLE->cfObjectLink, hMem );
		}
	CloseClipboard();
	if ( wID == IDM_COPY )
		break;

	// else fall through to IDM_DELETE

	case IDM_DELETE:
	if ( !lpImage )
		break;
	{
	COLORINFO ColorInfo;

	DeactivateTool();
	ColorInfo.gray   = 255;
	SetColorInfo( &ColorInfo, &ColorInfo, CS_GRAY );
	TintFill( lpImage, &ColorInfo, 255, MM_NORMAL,
		wID == IDM_CUT ? IDS_UNDOCUT : IDS_UNDODELETE );
	}
	break;

	case IDM_PASTE:
	if ( !lpImage )
		break;

	case IDM_PASTEASNEW:
	if ( !OpenClipboard(hWndAstral) )
		{
		Message( IDS_ECLIPOPEN );
		break;
		}
	if ( !IsClipboardFormatAvailable(CF_DIB) &&
	     !IsClipboardFormatAvailable(CF_BITMAP) &&
	     !IsClipboardFormatAvailable(Control.cfImage) )
		{
		Message( IDS_ECLIPOPEN );
		CloseClipboard();
		break;
		}
	CloseClipboard();

	DeactivateTool();
	// First put clipboard contents into a file(s)
	AstralCursor(IDC_WAIT);
	if ( !PasteFromClipboard( hWindow, (wID == IDM_PASTE) /*fNeedMask*/ ) )
		{
		AstralCursor(NULL);
		Message(IDS_EMEMALLOC);
		break;
		}
	if ( wID == IDM_PASTE )
		{
		ProgressBegin(1, IDS_PROGPASTECLIP);
		TransformObjectsStart( YES/*fNewObject*/ );
        if ( ImgCreateClipInObject( lpImage, NO ) )
			;
		ProgressEnd();
		}
	else
	if ( wID == IDM_PASTEASNEW )
		{
		if ( lpFrame = AstralFrameLoad( Names.PasteImageFile, -1,
			 &idDataType, &idFileType) )
			{
			if ( NewImageWindow(
				NULL,			// lpOldFrame
				NULL,			// Name
				lpFrame, 		// lpNewFrame
				idFileType,		// lpImage->FileType
				idDataType,		// lpImage->DataType
				FALSE,			// New view?
				IMG_DOCUMENT,	// lpImage->DocumentType
				NULL,			// lpImage->ImageName
				MAYBE
				) )
					lpImage->fChanged = YES;
			}
		}
	break;

	case IDM_ESCAPE:
	if (!lpImage)
		break;
	if (lpImage->hWnd == hZoomWindow)
		break;
	if ( Tool.bActive && Tool.lpToolProc )
		DestroyProc( lpImage->hWnd, 1L );
	break;

	case IDM_SIZEUP:
	case IDM_SIZEDOWN:
	if (!Retouch.hBrush)
		break;				 
	SetFocus( hWindow ); // Take focus away from any controls
	if ( Retouch.BrushShape == IDC_BRUSHCUSTOM )
		break;
	if ( wID == IDM_SIZEUP )
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 ))
    		Retouch.BrushSize += 2;
        else        
    		Retouch.BrushSize++;
    }
	else	
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) 
    		Retouch.BrushSize -= 2;
        else        
    		Retouch.BrushSize--;
    }
	if ( Retouch.BrushSize < 1 || Retouch.BrushSize > MAX_BRUSH_SIZE )
		{
		Retouch.BrushSize = bound( Retouch.BrushSize, 1,MAX_BRUSH_SIZE);
		MessageBeep(0);
		break;
		}
	if (lpImage)
		DisplayBrush(0, 0, 0, OFF);
	SetMgxBrushSize(Retouch.hBrush, Retouch.BrushSize);
	if (lpImage && Window.hCursor == Window.hNullCursor)
		DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		SetSlide( Tool.hRibbon, IDC_BRUSHSIZE, Retouch.BrushSize );
	break;

	case IDM_SHAPEUP:
	case IDM_SHAPEDOWN:
	if (!Retouch.hBrush)
		break;
	SetFocus( hWindow ); // Take focus away from any controls
	NewShape = Retouch.BrushShape;
	if ( wID == IDM_SHAPEUP )
		NewShape++;
	else	NewShape--;
	if ( NewShape > IDC_BRUSHCUSTOM )
		NewShape = IDC_BRUSHCIRCLE;
	if ( NewShape < IDC_BRUSHCIRCLE )
		NewShape = IDC_BRUSHCUSTOM;
	if (lpImage)
	 	DisplayBrush(0, 0, 0, OFF);
	if (!SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush))
		{
		NewShape = IDC_BRUSHCIRCLE;
		SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush);
		}
	Retouch.BrushShape = NewShape;
	if (lpImage && Window.hCursor == Window.hNullCursor)
	 	DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		{
		CheckComboItem( Tool.hRibbon, IDC_BRUSHSHAPE, IDC_BRUSHCIRCLE,
			IDC_BRUSHCUSTOMNEW, Retouch.BrushShape );
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
		}
	break;

	case IDM_MOVEUP:
	case IDM_MOVEDOWN:
	case IDM_MOVELEFT:
	case IDM_MOVERIGHT:
	if (!lpImage)
		break;
	lpBase = ImgGetBase(lpImage);
	if (ImgGetSelObject(lpImage, NULL) == lpBase)
		break;
	dx = dy = 0;
	if (wID == IDM_MOVEUP)
		--dy;
	if (wID == IDM_MOVEDOWN)
		++dy;
	if (wID == IDM_MOVELEFT)
		--dx;
	if (wID == IDM_MOVERIGHT)
		++dx;
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&rect, dx, dy);
		if (!AstralIntersectRect(&rTemp, &lpBase->rObject, &rect))
			break;
		}
	if (lpObject)
		break;
	AstralSetRectEmpty(&rAll);
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&lpObject->rObject, dx, dy);
		AstralUnionRect(&rAll, &rAll, &lpObject->rObject);
		if (!lpObject->Pixmap.fNewFrame &&
				EqualRect(&rect, &lpObject->rUndoObject))
			lpObject->rUndoObject = lpObject->rObject;
		UpdateImage(&rect, TRUE);
		UpdateImage(&lpObject->rObject, TRUE);
		}
	if (wID == IDM_MOVEUP)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.top;
		}
	else
	if (wID == IDM_MOVEDOWN)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.bottom;
		}
	else
	if (wID == IDM_MOVELEFT)
		{
		x = rAll.left;
		y = (rAll.top + rAll.bottom)/2;
		}
	else
	if (wID == IDM_MOVERIGHT)
		{
		x = rAll.right;
		y = (rAll.top + rAll.bottom)/2;
		}
	File2Display(&x, &y);
	AutoScroll(lpImage->hWnd, x, y);
	AstralUpdateWindow(lpImage->hWnd);
	DisplayInfo(-1, &rAll);
	break;

	case IDM_LASTTOOL:
	DeactivateTool();
	if ( Tool.idLast && (hWnd = AstralDlgGet(IDD_MAIN)) )
		SendMessage( hWnd, WM_COMMAND, Tool.idLast, 2L);
	break;

	case IDM_PREF:
	// prevent problems if running animations and they change
	// the wave mix dll setting in preferences
	StopAnimation();
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PREF, DlgPrefProc );
	break;

	case IDC_VIEWLAST: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	RevertLastView();
	break;

//	case IDC_VIEWFULL: // duplicate of function in the view ribbon
//	if ( !lpImage )
//		break;
//	AstralDlg( NO, hInstAstral, hWindow, IDD_VIEWFULL, DlgFullScreenViewProc );
//	break;

	case IDC_VIEWALL: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	ViewAll();
	break;

	case IDC_ZOOMIN: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, +100, YES, ( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDC_ZOOMOUT: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, -100, YES,( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDM_HELP:
	Control.Hints = !Control.Hints;
	PutDefInt (Control.Hints,Control.Hints);
	break;

	default:
	return( FALSE );
	}

return( TRUE );
}
SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	SDL_Surface *video;
	int prev_w, prev_h;
	Uint32 prev_flags;
	DWORD style;
	const DWORD directstyle =
			(WS_POPUP);
	const DWORD windowstyle =
			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
	const DWORD resizestyle =
			(WS_THICKFRAME|WS_MAXIMIZEBOX);
	int binfo_size;
	BITMAPINFO *binfo;
	HDC hdc;
	RECT bounds;
	int x, y;
	Uint32 Rmask, Gmask, Bmask;

	/* Clean up any GL context that may be hanging around */
	if ( current->flags & SDL_OPENGL ) {
		WIN_GL_ShutDown(this);
	}
	SDL_resizing = 1;

	/* Recalculate the bitmasks if necessary */
	if ( bpp == current->format->BitsPerPixel ) {
		video = current;
	} else {
		switch (bpp) {
			case 15:
			case 16:
				if ( DIB_SussScreenDepth() == 15 ) {
					/* 5-5-5 */
					Rmask = 0x00007c00;
					Gmask = 0x000003e0;
					Bmask = 0x0000001f;
				} else {
					/* 5-6-5 */
					Rmask = 0x0000f800;
					Gmask = 0x000007e0;
					Bmask = 0x0000001f;
				}
				break;
			case 24:
			case 32:
				/* GDI defined as 8-8-8 */
				Rmask = 0x00ff0000;
				Gmask = 0x0000ff00;
				Bmask = 0x000000ff;
				break;
			default:
				Rmask = 0x00000000;
				Gmask = 0x00000000;
				Bmask = 0x00000000;
				break;
		}
		video = SDL_CreateRGBSurface(SDL_SWSURFACE,
					0, 0, bpp, Rmask, Gmask, Bmask, 0);
		if ( video == NULL ) {
			SDL_OutOfMemory();
			return(NULL);
		}
	}

	/* Fill in part of the video surface */
	prev_flags = video->flags;
	prev_w = video->w;
	prev_h = video->h;
	video->flags = 0;	/* Clear flags */
	video->w = width;
	video->h = height;
	video->pitch = SDL_CalculatePitch(video);

	/* Small fix for WinCE/Win32 - when activating window
	   SDL_VideoSurface is equal to zero, so activating code
	   is not called properly for fullscreen windows because
	   macros WINDIB_FULLSCREEN uses SDL_VideoSurface
	*/
	SDL_VideoSurface = video;

#if defined(_WIN32_WCE)
	if ( flags & SDL_FULLSCREEN )
		video->flags |= SDL_FULLSCREEN;
#endif

#ifndef NO_CHANGEDISPLAYSETTINGS
	/* Set fullscreen mode if appropriate */
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		DEVMODE settings;
		BOOL changed;

		SDL_memset(&settings, 0, sizeof(DEVMODE));
		settings.dmSize = sizeof(DEVMODE);

#ifdef _WIN32_WCE
		// try to rotate screen to fit requested resolution
		if( this->hidden->supportRotation )
		{
			DWORD rotation;

			// ask current mode
			settings.dmFields = DM_DISPLAYORIENTATION;
			ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL);
			rotation = settings.dmDisplayOrientation;

			if( (width > GetDeviceCaps(GetDC(NULL), HORZRES))
				&& (height < GetDeviceCaps(GetDC(NULL), VERTRES)))
			{
				switch( rotation )
				{
				case DMDO_0:
					settings.dmDisplayOrientation = DMDO_90;
					break;
				case DMDO_270:
					settings.dmDisplayOrientation = DMDO_180;
					break;
				}
				if( settings.dmDisplayOrientation != rotation )
				{
					// go to landscape
					this->hidden->origRotation = rotation;
					ChangeDisplaySettingsEx(NULL,&settings,NULL,CDS_RESET,NULL);
				}
			}
			if( (width < GetDeviceCaps(GetDC(NULL), HORZRES))
				&& (height > GetDeviceCaps(GetDC(NULL), VERTRES)))
			{
				switch( rotation )
				{
				case DMDO_90:
					settings.dmDisplayOrientation = DMDO_0;
					break;
				case DMDO_180:
					settings.dmDisplayOrientation = DMDO_270;
					break;
				}
				if( settings.dmDisplayOrientation != rotation )
				{
					// go to portrait
					this->hidden->origRotation = rotation;
					ChangeDisplaySettingsEx(NULL,&settings,NULL,CDS_RESET,NULL);
				}
			}

		}
#endif

#ifndef _WIN32_WCE
		settings.dmBitsPerPel = video->format->BitsPerPixel;
		settings.dmPelsWidth = width;
		settings.dmPelsHeight = height;
		settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
		if ( width <= (int)SDL_desktop_mode.dmPelsWidth &&
		     height <= (int)SDL_desktop_mode.dmPelsHeight ) {
			settings.dmDisplayFrequency = SDL_desktop_mode.dmDisplayFrequency;
			settings.dmFields |= DM_DISPLAYFREQUENCY;
		}
		changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL);
		if ( ! changed && (settings.dmFields & DM_DISPLAYFREQUENCY) ) {
			settings.dmFields &= ~DM_DISPLAYFREQUENCY;
			changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL);
		}
#else
		changed = 1;
#endif
		if ( changed ) {
			video->flags |= SDL_FULLSCREEN;
			SDL_fullscreen_mode = settings;
		}

	}
#endif /* !NO_CHANGEDISPLAYSETTINGS */

	/* Reset the palette and create a new one if necessary */
	if ( grab_palette ) {
		DIB_ReleaseStaticColors(SDL_Window);
		grab_palette = FALSE;
	}
	if ( screen_pal != NULL ) {
	/*	RJR: March 28, 2000
		delete identity palette if switching from a palettized mode */
		DeleteObject(screen_pal);
		screen_pal = NULL;
	}
	if ( screen_logpal != NULL ) {
		SDL_free(screen_logpal);
		screen_logpal = NULL;
	}

	if ( bpp <= 8 )
	{
	/*	RJR: March 28, 2000
		create identity palette switching to a palettized mode */
		DIB_CreatePalette(this, bpp);
	}

	style = GetWindowLong(SDL_Window, GWL_STYLE);
	style &= ~(resizestyle|WS_MAXIMIZE);
	if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		style &= ~windowstyle;
		style |= directstyle;
	} else {
#ifndef NO_CHANGEDISPLAYSETTINGS
		if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
			ChangeDisplaySettings(NULL, 0);
		}
#endif
		if ( flags & SDL_NOFRAME ) {
			style &= ~windowstyle;
			style |= directstyle;
			video->flags |= SDL_NOFRAME;
		} else {
			style &= ~directstyle;
			style |= windowstyle;
			if ( flags & SDL_RESIZABLE ) {
				style |= resizestyle;
				video->flags |= SDL_RESIZABLE;
			}
		}
#if WS_MAXIMIZE
		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif
	}

	/* DJM: Don't piss of anyone who has setup his own window */
	if ( !SDL_windowid )
		SetWindowLong(SDL_Window, GWL_STYLE, style);

	/* Delete the old bitmap if necessary */
	if ( screen_bmp != NULL ) {
		DeleteObject(screen_bmp);
	}
	if ( ! (flags & SDL_OPENGL) ) {
		BOOL is16bitmode = (video->format->BytesPerPixel == 2);

		/* Suss out the bitmap info header */
		binfo_size = sizeof(*binfo);
		if( is16bitmode ) {
			/* 16bit modes, palette area used for rgb bitmasks */
			binfo_size += 3*sizeof(DWORD);
		} else if ( video->format->palette ) {
			binfo_size += video->format->palette->ncolors *
							sizeof(RGBQUAD);
		}
		binfo = (BITMAPINFO *)SDL_malloc(binfo_size);
		if ( ! binfo ) {
			if ( video != current ) {
				SDL_FreeSurface(video);
			}
			SDL_OutOfMemory();
			return(NULL);
		}

		binfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		binfo->bmiHeader.biWidth = video->w;
		binfo->bmiHeader.biHeight = -video->h;	/* -ve for topdown bitmap */
		binfo->bmiHeader.biPlanes = 1;
		binfo->bmiHeader.biSizeImage = video->h * video->pitch;
		binfo->bmiHeader.biXPelsPerMeter = 0;
		binfo->bmiHeader.biYPelsPerMeter = 0;
		binfo->bmiHeader.biClrUsed = 0;
		binfo->bmiHeader.biClrImportant = 0;
		binfo->bmiHeader.biBitCount = video->format->BitsPerPixel;

		if ( is16bitmode ) {
			/* BI_BITFIELDS tells CreateDIBSection about the rgb masks in the palette */
			binfo->bmiHeader.biCompression = BI_BITFIELDS;
			((Uint32*)binfo->bmiColors)[0] = video->format->Rmask;
			((Uint32*)binfo->bmiColors)[1] = video->format->Gmask;
			((Uint32*)binfo->bmiColors)[2] = video->format->Bmask;
		} else {
			binfo->bmiHeader.biCompression = BI_RGB;	/* BI_BITFIELDS for 565 vs 555 */
			if ( video->format->palette ) {
				SDL_memset(binfo->bmiColors, 0,
					video->format->palette->ncolors*sizeof(RGBQUAD));
			}
		}

		/* Create the offscreen bitmap buffer */
		hdc = GetDC(SDL_Window);
		screen_bmp = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS,
					(void **)(&video->pixels), NULL, 0);
		ReleaseDC(SDL_Window, hdc);
		SDL_free(binfo);
		if ( screen_bmp == NULL ) {
			if ( video != current ) {
				SDL_FreeSurface(video);
			}
			SDL_SetError("Couldn't create DIB section");
			return(NULL);
		}
		this->UpdateRects = DIB_NormalUpdate;

		/* Set video surface flags */
		if ( screen_pal && (flags & (SDL_FULLSCREEN|SDL_HWPALETTE)) ) {
			grab_palette = TRUE;
		}
		/* BitBlt() maps colors for us */
		video->flags |= SDL_HWPALETTE;
	}
#ifndef _WIN32_WCE
	/* Resize the window */
	if ( !SDL_windowid && !IsZoomed(SDL_Window) ) {
#else
	if ( !SDL_windowid ) {
#endif
		HWND top;
		UINT swp_flags;
		const char *window = NULL;
		const char *center = NULL;

		if ( video->w != prev_w || video->h != prev_h ) {
			window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
			center = SDL_getenv("SDL_VIDEO_CENTERED");
			if ( window ) {
				if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) {
					SDL_windowX = x;
					SDL_windowY = y;
				}
				if ( SDL_strcmp(window, "center") == 0 ) {
					center = window;
				}
			}
		}
		swp_flags = (SWP_NOCOPYBITS | SWP_SHOWWINDOW);

		bounds.left = SDL_windowX;
		bounds.top = SDL_windowY;
		bounds.right = SDL_windowX+video->w;
		bounds.bottom = SDL_windowY+video->h;
#ifndef _WIN32_WCE
		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), (GetMenu(SDL_Window) != NULL), 0);
#else
		// The bMenu parameter must be FALSE; menu bars are not supported
		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), 0, 0);
#endif
		width = bounds.right-bounds.left;
		height = bounds.bottom-bounds.top;
		if ( (flags & SDL_FULLSCREEN) ) {
			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
		} else if ( center ) {
			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
		} else if ( SDL_windowX || SDL_windowY || window ) {
			x = bounds.left;
			y = bounds.top;
		} else {
			x = y = -1;
			swp_flags |= SWP_NOMOVE;
		}
		if ( flags & SDL_FULLSCREEN ) {
			top = HWND_TOPMOST;
		} else {
			top = HWND_NOTOPMOST;
		}
		SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags);
		if ( !(flags & SDL_FULLSCREEN) ) {
			SDL_windowX = SDL_bounds.left;
			SDL_windowY = SDL_bounds.top;
		}
		SetForegroundWindow(SDL_Window);
	}
	SDL_resizing = 0;

	/* Set up for OpenGL */
	if ( flags & SDL_OPENGL ) {
		if ( WIN_GL_SetupWindow(this) < 0 ) {
			return(NULL);
		}
		video->flags |= SDL_OPENGL;
	}

	/* JC 14 Mar 2006
		Flush the message loop or this can cause big problems later
		Especially if the user decides to use dialog boxes or assert()!
	*/
	WIN_FlushMessageQueue();

	/* We're live! */
	return(video);
}

/* We don't actually allow hardware surfaces in the DIB driver */
static int DIB_AllocHWSurface(_THIS, SDL_Surface *surface)
{
	return(-1);
}
static void DIB_FreeHWSurface(_THIS, SDL_Surface *surface)
{
	return;
}
static int DIB_LockHWSurface(_THIS, SDL_Surface *surface)
{
	return(0);
}
static void DIB_UnlockHWSurface(_THIS, SDL_Surface *surface)
{
	return;
}

static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
{
	HDC hdc, mdc;
	int i;

	hdc = GetDC(SDL_Window);
	if ( screen_pal ) {
		SelectPalette(hdc, screen_pal, FALSE);
	}
	mdc = CreateCompatibleDC(hdc);
	SelectObject(mdc, screen_bmp);
	for ( i=0; i<numrects; ++i ) {
		BitBlt(hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h,
					mdc, rects[i].x, rects[i].y, SRCCOPY);
	}
	DeleteDC(mdc);
	ReleaseDC(SDL_Window, hdc);
}
Beispiel #21
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;
}
Beispiel #22
0
/*
 * SelectDynamicBitmap - let the user select the bitmap from the screen
 */
BOOL SelectDynamicBitmap( img_node *node, int imgcount, char *filename )
{
    HDC         hdc;
    HDC         memdc;
    HBITMAP     oldbitmap;
    HWND        bitmappickwindow;
    MSG         msg;
    RECT        screen_coords;

    if( IsZoomed( HMainWindow ) ) {
        prevState = SW_SHOWMAXIMIZED;
    } else {
        prevState = SW_SHOWNORMAL;
    }
#ifdef __NT__
    RegisterSnapClass( Instance );
    ShowWindow( HMainWindow, SW_SHOWMINIMIZED );
    ShowWindow( HMainWindow, SW_HIDE );
    deskTopWindow = DisplayDesktop( HMainWindow );
#else
    ShowWindow( HMainWindow, SW_SHOWMINIMIZED );
    ShowWindow( HMainWindow, SW_HIDE );
#endif

    bitmappickwindow = CreateWindow(
        BitmapPickClass,    /* Window class name */
        "",                 /* Window caption */
        WS_CHILDWINDOW,     /* Window style */
        0,                  /* Initial X position */
        0,                  /* Initial Y position */
        0,                  /* Initial X size */
        0,                  /* Initial Y size */
        HMainWindow,        /* Parent window handle */
        (HMENU)NULL,        /* Window menu handle */
        Instance,           /* Program instance handle */
        NULL );             /* Create parameters */

    if( bitmappickwindow == NULL ) {
        return( FALSE );
    }

    while( notDestroyed && GetMessage( &msg, bitmappickwindow, 0, 0 ) ) {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }

    if( bmpRegion.right > bmpRegion.left ) {
        screen_coords.left = bmpRegion.left;
        screen_coords.right = bmpRegion.right;
    } else {
        screen_coords.left = bmpRegion.right;
        screen_coords.right = bmpRegion.left;
    }
    if( bmpRegion.bottom > bmpRegion.top ) {
        screen_coords.bottom = bmpRegion.bottom;
        screen_coords.top = bmpRegion.top;
    } else {
        screen_coords.bottom = bmpRegion.top;
        screen_coords.top = bmpRegion.bottom;
    }
    if( screen_coords.right - screen_coords.left == 0 ||
        screen_coords.bottom - screen_coords.top == 0 ) {
        ShowWindow( HMainWindow, prevState );
#ifdef __NT__
        DestroyWindow( deskTopWindow );
#endif
        IEDisplayErrorMsg( WIE_APPNAME, WIE_INVALIDREGIONSELECTED,
                           MB_OK | MB_ICONINFORMATION );
        notDestroyed = TRUE;
        return( FALSE );
    }

    node->imgtype = BITMAP_IMG;
    node->width = (short)(screen_coords.right-screen_coords.left);
    node->height = (short)(screen_coords.bottom-screen_coords.top);
    node->bitcount = 4;                 // ?????
    node->hotspot.x = 0;
    node->hotspot.y = 0;
    node->num_of_images = 1;
    node->nexticon = NULL;
    node->issaved = FALSE;
    node->next = NULL;
    if( filename != NULL ) {
        strcpy( node->fname, filename );
    } else {
        sprintf( node->fname, "%s (%d)", IEImageUntitled, imgcount );
    }

    MakeBitmap( node, TRUE );

    hdc = GetDC( NULL );
    memdc = CreateCompatibleDC( hdc );

    oldbitmap = SelectObject( memdc, node->handbitmap );
    PatBlt( memdc, 0, 0, node->width, node->height, BLACKNESS );

    SelectObject( memdc, node->hxorbitmap );
    BitBlt( memdc, 0, 0, node->width, node->height, hdc, screen_coords.left,
            screen_coords.top, SRCCOPY );
    ReleaseDC( NULL, hdc );
    SelectObject( memdc, oldbitmap );
    DeleteDC( memdc );

    ShowWindow( HMainWindow, prevState );
#ifdef __NT__
    DestroyWindow( deskTopWindow );
#endif
    notDestroyed = TRUE;
    return( TRUE );

} /* SelectDynamicBitmap */
/* static */
LRESULT
sbWindowChromeService::WndProc(HWND hWnd,
                               UINT uMsg,
                               WPARAM wParam,
                               LPARAM lParam,
                               UINT_PTR uIdSubclass,
                               DWORD_PTR dwRefData)
{
  if (uIdSubclass != gSubclassId) {
    // We're majorly screwed up somehow; do nothing
    return DefSubclassProc(hWnd, uMsg, wParam, lParam);
  }
  TRACE(("%s: WndProc(%p, %08x)", __FUNCTION__, hWnd, uMsg));
  switch (uMsg) {
  case WM_NCDESTROY:
  {
    // clean up
    RemoveWindowSubclass(hWnd, &sbWindowChromeService::WndProc, uIdSubclass);
    break;
  }
  case WM_NCCALCSIZE:
  {
    if (!(BOOL)wParam) {
      // we do not need to do anything special for this case
      break;
    }
    NCCALCSIZE_PARAMS* params = (NCCALCSIZE_PARAMS*)lParam;
    bool willMinimize = (params->rgrc[0].left == -32000) &&
                        (params->rgrc[0].top  == -32000);
    if (willMinimize) {
      // we are going to minimize; don't touch anything
      break;
    }
    if (IsZoomed(hWnd)) {
      // On Windows 7, Windows will adjust the size of the maximized windows
      // so that they're larger than the screen to account for the window
      // border (even with Aero disabled).  On XP, however, it does _not_ do
      // that.  So, figure out how big the window wants to be, and how big the
      // screen is, and go for the closest solution.
      RECT* rectWindow = &params->rgrc[0]; // shorthand
      RECT rectMon = {0};
      int xSize = ::GetSystemMetrics(SM_CXSIZEFRAME);
      int ySize = ::GetSystemMetrics(SM_CYSIZEFRAME);
      // Bug 21344 - HMONITOR's are not handles
      HMONITOR hMon = ::MonitorFromRect(rectWindow, MONITOR_DEFAULTTONULL);
      if (hMon) {
        MONITORINFO monInfo = {0};
        monInfo.cbSize = sizeof(monInfo);
        BOOL success = ::GetMonitorInfo(hMon, &monInfo);
        if (success) {
          ::CopyRect(&rectMon, &monInfo.rcWork);
        }
        else {
          ::CopyRect(&rectMon, rectWindow);
        }
      }
      else {
        // no monitor!?
        ::CopyRect(&rectMon, rectWindow);
      }

      const LONG TOLERANCE = 2;
      if (rectMon.top > rectWindow->top &&
          rectMon.top - rectWindow->top < ySize + TOLERANCE)
      {
        rectWindow->top += ySize;
      }
      if (rectWindow->bottom > rectMon.bottom &&
          rectWindow->bottom - rectMon.bottom < ySize + TOLERANCE)
      {
        rectWindow->bottom -= ySize;
      }
      if (rectMon.left > rectWindow->left &&
          rectMon.left - rectWindow->left < xSize + TOLERANCE)
      {
        rectWindow->left += xSize;
      }
      if (rectWindow->right > rectMon.right &&
          rectWindow->right - rectMon.right < xSize + TOLERANCE)
      {
        rectWindow->right -= xSize;
      }

      // Chop off one pixel on any edge with auto-hidden taskbars (deskbars,
      // really).  This is required to make sure those taskbars will remain
      // functional (i.e. pop up) when the mouse goes near them - otherwise
      // Windows assumes we really meant to be a full screen window instead.
      APPBARDATA appbarData = {sizeof(APPBARDATA)};
      appbarData.hWnd = hWnd;
      HWND wnd;
      // Bug 21344 - HMONITOR's are not handles
      HMONITOR selfMon = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST),
               targetMon;

      appbarData.uEdge = ABE_TOP;
      wnd = (HWND)::SHAppBarMessage(ABM_GETAUTOHIDEBAR, &appbarData);
      if (wnd) {
        targetMon = ::MonitorFromWindow(wnd, MONITOR_DEFAULTTONEAREST);
        if (targetMon == selfMon) {
          // instead of bumping the window down, subtract a pixel from the
          // bottom instead - otherwise we end up exposing a pixel of the
          // top which 1) can lead to clicking on nearly-invisible widgets (e.g.
          // the close button), 2) loses fitt's law gains of having things at top
          params->rgrc[0].bottom -= 1;
        }
      }
      appbarData.uEdge = ABE_RIGHT;
      wnd = (HWND)::SHAppBarMessage(ABM_GETAUTOHIDEBAR, &appbarData);
      if (wnd) {
        targetMon = ::MonitorFromWindow(wnd, MONITOR_DEFAULTTONEAREST);
        if (targetMon == selfMon) {
          params->rgrc[0].right -= 1;
        }
      }
      appbarData.uEdge = ABE_BOTTOM;
      wnd = (HWND)::SHAppBarMessage(ABM_GETAUTOHIDEBAR, &appbarData);
      if (wnd) {
        targetMon = ::MonitorFromWindow(wnd, MONITOR_DEFAULTTONEAREST);
        if (targetMon == selfMon) {
          params->rgrc[0].bottom -= 1;
        }
      }
      appbarData.uEdge = ABE_LEFT;
      wnd = (HWND)::SHAppBarMessage(ABM_GETAUTOHIDEBAR, &appbarData);
      if (wnd) {
        targetMon = ::MonitorFromWindow(wnd, MONITOR_DEFAULTTONEAREST);
        if (targetMon == selfMon) {
          params->rgrc[0].left += 1;
        }
      }
      return 0;
    }
    // we have a window we want to hook, but it's not maximized; leave the
    // rectangles as-is, meaning that there should be no non-client area (i.e.
    // no chrome at all).
    return 0;
  }
  case WM_NCACTIVATE:
  {
    if (IsCompositionEnabled((sbWindowChromeService*)uIdSubclass)) {
      // When DWM composition is enabled, call the default handler so that
      // it draws the window shadow.  In this case the window is also double
      // buffered (by the DWM), so we don't have to worry about flickering.
      
      // We skip doing this if we're maximized (or look like we are, since that
      // is how Mozilla implemented full screen) to avoid problems with the
      // video window showing the (win9x) non-client area.  We don't need to
      // have shadows in that case anyway.
      RECT rectMon = {0}, rectWindow;
      BOOL success = ::GetWindowRect(hWnd, &rectWindow);
      if (!success) {
        ::SetRect(&rectWindow, -1, -1, -1, -1);
      }
      // Bug 21344 - HMONITOR's are not handles
      HMONITOR hMon = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
      if (hMon) {
        MONITORINFO monInfo = {0};
        monInfo.cbSize = sizeof(monInfo);
        success = ::GetMonitorInfo(hMon, &monInfo);
        if (success) {
          ::CopyRect(&rectMon, &monInfo.rcMonitor);
        }
      }
      if (!::EqualRect(&rectMon, &rectWindow)) {
        return DefSubclassProc(hWnd, uMsg, wParam, lParam);
      }
    }
    else {
      // Let's turn off themes to make sure our borders don't get rounded!
      ::SetWindowTheme(hWnd, L"", L"");
    }
    // No DWM, don't do anything to avoid extra paints of the non-client area
    // which causes bad flickering.
    return TRUE;
  }
  case WM_NCPAINT:
  {
    TRACE(("WM_NCPAINT(%p)", hWnd));
    // We need to call the default implementation in order to get window shadow.
    // Since that only works when DWM is enabled anyway, check if it is - if it
    // is not, do not call the default implementation since that causes flicker
    // on systems with theming but not DWM (e.g. XP, or Vista with 16bpp).
    if (!IsCompositionEnabled((sbWindowChromeService*)uIdSubclass)) {
      // no need to do anything; however, invalidate the window anyway in case
      // this paint was caused by invalidation.
      InvalidateRgn(hWnd, NULL, FALSE);
      return 0;
    }
    return DefSubclassProc(hWnd, uMsg, wParam, lParam);
  }
  case 0xAE: /* undocumented: WM_NCUAHDRAWCAPTION */
  case 0xAF: /* undocumented: WM_NCUAHDRAWFRAME */
    // these messages, according to chromium.org, are sent by Windows to redraw
    // the caption / frame at unpredictable times.  Intercept these and don't
    // use the default behaviour.
    return 0;
  }
  return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
Beispiel #24
0
LRESULT APIENTRY MainWndProc (HWND hWnd, 
                              UINT message, 
                              DWORD wParam, 
                              LONG lParam)
   {
   LONG     lRetCode = 0L ;
   BOOL     bCallDefWinProc = FALSE ;

   switch (LOWORD (message))
      {  // switch
      case WM_LBUTTONDBLCLK:
         ShowPerfmonMenu (!Options.bMenubar) ;
         if (Options.bMenubar)
            {
            PrepareMenu (GetMenu (hWnd)) ;
            }
         break ;

	   case WM_COMMAND:
	      if (PerfmonCommand (hWnd,wParam,lParam))
	         return(0);
         else
            bCallDefWinProc = TRUE ;
         break;

      case WM_MENUSELECT:
         MenuBarHit (wParam) ;
         break ;

      case WM_NCHITTEST:
        /* if we have no title/menu bar, clicking and dragging the client
         * area moves the window. To do this, return HTCAPTION.
         * Note dragging not allowed if window maximized, or if caption
         * bar is present.
         */
        wParam = DefWindowProc(hWnd, message, wParam, lParam);
        if (!Options.bMenubar && 
            (wParam == HTCLIENT) &&
            !IsZoomed (hWndMain))
           return HTCAPTION ;
        else
           return wParam ;
        break ;

      
      case WM_SHOWWINDOW:
         PrepareMenu (GetMenu (hWnd)) ;
         break ;

      case WM_SIZE:
         OnSize (hWnd, LOWORD (lParam), HIWORD (lParam)) ;
         break ;

      case WM_GETMINMAXINFO:
         {
         MINMAXINFO   *pMinMax ;

         pMinMax = (MINMAXINFO *) lParam ;
         pMinMax->ptMinTrackSize.x = MinimumSize ;
         pMinMax->ptMinTrackSize.y = MinimumSize ;
         }
         break ;

      case WM_NOTIFY:
         {
            LPTOOLTIPTEXT lpTTT = (LPTOOLTIPTEXT)lParam;

            if (lpTTT->hdr.code == TTN_NEEDTEXT) {
                LoadString (hInstance, lpTTT->hdr.idFrom, lpTTT->szText,
                    sizeof(lpTTT->szText)/sizeof(TCHAR));
                return TRUE;
            } else {
                bCallDefWinProc = FALSE ;
                break;
            }
         }

      case WM_F1DOWN:
         if (dwCurrentDlgID)
            {
            CallWinHelp (dwCurrentDlgID) ;
            }
         else if (dwCurrentMenuID)
            {
            CallWinHelp (dwCurrentMenuID) ;
            dwCurrentMenuID = 0 ;
            }
         break ;

      case WM_CREATE:
         OnCreate (hWnd) ;
         ViewChart (hWnd) ;
         PrepareMenu (GetMenu (hWnd)) ;
         break ;

      case WM_DESTROY:
         WinHelp (hWndMain, pszHelpFile, HELP_QUIT, 0) ;
         PostQuitMessage (0);
         break ;

      case WM_QUERYENDSESSION:
         // please shut it down
         return (1) ;
         break ;

      case WM_ENDSESSION:
         if (wParam == TRUE)
            {
            // close any log file before closing down
            PerfmonClose (hWnd) ;
            return (1) ;
            }
         else
            bCallDefWinProc = TRUE ;
         break ;

      case WM_CLOSE:
         PerfmonClose (hWnd) ;
         break ;

      case WM_ACTIVATE:
         {
         int   fActivate = LOWORD (wParam) ;

         bPerfmonIconic = (BOOL) HIWORD (wParam) ;
         if (bPerfmonIconic == 0 && fActivate != WA_INACTIVE)
            {
            // set focus on the Legend window
            if (iPerfmonView == IDM_VIEWCHART)
               {
               SetFocus (hWndGraphLegend) ;
               }
            else if (iPerfmonView == IDM_VIEWALERT)
               {
               SetFocus (hWndAlertLegend) ;
               }
            else if (iPerfmonView == IDM_VIEWLOG)
               {
               SetFocus (hWndLogEntries) ;
               }
            else if (iPerfmonView == IDM_VIEWREPORT)
               {
               SetFocus (hWndReport) ;
               }
            }
         }
         break ;

      case WM_SYSCOLORCHANGE:
         DeletePerfmonSystemObjects () ;
         CreatePerfmonSystemObjects () ;
         WindowInvalidate (PerfmonViewWindow()) ;
         break ;

      case WM_WININICHANGE:
         if (!lParam || strsamei((LPTSTR)lParam, szInternational))
            {
            GetDateTimeFormats () ;
            }
         break ;

      case WM_DROPFILES:
         OnDropFile (wParam) ;
         return (0) ;
         break ;

      default:
         bCallDefWinProc = TRUE ;
         break;

      }  // switch

   if (bCallDefWinProc)
      {
      lRetCode = DefWindowProc (hWnd, message, wParam, lParam) ;
      }
   return (lRetCode);
   }  // MainWndProc
Beispiel #25
0
/* text window */
LRESULT CALLBACK
WndTextProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    RECT rect;
    int nYinc, nXinc;
    TW *tw;
    if (message == WM_CREATE) {
	/* Object is stored in window extra data.
	 * Nothing must try to use the object before WM_CREATE
	 * initializes it here.
	 */
	tw = (TW *)(((CREATESTRUCT FAR *)lParam)->lpCreateParams);
	SetWindowLong(hwnd, 0, (LONG)tw);
    }
    tw = (TW *)GetWindowLong(hwnd, 0);

    switch(message) {
	case WM_SYSCOMMAND:
	    switch(LOWORD(wParam)) {
		case M_COPY_CLIP:
		    text_copy_to_clipboard(tw);
		    return 0;
		case M_PASTE_CLIP:
		    text_paste_from_clipboard(tw);
		    return 0;
	    }
	    break;
	case WM_SETFOCUS: 
	    tw->bFocus = TRUE;
	    CreateCaret(hwnd, 0, tw->CharSize.x, 2+tw->CaretHeight);
	    SetCaretPos(tw->CursorPos.x*tw->CharSize.x - tw->ScrollPos.x,
		    tw->CursorPos.y*tw->CharSize.y + tw->CharAscent
		     - tw->CaretHeight - tw->ScrollPos.y);
	    if (tw->bGetCh)
		    ShowCaret(hwnd);
	    break;
	case WM_KILLFOCUS: 
	    DestroyCaret();
	    tw->bFocus = FALSE;
	    break;
	case WM_MOVE:
	    if (!IsIconic(hwnd) && !IsZoomed(hwnd)) {
		GetWindowRect(hwnd, &rect);
		tw->x = rect.left;
		tw->y = rect.top;
	    }
	    break;
	case WM_SIZE:
	    if (wParam == SIZE_MINIMIZED)
		    return(0);

	    /* remember current window size */
	    if (wParam != SIZE_MAXIMIZED) {
		GetWindowRect(hwnd, &rect);
		tw->cx = rect.right - rect.left;
		tw->cy = rect.bottom - rect.top;
		tw->x = rect.left;
		tw->y = rect.top;
	    }

	    tw->ClientSize.y = HIWORD(lParam);
	    tw->ClientSize.x = LOWORD(lParam);

	    tw->ScrollMax.y = max(0, tw->CharSize.y*tw->ScreenSize.y - tw->ClientSize.y);
	    tw->ScrollPos.y = min(tw->ScrollPos.y, tw->ScrollMax.y);

	    SetScrollRange(hwnd, SB_VERT, 0, tw->ScrollMax.y, FALSE);
	    SetScrollPos(hwnd, SB_VERT, tw->ScrollPos.y, TRUE);

	    tw->ScrollMax.x = max(0, tw->CharSize.x*tw->ScreenSize.x - tw->ClientSize.x);
	    tw->ScrollPos.x = min(tw->ScrollPos.x, tw->ScrollMax.x);

	    SetScrollRange(hwnd, SB_HORZ, 0, tw->ScrollMax.x, FALSE);
	    SetScrollPos(hwnd, SB_HORZ, tw->ScrollPos.x, TRUE);

	    if (tw->bFocus && tw->bGetCh) {
		SetCaretPos(tw->CursorPos.x*tw->CharSize.x - tw->ScrollPos.x,
			    tw->CursorPos.y*tw->CharSize.y + tw->CharAscent 
			    - tw->CaretHeight - tw->ScrollPos.y);
		ShowCaret(hwnd);
	    }
	    return(0);
	case WM_VSCROLL:
	    switch(LOWORD(wParam)) {
		case SB_TOP:
		    nYinc = -tw->ScrollPos.y;
		    break;
		case SB_BOTTOM:
		    nYinc = tw->ScrollMax.y - tw->ScrollPos.y;
		    break;
		case SB_LINEUP:
		    nYinc = -tw->CharSize.y;
		    break;
		case SB_LINEDOWN:
		    nYinc = tw->CharSize.y;
		    break;
		case SB_PAGEUP:
		    nYinc = min(-1,-tw->ClientSize.y);
		    break;
		case SB_PAGEDOWN:
		    nYinc = max(1,tw->ClientSize.y);
		    break;
		case SB_THUMBPOSITION:
		    nYinc = HIWORD(wParam) - tw->ScrollPos.y;
		    break;
		default:
		    nYinc = 0;
	    }
	    if ( (nYinc = max(-tw->ScrollPos.y, 
		    min(nYinc, tw->ScrollMax.y - tw->ScrollPos.y)))
		    != 0 ) {
		    tw->ScrollPos.y += nYinc;
		    ScrollWindow(hwnd,0,-nYinc,NULL,NULL);
		    SetScrollPos(hwnd,SB_VERT,tw->ScrollPos.y,TRUE);
		    UpdateWindow(hwnd);
	    }
	    return(0);
	case WM_HSCROLL:
	    switch(LOWORD(wParam)) {
		case SB_LINEUP:
		    nXinc = -tw->CharSize.x;
		    break;
		case SB_LINEDOWN:
		    nXinc = tw->CharSize.x;
		    break;
		case SB_PAGEUP:
		    nXinc = min(-1,-tw->ClientSize.x);
		    break;
		case SB_PAGEDOWN:
		    nXinc = max(1,tw->ClientSize.x);
		    break;
		case SB_THUMBPOSITION:
		    nXinc = HIWORD(wParam) - tw->ScrollPos.x;
		    break;
		default:
		    nXinc = 0;
	    }
	    if ( (nXinc = max(-tw->ScrollPos.x, 
		    min(nXinc, tw->ScrollMax.x - tw->ScrollPos.x)))
		    != 0 ) {
		    tw->ScrollPos.x += nXinc;
		    ScrollWindow(hwnd,-nXinc,0,NULL,NULL);
		    SetScrollPos(hwnd,SB_HORZ,tw->ScrollPos.x,TRUE);
		    UpdateWindow(hwnd);
	    }
	    return(0);
	case WM_KEYDOWN:
	    switch(wParam) {
	      case VK_HOME:
		      SendMessage(hwnd, WM_VSCROLL, SB_TOP, (LPARAM)0);
		      break;
	      case VK_END:
		      SendMessage(hwnd, WM_VSCROLL, SB_BOTTOM, (LPARAM)0);
		      break;
	      case VK_PRIOR:
		      SendMessage(hwnd, WM_VSCROLL, SB_PAGEUP, (LPARAM)0);
		      break;
	      case VK_NEXT:
		      SendMessage(hwnd, WM_VSCROLL, SB_PAGEDOWN, (LPARAM)0);
		      break;
	      case VK_UP:
		      SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, (LPARAM)0);
		      break;
	      case VK_DOWN:
		      SendMessage(hwnd, WM_VSCROLL, SB_LINEDOWN, (LPARAM)0);
		      break;
	      case VK_LEFT:
		      SendMessage(hwnd, WM_HSCROLL, SB_LINEUP, (LPARAM)0);
		      break;
	      case VK_RIGHT:
		      SendMessage(hwnd, WM_HSCROLL, SB_LINEDOWN, (LPARAM)0);
		      break;
	    }
	    break;
	case WM_CHAR:
	    { /* store key in circular buffer */
		long count = tw->KeyBufIn - tw->KeyBufOut;
		if (count < 0) count += tw->KeyBufSize;
		if (count < tw->KeyBufSize-1) {
		    *tw->KeyBufIn++ = wParam;
		    if (tw->KeyBufIn - tw->KeyBuf >= tw->KeyBufSize)
			tw->KeyBufIn = tw->KeyBuf;	/* wrap around */
		}
	    }
	    return(0);
	case WM_PAINT:
	    {
	    POINT source, width, dest;
	    hdc = BeginPaint(hwnd, &ps);
	    SelectFont(hdc, tw->hfont);
	    SetMapMode(hdc, MM_TEXT);
	    SetBkMode(hdc,OPAQUE);
	    GetClientRect(hwnd, &rect);
	    source.x = (rect.left + tw->ScrollPos.x) / tw->CharSize.x; /* source */
	    source.y = (rect.top + tw->ScrollPos.y) / tw->CharSize.y;
	    dest.x = source.x * tw->CharSize.x - tw->ScrollPos.x; /* destination */
	    dest.y = source.y * tw->CharSize.y - tw->ScrollPos.y;
	    width.x = ((rect.right  + tw->ScrollPos.x + tw->CharSize.x - 1) / tw->CharSize.x) - source.x; /* width */
	    width.y = ((rect.bottom + tw->ScrollPos.y + tw->CharSize.y - 1) / tw->CharSize.y) - source.y;
	    if (source.x < 0)
		    source.x = 0;
	    if (source.y < 0)
		    source.y = 0;
	    if (source.x+width.x > tw->ScreenSize.x)
		    width.x = tw->ScreenSize.x - source.x;
	    if (source.y+width.y > tw->ScreenSize.y)
		    width.y = tw->ScreenSize.y - source.y;
	    /* for each line */
	    while (width.y>0) {
		    TextOut(hdc,dest.x,dest.y,
			(LPSTR)(tw->ScreenBuffer + source.y*tw->ScreenSize.x + source.x),
			width.x);
		    dest.y += tw->CharSize.y;
		    source.y++;
		    width.y--;
	    }
	    EndPaint(hwnd, &ps);
	    return 0;
	    }
	case WM_DROPFILES:
	    text_drag_drop(tw, (HDROP)wParam);
	    break;
	case WM_CREATE:
	    {
	    RECT crect, wrect;
	    int cx, cy;

	    tw->hwnd = hwnd;

	    /* make window no larger than screen buffer */
	    GetWindowRect(hwnd, &wrect);
	    GetClientRect(hwnd, &crect);
	    cx = min(tw->CharSize.x*tw->ScreenSize.x, crect.right);
	    cy = min(tw->CharSize.y*tw->ScreenSize.y, crect.bottom);
	    MoveWindow(hwnd, wrect.left, wrect.top,
		 wrect.right-wrect.left + (cx - crect.right),
		 wrect.bottom-wrect.top + (cy - crect.bottom),
		     TRUE);

	    if ( (tw->DragPre!=(LPSTR)NULL) && (tw->DragPost!=(LPSTR)NULL) )
		DragAcceptFiles(hwnd, TRUE);
	    }
	    break;
	case WM_CLOSE:
	    /* Tell user that we heard them */
	    if (!tw->quitnow) {
		char title[256];
		int count = GetWindowText(hwnd, title, sizeof(title)-11);
		strcpy(title+count, " - closing");
		SetWindowText(hwnd, title);
	    }
	    tw->quitnow = TRUE;
	    /* wait until Ghostscript exits before destroying window */
	    return 0;	
	case WM_DESTROY:
	    DragAcceptFiles(hwnd, FALSE);
	    if (tw->hfont)
		DeleteFont(tw->hfont);
	    tw->hfont = (HFONT)0;
	    tw->quitnow = TRUE;
	    PostQuitMessage(0);
	    break;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
Beispiel #26
0
static char* winDialogGetMaximizedAttrib(Ihandle *ih)
{
  return iupStrReturnBoolean(IsZoomed(ih->handle));
}
Beispiel #27
0
bool CWeapon::OnActionZoom(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if (IsModifying())
	{
		return false;
	}

	const bool zoomingIn = IsZoomingIn();
	const bool zoomed = IsZoomed();

	const bool toggleMode = (g_pGameCVars->cl_zoomToggle > 0);
	const bool toggleZoomOn = !(zoomingIn || zoomed);

	const bool buttonPressed = (activationMode == eAAM_OnPress);

	if (!toggleMode)
	{
		// Toggle mode is off, i.e. You have to hold to stay zoomed.
		if(buttonPressed || activationMode == eAAM_OnHold)
		{
			SetInputFlag(eWeaponAction_Zoom);
		}
		else
		{
			ClearInputFlag(eWeaponAction_Zoom);
		}
	}
	else
	{
		// Toggle mode is on.
		if(buttonPressed)
		{
			if (toggleZoomOn)
			{
				SetInputFlag(eWeaponAction_Zoom);
			}
			else
			{
				ClearInputFlag(eWeaponAction_Zoom);
			}
		}
	}
	
	//can ironsight while super jumping in MP
	const bool trumpZoom = !CanZoomInState();

	if (!AreAnyItemFlagsSet(eIF_Modifying) && !trumpZoom)	
	{
		if (!m_fm || !m_fm->IsReloading())
		{
			if (buttonPressed && (!toggleMode || toggleZoomOn))
			{
				if(m_fm && !m_fm->AllowZoom())
				{
					if(IsTargetOn())
					{
						m_fm->Cancel();
					}
					else
					{
						return false;
					}
				}
			}
			else if ((!toggleMode && activationMode == eAAM_OnRelease) || // Not toggle mode and button is released
							 (toggleMode && !toggleZoomOn && buttonPressed)) // Toggle mode, zoom is to be toggled off and button is pressed
			{
				StopZoom(actorId);
			}

			const bool shouldStartZoom = (!toggleMode && (buttonPressed || activationMode == eAAM_OnHold)) ||
																	 (toggleMode && toggleZoomOn && buttonPressed);
			if (m_zm && shouldStartZoom)
			{
				const bool zoomingOut = m_zm->IsZoomingInOrOut() && !zoomingIn;
				if ((!zoomed && !zoomingIn) || zoomingOut)
				{
					StartZoom(actorId,1);
				}
				if (buttonPressed)
				{
					m_snapToTargetTimer = 0.5f;
				}
			}
		}
		else if( (!toggleMode && activationMode == eAAM_OnRelease) || (toggleMode && !toggleZoomOn && buttonPressed) )
		{
			StopZoom(actorId);
		}
	}
	else if (trumpZoom)
	{
		StopZoom(actorId);
	}

	return true;
}
Beispiel #28
0
int iupdrvDialogSetPlacement(Ihandle* ih)
{
  char* placement;
  int no_activate;

  ih->data->cmd_show = SW_SHOWNORMAL;
  ih->data->show_state = IUP_SHOW;

  if (iupAttribGetBoolean(ih, "FULLSCREEN"))
    return 1;

  placement = iupAttribGet(ih, "PLACEMENT");
  if (!placement)
  {
    if (IsIconic(ih->handle) || IsZoomed(ih->handle))
      ih->data->show_state = IUP_RESTORE;
    return 0;
  }

  no_activate = iupAttribGetBoolean(ih, "SHOWNOACTIVATE");
  if (no_activate)
    ih->data->cmd_show = SW_SHOWNOACTIVATE;

  if (iupStrEqualNoCase(placement, "MAXIMIZED"))
  {
    if (no_activate)
      ih->data->cmd_show = SW_MAXIMIZE;
    else
      ih->data->cmd_show = SW_SHOWMAXIMIZED;
    ih->data->show_state = IUP_MAXIMIZE;
  }
  else if (iupStrEqualNoCase(placement, "MINIMIZED"))
  {
    if (no_activate)
      ih->data->cmd_show = SW_SHOWMINNOACTIVE;
    else if (iupAttribGetBoolean(ih, "SHOWMINIMIZENEXT"))
      ih->data->cmd_show = SW_MINIMIZE;
    else
      ih->data->cmd_show = SW_SHOWMINIMIZED;
    ih->data->show_state = IUP_MINIMIZE;
  }
  else if (iupStrEqualNoCase(placement, "FULL"))
  {
    int width, height, x, y;
    int caption, border, menu;
    iupdrvDialogGetDecoration(ih, &border, &caption, &menu);

    /* the dialog will cover the task bar */
    iupdrvGetFullSize(&width, &height);

    /* position the decoration and menu outside the screen */
    x = -(border);
    y = -(border+caption+menu);

    width += 2*border;
    height += 2*border + caption + menu;

    /* set the new size and position */
    /* WM_SIZE will update the layout */
    SetWindowPos(ih->handle, HWND_TOP, x, y, width, height, 0);

    if (IsIconic(ih->handle) || IsZoomed(ih->handle))
      ih->data->show_state = IUP_RESTORE;
  }

  iupAttribSet(ih, "PLACEMENT", NULL); /* reset to NORMAL */

  return 1;
}
Beispiel #29
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	MSG msg;
    INITCOMMONCONTROLSEX ctrls;
	HACCEL haccel;
	static char *class_name="DB_UTIL_CLASS";
	int first_instance=TRUE;
	int debug=0;

	first_instance=set_single_instance(TRUE);

	ghinstance=hInstance;
	init_ini_file();

#ifdef _DEBUG
	debug=1;
#else
	get_ini_value("SETTINGS","DEBUG",&debug);
#endif
	if(debug!=0){
		open_console();
	}

	{
		int val=0;
		get_ini_value("SETTINGS","SINGLE_INSTANCE",&val);
		if(val && (!first_instance)){
			COPYDATASTRUCT cd={0};
			HWND hdbutil;
			cd.cbData=nCmdShow;
			cd.cbData=strlen(lpCmdLine)+1;
			cd.lpData=lpCmdLine;
			hdbutil=FindWindow("DB_UTIL_CLASS",NULL);
			if(hdbutil!=0){
				int sw;
				SendMessage(hdbutil,WM_COPYDATA,hInstance,&cd);
				if (IsZoomed(hdbutil))
					sw=SW_MAXIMIZE;
				else if(IsIconic(hdbutil))
					sw=SW_RESTORE;
				else
					sw=SW_SHOW;
				ShowWindow(hdbutil,sw);
				SetForegroundWindow(hdbutil);
			}
			return TRUE;
		}
		set_single_instance(val);
	}
	init_mdi_stuff();

	LoadLibrary("RICHED20.DLL");
	LoadLibrary("Msftedit.dll");

	ctrls.dwSize=sizeof(ctrls);
    ctrls.dwICC = ICC_LISTVIEW_CLASSES|ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES;
	InitCommonControlsEx(&ctrls);
	
	InitializeCriticalSection(&mutex);

	start_worker_thread();
	start_intellisense_thread();

	setup_mdi_classes(ghinstance);
	
	ghmenu=LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1));
	ghmainframe=create_mainwindow(&WndProc,ghmenu,hInstance,class_name,"DB_UTIL");

	ShowWindow(ghmainframe,nCmdShow);
	UpdateWindow(ghmainframe);

	haccel=LoadAccelerators(ghinstance,MAKEINTRESOURCE(IDR_ACCELERATOR1));

	process_cmd_line(lpCmdLine);

    while(GetMessage(&msg,NULL,0,0)){
		if(!custom_dispatch(&msg))
		if(!TranslateMDISysAccel(ghmdiclient, &msg) && !TranslateAccelerator(ghmainframe,haccel,&msg)){
			TranslateMessage(&msg);
			//if(msg!=WM_MOUSEFIRST&&msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_NOTIFY)
			if(FALSE)
			if(msg.message!=0x118&&msg.message!=WM_NCHITTEST&&msg.message!=WM_SETCURSOR&&msg.message!=WM_ENTERIDLE&&msg.message!=WM_NCMOUSEMOVE&&msg.message!=WM_MOUSEFIRST)
			{
				static DWORD tick=0;
				if((GetTickCount()-tick)>500)
					printf("--\n");
				printf("x");
				print_msg(msg.message,msg.lParam,msg.wParam,msg.hwnd);
				tick=GetTickCount();
			}
			DispatchMessage(&msg);
		}
    }
	DeleteCriticalSection(&mutex);
    return msg.wParam;
	
}
Beispiel #30
0
SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	SDL_Surface *video;
	Uint32 prev_flags;
	DWORD style;
	const DWORD directstyle =
			(WS_POPUP);
	const DWORD windowstyle = 
			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
	const DWORD resizestyle =
			(WS_THICKFRAME|WS_MAXIMIZEBOX);
	int binfo_size;
	BITMAPINFO *binfo;
	HDC hdc;
	RECT bounds;
	int x, y;
	Uint32 Rmask, Gmask, Bmask;

	/* Clean up any GL context that may be hanging around */
	if ( current->flags & SDL_OPENGL ) {
		WIN_GL_ShutDown(this);
	}

	/* Recalculate the bitmasks if necessary */
	if ( bpp == current->format->BitsPerPixel ) {
		video = current;
	} else {
		switch (bpp) {
			case 15:
			case 16:
				if ( DIB_SussScreenDepth() == 15 ) {
					/* 5-5-5 */
					Rmask = 0x00007c00;
					Gmask = 0x000003e0;
					Bmask = 0x0000001f;
				} else {
					/* 5-6-5 */
					Rmask = 0x0000f800;
					Gmask = 0x000007e0;
					Bmask = 0x0000001f;
				}
				break;
			case 24:
			case 32:
				/* GDI defined as 8-8-8 */
				Rmask = 0x00ff0000;
				Gmask = 0x0000ff00;
				Bmask = 0x000000ff;
				break;
			default:
				Rmask = 0x00000000;
				Gmask = 0x00000000;
				Bmask = 0x00000000;
				break;
		}
		video = SDL_CreateRGBSurface(SDL_SWSURFACE,
					0, 0, bpp, Rmask, Gmask, Bmask, 0);
		if ( video == NULL ) {
			SDL_OutOfMemory();
			return(NULL);
		}
	}

	/* Fill in part of the video surface */
	prev_flags = video->flags;
	video->flags = 0;	/* Clear flags */
	video->w = width;
	video->h = height;
	video->pitch = SDL_CalculatePitch(video);

#ifdef WIN32_PLATFORM_PSPC
	 /* Stuff to hide that $#!^%#$ WinCE taskbar in fullscreen... */
	if ( flags & SDL_FULLSCREEN ) {
		if ( !(prev_flags & SDL_FULLSCREEN) ) {
			SHFullScreen(SDL_Window, SHFS_HIDETASKBAR);
			SHFullScreen(SDL_Window, SHFS_HIDESIPBUTTON);
			ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE);
		}
		video->flags |= SDL_FULLSCREEN;
	} else {
		if ( prev_flags & SDL_FULLSCREEN ) {
			SHFullScreen(SDL_Window, SHFS_SHOWTASKBAR);
			SHFullScreen(SDL_Window, SHFS_SHOWSIPBUTTON);
			ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOWNORMAL);
		}
	}
#endif
#ifndef NO_CHANGEDISPLAYSETTINGS
	/* Set fullscreen mode if appropriate */
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		DEVMODE settings;

		memset(&settings, 0, sizeof(DEVMODE));
		settings.dmSize = sizeof(DEVMODE);
		settings.dmBitsPerPel = video->format->BitsPerPixel;
		settings.dmPelsWidth = width;
		settings.dmPelsHeight = height;
		settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
		if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
			video->flags |= SDL_FULLSCREEN;
			SDL_fullscreen_mode = settings;
		}
	}
#endif /* !NO_CHANGEDISPLAYSETTINGS */

	/* Reset the palette and create a new one if necessary */
	if ( screen_pal != NULL ) {
	/*	RJR: March 28, 2000
		delete identity palette if switching from a palettized mode */
		DeleteObject(screen_pal);
		screen_pal = NULL;
	}
	if ( bpp <= 8 )
	{
	/*	RJR: March 28, 2000
		create identity palette switching to a palettized mode */
		screen_pal = DIB_CreatePalette(bpp);
	}

	style = GetWindowLong(SDL_Window, GWL_STYLE);
	style &= ~(resizestyle|WS_MAXIMIZE);
	if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		style &= ~windowstyle;
		style |= directstyle;
	} else {
#ifndef NO_CHANGEDISPLAYSETTINGS
		if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
			ChangeDisplaySettings(NULL, 0);
		}
#endif
		if ( flags & SDL_NOFRAME ) {
			style &= ~windowstyle;
			style |= directstyle;
			video->flags |= SDL_NOFRAME;
		} else {
			style &= ~directstyle;
			style |= windowstyle;
			if ( flags & SDL_RESIZABLE ) {
				style |= resizestyle;
				video->flags |= SDL_RESIZABLE;
			}
		}
#if WS_MAXIMIZE
		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif
	}

	/* DJM: Don't piss of anyone who has setup his own window */
	if ( SDL_windowid == NULL )
		SetWindowLong(SDL_Window, GWL_STYLE, style);

	/* Delete the old bitmap if necessary */
	if ( screen_bmp != NULL ) {
		DeleteObject(screen_bmp);
	}
	if ( ! (flags & SDL_OPENGL) ) {
		BOOL is16bitmode = (video->format->BytesPerPixel == 2);

		/* Suss out the bitmap info header */
		binfo_size = sizeof(*binfo);
		if( is16bitmode ) {
			/* 16bit modes, palette area used for rgb bitmasks */
			binfo_size += 3*sizeof(DWORD);
		} else if ( video->format->palette ) {
			binfo_size += video->format->palette->ncolors *
							sizeof(RGBQUAD);
		}
		binfo = (BITMAPINFO *)malloc(binfo_size);
		if ( ! binfo ) {
			if ( video != current ) {
				SDL_FreeSurface(video);
			}
			SDL_OutOfMemory();
			return(NULL);
		}

		binfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		binfo->bmiHeader.biWidth = video->w;
		binfo->bmiHeader.biHeight = -video->h;	/* -ve for topdown bitmap */
		binfo->bmiHeader.biPlanes = 1;
		binfo->bmiHeader.biSizeImage = video->h * video->pitch;
		binfo->bmiHeader.biXPelsPerMeter = 0;
		binfo->bmiHeader.biYPelsPerMeter = 0;
		binfo->bmiHeader.biClrUsed = 0;
		binfo->bmiHeader.biClrImportant = 0;
		binfo->bmiHeader.biBitCount = video->format->BitsPerPixel;

		if ( is16bitmode ) {
			/* BI_BITFIELDS tells CreateDIBSection about the rgb masks in the palette */
			binfo->bmiHeader.biCompression = BI_BITFIELDS;
			((Uint32*)binfo->bmiColors)[0] = video->format->Rmask;
			((Uint32*)binfo->bmiColors)[1] = video->format->Gmask;
			((Uint32*)binfo->bmiColors)[2] = video->format->Bmask;
		} else {
			binfo->bmiHeader.biCompression = BI_RGB;	/* BI_BITFIELDS for 565 vs 555 */
			if ( video->format->palette ) {
				memset(binfo->bmiColors, 0,
					video->format->palette->ncolors*sizeof(RGBQUAD));
			}
		}

		/* Create the offscreen bitmap buffer */
		hdc = GetDC(SDL_Window);
		screen_bmp = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS,
					(void **)(&video->pixels), NULL, 0);
		ReleaseDC(SDL_Window, hdc);
		free(binfo);
		if ( screen_bmp == NULL ) {
			if ( video != current ) {
				SDL_FreeSurface(video);
			}
			SDL_SetError("Couldn't create DIB section");
			return(NULL);
		}
		this->UpdateRects = DIB_NormalUpdate;

		/* Set video surface flags */
		if ( bpp <= 8 ) {
			/* BitBlt() maps colors for us */
			video->flags |= SDL_HWPALETTE;
		}
	}

	/* Resize the window */
	if ( SDL_windowid == NULL ) {
		HWND top;
		UINT swp_flags;
		const char *window = getenv("SDL_VIDEO_WINDOW_POS");
		const char *center = getenv("SDL_VIDEO_CENTERED");

		if ( !SDL_windowX && !SDL_windowY ) {
			if ( window ) {
				if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
					SDL_windowX = x;
					SDL_windowY = y;
				}
				if ( strcmp(window, "center") == 0 ) {
					center = window;
					window = NULL;
				}
			}
		}
		swp_flags = (SWP_NOCOPYBITS | SWP_SHOWWINDOW);

		SDL_resizing = 1;
		bounds.left = SDL_windowX;
		bounds.top = SDL_windowY;
		bounds.right = SDL_windowX+video->w;
		bounds.bottom = SDL_windowY+video->h;
		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
		width = bounds.right-bounds.left;
		height = bounds.bottom-bounds.top;
		if ( (flags & SDL_FULLSCREEN) ) {
			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
		} else if ( SDL_windowX || SDL_windowY || window ) {
			x = bounds.left;
			y = bounds.top;
		} else if ( center ) {
			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
		} else {
			x = y = -1;
			swp_flags |= SWP_NOMOVE;
		}
		if ( y < 0 ) { /* Cover up title bar for more client area */
			y -= GetSystemMetrics(SM_CYCAPTION)/2;
		}
		if ( flags & SDL_FULLSCREEN ) {
			top = HWND_TOPMOST;
		} else {
			top = HWND_NOTOPMOST;
		}
		SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags);
		SDL_resizing = 0;
		SetForegroundWindow(SDL_Window);
	}

	/* Set up for OpenGL */
	if ( flags & SDL_OPENGL ) {
		if ( WIN_GL_SetupWindow(this) < 0 ) {
			return(NULL);
		}
		video->flags |= SDL_OPENGL;
	}

	/* We're live! */
	return(video);
}