Loading ...
Sorry, an error occurred while loading the content.

13086AW: HOWTO: vim dos32 and windows clipboard

Expand Messages
  • Hast, Klaus
    Jan 11, 2000
    • 0 Attachment
      AW: HOWTO: vim dos32 and windows clipboard

      Hello Vince,
      i don't know if it is of any usage (because it's from a Windows (MFC) program),
      but maybe the calls are somehow adaptable ?? See below ..
      If there are any plans to integrate clipboard support for dos32 - could i
      receive a notification?
      About your speed-up hint gvim:
              You should set guioptions in your _vimrc (yes, _vimrc)
              to stop the processing of menu.vim, and turn off the
              menubar and toolbar. This considerably speeds the gui
              version startup. (I use this trick on my P75 :)
      I tried that (_vimrc):
              set guioptions-=m
              set guioptions-=M
              set guioptions-=T
      It speeds up a little bit, but not much.
      Basically, my experience with the startup time of gvim is:
      - on a fast system ("where you don't need it"), eg. P400, gvim loads nearly as fast
        as vim32(dos).  Settings above don't play a big role.
      - on a slower system ("where you would need it"), eg. P133, the starting time
        of gvim against dos32-vim is drastical, with or without the hint above.
      Whey i tell this?
      The features of VIM are great!
      But using vim oftenly from the dos box, none of the three version is really usable
      as a daily used default editor on Windows95 (what i mean is: starting it *oftenly* for some kind of files,
      quitting it oftenly ..), because console-dos-32 and gvim are too slow when starting,
      and dos32 is wonderful to use, but it lacks of the clipboard capability which is a
      real ugly restriction.  
      A clipboard extentions would be great great great :-)
      Best Regards,

      Best Regards!
      BOOL CProbrdrcView::CopyTextToClipboard(CString * pString)
              HRESULT hRet = NOERROR;
              HGLOBAL hGlobal;
              unsigned length = pString->GetLength() + 1;
              if( pString )                                            // Arg Ok      
              {   if( OpenClipboard() )                                // Open Clipboard Ok
                  {   hGlobal = GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE, length);
                      if( hGlobal )                                    // Mem Ok
                      {  char *pGlMem;
                         pGlMem = (char *) GlobalLock( hGlobal );
                         if( pGlMem )                                  // Lock Ok
                         {   strcpy (pGlMem, *pString);
                             GlobalUnlock( pGlMem );
                             HANDLE hClip = SetClipboardData( CF_TEXT, hGlobal );
                             if( hClip == NULL )                       // Can't set Text
                             {     GlobalFree( hGlobal );
                                   hRet = GetLastError();
                         }   }
                             GlobalFree( hGlobal );
                             hRet = GetLastError();
                      } // if Mem Ok
                         hRet = E_OUTOFMEMORY;
                  } // if Open Clipboard Ok
                      hRet = GetLastError();
              } // if Arg Ok
                  hRet = E_FAIL;
              if (hRet == NOERROR)
                  MessageBox("Copy done!", "Copy to Clipboard  ");
              else AfxMessageBox( "Unable to set Clipboard data" );
              return hRet;

        Von:    Vince Negri[SMTP:vnegri@...]
        Gesendet:       Dienstag, 11. Januar 2000 12:04
        An:     'Hast, Klaus'; 'vim developers list'
        Cc:     Bram Moolenaar
        Betreff:        HOWTO: vim dos32 and windows clipboard

        > From: Hast, Klaus [SMTP:khast@...]
        > Vim dos32 with clipboard access would be a fine thing ... and would avoid
        > > the need to use different editors for different needs.
        If you're interested in doing this (or anyone else is),
        here's the information:

        For Windows 3.x in 386 enhanced mode, Windows for Workgroups, or
        Win95 or later, Dos boxes support an INT 2fh interface to the clipboard.,
        NOTE: The Wws functions RegisterClipboardFormat() and
              EnumClipboardFormats() are not supported.

        Function Call Definitions
        Name            IdentifyWinOldApVersion()
        Parameters      AX = 1700H
        Return Values   AX == 1700H: Clipboard functions not available
                           <> 1700H: AL = Major version number
                                     AH = Minor version number

        Name            OpenClipboard()
        Parameters      AX = 1701H
        Return Values   AX == 0: Clipboard already open
                           <> 0: Clipboard opened

        Name            EmptyClipboard()
        Parameters      AX = 1702H
        Return Values   AX == 0: Error occurred
                           <> 0: OK, Clipboard emptied

        Name            SetClipboardData()
        Parameters      AX = 1703H
                        DX = WinOldAp-Supported Clipboard format
                        ES:BX = Pointer to data
                        SI:CX = Size of data in bytes
        Return Values   AX == 0: Error occurred
                           <> 0: OK.  Data copied into allocated memory.
        Note            The MS-DOS-based application should call the
                        ClipboardCompact() function prior to this to determine
                        if the data can be accommodated in memory.

        Name            GetClipboardDataSize()
        Parameters      AX = 1704H
                        DX = WinOldAp-Supported Clipboard format
        Return Values   DX:AX == Size of the data in bytes, including any
                              == 0 If data in this format is not in the clipboard.

        Name            GetClipboardData()
        Parameters      AX = 1705H
                        DX = WinOldAp-Supported Clipboard format
                        ES:BX = Pointer to data buffer to hold data
        Return Values   AX == 0: Error occurred (or data in this format is not
                                 in the clipboard)
                           <> 0: OK
        Note           This call should be preceded by a
                       GetClipBoardDataSize() call to find out how much memory
                       is required for the buffer. No checking is performed, the
                       caller must ensure that the buffer is big enough;
                       otherwise, some of the callers code or data may be

        Name            CloseClipboard()
        Parameters      AX = 1708H
        Return Values   AX == 0: Error occurred
                           <> 0: OK

        Name            ClipboardCompact()
        Parameters      AX = 1709H
                        SI:CX = Desired memory size in bytes.
        Return Values   DX:AX == Number of bytes of largest block of free memory.
                              == 0 if error or no memory
        Notes           The MS-DOS-based application is responsible for including
                        the size of any headers in the desired memory size.

        Name            GetDeviceCaps()
        Parameters      AX = 170AH
                        DX = GDI information index
        Return Values   AX == integer value of desired item
                           == 0 if error
        Notes           The implied hDC for this call will be for the display.

        Supported Clipboard Formats
        The following Windows clipboard formats are supported:
           CF_TEXT         = 1
           CF_BITMAP       = 2         ; See structures section
           CF_OEMTEXT      = 7
           CF_DSPTEXT      = 81h
           CF_DSPBITMAP    = 82h

        NOTE: Since the RegisterClipboardFormat() and EnumClipboardFormats()
              functions are not available at this time, the use of private
              clipboard formats is not supported.

        These structures mimic the actual Windows structures with one major
        difference: instead of including a handle or pointer to other memory
        containing the actual data, the data follows the structure. The structure
        information now behaves like a header prefacing the data.
        Bitmap structure:
           bmType          DW      ?   ; Always 0
           bmWidth         DW      ?   ; Width of bitmap in pixels
           bmHeight        DW      ?   ; Height of bitmap in raster lines
           bmWidthBytes    DW      ?   ; Bytes/raster line
           bmPlanes        DB      ?   ; Number of color planes in the bitmap
           bmBitsPixel     DB      ?   ; Number of adj color bits to def pixel
           bmBits          DQ      ?   ; Points to byte following bmHigDim
           bmWidDim        DW      ?   ; Width of bitmap in 0.1 mm units
           bmHigDim        DW      ?   ; Height of bitmap in 0.1 mm units
           BitmapData      nBytes      ; The actual data

        Legal Disclaimer: Any views expressed by the sender of this message are
        not necessarily those of Application Solutions Ltd. Information in this
        e-mail may be confidential and is for the use of the intended recipient
        only, no mistake in transmission is intended to waive or compromise such
        privilege. Please advise the sender if you receive this e-mail by mistake.