Autor Beitrag
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Fr 04.12.09 20:29 
hätte nich gedacht, das dies probleme macht :D aber ich habe dieses problem
bin grade dabei, nen kleines spiel zu programmieren. dazu wird ne picturebox auf die form gezeichnet. diese wird proportional zur form in der höhe verändert und in der mitte angezeigt.
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
private void Form1_Resize(object sender, EventArgs e)
        {
            pictureBox1.Height = Height / 5;
            pictureBox1.Top = Height / 2;
        }

problem: es geht nich. Height scheint die höhe des bildschirms zu sein, nicht die der form. in delphi gehts mit form1.height, aber diese eigenschaft hat die form nich. hab auch schon form1.size.height versucht, weil das im eigenschaftsfenster die höhe verändert. im code wirds aber nich gefunden...
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Fr 04.12.09 20:56 
Mal abgesehen davon, dass deine Berechnungen noch nicht ganz stimmen, funktioniert das bei mir so :nixweiss: .


user profile iconhuuuuuh hat folgendes geschrieben Zum zitierten Posting springen:
in delphi gehts mit form1.height, aber diese eigenschaft hat die form nich.
Überleg dir noch einmal genau, was dieses "Form1" in Delphi überhaupt bedeutete ;) .

_________________
>λ=
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Fr 04.12.09 21:53 
sorry, hab mich nen bissl vertan :oops: die stelle macht keine probleme
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
 private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            pictureBox1.Top = MousePosition.Y - pictureBox1.Height / 2;

        }

das macht probleme. und zwar soll die mitte der picturebox auf der höhe der maus sein. funktioniert aber leider nur im fullscreen...
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Fr 04.12.09 23:52 
hab jetz das problem ;) MousePosition gibt die absoluten Koordinaten auf dem bildschirm wieder, die PictureBox nutzt aber die koordinaten innerhalb des fensters.
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            
            pictureBox1.Top = MousePosition.Y - (Top + 30) - pictureBox1.Height / 2;

        }

so funktionierts jetz :)
JasonDelife
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81

Windows 7 Professional
C# (Visual Studio 2008 Professional), Java (NetBeans IDE 6.7)
BeitragVerfasst: Sa 05.12.09 00:38 
Wäre es nicht einfacher das Y-Property des MouseEventArgs zu nutzen?
Das gibt die Position innerhalb des Fensters.

Grüße, JasonDelife.
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 05.12.09 11:26 
danke, werd mir das mal anschaun