C++ 本机 Win32 简单编辑控件
C++ Native Win32 simple Edit Control
我目前正在尝试制作一个小的本机 Win32 可执行文件。所以没有外部libraries/wrappers/frameworks。我添加了一个简单的编辑控件和一个按钮。问题是我无法在 Visual Studio 的属性 window 中更改编辑控件的文本。默认文本是 Sample edit box
,它不会显示在属性 window (IDC_EDIT1) 中,所以我无法更改它。
如何更改编辑控件的文本(最好在属性 window 中)?还有,MFC库的编辑控件是不是?
Visual Studio的属性 window是图形UI的一部分,可以直接创建和修改Resource Files. Resource files are used, among other things, to store dialog templates, including the dialog's child controls. Since the EDITTEXT resource statement doesn't allow for an initial text entry, you cannot statically set one. You will have to set the control text at runtime, either by using the Edit_SetText macro, or by calling SetWindowText。
Edit Control is a standard Windows control, not part of MFC. MFC provides a wrapper class, CEdit,就像所有其他标准控件一样。
在您的对话框 window 函数中使用此结构为您的控件设置文本(假定其 ID 为 ID_BUTTON)
BOOL CALLBACK DialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch (iMsg)
{
case WM_INITDIALOG :
SetDlgItemText ( hDlg, ID_BUTTON, "Button Text" );
return TRUE ;
}
return FALSE ;
}
我目前正在尝试制作一个小的本机 Win32 可执行文件。所以没有外部libraries/wrappers/frameworks。我添加了一个简单的编辑控件和一个按钮。问题是我无法在 Visual Studio 的属性 window 中更改编辑控件的文本。默认文本是 Sample edit box
,它不会显示在属性 window (IDC_EDIT1) 中,所以我无法更改它。
如何更改编辑控件的文本(最好在属性 window 中)?还有,MFC库的编辑控件是不是?
Visual Studio的属性 window是图形UI的一部分,可以直接创建和修改Resource Files. Resource files are used, among other things, to store dialog templates, including the dialog's child controls. Since the EDITTEXT resource statement doesn't allow for an initial text entry, you cannot statically set one. You will have to set the control text at runtime, either by using the Edit_SetText macro, or by calling SetWindowText。
Edit Control is a standard Windows control, not part of MFC. MFC provides a wrapper class, CEdit,就像所有其他标准控件一样。
在您的对话框 window 函数中使用此结构为您的控件设置文本(假定其 ID 为 ID_BUTTON)
BOOL CALLBACK DialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch (iMsg)
{
case WM_INITDIALOG :
SetDlgItemText ( hDlg, ID_BUTTON, "Button Text" );
return TRUE ;
}
return FALSE ;
}