Imprimir y exportar a la funcionalidad USB (Formato de archivo: XML/CSV/Excel) en la aplicación Smart Device [Symbo MotorOal MC75 (Windows Mobile 6.1)]?

StackOverflow https://stackoverflow.com/questions/7817689

Pregunta

Tengo un formulario que contiene cuadros combinados, cuadros de texto y una cuadrícula de datos con muchas filas. Quiero tomar la impresión (con código de barras generado [aplicación de generación de barras como imagen]) y también quiero exportar los datos en esa página como formato CSV/XML/Excel en USB o directorio físico del teléfono. Por favor, guíame cómo. Esta es mi primera aplicación de Windows Mobile. No soy tan sabio en Windows Mobile. Ayúdame a encontrar una mejor solución como código o enlace o simplemente dirídame.

¿Fue útil?

Solución

Para crear la impresión, deberá escribir en su PrintDocument usando GDI. No hay nada realmente integrado. Posiblemente podría hacer una captura de pantalla (código a continuación).

Exportar datos a CSV también se realiza mejor por su cuenta. Simplemente cree/abra una transmisión de archivo y escriba lo que quiera.

Captura de pantalla: requiere pinvoke con bitblt y getdc

const int SRCCOPY = 0x00CC0020;

[DllImport("coredll.dll")]
private static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);

[DllImport("coredll.dll")]
private static extern IntPtr GetDC(IntPtr hwnd);

public Bitmap ScreenCapture(string fileName) {
  Bitmap bitmap = new Bitmap(this.Width, this.Height);
  using (Graphics gScr = Graphics.FromHdc(GetDC(IntPtr.Zero))) { // A Zero Pointer will Get the screen context
    using (Graphics gBmp = Graphics.FromImage(bitmap)) { // Get the bitmap graphics
      BitBlt(gBmp.GetHdc(), 0, 0, this.Width, this.Height, gScr.GetHdc(), this.Left, this.Top, SRCCOPY); // Blit the image data
    }
  }
  bitmap.Save(fileName, ImageFormat.Png); //Saves the image
  return bitmap;
}

Actualizar]:

  • Si desea guardar la imagen en una ubicación en particular, envíe la ruta completa con el nombre de archivo (es decir, \\Windows\Temp\screenShot.png).

  • Si desea excluir los controles, reduzca el this.Width, this.Height, this.Left y this.Right Hasta que tenga el tamaño que se ajuste a la región que funciona.

  • Por último, si quieres el Bitmap Para usar en la memoria, simplemente guárdelo y úselo según sea necesario. Ejemplo:

    panel1.image = screencapture ("image.png"); panel1.BringTofront ();

Espero que ayude.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top