Exemplo n.º 1
0
Arquivo: Text.c Projeto: atrniv/CLIPS
/****************************************************************************
* text_New
* Inputs:
*       HWND hwnd: Parent window
* Result: BOOL
*       HWND if successful
*       NULL if failure
* Effect: 
*       Creates a new text window
****************************************************************************/
HWND text_New(
  HWND hwnd,
  char *fileName)
  {
   HWND hwndChild;
   static int titleIndex = 1;
   char titleBuffer[20];
   
   if (fileName == NULL)
     { 
      sprintf(titleBuffer,"Untitled%d",titleIndex++);
      hwndChild = mdi_Create(MDIClientWnd,0,IDR_TEXT,titleBuffer,
                             CW_USEDEFAULT,0,CW_USEDEFAULT,0); 
     }
   else
     { 
      hwndChild = mdi_Create(MDIClientWnd,0,IDR_TEXT,fileName,
                             CW_USEDEFAULT,0,CW_USEDEFAULT,0);
     }

   if (hwndChild != NULL)
     { /* success */
      HWND hedit;

	  hedit = edit_New(hwndChild,WS_CHILD | 
	 			                 WS_VISIBLE | 
                                 ES_MULTILINE | 
                                 ES_WANTRETURN |
                                 ES_AUTOVSCROLL |
                                 WS_VSCROLL, TRUE);
	  if (hedit == NULL)
	    { /* no edit window */
	     DestroyWindow(hwndChild);
	     return NULL;
	    } /* no edit window */
	  
	  PostMessage(hwnd,UWM_UPDATE_MENU,0,0);
     } /* success */

   return (hwndChild);
  }
Exemplo n.º 2
0
static HWND statusWindow_New(
  HWND hwnd,
  char *baseName,
  int xpos,
  int ypos,
  int width,
  int height,
  void (*getPPForm)(void *,char *,size_t,void *),
  void *(*getNextValue)(void *,void *),
  int (*getChanged)(void *),
  void (*setChanged)(void *,int),
  int (*getCount)(void *))
  {
   HWND hwndChild;
   struct statusWindowData *theData;
   HDC hDC;
   TEXTMETRIC tm;
   char buffer[255];
   LOGFONT lf;
   HFONT hfont;

   theData = (struct statusWindowData *) malloc(sizeof(struct statusWindowData));
   
   if (theData == NULL)
     { return(NULL); }
              
   sprintf(buffer,"%s Window",baseName);

   hwndChild = mdi_Create(MDIClientWnd,0,IDR_STATUS,buffer,
                          CW_USEDEFAULT,0,CW_USEDEFAULT,0);
  
   if (hwndChild == NULL) 
     { 
      free(theData);
      return(NULL); 
     }

   theData->getNextValue = getNextValue;
   theData->getPPForm = getPPForm;
   theData->lastLine = 0;
   theData->noLines = 0;
   theData->getChanged = getChanged;
   theData->setChanged = setChanged;
   theData->getCount = getCount;
   theData->baseName = baseName;

   hDC = GetDC(hwndChild);
   memset(&lf,0,sizeof(LOGFONT));
   lf.lfHeight = -13;
   strcpy(lf.lfFaceName,"Courier New");
   hfont = CreateFontIndirect(&lf);
   SelectObject(hDC,hfont);

   GetTextMetrics(hDC,&tm);
   ReleaseDC(hwnd,hDC);
      
   theData->lineSize = tm.tmHeight+ tm.tmExternalLeading;
     
   //SetWindowLong(hwndChild,GWL_USERDATA,(long) theData);
   SetWindowLongPtr(hwndChild,GWLP_USERDATA, (LONG_PTR) theData);
   
   MoveWindow(hwndChild,xpos,ypos,width,height,TRUE);
   
   SetScrollRange(hwndChild,SB_HORZ,0,255,TRUE);
       
   ShowWindow(hwndChild,SW_HIDE);

   return(hwndChild);
  }