我现在被分配制作一个图形/笛卡尔平面制作程序,我被要求用 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);
“图形场”似乎消失了。我该如何解决