这是C++Builder与windows API的混合编程,希望高人多指点~~~void __fastcall TForm1::Button1Click(TObject *Sender)
{
HWND hWnd
Form2->Show();
if(hWnd=FindWindow(NULL,"Form2"))
{
//ShowMessage("OK");
EnumChildWindows(hWnd,(WNDENUMPROC)EnumChildProc,(LPARAM)(LPCTSTR)"1");
}
}//---------------------------------------------------------------------------
BOOL CALLBACK EnumChildProc(HWND hWnd,LPARAM lParam)
{
static char cClassName[51];
static char cTitle[51];
static const int iBufSize=50; GetClassName(hWnd,cClassName,iBufSize); if(stricmp(cClassName,"TEdit")==0)
SetWindowText(hWnd,(LPCTSTR)lParam);
if(stricmp(cClassName,"TCheckBox")==0)
{
GetWindowText(hWnd,cTitle,iBufSize);
if(cTitle=="cb1")//下面我想实现的功能是:如果是TCheckBox类型的标题文本是"cb1"的CheckBox,
//就去掉复选框的勾选,请问应该怎么实现?
}
return true;}
{
HWND hWnd
Form2->Show();
if(hWnd=FindWindow(NULL,"Form2"))
{
//ShowMessage("OK");
EnumChildWindows(hWnd,(WNDENUMPROC)EnumChildProc,(LPARAM)(LPCTSTR)"1");
}
}//---------------------------------------------------------------------------
BOOL CALLBACK EnumChildProc(HWND hWnd,LPARAM lParam)
{
static char cClassName[51];
static char cTitle[51];
static const int iBufSize=50; GetClassName(hWnd,cClassName,iBufSize); if(stricmp(cClassName,"TEdit")==0)
SetWindowText(hWnd,(LPCTSTR)lParam);
if(stricmp(cClassName,"TCheckBox")==0)
{
GetWindowText(hWnd,cTitle,iBufSize);
if(cTitle=="cb1")//下面我想实现的功能是:如果是TCheckBox类型的标题文本是"cb1"的CheckBox,
//就去掉复选框的勾选,请问应该怎么实现?
}
return true;}
Platform SDK Documentation -> Windows API -> Overview of the Windows API -> User Interface -> Buttons -> Button Reference -> Button Messages