全局使用属性页上的SetDlgItemText [英] Usage of SetDlgItemText on Property pages globally

查看:41
本文介绍了全局使用属性页上的SetDlgItemText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,

在我的MFC应用程序中,我使用CPropertyPage& amp;创建了两个选项卡式控件(Tab1& Tab2)。 CPropertySheet的。在Tab1中我有一个静态变量(IDC_SELL)&在运行时我需要更改变量的标签。我的snipnet代码如下所示:

Hello All,
In my MFC application, I''ve created the two tabbed control ( Tab1 & Tab2 ) using CPropertyPage & CPropertySheet. In Tab1 am having a static variable (IDC_SELL) & during runtime i need to change the label of the variable. My snipnet code looks like this:

UINT Thread(LPVOID lParam)
{
  //SampleApp --> Current MFC Application window.
  HWND hWnd = ::FindWindow(0,"SampleApp");

  while(1)
  {
    // Other stuffs ...
   
    ::SetDlgItemText(hWnd,IDC_SELL,"Hello");

  }
   return(1);
}

void CTab1Dlg :: OnButtonOK()
{
  AfxBeginThread(Thread,0);
}





使用此代码,标签IDC_SELL不会更改为Hello。但是当我这样编码:



With this code, the label IDC_SELL doesn''t change to Hello. But when i code like this:

void CTab1Dlg :: OnButtonOk()
{
 SetDlgItemText(IDC_SELL,"Hello");
}



这很好用......我试着在课堂上创建一个这样的线程:




This works pretty well... I tried to create a thread in class like this:

//CTab1Dlg.h
class CTab1Dlg : public CPropertyPage
{
public:
  static UINT Thread(LPVOID lParam);
}
//CTablDlg.cpp
UINT CTab1Dlg :: Thread(LPVOID lParam)
{
while(1)
  {
    // Other stuffs ...
SetDlgItemText(IDC_SELL,"Hello"); // Here SetDlgItemText Crashes stating that m_hWnd is NULL.
  }
   return(1);
}





请问,有人可以建议我如何在PropertyPages中全局使用SetDlgItemText。



谢谢大家。



Please, Can anyone suggest me how to use SetDlgItemText globally in PropertyPages.

Thank you All.

推荐答案

hWnd (在 :: SetDlgItemText(hWnd,IDC_SELL,Hello); )是 CTab1Dlg 窗口的句柄?

Does hWnd (in ::SetDlgItemText(hWnd,IDC_SELL,"Hello");) is the handle of the CTab1Dlg window?

调用SetDlgItemText(IDC_SELL,Hello); 调用 CTab1Dlg ,使用 CTab1Dlg 窗口的句柄调用全局 :: SetDlgItemText 函数,并提供与提供的参数相同的参数到 SetDlgItemText 函数。

The call of SetDlgItemText(IDC_SELL,"Hello"); inside CTab1Dlg, calls the global ::SetDlgItemText function with the handle of the CTab1Dlg window and, the same parameters as provided to the SetDlgItemText function.

尝试找到 CTab1Dlg 并使用它的句柄。

Try to find the window of CTab1Dlg and use its handle.


这篇关于全局使用属性页上的SetDlgItemText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆