Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

poppabaggins

@poppabaggins
About
Posts
11
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Problem with properly displaying color( with alpha) of JButton
    P poppabaggins

    For my Java class, I have to implement a computer version of the game of Simon (with the color panel sequence). In the program, I have a subclass of JButton, SimonButton. I want SimonButton to display a dimmed color. The SimonButtons are in a JPanel, which is in a JFrame. I do this by giving it a low alpha as such:

    public void setColor(Color color) {
    this.setBackground(new Color(color.getRed(),
    color.getGreen(),
    color.getBlue(),
    alpha));
    }

    with alpha = 20. The program starts off working well, but every time I move the mouse over a button, the color becomes brighter. I'm assuming that the SimonButtons are just being drawn over each other, thus making the colors cumulative. How do I make it so that the buttons get completely redrawn instead of drawing over top of them?

    Java question java graphics game-dev help

  • Arrays and enums in an extended control
    P poppabaggins

    Thanks, I was trying to come up with some sort of sensible code from searching the internet, but nothing seemed to work for me. Basically, I'm working off of what little I know from C# and the small amount of information I can get from my professor after class. It obviously wasn't working well for me. This is part of a project for school, but my book has absolutely nothing on managed c++. I would take the time to learn C++/cli, but this project is due at the end of the semester, and I have so many other things I'm reading now for classes/personal study/entertainment. I'll get to it eventually, but I have a lot of other things I'm doing now.

    Managed C++/CLI graphics c++ data-structures help tutorial

  • Arrays and enums in an extended control
    P poppabaggins

    Hi, I'm completely new to C++ as a whole, so there might be a simple answer to my question, so here goes. I'm trying to write a program that will have the screen broken up into zones, or areas, each with a Point (location) a Size, an Image, and an array of terrain types (an enum). Trying to include a bitmap in my class made the compiler tell me that I couldn't mix managed and unmanaged types. To try to work around this, I tried extending the PictureBox control, but this has given me even more headaches. Basically, I can't figure out how to declare/use an array in an extended control.

    #pragma once

    using namespace System::Drawing;
    using namespace System::Windows::Forms;
    using namespace cli; //something I think MSDN said I had to do

    namespace MapEdit
    {
    //better than a "magic number". there can only be 3 different types of terrain per square
    //used in the TerrainTypes array
    const int MAX_TERRAIN = 3;

    public ref class Zone : public System::Windows::Forms::PictureBox
    {
    	
    public:
    	enum Terrain //says I can't mix types
    	{
    		Plain,
    		Hill,
    		Wood,
    		Marsh,
    		Stream,
    		River,
    		ShoreLine,
    		Impassable
    	};
    	
    	array<byte^> ^TerrainTypes; //this doesn't work
    	int TerrainTypes\[3\]; //neither does this.
    

    ... All of my errors (except the parts where I try to use these faulty enum/ array) come from this block. Frankly, I'm at a loss as to how to fix this. Also, if someone could tell me how to include a Bitmap in an unmanged class, that would be nice too. Thanks, Christian

    Managed C++/CLI graphics c++ data-structures help tutorial

  • Arrays and Enums in an extended control
    P poppabaggins

    Thanks, I'm so new at C++, I wasn't sure which forum to ask in.

    C / C++ / MFC graphics c++ data-structures help tutorial

  • Arrays and Enums in an extended control
    P poppabaggins

    Hi, I'm completely new to C++ as a whole, so there might be a simple answer to my question, so here goes. I'm trying to write a program that will have the screen broken up into zones, or areas, each with a Point (location) a Size, an Image, and an array of terrain types (an enum). Trying to include a bitmap in my class made the compiler tell me that I couldn't mix managed and unmanaged types. To try to work around this, I tried extending the PictureBox control, but this has given me even more headaches. Basically, I can't figure out how to declare/use an array in an extended control.

    #pragma once

    using namespace System::Drawing;
    using namespace System::Windows::Forms;
    using namespace cli; //something I think MSDN said I had to do

    namespace MapEdit
    {
    //better than a "magic number". there can only be 3 different types of terrain per square
    //used in the TerrainTypes array
    const int MAX_TERRAIN = 3;

    public ref class Zone : public System::Windows::Forms::PictureBox
    {
    	
    public:
    	enum Terrain //says I can't mix types
    	{
    		Plain,
    		Hill,
    		Wood,
    		Marsh,
    		Stream,
    		River,
    		ShoreLine,
    		Impassable
    	};
    	
    	array<byte^> ^TerrainTypes; //this doesn't work
    	int TerrainTypes\[3\]; //neither does this.
    

    ...

    All of my errors (except the parts where I try to use these faulty enum/ array) come from this block. Frankly, I'm at a loss as to how to fix this. Also, if someone could tell me how to include a Bitmap in an unmanged class, that would be nice too. Thanks, Christian

    C / C++ / MFC graphics c++ data-structures help tutorial

  • Problems with Keyboard input (KeyDown, KeyPress, KeyUp)
    P poppabaggins

    Thanks, setting the KeyPreview to true worked perfectly for me.

    C# graphics csharp testing beta-testing help

  • Problems with Keyboard input (KeyDown, KeyPress, KeyUp)
    P poppabaggins

    Ok, I found my problem. Once I removed my button, the key input worked again. Can anyone tell me what else would have worked?

    modified on Sunday, August 17, 2008 7:36 PM

    C# graphics csharp testing beta-testing help

  • Problems with Keyboard input (KeyDown, KeyPress, KeyUp)
    P poppabaggins

    Right, I actually had that earlier before I started messing with things. Even with this.Invalidate() after it, nothing happens. I think that the event isn't being fired at all, since, for parts of my test, I just told the keydown, keypress, and keyup to change the text of the form. Nothing happened anytime I pressed a button.

    C# graphics csharp testing beta-testing help

  • Problems with Keyboard input (KeyDown, KeyPress, KeyUp)
    P poppabaggins

    Hi, I'm a rather new C# user and I'm still figuring out the ropes of forms programming and such. For the part of the program I'm working on, I basically want to move an image around on the screen, in a region (advanced, I know ). I achieved this just fine with mouse click and drag, but I'm unable to get any sort of keyboard input. Here's the part of the code I'm using:

        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
    
            using(Region boardRegion = new Region(new Rectangle(ClientRectangle.X, ClientRectangle.Y,
                (int)(ClientRectangle.Width), (int)(ClientRectangle.Height \* boardRegionSize))))
            {
                g.Clip = boardRegion;
                using(Bitmap boardImage = new Bitmap(board.ImagePath)){
                    g.DrawImage(boardImage, board.X, board.Y);
                }
            }
            base.OnPaint(e);
        }
    
        private void CMGame\_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Up)
                board.Y -= 30;
        }
    

    And for part of InitializeComponent(), I have

    this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CMGame_KeyDown);

    (automatically done by windows) Basically, nothing happens when I press a key (the up arrow or anything else, since I've tried different keys in testing) I read somewhere that I could try overriding WndProc, but I don't know how I would do this (even after I wrote the override method header and and found the code for KeyDown, 0x0100) For reference, I also have a button in the form with a click event. Help would be much appreciated.

    C# graphics csharp testing beta-testing help

  • ControlStyles.OptimizedDoubleBuffer increases my flicker problems
    P poppabaggins

    Thank you so much. changing it to e.Graphics fixed everything. Also, it went from extreme flicker (practically disappearing for a full second or two) to incredibly minor flicker at a 10ms interval.

    C# csharp asp-net graphics hardware testing

  • ControlStyles.OptimizedDoubleBuffer increases my flicker problems
    P poppabaggins

    I'm new to form programming in C#. Just for learning purposes, I tried double buffering to get rid of my flicker problems with a simple test program. The problem is, that enabling double buffering made increased my flicker exponentially. What should I do to solve this? Here's the code for reference

    public partial class DoubleBufferPractice : Form
        {
            Timer timer;
            Rectangle rect;
    
            public DoubleBufferPractice()
            {
                InitializeComponent();
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                this.SetStyle(ControlStyles.UserPaint, true);
                rect = new Rectangle(0, this.Height/3, 50, 50);
                InitializeTimer();
            }
    
            private void InitializeTimer()
            {
                timer = new Timer();
                timer.Interval = 10;
                timer.Tick += new EventHandler(timer_Tick);
                timer.Start();
            }
    
            private void timer_Tick(object sender, EventArgs e) 
            {
                if(rect.X + rect.Width < this.Width)
                    rect.X += 10;
                else
                    rect.X = 0;
                this.Invalidate();
            }
    
            protected override void OnPaint(PaintEventArgs e)
            {
                using(Graphics g = this.CreateGraphics()) {
                    using(Brush brush = new SolidBrush(Color.Magenta)) {
                        g.FillRectangle(brush, rect);
                    }
                }
                base.OnPaint(e);
            }
        }
    

    Also, I'm testing this on my laptop with a 2.0ghz Dual Core Pentium, 2gigs ram, and a 256meg nonshared vram NVidia Geforce 8600 M GT, so I don't think that hardware is the problem.

    C# csharp asp-net graphics hardware testing
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups