在运行时使用 C 在 win32 中移动按钮的 x 位置
Move the x position of a button during runtime in win32 using C
我无法在我的 win32 书籍或使用 google 中找到很多关于此的信息。我想移动我在对话框 window 中创建的按钮的 x 位置。简而言之,我有 6 个按钮,并且想根据是否必须显示 4、5 或 6 个按钮来重新定位它们。
目标是在运行时向按钮发送消息并移动它的 x 位置。我可以找到在运行时更新按钮文本字段和颜色的简单方法,但不是位置。
我的按钮是...
#define IDC_PB_BUTTON_A
并在对话框中如此创建 window...
PUSHBUTTON "A", IDC_PB_BUTTON_A, 4, 4, 30, 30, BS_MULTILINE
我想在运行时获取前 4 个值并将其移动超过 10 个单位,使其...其中 x 位置值已从 4 变为 14。
PUSHBUTTON "A", IDC_PB_BUTTON_A, 14, 4, 30, 30, BS_MULTILINE
我希望我可以使用某种 SendDlgItemMessage() 来完成此操作,但找不到有关该主题的任何内容。有什么建议吗?
移动 window 的 API 调用是 SetWindowPos1。确保传递 SWP_NOSIZE
以便控件保持其初始大小。
1 你可以先用MoveWindow as well, but that requires that you pass in the new window size as well as the position. To retain the window size you'd have to call GetWindowRect。
我无法在我的 win32 书籍或使用 google 中找到很多关于此的信息。我想移动我在对话框 window 中创建的按钮的 x 位置。简而言之,我有 6 个按钮,并且想根据是否必须显示 4、5 或 6 个按钮来重新定位它们。
目标是在运行时向按钮发送消息并移动它的 x 位置。我可以找到在运行时更新按钮文本字段和颜色的简单方法,但不是位置。
我的按钮是...
#define IDC_PB_BUTTON_A
并在对话框中如此创建 window...
PUSHBUTTON "A", IDC_PB_BUTTON_A, 4, 4, 30, 30, BS_MULTILINE
我想在运行时获取前 4 个值并将其移动超过 10 个单位,使其...其中 x 位置值已从 4 变为 14。
PUSHBUTTON "A", IDC_PB_BUTTON_A, 14, 4, 30, 30, BS_MULTILINE
我希望我可以使用某种 SendDlgItemMessage() 来完成此操作,但找不到有关该主题的任何内容。有什么建议吗?
移动 window 的 API 调用是 SetWindowPos1。确保传递 SWP_NOSIZE
以便控件保持其初始大小。
1 你可以先用MoveWindow as well, but that requires that you pass in the new window size as well as the position. To retain the window size you'd have to call GetWindowRect。