请问如何在这段代码的基础上,实现用鼠标拖动窗口缩放的同时保持生成的easyx图片按比例缩放,换言之,我该在代码中哪一部分插入easyx图片生成代码才能保证每次鼠标拖动缩放后图片按比例变化?由于该段代码来自问答区拷贝,所以如果有大佬有别的好方法能教教我也是完全可以的qwq:核心在于用easyx生成图片后在程序运行中实现窗口——图片的随时主动同步缩放功能,本人对Windowsapi之类的窗口编程差不多零基础,可能会有续问题价格再议
windows系统,vs2022编译
#include <windows.h>
#include <graphics.h>
#include <conio.h>
#include<iostream>
bool change_size = false;
int change_size_width;
int change_size_height;
WNDPROC EasyXProcess;
LRESULT MyWindowProcess(HWND handle, UINT message, WPARAM wparam, LPARAM lparam) {
switch (message) {
case WM_SIZING: {
RECT* rect = (RECT*)lparam;
change_size = true;
change_size_width = rect->right - rect->left;
change_size_height = rect->bottom - rect->top;
setbkcolor(WHITE);
int x0 = rect->left, y0 = rect->bottom;
setlinecolor(BLACK);
settextcolor(BLACK);
cleardevice();
setorigin(x0, y0);
line(x0+20, y0-30, x0+1580, y0-30);
return 0;
}
}
return EasyXProcess(handle, message, wparam, lparam);
}
int main() {
initgraph(900, 900);
// 取消拖动改变大小限制
SetWindowLong(GetHWnd(), GWL_STYLE, GetWindowLong(GetHWnd(), GWL_STYLE) | (WS_MAXIMIZEBOX));
SetWindowLong(GetHWnd(), GWL_STYLE, (GetWindowLong(GetHWnd(), GWL_STYLE) | WS_THICKFRAME));
EasyXProcess = reinterpret_cast<WNDPROC>(GetWindowLongPtr(GetHWnd(), GWLP_WNDPROC));
SetWindowLongPtr(GetHWnd(), GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(MyWindowProcess));
// 计时器
time_t timer = clock();
setbkcolor(WHITE);
int x0 = getmaxx() - getmaxx(), y0 = getmaxy();
setlinecolor(BLACK);
settextcolor(BLACK);
cleardevice();
setorigin(x0, y0);
line(20, -30, 1580, -30);
BeginBatchDraw();
FlushBatchDraw();
while (true) {
if (clock() - timer >= 38) {
if (change_size == true) {
change_size = false;
Resize(NULL, change_size_width, change_size_height);
cleardevice();
FlushBatchDraw();
}
}
}
EndBatchDraw();
_getch();
return 0;
}