简体   繁体   中英

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.

If you are editing an .rc file by hand, you'd add a line similar to the following within the dialog definition section:

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

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. A good place to call this is when you handle the WM_INITDIALOG message for the dialog.

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 . I assume you call CreateDialogIndirect since you mention "in C". In the dialog box template you use, simply add the spin control. You will need to identify it by name in DLGTEMPLATEEX.windowClass.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM