首页 \ 问答 \ 将c#windows面板转换为c HWND(Convert c# windows panel to c HWND)

将c#windows面板转换为c HWND(Convert c# windows panel to c HWND)

我有一个接受HWND的dll,(dll中的代码);

void VideoCapture::SetVideoWindow(HWND VidWind)
{
    VideoWindow = VidWind;
}

我在c#.net应用程序中调用了上面的dll,在c#.net中添加了dll,我有一个带有Panel的表单,是否可以将该面板传递给dll? 我在c#中给出了如下代码

VidCapWrapper.ManagedVideoCapture cc = new VidCapWrapper.ManagedVideoCapture();

cc.SetVideoWindow( panel1);

我得到的错误如下:'错误2'VidCapWrapper.ManagedVideoCapture.SetVideoWindow(HWND__ )'的最佳重载方法匹配有一些无效的参数D:\ DirectShow_Capture_GUI \ DirectShow_Capture_GUI \ Form1.cs 44 13 DirectShow_Capture_GUI错误3参数1:无法转换从'System.Windows.Forms.Panel'到'HWND__ 'D:\ DirectShow_Capture_GUI \ DirectShow_Capture_GUI \ Form1.cs 44 32 DirectShow_Capture_GUI`

任何人都可以告诉我如何将面板传递给dll,(任何一个例子都会很好)? (抱歉,我对.net很新,但尝试创建一个示例应用程序,显示集成网络摄像头等可用设备...然后在c#.net表单面板上显示预览)

编辑 :感谢@Blachshma和@Hans Passant,现在我能够将c#windows窗体的面板传递给我的c ++ dll。

我在dll中改变了我的功能

void VideoCapture::SetVideoWindow(IntPtr windowHandle)
{
    VideoWindow = (HWND)windowHandle.ToPointer();
}

在c#我称之为cc.SetVideoWindow(panel1.Handle);


I have a dll which accepts HWND, (code in the dll);

void VideoCapture::SetVideoWindow(HWND VidWind)
{
    VideoWindow = VidWind;
}

i am calling the above dll in a sample c#.net application by adding the dll in references, in c#.net i have a form with Panel, is it possible to pass that panel to the dll? i gave code as below in c#

VidCapWrapper.ManagedVideoCapture cc = new VidCapWrapper.ManagedVideoCapture();

cc.SetVideoWindow( panel1);

i am getting errors as below: 'Error 2 The best overloaded method match for 'VidCapWrapper.ManagedVideoCapture.SetVideoWindow(HWND__)' has some invalid arguments D:\DirectShow_Capture_GUI\DirectShow_Capture_GUI\Form1.cs 44 13 DirectShow_Capture_GUI Error 3 Argument 1: cannot convert from 'System.Windows.Forms.Panel' to 'HWND__' D:\DirectShow_Capture_GUI\DirectShow_Capture_GUI\Form1.cs 44 32 DirectShow_Capture_GUI`

Can any one please tell me how to pass panel to dll, (any example will be good)? (sorry i am very new to .net, but trying to create a sample app which shows available devices like integrated webcam... and then shows preview on c#.net form panel)

EDIT: Thanks to Both @Blachshma and @Hans Passant, Now i am able to pass c# windows form's panel to my c++ dll.

I changed my func in dll as

void VideoCapture::SetVideoWindow(IntPtr windowHandle)
{
    VideoWindow = (HWND)windowHandle.ToPointer();
}

and in c# i am calling it as cc.SetVideoWindow(panel1.Handle);


原文:https://stackoverflow.com/questions/13821680
更新时间:2023-07-28 16:07

最满意答案

添加文本框架文本后,需要设置字体大小。

data_label = p.data_label
...
text_frame = data_label.text_frame
# text_frame.clear()  # this line is not needed, assigning to .text does this
text_frame.text = str.format('{0:.1f}', v)
for paragraph in text_frame.paragraphs:
    paragraph.font.size = Pt(10)

# -- OR --

for run in text_frame.paragraphs[0].runs:
    run.font.size = Pt(10)

当您调用TextFrame.text ,将删除所有现有段落并添加一个新段落。 在此过程中,删除所有字符格式以在添加指定文本之前生成“干净的平板”。

我不记得PowerPoint是否尊重段落级别的字体集(使用a:defRPr元素)。 如果没有,您需要在运行级别执行此操作,如“ - OR”行后所示。


You need to set the font size after adding the text frame text.

data_label = p.data_label
...
text_frame = data_label.text_frame
# text_frame.clear()  # this line is not needed, assigning to .text does this
text_frame.text = str.format('{0:.1f}', v)
for paragraph in text_frame.paragraphs:
    paragraph.font.size = Pt(10)

# -- OR --

for run in text_frame.paragraphs[0].runs:
    run.font.size = Pt(10)

When you call TextFrame.text, all existing paragraphs are removed and a single new paragraph is added. Along the way, all character formatting is removed to produce a "clean slate" before adding the specified text.

I don't recall whether PowerPoint respects the font set at the paragraph level (using the a:defRPr element). If not, you'll need to do it at the run level, as shown after the -- OR -- line.

相关问答

更多
  • 3.4和3.5之间的差异不太可能打破已经能够处理2.7和更低的包,差异不是那么大。 听起来更像是没有为python-pptx所依赖的lxml安装正确的二进制文件。 由于lxml仅作为python 3.2的wheel使用,因此你的pip install会尝试从源代码编译lxml 。 从包含\r\n的消息我假设你使用的是Windows和Python 3.5,在PyPI上没有lxml轮子,所以你应该尝试从Christoph Gohlke的非官方版本中安装lxml ,特别是最后两个中的一个,在名称中有cp35 ,来 ...
  • Table中.columns的属性是.columns ,因此: for column in table.columns: yield column.width 文档的API部分提供了每个属性和每个属性的描述,例如,此页面描述了表对象API: http : //python-pptx.readthedocs.io/en/latest/api/table.html The property you want on Table is .columns, so: for column in table.c ...
  • 它不会像文本一样工作; 图像上没有中心对齐或对齐属性。 你需要使用一个公式。 image.left = (prs.slide_width - image.width) / 2 It's not going to work the same way as text; there's no center justification or alignment property on an image. You'll need to use a formula. image.left = (prs.slide_w ...
  • _Cell对象不直接包含段落。 但是,它确实包含.text_frame上的.text_frame对象,其中包含段落。 所以如果你只是使用: cell.text_frame.paragraphs[0] ..你应该得到你所期望的。 请注意,它是.paragraphs,而不是.paragraph。 _Cell的API文档位于: http : _Cell 并且通常提供解决像这样的更精细点所需的所有细节。 A _Cell object doesn't directly contain paragraphs. How ...
  • 也许不是真正干净的代码,但允许我调整表中所有单元格的所有边框: from pptx.oxml.xmlchemy import OxmlElement def SubElement(parent, tagname, **kwargs): element = OxmlElement(tagname) element.attrib.update(kwargs) parent.append(element) return element def _ ...
  • 图表中的条形图没有单独的位置和大小信息,至少不存储在.pptx文件的XML中。 所以简短的回答是你不能直接做你要求使用的python-pptx。 例如,使用VBA访问的MS API,以及使用Iron Python的MS API,确实提供了Point.left,.top,.width和.height。 所以,如果你能够忍受艰辛,那么你可以在那个环境中做点什么:)请注意,像这样的代码直接操作PowerPoint应用程序实例,只有在我没有弄错的情况下才能在Windows中操作。 因此,如果您尝试在服务器端运行,那 ...
  • 添加文本框架文本后,需要设置字体大小。 data_label = p.data_label ... text_frame = data_label.text_frame # text_frame.clear() # this line is not needed, assigning to .text does this text_frame.text = str.format('{0:.1f}', v) for paragraph in text_frame.paragraphs: paragr ...
  • 引自python-ppty开发人员的dev-group - 如果你知道它的索引,就像table = slide.shapes[2]那样可以解决问题。 然后,您需要在更改其内容之前导航单元格: for idx, row in enumerate(table.rows): if idx = 0: # skip header row continue name_cell = row.cells[0] name_cell.text = 'foobar' corner ...
  • 我不确定Word中的哪些对象可以有边框。 我希望段落可以,但不确定一行文本可以。 您可以通过试用Word UI快速确定这一点。 无论如何,该功能尚未在python-docx实现。 I'm not sure what objects in Word can have a border. I expect a paragraph can, but not sure a run of text can. You can determine this pretty quickly by experimenting ...
  • 我的工作类似于一个类似的要求,这就是我处理一个具有随机可能行数的表的方法。 识别具有最大字符的列。在我的情况下,我只有一列具有不同的内容。 尝试粗略估计一张幻灯片上可容纳的字符数。 如果文本达到最大字符并进入下一张幻灯片,创建表格并填写剩余内容,请提供逻辑来打破文本。 I worked on a similar requirement and this is how I handled a table with random number of possible rows. Identify the col ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)