gpt4 book ai didi

c - 将一个窗口放在一个窗口中

转载 作者:行者123 更新时间:2023-11-30 17:50:15 25 4
gpt4 key购买 nike

我现在被分配制作一个图形/笛卡尔平面制作程序,我被要求用 C 语言,或者更准确地说,在 Win32 中,但我有一个小问题,我想在我的程序中放置一个弹出窗口窗口作为临时图形字段,问题是当我创建窗口时,应该是“图形字段”出现在主/父窗口之外,并且它似乎使用整个屏幕作为对其位置的引用,而不是指定的位置父/主窗口:

HWND DrawGrap(HWND hwnd)
{
LPSTR nme = "graph";
WNDCLASSEX c;
c.style = CS_VREDRAW|CS_HREDRAW;
c.lpfnWndProc = MathProc;
c.cbClsExtra = 0;
c.cbWndExtra = 0;
c.hInstance = GetModuleHandle(NULL);
c.hIcon = LoadIcon(NULL,IDI_APPLICATION);
c.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
c.hCursor = LoadCursor(NULL,IDC_ARROW);
c.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
c.lpszMenuName = NULL;
c.lpszClassName = nme;
c.cbSize = sizeof(c);

RegisterClassEx(&c);

return CreateWindowEx(0,nme,"",WS_VISIBLE|WS_POPUP|WS_CHILD,
10, 10,
460,200,hwnd,NULL,GetModuleHandle(NULL),0);

}
void InitializeUI(HWND hwnd)
{
//Graph
DrawGrap(hwnd);
//GroupBoxes for coordinate inputs
P1BOX = CreateWindowEx(0,"BUTTON","Point 1",
WS_VISIBLE|WS_CHILD|BS_GROUPBOX,
10,230,225,120,hwnd,(HMENU)111,
GetModuleHandle(NULL),0);
P2BOX = CreateWindowEx(0,"BUTTON","Point 2",
WS_VISIBLE|WS_CHILD|BS_GROUPBOX,
250,230,225,120,hwnd,(HMENU)112,
GetModuleHandle(NULL),0);

//Coordinate Labels:
CreateLabel("X :",P1BOX,30);
CreateLabel("Y :",P1BOX,80);
CreateLabel("X :",P2BOX,30);
CreateLabel("Y :",P2BOX,80);
//Input boxes
hP1X = CreateBox(P1BOX,40,30,P1X);
hP1Y = CreateBox(P1BOX,40,80,P1X);
hP2X = CreateBox(P2BOX,40,30,P1X);
hP2Y = CreateBox(P2BOX,40,80,P1X);

//buttons
CreateButton("Gen. Equation",125,360,hwnd,GENEQBTN);
CreateButton("Point-Slope",255,360,hwnd,PSLOPEBTN);
CreateButton("Slope-intercept",125,395,hwnd,SINTERCEPTBTN);
CreateButton("Intercept",255,395,hwnd,INTERCEPTBTN);
CreateButton("Slope",195,430,hwnd,SLOPEBTN);
}

但是当我替换 NULL 时:

return CreateWindowEx(0,nme,"",WS_VISIBLE|WS_POPUP|WS_CHILD,
10, 10,
460,200,hwnd,NULL,GetModuleHandle(NULL),0);

与:

return CreateWindowEx(0,nme,"",WS_VISIBLE|WS_POPUP|WS_CHILD,
10, 10,
460,200,hwnd,(HMENU)443,GetModuleHandle(NULL),0);

“绘图场”似乎消失了。我该如何解决这个问题

最佳答案

似乎弹出窗口不尊重其父窗口的偏移量。

使用ClientToScreen函数将父窗口内部的坐标转换为屏幕坐标,然后使用转换后的坐标创建弹出窗口。

关于c - 将一个窗口放在一个窗口中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17377985/

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