Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 智能设备[Symbo Motoroal MC75(Windows Mobile 6.1)]应用程序中的打印和导出到USB(文件格式:XML/CSV/Excel)功能?_C#_Windows Mobile_Symbols_Windows Mobile 6_Smart Device - Fatal编程技术网

C# 智能设备[Symbo Motoroal MC75(Windows Mobile 6.1)]应用程序中的打印和导出到USB(文件格式:XML/CSV/Excel)功能?

C# 智能设备[Symbo Motoroal MC75(Windows Mobile 6.1)]应用程序中的打印和导出到USB(文件格式:XML/CSV/Excel)功能?,c#,windows-mobile,symbols,windows-mobile-6,smart-device,C#,Windows Mobile,Symbols,Windows Mobile 6,Smart Device,我有一个表单,其中包含组合框、文本框和一个包含许多行的数据网格。我想打印出来(使用生成的条形码[应用程序生成条形码作为图像]),还想将该页面中的数据以CSV/XML/Excel格式导出到USB或手机的物理目录。请告诉我怎么做。这是我的第一个Windows Mobile应用程序。我对Windows Mobile不是那么明智。请通过代码或链接帮助我找到更好的解决方案,或者直接告诉我。要创建打印输出,您必须使用GDI写入您的打印文档。没有什么真正的内在因素。你可以做一个屏幕截图(代码如下) 将数据导出

我有一个表单,其中包含组合框、文本框和一个包含许多行的数据网格。我想打印出来(使用生成的条形码[应用程序生成条形码作为图像]),还想将该页面中的数据以CSV/XML/Excel格式导出到USB或手机的物理目录。请告诉我怎么做。这是我的第一个Windows Mobile应用程序。我对Windows Mobile不是那么明智。请通过代码或链接帮助我找到更好的解决方案,或者直接告诉我。

要创建打印输出,您必须使用GDI写入您的打印文档。没有什么真正的内在因素。你可以做一个屏幕截图(代码如下)

将数据导出到CSV也最好由您自己完成。只需创建/打开一个文件流,然后编写您想要的任何内容即可

屏幕截图:需要PInvoke到BitBlt和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;
}
[更新]:

  • 如果要将图像保存到特定位置,请发送带有文件名的完整路径(即
    \\Windows\Temp\screenShot.png

  • 如果要排除控件,请减小
    this.Width
    this.Height
    this.Left
    this.Right
    ,直到获得适合工作区域的大小

  • 最后,如果要在内存中使用
    位图
    ,只需保存它并根据需要使用它即可。例如:

    panel1.Image=屏幕截图(“Image.png”); 面板1.BringToFront()


希望能有所帮助。

非常感谢您的回复…我对这一点一无所知。我只想知道tat,它将在何时保存此图像?我想将数据集的内容写入此图像…并将其保存在物理内存中。您好,实际上,它在生成的图像中显示了所有的控件和按钮。你能给我发送打印此图像的代码/链接吗?在windows mobile 6[motorola mc75]中,可以是blutooth,也可以是usb…谢谢你的朋友。我需要知道,在我的数据网格中有50多行。我能在这个屏幕截图中获得所有这行吗[bcoz datagrid设置为滚动,其顶部仅显示部分]…如何迭代通过datagrid并将每一行保存为图像…还有一个…我可以通过蓝牙连接windows mobile 6吗[如何查找蓝牙打印机设备并以c#获取其mac id]等待你的回复…我希望你能帮我找到它…对于类似的事情,你必须编写一个自定义例程。屏幕捕获将只捕获屏幕上显示的内容。