[英]How to add spin control to the dialog box using win32 C?
只想知道如何使用C程序(win32 / code :: block / mingw编译器)在对话框中添加旋转控件(即上/下控件)。
Simplest way is by using a resource editor to design your dialog. 最简单的方法是使用资源编辑器来设计对话框。 Code::Blocks doesn't come with one, but ResEdit is one I've used.
代码:: Blocks没有附带一个,但是ResEdit是我用过的一个。
If you are editing an .rc file by hand, you'd add a line similar to the following within the dialog definition section: 如果要手动编辑.rc文件,则可以在对话框定义部分中添加类似于以下内容的行:
CONTROL "", IDC_SPIN1, UPDOWN_CLASS, UDS_ARROWKEYS, 7, 22, 11, 14
If you want to add it programatically, you can do so through the CreateWindow
API function, eg 如果要以编程方式添加它,则可以通过
CreateWindow
API函数进行添加,例如
HWND hwndUpDown = CreateWindow(UPDOWN_CLASS, NULL,
WS_CHILD | WS_VISIBLE | UDS_ARROWKEYS,
7, 22, 11, 14,
hwndDlg, NULL, hInst, NULL);
where the hwndDlg
parameter is the HWND of your dialog window. 其中
hwndDlg
参数是对话框窗口的HWND。 A good place to call this is when you handle the WM_INITDIALOG message for the dialog. 调用此对话框的一个好地方是当您处理对话框的WM_INITDIALOG消息时。
It depends. 这取决于。 There are two ways to create a dialog.
有两种创建对话框的方法。 Programmatically, or via a dialog resource.
以编程方式或通过对话框资源。 In the first case, you call
CreateDialogIndirect
, in the second case CreateDialog
. 在第一种情况下,您调用
CreateDialogIndirect
,在第二种情况下,调用CreateDialog
。 I assume you call CreateDialogIndirect
since you mention "in C". 由于您提到“在C中”,因此我假设您调用
CreateDialogIndirect
。 In the dialog box template you use, simply add the spin control. 在您使用的对话框模板中,只需添加旋转控件。 You will need to identify it by name in DLGTEMPLATEEX.windowClass.
您将需要在DLGTEMPLATEEX.windowClass中通过名称进行标识。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.