mzdmr's picture

Making transparent local area in windowsform

In windows form properties I can change the "TransparencyKey" and I can make the whole form transparent. But I want to do like that only for panel in windows form. Maybe it can be done with another element different from Panel but I exactly want to make transparent local area in windows form in other words I want to see behind this local area , not whole form. Is there any way in C# ? Thanks


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

This is not directly supported in WinForms, but you can render transparent controls with a little bit of effort. This is a platform-specific approach (windows-only): http://stackoverflow.com/questions/9358500/winforms-making-a-control-tra...

Note that this will not (cannot) work correctly if your transparent control covers an OpenGL surface. This is a limitation of Windows/GDI.

mzdmr's picture

Because I couldn't embed the OpenGL console in WindowsForm and I thought that I can make a transparent panel , so I could see the OpenGL secreen. Is it not possible?

the Fiddler's picture
Quote:

Because I couldn't embed the OpenGL console in WindowsForm and I thought that I can make a transparent panel , so I could see the OpenGL secreen. Is it not possible?

Can you please describe what you are trying to achieve? A screenshot might be useful.

You can embed OpenGL inside a Windows Form using OpenTK.GLControl. This is a regular WinForms Control that you can add through the WinForms designer.

mzdmr's picture

I have windows form and external OpenGL console window. I tried to embed it by using OpenK.GLControl but I couldn't succeed. I have glut functions so I don't know how can I embed this.

This is myreshape , myDisplay and myIdle functions

               public static void myIdle()
            {
                Glut.glutPostRedisplay();
            }
 
 
             static void DrawGroundPlane2_1(int numSegs)
            {
                Gl.glColor3f(0.7f, 0.1f, 0.1f);
                Gl.glBegin(Gl.GL_POLYGON);
                Gl.glNormal3f(0f, 0f, 1f);
                // right side
 
                Gl.glVertex3f(-0.8f, (float)(z7 + zz7 + 180) / 600, 0f);
                Gl.glVertex3f(-0.8f, 0f, 0f);
                Gl.glVertex3f((float)(-x8) / 600, 0f, 0f);
                Gl.glVertex3f((float)(-x8) / 600, (float)(z8 + zz8 + 180) / 600, 0f);
                Gl.glVertex3f((float)(-x7) / 600, (float)(z7 + zz7 + 180) / 600, 0f);
 
                Gl.glEnd();
            }
 
 
 
            public static void myDisplay()
            {
                Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
 
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glLoadIdentity();
                Glu.gluLookAt(0f, 1f, 4.25f, 0f, 1f, 0f, 0f, 0.5f,0f);
                // Glu.gluLookAt(ekrn sla dn, Dik krşıdn,kçldkçe zoom ypıyr,ekrn sğa dn,ekrn ykrı,ekrn aşağı,grk yk,grk yk,grk yk)
 
               // DrawGroundPlane(16);
                DrawGroundPlane3(16);
                DrawGroundPlane1(16);
                DrawGroundPlane2(16);
                DrawGroundPlane0(16);
                DrawGroundPlane1_1(16);
                DrawGroundPlane2_1(16);
 
                DrawRobotArm(16);
 
                Glut.glutSwapBuffers();
            }
 
 
 
            public static void myReshape(int w, int h)
            {
                Gl.glViewport(0, 0, w, h);
 
                Gl.glMatrixMode(Gl.GL_PROJECTION);
                Gl.glLoadIdentity();
                Glu.gluPerspective(30, w / h, 0.1, 10);
 
                Gl.glMatrixMode(Gl.GL_MODELVIEW);
                Gl.glLoadIdentity();
                Gl.glTranslatef(3.0f, 0.5f, -7.0f);
 
            }

And these are glControl1_Load and glControl1_Paint functions;

           private void glControl1_Load(object sender, EventArgs e)
            {
 
            }
 
            private void glControl1_Paint(object sender, PaintEventArgs e)
            {
 
            }

If you can give my your mail address I can send you my .sln file. My address " demir.muaz@gmail.com "