GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Aug-2007, 00:25
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 406
Howard_L has a spectacular aura aboutHoward_L has a spectacular aura about

Multiple 'windows' in one msdos console character-mode application


I have a program that I would like to make into a character-mode console application.
Specifically I'd like the screen to have two or three 'windows' for status, menus , etc.
I need to do this program for msdos so I will not be able to use the awesome Linux ncurses libraries with which I have done a little of the multiple windowing. Instead I am mired in the world of ms api... I have been revisiting msdn/library from about here on:
http://msdn2.microsoft.com/en-us/library/ms682010.aspx
...and am beginning to wonder if this is possible. It should be. If I remember correctly, they used to do this back in ot-1. They sure don't advertise it now. Anybody know how to do this ?
I'm not ready for win32 graphical api at this time.... figured I'd get this HANDLE'd first, thanks,
Howard;
ps: just to jog the memory, this is a basic start (compiles and runs):
CPP / C++ / C Code:
/* books_mscon.c  trying to set up console screen for books.c */
#include <windows.h>
#include <stdio.h>
#define PAUSE while(getc(stdin) != '\n')

HANDLE WinOut1, WinOut2;
COORD Pos1, Pos2;
COORD SBSize;

void CLEAR_WinOut1(HANDLE WinOut);
void Info(HANDLE WinOut);

int main(void)
{
  WinOut1 = GetStdHandle(STD_OUTPUT_HANDLE);

  SBSize.X = 95;  SBSize.Y =  40;  SetConsoleScreenBufferSize(WinOut1, SBSize);

  SetConsoleTitle("Dude! we gotcher: books_mscon.exe for ya (under construction) ");
  CLEAR_WinOut1(WinOut1);
  Info(WinOut1);
  PAUSE;

  /* WinOut2 = GetStdHandle(STD_OUTPUT_HANDLE); */
  WinOut2 = WinOut1;

  SBSize.X = 10;  SBSize.Y =  20;  SetConsoleScreenBufferSize(WinOut2, SBSize);

  Pos2.X = 80;  Pos2.Y = 0;  SetConsoleCursorPosition(WinOut2, Pos2);
  printf("This is WinOut2! \n123456789012345678901234567890\n");
  PAUSE;
  return 0;
}
/********************************************************************/
void CLEAR_WinOut1(HANDLE WinOut)
{
  static COORD Pos;            /* assign Pos members for new position */
  static DWORD Written;        /* define identifier of type 'DWORD'   */
  Pos.X= 0; Pos.Y= 0;
  FillConsoleOutputCharacter(WinOut, ' ', (90*40), Pos, &Written);
  Pos.X= 10; Pos.Y= 0;
  SetConsoleCursorPosition(WinOut, Pos);
  printf("This will be our main window.  Can we make a subwindow? \n\n");
}

void Info(HANDLE WinOut)
{
  CONSOLE_SCREEN_BUFFER_INFO SBInfo;               /* pointer to structure */

  GetConsoleScreenBufferInfo(WinOut, &SBInfo);
  printf("GetConsoleScreenBufferInfo(hOut, &SBInfo);   A snapshot:\n");
  printf("SBInfo.dwSize.X , Y            : %d x %d  \n", SBInfo.dwSize.X, SBInfo.dwSize.Y);
  printf("SBInfo.dwCursorPosition.X, Y   : (%d, %d) \n", SBInfo.dwCursorPosition.X, SBInfo.dwCursorPosition.Y);
  printf("SBInfo.wAttributes             : 0x%04x   \n", (unsigned)SBInfo.wAttributes);
  printf("SBInfo.srWindow.Top            : %d  \n", SBInfo.srWindow.Top);
  printf("SBInfo.srWindow.Left           : %d  \n", SBInfo.srWindow.Left);
  printf("SBInfo.srWindow.Bottom         : %d  \n", SBInfo.srWindow.Bottom);
  printf("SBInfo.srWindow.Right          : %d  \n", SBInfo.srWindow.Right);
  printf("SBInfo.dwMaximumWindowSize.X, Y: %d x %d  \n", SBInfo.dwMaximumWindowSize.X, SBInfo.dwMaximumWindowSize.Y);
}
  #2  
Old 06-Aug-2007, 19:36
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 406
Howard_L has a spectacular aura aboutHoward_L has a spectacular aura about

Re: Multiple 'windows' in one msdos console character-mode application


Just to get something up on the forum about this, I was enlightened to the fact
that there is a curses port to win32. On searching I found that it must be this:
http://pdcurses.sourceforge.net/

I downloaded PDCurses33.zip and, after some struggling with my waning
conceptions of package building and reading and understanding instructions,
wound up with a library and header file installed for my \cs1300\mingw\gcc.
So far it works great. There is still a good ncurses tutorial at:
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

It's the first time I've looked at a source file like this and had enough
knowledge to half understand what is going on. In particular, in the win32
subdirectory I can see how they are converting the console API functions into
use as the curses functions. Very interesting.
...and just when I was starting to get a grip on msdn.... how can I quit now?
++Howard;
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change 98 console character size in program? Howard_L C Programming Language 1 25-Apr-2007 14:25
need help with a console menu system BullBuchanan CPP / C++ Forum 6 20-Aug-2006 14:46
Bloodshed Dev C++ Project Options JdS CPP / C++ Forum 6 11-Nov-2005 17:23
Help! Some basal questions about MFC xutingnjupt MS Visual C++ / MFC Forum 1 05-Dec-2004 03:38

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:45.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.