本文整理汇总了C#中System.Form1.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# Form1.Focus方法的具体用法?C# Form1.Focus怎么用?C# Form1.Focus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Form1
的用法示例。
在下文中一共展示了Form1.Focus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGLWindow
//.........这里部分代码省略.........
//pc1.Width = width-100;
//pc1.Height = height-100 ;
//form.Width = 100 + width;
//form.Height = 100 + height;
form.Text = title; // Set Window Title
Gdi.PIXELFORMATDESCRIPTOR pfd = new Gdi.PIXELFORMATDESCRIPTOR(); // pfd Tells Windows How We Want Things To Be
pfd.nSize = (short)Marshal.SizeOf(pfd); // Size Of This Pixel Format Descriptor
pfd.nVersion = 1; // Version Number
pfd.dwFlags = Gdi.PFD_DRAW_TO_WINDOW| // Format Must Support Window
Gdi.PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
Gdi.PFD_DOUBLEBUFFER; // Format Must Support Double Buffering
pfd.iPixelType = (byte)Gdi.PFD_TYPE_RGBA; // Request An RGBA Format
pfd.cColorBits = (byte)bits; // Select Our Color Depth
pfd.cRedBits = 0; // Color Bits Ignored
pfd.cRedShift = 0;
pfd.cGreenBits = 0;
pfd.cGreenShift = 0;
pfd.cBlueBits = 0;
pfd.cBlueShift = 0;
pfd.cAlphaBits = 0; // No Alpha Buffer
pfd.cAlphaShift = 0; // Shift Bit Ignored
pfd.cAccumBits = 0; // No Accumulation Buffer
pfd.cAccumRedBits = 0; // Accumulation Bits Ignored
pfd.cAccumGreenBits = 0;
pfd.cAccumBlueBits = 0;
pfd.cAccumAlphaBits = 0;
pfd.cDepthBits = 16; // 16Bit Z-Buffer (Depth Buffer)
pfd.cStencilBits = 0; // No Stencil Buffer
pfd.cAuxBuffers = 0; // No Auxiliary Buffer
pfd.iLayerType = (byte)Gdi.PFD_MAIN_PLANE; // Main Drawing Layer
pfd.bReserved = 0; // Reserved
pfd.dwLayerMask = 0; // Layer Masks Ignored
pfd.dwVisibleMask = 0;
pfd.dwDamageMask = 0;
hDC = User.GetDC(pc1.Handle);
//hDC = User.GetDC(form.Handle); // Attempt To Get A Device Context
if (hDC == IntPtr.Zero)
{ // Did We Get A Device Context?
KillGLWindow(); // Reset The Display
MessageBox.Show("Can't Create A GL Device Context.", "ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
pixelFormat = Gdi.ChoosePixelFormat(hDC, ref pfd); // Attempt To Find An Appropriate Pixel Format
if (pixelFormat == 0)
{ // Did Windows Find A Matching Pixel Format?
KillGLWindow(); // Reset The Display
MessageBox.Show("Can't Find A Suitable PixelFormat.", "ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
if (!Gdi.SetPixelFormat(hDC, pixelFormat, ref pfd))
{ // Are We Able To Set The Pixel Format?
KillGLWindow(); // Reset The Display
MessageBox.Show("Can't Set The PixelFormat.", "ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
hRC = Wgl.wglCreateContext(hDC); // Attempt To Get The Rendering Context
if (hRC == IntPtr.Zero)
{ // Are We Able To Get A Rendering Context?
KillGLWindow(); // Reset The Display
MessageBox.Show("Can't Create A GL Rendering Context.", "ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
if (!Wgl.wglMakeCurrent(hDC, hRC))
{ // Try To Activate The Rendering Context
KillGLWindow(); // Reset The Display
MessageBox.Show("Can't Activate The GL Rendering Context.", "ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
form.Show(); // Show The Window
form.TopMost = true; // Topmost Window
form.Focus(); // Focus The Window
// pc1.Focus();
if (fullscreen)
{ // This Shouldn't Be Necessary, But Is
Cursor.Hide();
}
ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
if (!InitGL())
{ // Initialize Our Newly Created GL Window
KillGLWindow(); // Reset The Display
MessageBox.Show("Initialization Failed.", "ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true; // Success
}