コード例 #1
0
/*
=========================
EntityWndProc
=========================
*/
BOOL CALLBACK EntityWndProc(
    HWND hwndDlg,	// handle to dialog box
    UINT uMsg,		// message
    WPARAM wParam,	// first message parameter
    LPARAM lParam)	// second message parameter
{
	RECT	rc;

	GetClientRect(hwndDlg, &rc);

    switch (uMsg)
    {

      case WM_CHAR :
      {
        char c = toupper(LOWORD(wParam));
        if (c == 'N')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_ENTITY, 0);
        else
        if (c == 'O')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_CONSOLE, 0);
        else
        if (c == 'T')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_TEXTURE, 0);
        else
			    DefWindowProc (hwndDlg, uMsg, wParam, lParam);
        break;
      }

	case WM_SIZE:

			DefWindowProc (hwndDlg, uMsg, wParam, lParam);
      break;

  case WM_DESTROY:
      SaveWindowPlacement(g_qeglobals.d_hwndEntity, "EntityWindowPlace");
      DefWindowProc(hwndDlg, uMsg, wParam, lParam);
      break;

	case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO	lpmmi;

			lpmmi = (LPMINMAXINFO) lParam;
			lpmmi->ptMinTrackSize.x = 320;
			lpmmi->ptMinTrackSize.y = 700;
		}
		return 0;

	case WM_WINDOWPOSCHANGING:
		{
			LPWINDOWPOS	lpwp;
			lpwp = (LPWINDOWPOS) lParam;

			DefWindowProc (hwndDlg, uMsg, wParam, lParam);

			lpwp->flags |= SWP_NOCOPYBITS;
			SizeEntityDlg(lpwp->cx-8, lpwp->cy-32);
			return 0;

		}
		return 0;


	case WM_COMMAND: 
		switch (LOWORD(wParam)) { 

    case IDC_BTN_ASSIGNSOUND:
      AssignSound();
      break;

    case IDC_BTN_ASSIGNMODEL:
      AssignModel();
      break;

		case IDC_E_DELPROP:
			DelProp();
			SetFocus (g_qeglobals.d_hwndCamera);
			break;

		case IDC_E_0:
			SetKeyValue (edit_entity, "angle", "360");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_45:
			SetKeyValue (edit_entity, "angle", "45");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_90:
			SetKeyValue (edit_entity, "angle", "90");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_135:
			SetKeyValue (edit_entity, "angle", "135");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_180:
			SetKeyValue (edit_entity, "angle", "180");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_225:
			SetKeyValue (edit_entity, "angle", "225");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_270:
			SetKeyValue (edit_entity, "angle", "270");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_315:
			SetKeyValue (edit_entity, "angle", "315");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_UP:
			SetKeyValue (edit_entity, "angle", "-1");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_DOWN:
			SetKeyValue (edit_entity, "angle", "-2");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;

    case IDC_BTN_HIDE:
      ::PostMessage(g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_CAMERATOGGLE, 0);
      break;

		case IDC_CHECK1:
		case IDC_CHECK2:
		case IDC_CHECK3:
		case IDC_CHECK4:
		case IDC_CHECK5:
		case IDC_CHECK6:
		case IDC_CHECK7:
		case IDC_CHECK8:
		case IDC_CHECK9:
		case IDC_CHECK10:
		case IDC_CHECK11:
		case IDC_CHECK12:
		case IDC_CHECK13:
		case IDC_CHECK14:
		case IDC_CHECK15:
		case IDC_CHECK16:
		case IDC_CHECK17:
		case IDC_CHECK18:
		case IDC_CHECK19:
		case IDC_CHECK20:
		case IDC_CHECK21:
			GetSpawnFlags();
			SetFocus (g_qeglobals.d_hwndCamera);
			break;


		case IDC_E_PROPS: 
			switch (HIWORD(wParam))
			{ 
			case LBN_SELCHANGE:

				EditProp();
				return TRUE; 
			}
			break;

		case IDC_E_LIST: 
	   
			switch (HIWORD(wParam)) { 
			
			case LBN_SELCHANGE: 
			{
				int iIndex;
				eclass_t *pec;
				
				iIndex = SendMessage(hwndEnt[EntList], LB_GETCURSEL, 0, 0);	
				pec = (eclass_t *)SendMessage(hwndEnt[EntList], LB_GETITEMDATA, 
						iIndex, 0); 
			
				UpdateSel(iIndex, pec);

				return TRUE; 
				break; 
			}

			case LBN_DBLCLK: 
				CreateEntity ();
				SetFocus (g_qeglobals.d_hwndCamera);
				break; 
			} 
            break; 


            default: 
              return DefWindowProc( hwndDlg, uMsg, wParam, lParam ); 
        } 

		return 0;
	}

    return DefWindowProc (hwndDlg, uMsg, wParam, lParam);
}
コード例 #2
0
void CTabsDlg::DockWindow(int ID , bool dock)
{
	DockedWindowInfo *info = NULL;
	m_Windows.Lookup((WORD)ID , (void* &)info);

	ASSERT(info);
	ASSERT(m_Tabs.GetSafeHwnd());

	ShowAllWindows(FALSE);

	if (!dock) {
		//make a containing window and assign the dialog to it
		CRect rect;
		CString classname = AfxRegisterWndClass(CS_DBLCLKS , 0 , 0 , 0);
		info->m_State = DockedWindowInfo::FLOATING;

		info->m_Window->GetWindowRect(rect);
		info->m_Container.CreateEx(WS_EX_TOOLWINDOW , classname , info->m_Title , WS_THICKFRAME | WS_SYSMENU | WS_POPUP | WS_CAPTION, rect , this , 0);
		info->m_Window->SetParent(&info->m_Container);
		info->m_Window->ShowWindow(TRUE);

		info->m_Container.SetDockManager(this);
		info->m_Container.ShowWindow(TRUE);
		info->m_Container.SetDialog(info->m_Window , info->m_ID);

		if (info->m_TabControlIndex >= 0) {
			m_Tabs.DeleteItem(info->m_TabControlIndex);
		}

		if (m_Tabs.GetItemCount() > 0) {
			m_Tabs.SetCurFocus(0);
		}

		CString placementName = info->m_Title + "Placement";
		LoadWindowPlacement(info->m_Container , placementName);
	} else {
		info->m_State = DockedWindowInfo::DOCKED;

		info->m_TabControlIndex = m_Tabs.InsertItem(TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM , 0 , info->m_Title , info->m_ImageID , (LPARAM)info);

		info->m_Window->SetParent(this);
		info->m_Window->ShowWindow(TRUE);

		info->m_Container.SetDockManager(NULL);	//so it doesn't try to call back and redock this window
		info->m_Container.DestroyWindow();

		CRect rect;
		GetWindowRect(rect);

		//stupid hack to get the window reitself properly
		rect.DeflateRect(0,0,0,1);
		MoveWindow(rect);
		rect.InflateRect(0,0,0,1);
		MoveWindow(rect);
	}

	UpdateTabControlIndices();
	FocusWindow(ID);

	if (info->m_DockCallback) {
		info->m_DockCallback(dock , info->m_ID , info->m_Window);
	}

	SaveWindowPlacement();
}
コード例 #3
0
ファイル: app_win.cpp プロジェクト: kamilik26/zephyros
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;

    // callback for the main window
    switch (message)
    {
    case WM_CREATE:
    {
        // create the single static handler class instance
        g_handler = new ClientHandler();
        g_handler->SetMainHwnd(hWnd);

        // create the child windows used for navigation
        RECT rect;
        GetClientRect(hWnd, &rect);

        CefWindowInfo info;
        CefBrowserSettings settings;
        settings.web_security = STATE_DISABLED;

        // initialize window info to the defaults for a child window.
        info.SetAsChild(hWnd, rect);

        // create the new child browser window
        CefBrowserHost::CreateBrowser(info, g_handler.get(), g_handler->GetStartupURL(), settings, NULL);

        // Todo: find a better solution for applying this e.g. with timeout in case showing of windows initially fails
        //ShowWindow(hWnd, SW_SHOWDEFAULT);
        //UpdateWindow(hWnd);
        SetTimer(hWnd, TIMER_SHOW_WINDW, 5000, NULL);

        return 0;
    }

    case WM_TIMER:
        if (wParam == TIMER_SHOW_WINDW)
        {
            HWND hWndMain = g_handler->GetMainHwnd();
            if (!IsWindowVisible(hWndMain))
            {
                ShowWindow(hWndMain, g_nCmdShow);
                UpdateWindow(hWndMain);
            }
            KillTimer(hWndMain, TIMER_SHOW_WINDW);
            return 0;
        }
        return 1;

    case WM_COMMAND:
    {
        CefRefPtr<CefBrowser> browser;
        if (g_handler.get())
            browser = g_handler->GetBrowser();

        int wmId = LOWORD(wParam);
        int wmEvent = HIWORD(wParam);

        // parse the menu selections
        if (g_mapMenuCommands.find(wmId) != g_mapMenuCommands.end())
        {
            String commandId = g_mapMenuCommands[wmId];
            if (g_handler.get())
            {
                CefRefPtr<CefListValue> args = CefListValue::Create();
                args->SetString(0, commandId);
                g_handler->GetClientExtensionHandler()->InvokeCallbacks(TEXT("onMenuCommand"), args);
            }

            return 0;
        }
        else
        {
            // handle other menu commands
            switch (wmId)
            {
            case IDM_EXIT:
                if (g_handler.get())
                    g_handler->CloseAllBrowsers(false);
                return 0;
            }
        }

        break;
    }

    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        EndPaint(hWnd, &ps);
        return 0;

    case WM_SETFOCUS:
        if (g_handler.get() && g_handler->GetBrowser())
        {
            // pass focus to the browser window
            CefWindowHandle hwnd = g_handler->GetBrowser()->GetHost()->GetWindowHandle();
            if (hwnd)
                PostMessage(hwnd, WM_SETFOCUS, wParam, NULL);
        }
        return 0;

    case WM_SIZE:
        // minimizing resizes the window to 0x0 which causes our layout to go all
        // screwy, so we just ignore it.
        if (wParam != SIZE_MINIMIZED && g_handler.get() && g_handler->GetBrowser())
        {
            CefWindowHandle hwnd = g_handler->GetBrowser()->GetHost()->GetWindowHandle();
            if (hwnd)
            {
                // resize the browser window and address bar to match the new frame window size
                RECT rect;
                GetClientRect(hWnd, &rect);

                HDWP hdwp = BeginDeferWindowPos(1);
                hdwp = DeferWindowPos(hdwp, hwnd, NULL,
                                      rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);
                EndDeferWindowPos(hdwp);
            }
        }
        break;

    case WM_ERASEBKGND:
        if (g_handler.get() && g_handler->GetBrowser())
        {
            CefWindowHandle hwnd = g_handler->GetBrowser()->GetHost()->GetWindowHandle();
            if (hwnd)
            {
                // don't erase the background if the browser window has been loaded (this avoids flashing)
                return 1;
            }
        }
        break;

    case WM_ENTERMENULOOP:
        if (!wParam)
        {
            // entering the menu loop for the application menu
            CefSetOSModalLoop(true);
        }
        break;

    case WM_EXITMENULOOP:
        if (!wParam)
        {
            // Exiting the menu loop for the application menu.
            CefSetOSModalLoop(false);
        }
        break;

    case WM_CLOSE:
        if (g_handler.get() && !g_handler->IsClosing())
        {
            WINDOWPLACEMENT wpl;
            wpl.length = sizeof(WINDOWPLACEMENT);
            GetWindowPlacement(App::GetMainHwnd(), &wpl);
            Rect r;
            r.x = wpl.rcNormalPosition.left;
            r.y = wpl.rcNormalPosition.top;
            r.w = wpl.rcNormalPosition.right - wpl.rcNormalPosition.left;
            r.h = wpl.rcNormalPosition.bottom - wpl.rcNormalPosition.top;
            SaveWindowPlacement(&r, wpl.showCmd);

            g_handler->GetClientExtensionHandler()->InvokeCallbacks(TEXT("onAppTerminating"), CefListValue::Create());

            CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
            if (browser.get())
            {
                // Notify the browser window that we would like to close it. This
                // will result in a call to ClientHandler::DoClose() if the
                // JavaScript 'onbeforeunload' event handler allows it.
                browser->GetHost()->CloseBrowser(false);

                // cancel the close
                return 0;
            }
        }

        // allow the close
        break;

    case WM_DESTROY:
        // quitting CEF is handled in ClientHandler::OnBeforeClose().
        return 0;
    }

    return DefWindowProc(hWnd, message, wParam, lParam);
}