Thread: i got the box

  1. #1
    xlord
    Guest

    i got the box

    YaY i finaly got the box working.. but i cant seem to make it move =( can anyone help please..

    Code:
    WINDOW *windows(int x, int y, int height, int width);
    
    int main()
    {
      WINDOW *win;
      int ch;
      int x,y;
      int height = 3;
      int width = 10;
    
      initscr();
      cbreak();
      start_color();
      keypad(stdscr,TRUE);
    
      x = (LINES - height) / 2;
      y = (COLS - width) / 2;
    
    printw("Press F1 to exit\n");
    win = windows(height, width, x, y);
    
    while(1)
    {
       ch = getch();
    
       if(ch == KEY_F(1))
       {
    
        refresh();
        endwin();
        return 0;
    }
    
        switch(ch)
        {
    
           case  KEY_LEFT:
    
                   init_pair(2,COLOR_RED, COLOR_BLACK);
    	       attron(COLOR_PAIR(2));
                   win = windows(height, width, x, y);
    	       attroff(COLOR_PAIR(2));
    	       break;
    
           case KEY_RIGHT:
    
                  init_pair(2,COLOR_RED, COLOR_BLACK);
    	      attron(COLOR_PAIR(2));
                  win = windows(height, width, x, y);
    	      attroff(COLOR_PAIR(2));
    	      break;
    
           case KEY_UP:
    
                  init_pair(2,COLOR_RED, COLOR_BLACK);
    	      attron(COLOR_PAIR(2));
                  win = windows(height, width, x, y);
    	      break;
    
           case KEY_DOWN:
    
                  init_pair(2,COLOR_RED, COLOR_BLACK);
    	      attron(COLOR_PAIR(2));
                  win = windows(height, width, x, y);
    	      break;
    
    	      }
    	   }
    	     refresh();
    	     endwin();
    	     return 0;
      }
    
    WINDOW *windows(int x, int y, int height, int width)
    {
      WINDOW *local_win;
    
      local_win = newwin(height, width, x, y);
      box(local_win,0,0);
      wrefresh(local_win);
      return local_win;
      }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I suspect this is your problem:

    box(local_win,0,0);

    Zero-Zero is the upper left pixel is it not? Shouldn't this be a non static location, ie: shouldn't you be using x and y here? I'm unfamiliar with the specific functions you're using, so I may be off there, but that's what it looks like to me.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    xlord
    Guest
    Originally posted by quzah
    I suspect this is your problem:

    box(local_win,0,0);

    Zero-Zero is the upper left pixel is it not? Shouldn't this be a non static location, ie: shouldn't you be using x and y here? I'm unfamiliar with the specific functions you're using, so I may be off there, but that's what it looks like to me.

    Quzah.
    No hehe x & y are for height and width.. if i wanted to make it move i would have to use the command move() but that is the thing i dont know how to here.. i am tring it out.. but still cant get it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Virtual Box
    By ssharish2005 in forum Tech Board
    Replies: 3
    Last Post: 02-12-2009, 05:08 AM
  2. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  3. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM