Entwickler-Ecke

WinForms - Problem mit eigenem Formstyle...


Delete - Do 12.08.10 14:07
Titel: Problem mit eigenem Formstyle...
Ich habe bereits in VB einige Formstyles geschrieben, jetzt habe ich mich in C# drangewagt und auch eigentlich keine probleme bekommen, bis ich eine Form von der klasse erben lasse dann bekomme ich einen haufen fehler...

Hier ma der Code...

C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Orbit_FTP_Client
{
    class FormStyle:Form
    {
        #region ContextMenuTaskbar
        const Int32 SC_SIZE = 0xf000;
        const Int32 SC_MOVE = 0xf010;
        const Int32 SC_MINIMIZE = 0xf020;
        const Int32 SC_MAXIMIZE = 0xf030;
        const Int32 SC_CLOSE = 0xf060;
        const Int32 SC_RESTORE = 0xf120;
        const Int32 MF_BYCOMMAND = 0x0;
        const Int32 MF_SEPARATOR = 0x800;
        private const int HTCAPTION = 2;
        //private const int MF_GRAYED = 0x1L;
        private const int TPM_RETURNCMD = 0x100;
        private const int WM_SYSCOMMAND = 0x112;

        // ERROR: Not supported in C#: DeclareDeclaration
        // ERROR: Not supported in C#: DeclareDeclaration
        [DllImport("user32.dll", EntryPoint = "EnableMenuItem")]
        private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);

        [DllImport("user32.dll", EntryPoint = "ReleaseCapture")]
        private static extern int ReleaseCapture();

        [DllImport("user32.dll", EntryPoint = "GetSystemMenu")]
        private static extern IntPtr GetSystemMenu(IntPtr hwnd, int bRevert);

        [DllImport("user32.dll", EntryPoint = "TrackPopupMenuEx")]
        private static extern int TrackPopupMenuEx(IntPtr hMenu, int wFlags, int x, int y, IntPtr hWnd, int lpTpm);

        protected override CreateParams CreateParams
        {
            get
            {
                const int WS_SYSMENU = 0x80000;
                const int WS_MAXIMIZEBOX = 0x10000;
                const int WS_MINIMIZEBOX = 0x20000;
                CreateParams oReturn = base.CreateParams;
                oReturn.Style = oReturn.Style | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
                return oReturn;
            }
        }
        #endregion

        #region Global Vars
        private Size titlebarLeft;
             private Size titlebarRight;
             private Size titlebarMid;
             private Size borderLeft;
             private Size borderRight;
             private Size borderBottom;
             private Size borderCornerLeft;
             private Size borderCornerRight;
             private Size closeButton;
             private Size maximizeButton;
             private Size minimizeButton;
             private Size closeButton_tool;

             private Font TextFont_;
             private Color TextColor_;

             private Image BG_Image = null;
             private Color BG_Color;

             private WindowStyle_ curWinStyle = WindowStyle_.Sizeable;

             private CursorState curstate_ = CursorState.Normal;
             private CursorState chSstate_ = CursorState.Normal;

             private ButtonState closeButtonState = ButtonState.Normal;
             private ButtonState minimizeButtonState = ButtonState.Normal;
             private ButtonState maximizeButtonState = ButtonState.Normal;

             private bool move_ = false;
             private bool mousedown_ = false;

             private Point oldpos_;
             private bool mov_chS = false;
             private bool chS = false;
             private Point oldformpos_;

             private Point oldscreenpos_;
             private Size oldsize_;
        #endregion

        #region Enums
             public enum CursorState
        { 
            TopLeft,
            TopMid,
            TopRight,
            BorderRight,
            BorderCornerRight,
            BorderBottom,
            BorderCornerLeft,
            BorderLeft,
            Normal
        }
             public enum ButtonState
        { 
            Normal,
            Over,
            Down
        }
             public enum WindowStyle_
        { 
            ToolBox,
            MSG_Box,
            Sizeable,
            Fixed
        }
        #endregion

        #region properties
        ///<summary>
        /// Schriftart des Fenstertitels
        /// </summary>
             public Font Font_Title
             {
                 get 
                 {
                     return TextFont_;
                 }

                 set 
                 {
                     TextFont_ = value;
                 }
             }

        ///<summary>
        /// Schriftfarbe des Fenstertitels
        ///</summary>
             public Color ForeColor_Title
             {
                 get 
                 {
                     return TextColor_;
                 }

                 set 
                 {
                     TextColor_ = value;
                 }
             }

        ///<summary>
        /// Hintergrundbild des Fensters
        /// </summmary>
             public Image BackGroundImage_Form
             {
                 get
                 {
                     return BG_Image;
                 }
                 set
                 {
                     BG_Image = value;
                 }
             }

        ///<summary>
        /// Hintergrundfarbe des Fensters
        /// </summary>
             public Color BackGroundColor_Form
             {
                 get 
                 {
                     return BG_Color;
                 }

                 set 
                 {
                     BG_Color = value;
                 }
             }

        ///<summary>
        /// Fensterstil
        /// </summary>
             public WindowStyle_ Fensterstyle
             {
                 get 
                 {
                     return curWinStyle;
                 }

                 set
                 {
                     curWinStyle = value;
                 }
             }
        //Overrides

             protected override System.Windows.Forms.Padding DefaultPadding
             {
                 get { return new Padding(borderLeft.Width, titlebarMid.Height, borderRight.Width, borderBottom.Height); }
             }

             [EditorBrowsable(EditorBrowsableState.Never)]
             [Browsable(false)]
             public override System.Drawing.Color BackColor
             {
                 get { return base.BackColor; }
                 set { base.BackColor = this.TransparencyKey; }
             }

             [EditorBrowsable(EditorBrowsableState.Never)]
             [Browsable(false)]
             public override System.Drawing.Image BackgroundImage
             {
                 get { return null; }

                 set { }
             }
        #endregion

        #region Initalisiren
        public void New()
         {
             this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
             this.DoubleBuffered = true;
             this.FormBorderStyle = FormBorderStyle.None;
             BG_Color = SystemColors.Control;
             this.BackColor = Color.LavenderBlush;
             this.TransparencyKey = Color.LavenderBlush;
             this.MaximizedBounds = SystemInformation.WorkingArea;
             titlebarLeft = Properties.Resources.titlebarLeft.Size;
             titlebarMid = new Size(this.Width - titlebarLeft.Width - titlebarRight.Width +2,titlebarRight.Height);
             titlebarRight = Properties.Resources.titlebarRight.Size;
             borderRight = new Size(7,this.Height-borderBottom.Height-titlebarLeft.Height +2);
             borderCornerRight = Properties.Resources.borderCornerRight.Size;
             borderBottom = new Size(this.Width, 7);
             borderCornerLeft = Properties.Resources.borderCornerLeft.Size;
             borderLeft = new Size(7this.Height - titlebarMid.Height - borderCornerLeft.Height);
             closeButton = Properties.Resources.closeNormal.Size;
             closeButton_tool = Properties.Resources.closeNormal_tool.Size;
             maximizeButton = Properties.Resources.maximizeNormal.Size;
             minimizeButton = Properties.Resources.minimizeNorm.Size;
             TextColor_ = Color.Black;
             try
             {
                 TextFont_ = new Font("Arial"9, FontStyle.Regular);
             }
             catch
             {
                 TextFont_ = this.Font;
             }
         }
        
        private void InitializeComponent()
{
    this.SuspendLayout();
    // 
    // FormStyle
    // 
    this.ClientSize = new System.Drawing.Size(284262);
    this.Name = "FormStyle";
    this.Paint += new System.Windows.Forms.PaintEventHandler(this.FormStyle_Paint);
    this.ResumeLayout(false);

}
        #endregion

        #region Zeichnen

        private void DrawSizableWindow(object sender, PaintEventArgs e)
        {
            //Graphic Vars
            Graphics g = e.Graphics;
            SolidBrush borderColor_ = new SolidBrush(Color.FromArgb(102102102));
            Rectangle B_Top = new Rectangle(titlebarLeft.Width -1,0,this.Width-titlebarLeft.Width-titlebarRight.Width +2,1);
            Rectangle T_Top = new Rectangle(titlebarLeft.Width - 11this.Width - titlebarLeft.Width - titlebarRight.Width + 2,6);
            Rectangle B_Bottom = new Rectangle(borderCornerLeft.Width - 1this.Height - 1this.Width - borderCornerLeft.Width - borderCornerRight.Width + 21);
            Rectangle T_Bottom = new Rectangle(borderCornerLeft.Width - 1this.Height - 7this.Width - borderCornerLeft.Width - borderCornerRight.Width + 26);
            Rectangle B_Right = new Rectangle(0,titlebarLeft.Height -1,1,this.Height-titlebarLeft.Height-borderCornerLeft.Height +2);
            Rectangle T_Right = new Rectangle(7, titlebarLeft.Height - 16this.Height - titlebarLeft.Height - borderCornerLeft.Height + 2);
            Rectangle B_Left = new Rectangle(this.Width - 1, titlebarRight.Height - 11this.Height - titlebarRight.Height - borderCornerRight.Height + 2);
            Rectangle T_Left = new Rectangle (this.Width - 7, titlebarRight.Height - 16this.Height - titlebarRight.Height - borderCornerRight.Height + 2);
            
            //Draw Borders
            g.FillRectangle(borderColor_, B_Top);
            g.FillRectangle(borderColor_, B_Right);
            g.FillRectangle(borderColor_, B_Left);
            g.FillRectangle(borderColor_, B_Bottom);

            g.FillRectangle(Brushes.White, T_Bottom);
            g.FillRectangle(Brushes.White, T_Left);
            g.FillRectangle(Brushes.White, T_Right);
            g.FillRectangle(Brushes.White, T_Top);
        }

        private void FormStyle_Paint(object sender, PaintEventArgs e)
            {
                if(this.Fensterstyle == WindowStyle_.Sizeable) DrawSizableWindow(sender,e);
            }
        #endregion

        #region Mouse Events

        private void FormStyle_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
  if (e.Button == MouseButtons.Left) {
    mousedown_ = true;

        if (new Rectangle(0, borderCornerLeft.Height, titlebarLeft.Width, this.Height - borderCornerLeft.Height - borderCornerLeft.Height).Contains(e.X, e.Y))
        {
      chSstate_ = CursorState.TopLeft;
      oldpos_ = e.Location;
      oldformpos_ = this.Location;
      oldscreenpos_ = PointToScreen(e.Location);
      oldsize_ = this.Size;
    } else if (new Rectangle(00, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) {
      chSstate_ = CursorState.TopLeft;
      oldpos_ = e.Location;
      oldformpos_ = this.Location;
      oldscreenpos_ = PointToScreen(e.Location);
      oldsize_ = this.Size;
    } else if (new Rectangle(00this.Width - borderCornerLeft.Width, borderLeft.Width).Contains(e.X, e.Y)) {
      chSstate_ = CursorState.TopMid;
      oldpos_ = e.Location;
      oldformpos_ = this.Location;
      oldscreenpos_ = PointToScreen(e.Location);
      oldsize_ = this.Size;
    } else if (new Rectangle(this.Width - borderCornerLeft.Width, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) {
      chSstate_ = CursorState.TopRight;
      oldpos_ = e.Location;
      oldformpos_ = this.Location;
      oldscreenpos_ = PointToScreen(e.Location);
      oldsize_ = this.Size;
    } else if (new Rectangle(this.Width - borderCornerRight.Width, borderCornerLeft.Height, borderCornerRight.Width, this.Height - 2 * borderCornerLeft.Height).Contains(e.X, e.Y)) {
      chSstate_ = CursorState.BorderCornerRight;
      oldpos_ = e.Location;
      oldformpos_ = this.Location;
      oldscreenpos_ = PointToScreen(e.Location);
      oldsize_ = this.Size;
    } else if (new Rectangle(this.Width - borderCornerLeft.Width, this.Height - borderCornerLeft.Height, borderCornerRight.Width, borderCornerRight.Height).Contains(e.X, e.Y)) {
      chSstate_ = CursorState.BorderCornerRight;
      oldpos_ = e.Location;
      oldformpos_ = this.Location;
      oldscreenpos_ = PointToScreen(e.Location);
      oldsize_ = this.Size;
    } else if (new Rectangle(borderCornerLeft.Width, this.Height - borderBottom.Height, this.Width - 2 * borderCornerLeft.Width, borderBottom.Height).Contains(e.X, e.Y)) {
      chSstate_ = CursorState.BorderBottom;
      oldpos_ = e.Location;
      oldformpos_ = this.Location;
      oldscreenpos_ = PointToScreen(e.Location);
      oldsize_ = this.Size;
    } else if (new Rectangle(0this.Height - borderCornerLeft.Height, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) {
      chSstate_ = CursorState.BorderCornerLeft;
      oldpos_ = e.Location;
      oldformpos_ = this.Location;
      oldscreenpos_ = PointToScreen(e.Location);
      oldsize_ = this.Size;
    }

    if (minimizeButtonState == ButtonState.Over) {
      minimizeButtonState = ButtonState.Down;
      Invalidate();
    } else if (maximizeButtonState == ButtonState.Over) {
      maximizeButtonState = ButtonState.Down;
      Invalidate();
    } else if (closeButtonState == ButtonState.Over) {
      closeButtonState = ButtonState.Down;
      Invalidate();
    }
  }
}

private void FormStyle_MouseLeave(System.Object sender, System.EventArgs e)
{
  minimizeButtonState = ButtonState.Normal;
  maximizeButtonState = ButtonState.Normal;
  closeButtonState = ButtonState.Normal;
  Invalidate();
}

private void IT_Tech_NET_Formstyle_MouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
  Point pts = PointToScreen(e.Location);

  if (move_) {
    this.Location = new Point(this.Location.X + e.X - oldpos_.X, this.Location.Y + e.Y - oldpos_.Y);
  } else {
    if (!mousedown_) {
            if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width - minimizeButton.Width, 0, minimizeButton.Width, minimizeButton.Height).Contains(e.X, e.Y))
            {
        this.Cursor = Cursors.Default;
        minimizeButtonState = ButtonState.Over;
        maximizeButtonState = ButtonState.Normal;
        closeButtonState = ButtonState.Normal;
            }
            else if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width, 0, maximizeButton.Width, maximizeButton.Height).Contains(e.X, e.Y))
            {
        this.Cursor = Cursors.Default;
        maximizeButtonState = ButtonState.Over;
        minimizeButtonState = ButtonState.Normal;
        closeButtonState = ButtonState.Normal;
            }
            else if (new Rectangle(this.Width - titlebarRight.Width + 2 - closeButton.Width, 0, closeButton.Width, closeButton.Height).Contains(e.X, e.Y))
            {
        this.Cursor = Cursors.Default;
        closeButtonState = ButtonState.Over;
        minimizeButtonState = ButtonState.Normal;
        maximizeButtonState = ButtonState.Normal;
      } else {
        closeButtonState = ButtonState.Normal;
        minimizeButtonState = ButtonState.Normal;
        maximizeButtonState = ButtonState.Normal;
      }
      Invalidate();
    }

    if (new Rectangle(0, borderCornerLeft.Height, borderLeft.Width, this.Height - borderCornerLeft.Height - borderCornerLeft.Height).Contains(e.X, e.Y)) {
      this.Cursor = Cursors.SizeWE;
      curstate_ = CursorState.BorderLeft;
    } else if (new Rectangle(00, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) {
      this.Cursor = Cursors.SizeNWSE;
      curstate_ = CursorState.TopLeft;
        }
        else if (new Rectangle(borderCornerLeft.Width, 0this.Width - borderCornerLeft.Width - titlebarRight.Width + 2 - closeButton.Width - maximizeButton.Width - minimizeButton.Width, borderLeft.Width).Contains(e.X, e.Y))
        {
      this.Cursor = Cursors.SizeNS;
      curstate_ = CursorState.TopMid;
    } else if (new Rectangle(this.Width - borderCornerLeft.Width, 0, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) {
      this.Cursor = Cursors.SizeNESW;
      curstate_ = CursorState.TopRight;
    } else if (new Rectangle(this.Width - borderRight.Width, borderCornerLeft.Height, borderRight.Width, this.Height - 2 * borderCornerLeft.Height).Contains(e.X, e.Y)) {
      this.Cursor = Cursors.SizeWE;
      curstate_ = CursorState.BorderRight;
    } else if (new Rectangle(this.Width - borderCornerLeft.Width, this.Height - borderCornerLeft.Height, borderCornerRight.Width, borderCornerRight.Height).Contains(e.X, e.Y)) {
      this.Cursor = Cursors.SizeNWSE;
      curstate_ = CursorState.BorderCornerRight;
    } else if (new Rectangle(borderCornerLeft.Width, this.Height - borderBottom.Height, this.Width - 2 * borderCornerLeft.Width, borderBottom.Height).Contains(e.X, e.Y)) {
      this.Cursor = Cursors.SizeNS;
      curstate_ = CursorState.BorderBottom;
    } else if (new Rectangle(0this.Height - borderCornerLeft.Height, borderCornerLeft.Width, borderCornerLeft.Height).Contains(e.X, e.Y)) {
      this.Cursor = Cursors.SizeNESW;
      curstate_ = CursorState.BorderCornerLeft;
    } else {
      this.Cursor = Cursors.Default;
      curstate_ = CursorState.Normal;
    }
  }

  if (chSstate_ == CursorState.TopLeft) {
    this.Location = pts;
    this.Size = new Size(oldsize_.Width + oldscreenpos_.X - pts.X, oldsize_.Height + oldscreenpos_.Y - pts.Y);
  } else if (chSstate_ == CursorState.TopRight) {
    this.Location = new Point(oldformpos_.X, pts.Y);
    this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height + oldformpos_.Y - this.Location.Y);
  } else if (chSstate_ == CursorState.BorderCornerLeft) {
    this.Location = new Point(oldformpos_.X - oldscreenpos_.X + pts.X, oldformpos_.Y);
    this.Size = new Size(oldsize_.Width - pts.X + oldscreenpos_.X, oldsize_.Height + pts.Y - oldscreenpos_.Y);
  } else if (chSstate_ == CursorState.BorderCornerRight) {
    this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height + pts.Y - oldscreenpos_.Y);
  } else if (chSstate_ == CursorState.TopMid) {
    this.Location = new Point(oldformpos_.X, oldformpos_.Y + pts.Y - oldscreenpos_.Y);
    this.Size = new Size(oldsize_.Width, oldsize_.Height - pts.Y + oldscreenpos_.Y);
  } else if (chSstate_ == CursorState.BorderLeft) {
    this.Location = new Point(oldformpos_.X - oldscreenpos_.X + pts.X, oldformpos_.Y);
    this.Size = new Size(oldsize_.Width - pts.X + oldscreenpos_.X, oldsize_.Height);
  } else if (chSstate_ == CursorState.BorderBottom) {
    this.Size = new Size(oldsize_.Width, oldsize_.Height + pts.Y - oldscreenpos_.Y);
  } else if (chSstate_ == CursorState.BorderRight) {
    this.Size = new Size(oldsize_.Width + pts.X - oldscreenpos_.X, oldsize_.Height);
  }
}

private void FormStyle_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
  if (e.Button == MouseButtons.Left) {
    mousedown_ = false;
    move_ = false;
    mov_chS = false;
    chS = false;
    chSstate_ = CursorState.Normal;

    if (closeButtonState == ButtonState.Down) {
      this.Close();
    } else if ((minimizeButtonState == ButtonState.Down) & this.MinimizeBox) {
      this.WindowState = FormWindowState.Minimized;
    } else if ((maximizeButtonState == ButtonState.Down) & this.MaximizeBox) {
      if (this.WindowState == FormWindowState.Maximized) {
        this.WindowState = FormWindowState.Normal;
      } else if (this.WindowState == FormWindowState.Normal) {
        this.WindowState = FormWindowState.Maximized;
      }
      Invalidate();
    }
  }
}

private void FormStyle_MouseDoubleClick(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
  if (e.Button == MouseButtons.Left) {
    if (new Rectangle(00this.Width - titlebarRight.Width, titlebarMid.Height).Contains(e.X, e.Y) & (curstate_ == CursorState.Normal)) {
      if (this.WindowState == FormWindowState.Normal) {
        this.WindowState = FormWindowState.Maximized;
      } else if (this.WindowState == FormWindowState.Maximized) {
        this.WindowState = FormWindowState.Normal;
      }
      Invalidate();
        }
        else if (new Rectangle(this.Width - titlebarRight.Width, minimizeButton.Height, this.Width, 1).Contains(e.X, e.Y) & (curstate_ == CursorState.Normal))
        {
      if (this.WindowState == FormWindowState.Normal) {
        this.WindowState = FormWindowState.Maximized;
      } else if (this.WindowState == FormWindowState.Maximized) {
        this.WindowState = FormWindowState.Normal;
      }
      Invalidate();
    }
  }
}
        #endregion

        private Size ZoomSize(Size def, Size z)
            {
              double q = z.Width / z.Height;
              Size res = default(Size);
              if ((def.Width / def.Height) < q) {
                res = new Size(def.Width, Convert.ToInt32(def.Width / q));
              } else if ((def.Width / def.Height) == q) {
                res = def;
              } else if ((def.Width / def.Height) > q) {
                res = new Size(Convert.ToInt32(def.Height * q), def.Height);
              }
              return res;
            }

    }
}



Könnte mir vlt jemand sagn was ich falsch mache?

LG Fabian


bakachan - Do 12.08.10 14:18

Wahrscheinlich trägst du das falsche Shirt beim programmieren.

Nein mal im ernst ohne zu wissen was für Fehler kommen ist es nicht so einfach zu helfen (vor allem da es ja doch ein nicht ganz so kleines Stück vom Code ist).

Aber so nebenbei: bei mir funktioniert dein Code (abgesehen von den 8 Ressourcen)


Delete - Do 12.08.10 14:23

o.Ô ok... Erstmah danke für echt schnelle Antwort... Ich weiß ich bin im erklären hald nich so der pro... das es bei dir geht und bei mir nich kann ich mir jetz nich wirk erklären... hier die/der Fehler:


Fehler 1 Inkonsistenter Zugriff: Basisklasse "Orbit_FTP_Client.FormStyle" ist weniger zugreifbar als Klasse "Orbit_FTP_Client.Form1" C:\Users\Fabian\documents\visual studio 2010\Projects\Orbit FTP Client\Orbit FTP Client\Form1.Designer.cs 3 19 Orbit FTP Client

und noch die warnungen :



Warnung 2 Der Primärverweis "Microsoft.CSharp", bei dem es sich um eine Frameworkassembly handelt, konnte im derzeit als Ziel verwendeten Framework nicht aufgelöst werden. ".NETFramework,Version=v3.5". Zur Beseitigung des Problems muss entweder der Verweis "Microsoft.CSharp" entfernt oder die Anwendung erneut als Ziel für eine Frameworkversion verwendet werden, die ".NETFramework,Version=v3.5" enthält. Orbit FTP Client



Warnung 3 Die Komponente "Microsoft.CSharp", auf die verwiesen wird, wurde nicht gefunden.

Danke dir und euch


bakachan - Do 12.08.10 14:34

Zum ersten Fehler:
Mach deine FormStyle-Klasse mal public.

Was die anderen beiden Fehler angeht:
Hast du zufällig auf ein anderes Zielframework umgestellt? (Properties, Application, Target framework)

So wies ausschaut benutzt du Verweise aus dem 3.5er Framework allerdings hast du wohl als Zielframework ein älteres angegeben.


Delete - Do 12.08.10 14:47

Also ich habe die Class Public gemacht jetz bekomme ich keine fehler mehr... aber an der Form die ich erben lasse ändert sich leider auch nichts....ratlos


Danke

LG Fabian


bakachan - Do 12.08.10 14:58

Ähm dir sollte klar sein das du keine Form erben lässt sondern von einer Form erbst.


Delete - Do 12.08.10 15:35

jaja aber von der klasse kann ich erben lassen in vb is das zumindest so...

danke


bakachan - Do 12.08.10 15:49

ähm ja logisch kannst du andere klassen davon ableiten

oder halt Instanzen deiner Klasse erstellen
aber daran wirds bestimmt nciht liegen das nichts geändert ist.

Schaun wir mal kurz in den Code...

Du hast direkt direkt von VB in C# geändert oder?
Es gibt da nen kleinen Unterschied bei Konstruktoren
VB:

Quelltext
1:
Public Sub New()                    

Du hast

C#-Quelltext
1:
public void New()                    

und in C# müsst es heissen::

C#-Quelltext
1:
public FormStyle()                    


Also wurde dein Kontruktor garnicht aufgerufen.


Delete - Do 12.08.10 16:02

Danke dir dachte mir schon sowas in der art ich werdes sobal wie möglich probiern und dann ein danke spenden :D

LG Fabi

//EDIT:

Wenn ich es aber abänder bekomme ich folgenden Fehler -.-':

Membernamen dürfen nicht mit den Namen des einschließenden Typs Identisch sein.

Danke LG Fabi


bakachan - Do 12.08.10 16:38

Dann hast du bestimmt

C#-Quelltext
1:
public void FormStyle()                    

geschrieben und nicht

C#-Quelltext
1:
public FormStyle()                    

(ohne void weil ja deine Klasse dem Rückgabetyp entspricht)


Delete - Do 12.08.10 16:43

Mit dem Code:

C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
 public CleanOrbit_WS() 
         {
             this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
             this.DoubleBuffered = true;
             this.FormBorderStyle = FormBorderStyle.None;
             BG_Color = SystemColors.Control;
             this.BackColor = Color.LavenderBlush;
             this.TransparencyKey = Color.LavenderBlush;
             this.MaximizedBounds = SystemInformation.WorkingArea;
             titlebarLeft = Properties.Resources.titlebarLeft.Size;
             titlebarMid = new Size(this.Width - titlebarLeft.Width - titlebarRight.Width +2,titlebarRight.Height);
             titlebarRight = Properties.Resources.titlebarRight.Size;
             borderRight = new Size(7,this.Height-borderBottom.Height-titlebarLeft.Height +2);
             borderCornerRight = Properties.Resources.borderCornerRight.Size;
             borderBottom = new Size(this.Width, 7);
             borderCornerLeft = Properties.Resources.borderCornerLeft.Size;
             borderLeft = new Size(7this.Height - titlebarMid.Height - borderCornerLeft.Height);
             closeButton = Properties.Resources.closeNormal.Size;
             closeButton_tool = Properties.Resources.closeNormal_tool.Size;
             maximizeButton = Properties.Resources.maximizeNormal.Size;
             minimizeButton = Properties.Resources.minimizeNorm.Size;
             TextColor_ = Color.Black;
             try
             {
                 TextFont_ = new Font("Arial"9, FontStyle.Regular);
             }
             catch
             {
                 TextFont_ = this.Font;
             }
         }


kommt der Fehler

klasse heißt: CleanOrbit_WS

Danke

LG Fabi


bakachan - Do 12.08.10 16:57

Find ich grade relativ seltsam eigentlich müsste es gehen.

Vielleicht hilft dir das hier weiter:
http://msdn.microsoft.com/de-de/library/hdhfk2xk%28VS.80%29.aspx


Delete - Do 12.08.10 16:59

danke dir aber ich bin noch nich so bewandelt in C# ich kann damit nich wirk was anfangen ... und den Fehler kann ich mir auch nich wirk erklärn -.-'

Danke dir

LG Fabi


Kha - Do 12.08.10 18:37

Poste bitte einmal die vollständige Klasse, der Fehler sollte wirklich nicht auftreten. Ist es denn wirklich die Konstruktor-Zeile?


Delete - Do 12.08.10 18:59

Siehe 1er Post, hat blos jetzt nen andren namen

siehe post's oben.

LG Fabi


Kha - Do 12.08.10 20:49

Das zusammenkopiert funktioniert bei mir wie erwartet.

Was passiert denn, wenn du alles außer dem Konstruktor entfernst?


Delete - Do 12.08.10 22:20

Ich habe das proj. gerade wieder geöffnet... ich bekomme keinen Fehler mehr... bis jetzt funktioniert es wie ich mir es vorgestellt habe.. keine ahnung was da schiefgelaufen ist vorhin... ich tippe darauf das die IDE etwas gespunnen hat

danke euch

ich melde mich wenn ich genaueres weiß

LG Fabian


Delete - Fr 13.08.10 00:09