Basic question about windows...

Help
2011-01-20
2013-04-25
  • Why isnt this working?

    #include <curses.h>
    int main()
    {
        initscr();
        noecho();
        WINDOW *a;
        a=newwin(12,40,0,0);
        wbkgd(a,'.');
        wrefresh(a);
        getch();
        endwin();
        return 0;
    }
    

    it should have made a window 40 by 12 at 0,0 with its background filled with dots but it isnt…
    i found out that if i add refresh() exactly after declaring WINDOW *a;
    it works…. why the heck if i didnt even initialize it with newwin???
    thanks a bunch

     
  • Your call to getch() is doing an implicit refresh(), which is to say, a wrefresh(stdscr) (getch() is really wgetch(stdscr)). Since stdscr covers the whole screen, refreshing it covers up your window. stdscr already exists without a newwin() call. Calling refresh() earlier updates stdscr so it's not touched when you implicitly refresh() it again.

    It's best not to mix and match the stdscr-oriented functions and the window-oriented functions - if you're going to create your own windows, then pretend stdscr doesn't exist. In your case, use wgetch(a) rather than getch().

     
  • aighty mate
    understand, made some changes here and it works like a charm ;)
    Btw how can i output special characters like ü? or é, á, ö… thank you once more!

     
  • oh forget it, i recompiled pdcurses with WIDE=wide and it worked ;)