Thread: Multiple threads, Dos APP, manage windows

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    1

    Unhappy Multiple threads, Dos APP, manage windows

    I'm a student at C programming, I need some help (teacher cannot help me now) with an idea I had.
    Basically, I wanted to show bottom screen current date / time in any program, I made a thread but I see, i.e., that when I'm listing some files, (too much printf) they appear on my bottom screen instead of normal screen. What I've tried atm is:

    Code:
    //Some includes
    int _FLAG_TIME_DONE
    
    void time_thread() //with his params (doesn't mind here)
    {
    //code
    
    int x=wherex();
    int y=wherey();
    gotoxy(1,24);
    printf("%s",time_string);
    gotoxy(x,y);
    //this way usually main thread writes text on 1,24 or after %s string
    
    /*another idea I had */
    int x=wherex();
    int y=wherey();
    _FLAG_TIME_DONE=1;
    gotoxy(1,24);
    printf("%s",time_string);
    gotoxy(x,y);
    _FLAG_TIME_DONE=0;
    
    }
    
    main()
    {
    //code
    for(int i=0;i<20;i++) {
    printf("This is a line"); getch;
    while(_FLAG_TIME_DONE); //it should pause it until x,y are back on main window..
    } //next step 
    
    }
    That while is to stop main till thread puts back cursor x,y on origin coords, but it's flagged to low time that it never goes out of it -sigh-

  2. #2
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    I don't really understand your question, but look my example, I print a message correctly, also, print a msg that will emulate your clock.

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    #define CLOCK_X 1
    #define CLOCK_Y 24
    
    void putmsg( char *msg ) {
    	int xtmp, ytmp;
    
    	xtmp = wherex();
    	ytmp = wherey()+1;
    
    	puts( msg );
    	gotoxy( CLOCK_X,CLOCK_Y );
    	printf( "2:33" ); /* here you should print your clock */
    	gotoxy(xtmp,ytmp);
    	return;
    }
    
    int main( void ) {
    	putmsg("lala");
    	putmsg("lele");
    	putmsg("lili");
    	putmsg("lolo");
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 11:14 AM
  2. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  3. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  4. Multiple toolboxes in an app.
    By Anonymous Cowar in forum Windows Programming
    Replies: 2
    Last Post: 12-03-2002, 03:17 AM
  5. Multiple keystrokes in Borland c++ in DOS
    By DomoDeathMage in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-14-2002, 10:07 PM