gpt4 book ai didi

winapi - 在 C++ Windows API 运行时调整窗口大小?

转载 作者:行者123 更新时间:2023-12-04 21:54:22 24 4
gpt4 key购买 nike

单击按钮时,如何在运行时调整全局 hwnd 变量的大小?

或者只是在运行时调整窗口大小的任何方式。
IE。

HWND hwnd; //global
int buttonid = 250; // an id for a button
//also global


int WINAPI wWinMain(/*blah blah blah */) {


//blah blah blah

hwnd = CreateWindowEx(
0,
L"WindowClass",
L"Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
300, 275,
NULL,
NULL,
hInstance,
NULL
);

HWND mybutton = CreateWindow(
L"BUTTON",
L"Button",
WS_VISIBLE | WS_CHILD | WS_TABSTOP,
14, 13,
250, 200,
hwnd,
(HMENU)buttonid,
hInstance,
NULL
);

//blah blah blah

}


LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lparam) {

switch(uMsg) {

case WM_COMMAND:
if(buttonid==wParam) {
//this is where i want the code for resizing hwnd so when you click the
//button it resizes the window
}



}

}

最佳答案

MoveWindowSetWindowPos (尽管如果您想做的不仅仅是调整大小,后者更有用)。

在这两种情况下,您不仅可以指定左上角的位置,还可以指定右下角的位置,因此如果您保持左上角不变,而移动右下角,则调整窗口大小而不“移动”它。

关于winapi - 在 C++ Windows API 运行时调整窗口大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5609486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com