当前位置: 首页>>代码示例>>C++>>正文


C++ WindowApplication::GetWindowTitle方法代码示例

本文整理汇总了C++中WindowApplication::GetWindowTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowApplication::GetWindowTitle方法的具体用法?C++ WindowApplication::GetWindowTitle怎么用?C++ WindowApplication::GetWindowTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WindowApplication的用法示例。


在下文中一共展示了WindowApplication::GetWindowTitle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Main


//.........这里部分代码省略.........
	GDHandle hGD = 0;
	GDHandle hgdNthDevice = GetDeviceList();
	unsigned int greatestArea = 0;

	// Check window against all gdRects in gDevice list and remember which
	// gdRect contains largest area of window.
	while (hgdNthDevice)
	{
		if (TestDeviceAttribute(hgdNthDevice, screenDevice)
		        &&  TestDeviceAttribute(hgdNthDevice, screenActive))
		{
			// The SectRect routine calculates the intersection of the window
			// rectangle and this gDevice rectangle and returns TRUE if the
			// rectangles intersect, FALSE if they don't.
			Rect rectSect;
			SectRect(&rect, &(**hgdNthDevice).gdRect, &rectSect);

			// Determine which screen holds greatest window area first.
			// Calculate area of rectangle on current device.
			unsigned int sectArea =
			    (unsigned int)(rectSect.right - rectSect.left) *
			    (rectSect.bottom - rectSect.top);
			if (sectArea > greatestArea)
			{
				greatestArea = sectArea; // set greatest area so far
				hGD = hgdNthDevice; // set zoom device
			}
			hgdNthDevice = GetNextDevice(hgdNthDevice);
		}
	}

	// Set window title.
	CFStringRef windowTitle = CFStringCreateWithCString(0,
	                          theApp->GetWindowTitle(), kCFStringEncodingASCII);
	SetWindowTitleWithCFString(window, windowTitle);
	CFRelease(windowTitle);

	theApp->SetWindowID((int)window);
	SetPortWindowPort(window);

	// Create the renderer.
	RendererInput input;
	input.mDevice = (AGLDevice)hGD;
	input.mWindow = window;
	mRenderer = new0 Renderer(input, theApp->GetWidth(), theApp->GetHeight(),
	                          mColorFormat, mDepthStencilFormat, mNumMultisamples);

	// Install quit apple event handler.
	error = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
	                              NewAEEventHandlerUPP((AEEventHandlerProcPtr)QuitAppleEventHandler), 0,
	                              false);
	if (error != noErr)
	{
		ExitToShell();
	}

	// Install window close handler.
	EventTypeSpec eventType;
	eventType.eventClass = kEventClassWindow;
	eventType.eventKind = kEventWindowClose;
	EventHandlerUPP handlerUPP = NewEventHandlerUPP(ProcessWindowClose);
	InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);

	// Install window bounds change handler.
	eventType.eventKind = kEventWindowBoundsChanged;
	handlerUPP = NewEventHandlerUPP(ProcessWindowBoundsChange);
开发者ID:bazhenovc,项目名称:WildMagic,代码行数:67,代码来源:Wm5AglApplication.cpp

示例2: Main

//----------------------------------------------------------------------------
int WindowApplication::Main (int, char**)
{
    WindowApplication* theApp = (WindowApplication*)TheApplication;
    theApp->KEY_TERMINATE = WindowApplication::KEY_ESCAPE;

#ifdef WM5_USE_DX9
    // DirectX uses a projection matrix for depth in [0,1].
    Camera::SetDefaultDepthType(Camera::PM_DEPTH_ZERO_TO_ONE);
#endif

#ifdef WM5_USE_OPENGL
    // OpenGL uses a projection matrix for depth in [-1,1].
    Camera::SetDefaultDepthType(Camera::PM_DEPTH_MINUS_ONE_TO_ONE);
#endif

    // Allow work to be done before the window is created.
    if (!theApp->OnPrecreate())
    {
        return -1;
    }

    // === Create the window for rendering. ===

    // Register the window class.
    static char sWindowClass[] = "Wild Magic 5 Application";
    WNDCLASS wc;
    wc.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    wc.lpfnWndProc   = MsWindowEventHandler;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = 0;
    wc.hIcon         = LoadIcon(0, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(0, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.lpszClassName = sWindowClass;
    wc.lpszMenuName  = 0;
    RegisterClass(&wc);

    DWORD dwStyle;
    if (mAllowResize)
    {
        dwStyle = WS_OVERLAPPEDWINDOW;
    }
    else
    {
        // This removes WS_THICKFRAME and WS_MAXIMIZEBOX, both of which allow
        // resizing of windows.
        dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
    }

    // Require the window to have the specified client area.
    RECT rect = { 0, 0, theApp->GetWidth()-1, theApp->GetHeight()-1 };
    AdjustWindowRect(&rect, dwStyle, FALSE);

    // Create the application window.
    HWND handle = CreateWindow(sWindowClass, theApp->GetWindowTitle(),
        dwStyle, theApp->GetXPosition(), theApp->GetYPosition(),
        rect.right - rect.left + 1, rect.bottom - rect.top + 1, 0, 0, 0, 0);

    // Save the handle as an 'int' for portable handle storage.
    theApp->SetWindowID(PtrToInt(handle));

    // ===

#ifdef WM5_USE_DX9
    // Create the device for rendering.
    RendererInput input;
    input.mWindowHandle = handle;
    input.mDriver = Direct3DCreate9(D3D_SDK_VERSION);
    assertion(input.mDriver != 0, "Failed to create Direct3D9\n");
    mRenderer = new0 Renderer(input, theApp->GetWidth(), theApp->GetHeight(),
        mColorFormat, mDepthStencilFormat, mNumMultisamples);
#endif

#ifdef WM5_USE_OPENGL
    // The pixelFormat variable is used to support creation of a window that
    // supports multisampling.  This process requires creating a normal window,
    // and then querying whether the renderer supports multisampling.  The
    // renderer creates a device context for the window which we then need to
    // create a second window that supports multisampling.  The device context
    // rendererDC is set by the renderer during the process.
    RendererInput input;
    input.mWindowHandle = handle;
    input.mPixelFormat = 0;
    input.mRendererDC = 0;
    input.mDisableVerticalSync = true;
    mRenderer = new0 Renderer(input, theApp->GetWidth(), theApp->GetHeight(),
        mColorFormat, mDepthStencilFormat, mNumMultisamples);

    // To determine whether multisampling is supported, it is necessary to
    // create a window, an OpenGL context, and query the driver for the
    // multisampling extensions.  If it is, a new window must be created
    // because the renderer creation involves SetPixelFormat(...) that can
    // be called only once for a window.
    int numMultisamples = mRenderer->GetNumMultisamples();
    if (numMultisamples > 0)
    {
        int attributes[256], pos = 0;
        attributes[pos++] = WGL_SUPPORT_OPENGL_ARB;
//.........这里部分代码省略.........
开发者ID:rasslingcats,项目名称:calico,代码行数:101,代码来源:Wm5WinApplication.cpp

示例3: Main

//----------------------------------------------------------------------------
int WindowApplication::Main (int numArguments, char** arguments)
{
    // Initialize the extra data.  TODO:  Port the extra-data system of WM4
    // to WM5.
    memset(gsExtraData, 0, APP_EXTRA_DATA_QUANTITY*sizeof(char));

    WindowApplication* theApp = (WindowApplication*)TheApplication;
    theApp->KEY_TERMINATE = KEY_ESCAPE;

    // OpenGL uses a projection matrix for depth in [-1,1].
    Camera::SetDefaultDepthType(Camera::PM_DEPTH_MINUS_ONE_TO_ONE);

    // Allow work to be done before the window is created.
    if (!theApp->OnPrecreate())
    {
        return -1;
    }

    // Connect to the X server.
    const char* displayName = 0;
    Display* display = XOpenDisplay(displayName);
    if (!display)
    {
        return -2;
    }

    // Make sure the X server has OpenGL GLX extensions.
    int errorBase, eventBase;
    Bool success = glXQueryExtension(display, &errorBase, &eventBase);
    assertion(success == True, "GLX extensions not found.\n");
    if (!success)
    {
        return -3;
    }

    // Partial construction of a GLX renderer.  The window for the renderer
    // is not yet constructed.  When it is, the window identifier is supplied
    // to the renderer to complete its construction.
    RendererInput input;
    input.mDisplay = display;
    input.mVisual = 0;
    input.mContext = 0;
    mRenderer = new0 Renderer(input, theApp->GetWidth(), theApp->GetHeight(),
        mColorFormat, mDepthStencilFormat, mNumMultisamples);
    if (!input.mVisual || !input.mContext)
    {
        return -4;
    }

    // Create an X Window with the visual information created by the renderer
    // constructor.  The visual information might not be the default, so
    // create an X colormap to use.
    Window rootWindow = RootWindow(display, input.mVisual->screen);
    Colormap cMap = XCreateColormap(display, rootWindow,
        input.mVisual->visual, AllocNone);

    // Set the event mask to include exposure (paint), button presses (mouse),
    // and key presses (keyboard).
    XSetWindowAttributes windowAttributes;
    windowAttributes.colormap = cMap;
    windowAttributes.border_pixel = 0;
    windowAttributes.event_mask =
        ButtonPressMask |
        ButtonReleaseMask |
        PointerMotionMask |
        Button1MotionMask |
        Button2MotionMask |
        Button3MotionMask |
        KeyPressMask |
        KeyReleaseMask |
        ExposureMask |
        StructureNotifyMask;

    int xPos = theApp->GetXPosition();
    int yPos = theApp->GetYPosition();
    unsigned int width = (unsigned int)theApp->GetWidth();
    unsigned int height = (unsigned int)theApp->GetHeight();
    unsigned int borderWidth = 0;
    unsigned long valueMask = CWBorderPixel | CWColormap | CWEventMask;
    Window window = XCreateWindow(display, rootWindow, xPos, yPos, width,
        height, borderWidth, input.mVisual->depth, InputOutput,
        input.mVisual->visual, valueMask, &windowAttributes);

    XSizeHints hints;
    hints.flags = PPosition | PSize;
    hints.x = xPos;
    hints.y = yPos;
    hints.width = width;
    hints.height = height;
    XSetNormalHints(display, window, &hints);

    const char* iconName = theApp->GetWindowTitle();
    Pixmap iconPixmap = None;
    XSetStandardProperties(display, window, theApp->GetWindowTitle(),
        iconName, iconPixmap, arguments, numArguments, &hints);

    // Intercept the close-window event when the user selects the
    // window close button.  The event is a "client message".
    Atom wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", False);
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:GeometricTools,代码行数:101,代码来源:Wm5GlxApplication.cpp

示例4: Main

//----------------------------------------------------------------------------
int WindowApplication::Main (int, char**)
{
    WindowApplication* theApp = (WindowApplication*)TheApplication;
    theApp->KEY_TERMINATE = WindowApplication::KEY_ESCAPE;

    // OpenGL uses a projection matrix for depth in [-1,1].
    Camera::SetDefaultDepthType(Camera::PM_DEPTH_MINUS_ONE_TO_ONE);

    // Register the termination function so that we can destroy the window
    // after GLUT abnormally calls 'exit'.
    if (atexit(Terminate) != 0)
    {
        return -1;
    }

    // Give GLUT dummy arguments, because we are not allowing control to
    // GLUT via command-line parameters.
    int numArguments = 1;
    char* arguments[1];
    arguments[0] = new char[6];
    strcpy(arguments[0], "dummy");
    glutInit(&numArguments, arguments);
    delete[] arguments[0];

    // We will always use double buffering, 32-bit RGBA front buffer,
    // depth buffer, and stencil buffer.
    if (mNumMultisamples == 0)
    {
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
    }
    else
    {
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL
            | GLUT_MULTISAMPLE);
        mNumMultisamples = glutGet(GLUT_WINDOW_NUM_SAMPLES);
    }

    // Allow work to be done before the window is created.
    if (!theApp->OnPrecreate())
    {
        return -2;
    }

    // Create window and renderer.  Multisampling is not supported.
    glutInitWindowSize(theApp->GetWidth(), theApp->GetHeight());
    RendererInput input;
    input.mWindowID = glutCreateWindow(theApp->GetWindowTitle());
    input.mDisableVerticalSync = true;
    mRenderer = new0 Renderer(input, theApp->GetWidth(), theApp->GetHeight(),
        mColorFormat, mDepthStencilFormat, mNumMultisamples);

    // Save the handle as an 'int' for portable handle storage.
    theApp->SetWindowID(input.mWindowID);

    // Set the callbacks for event handling.
    glutReshapeFunc(ReshapeCallback);
    glutDisplayFunc(DisplayCallback);
    glutIdleFunc(IdleCallback);
    glutKeyboardFunc(KeyDownCallback);
    glutKeyboardUpFunc(KeyUpCallback);
    glutSpecialFunc(SpecialKeyDownCallback);
    glutSpecialUpFunc(SpecialKeyUpCallback);
    glutMouseFunc(MouseClickCallback);
    glutMotionFunc(MotionCallback);
    glutPassiveMotionFunc(PassiveMotionCallback);

    if (theApp->OnInitialize())
    {
        // The default OnPreidle() clears the buffers.  Allow the application
        // to fill them before the window is shown and before the event loop
        // starts.
        theApp->OnPreidle();

        glutMainLoop();
    }

    // Because glutMainLoop never exits, the clean-up is handled via the
    // static Terminate in this file (registered with 'atexit').
    return 0;
}
开发者ID:2asoft,项目名称:GeometricTools,代码行数:81,代码来源:Wm5GlutApplication.cpp


注:本文中的WindowApplication::GetWindowTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。