首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

关于VC++.NET调用FindWindow和SetWindowText函数.解决方案

2012-02-14 
关于VC++.NET调用FindWindow和SetWindowText函数.我引用了#include Windows.h后,怎么用FindWindow和SetW

关于VC++.NET调用FindWindow和SetWindowText函数.
我引用了#include <Windows.h>后,怎么用FindWindow和SetWindowText这两个函数?
在button1_Click事件里怎么写?

不用给我说这两个函数的参数什么的了,直接给代码.

比如改自身的FORM1窗体的名称. 

这是我写的:

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) 
{
HWND hwd;
hwd = FindWindow(Form1::Handle,"Form1");
SetWindowText(hwd,"Ri");
 
}



错误1error C2664: “FindWindowW”: 不能将参数 1 从“System::IntPtr”转换为“LPCWSTR”c:\documents and settings\mobin\my documents\visual studio 2008\projects\data\data\Form1.h110data
错误2error C2664: “SetWindowTextW”: 不能将参数 2 从“const char [3]”转换为“LPCWSTR”c:\documents and settings\mobin\my documents\visual studio 2008\projects\data\data\Form1.h111data


[解决办法]
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
HWND hwd;
hwd = ::FindWindow(NULL,L"Form1");
SetWindowText(hwd ,L"Ri");

}

你的错误时数据类型不对,LPCWSTR 是宽字符串的指针

热点排行