간단한 메뉴가 있고 간단한 작업을 수행하는 윈도우 폼이 있습니다. 메뉴 막대, 메시지 펌프 등의 모든 기능을 가진 다른 윈도우 폼을 만들 수 있어야합니다. 별도의 스레드로 작업의 결과를 두 번째 창에 공유 할 수 있습니다.CreateWindowsEx()를 사용하여 두 개의 윈도우 만들기
I.E.
1) A 형은 형태 B가 별도의 쓰레드로 열리고 열리고
2) A 형은 행하는 형태 A가 B를
4) B 형 표시 폼을 메모리를 통해 결과를 전달
3) 운전 결과
나는 그것에 대해 갈 방법에 관해서 혼란 스럽다, 주 응용 프로그램은 잘 실행되지만 첫 번째 창이 이미 존재하는 경우 두 번째 창을 추가하는 방법을 모르겠다. CreateWindow를 사용하면 다른 창을 만들 수 있지만 다시 메시지 펌프에 액세스하는 방법을 모르므로 두 번째 창에서 WM_CREATE와 같은 특정 이벤트에 응답 할 수 있다고 생각합니다.
나는 그것이 의미가 있기를 바랍니다.
감사합니다.
편집 :
나는 두 번째 창을 시도했고,이 컴파일 않지만, 어떤 창 atall에 구축 보여주지.
//////////////////////
// WINDOWS FUNCTION //
//////////////////////
LRESULT CALLBACK WindowFunc(HWND hMainWindow, UINT message,
WPARAM wParam, LPARAM lParam)
{
//Fields
WCHAR buffer[256];
struct DiceData storage;
HWND hwnd;
// Act on current message
switch(message)
{
case WM_CREATE:
AddMenus(hMainWindow);
hwnd = CreateWindowEx(
0,
"ChildWClass",
(LPCTSTR) NULL,
WS_CHILD | WS_BORDER | WS_VISIBLE,
0,
0,
0,
0,
hMainWindow,
NULL,
NULL,
NULL);
ShowWindow(hwnd, SW_SHOW);
break;
왜 이런 일이 발생하는지 제안 해주세요.
편집 2 :
이가 전부입니다 나는이 권리를 구현하고있어하지만 난 다른 윈도우 생성과 일치하도록 시도했다, 난 아무 생각도 없어.
//////////////////
// WINDOWS MAIN //
//////////////////
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
LPSTR lpszArgs, int nWinMode)
{
// Declaration of window class (used to register program),
// handle to window (returned by CreateWindow)
// and windows message (holds messages received from windows)
WNDCLASS wcl;
WNDCLASS scl;
HWND hwnd;
MSG msg;
// Name of window and window class
LPCWSTR szWinName = L"DiceRoller - Producer";
LPCWSTR szClassName = L"DiceRollProd";
LPCWSTR szCWinName = L"Dice - Consumer";
LPCWSTR szCClassName = L"DiceRollCon";
// Set up the windows class struct
wcl.hInstance = hThisInst;
wcl.lpszClassName = szClassName;
wcl.lpfnWndProc = WindowFunc;
wcl.style = 0;
wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.lpszMenuName = NULL;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
// Set up the windows class struct
scl.hInstance = hThisInst;
scl.lpszClassName = szCClassName;
scl.lpfnWndProc = WindowFunc;
scl.style = 0;
scl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
scl.hCursor = LoadCursor(NULL, IDC_ARROW);
scl.lpszMenuName = NULL;
scl.cbClsExtra = 0;
scl.cbWndExtra = 0;
scl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
// Register the windows class
if(!RegisterClass(&wcl))
{
return 0;
}
if(!RegisterClass(&scl))
{
return 0;
}
// Create the main window
hwnd = CreateWindowEx(0,
szClassName,
szWinName,
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN,
100,
100,
400,
400,
HWND_DESKTOP,
NULL,
hThisInst,
NULL);
// Show the main window
ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);
// Main message processing loop
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
//////////////////////
// WINDOWS FUNCTION //
//////////////////////
LRESULT CALLBACK WindowFunc(HWND hMainWindow, UINT message,
WPARAM wParam, LPARAM lParam)
{
//Fields
WCHAR buffer[256];
struct DiceData storage;
HWND hwnd;
// Act on current message
switch(message)
{
case WM_CREATE:
AddMenus(hMainWindow);
hwnd = CreateWindowEx(
0,
"ChildWClass",
(LPCTSTR) NULL,
WS_CHILD | WS_BORDER | WS_VISIBLE,
CW_USEDEFAULT, // x location
CW_USEDEFAULT, // y location
400, // width
300, // height
hMainWindow,
NULL,
NULL,
NULL);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
break;
어, 정말로 다른 프로세스가 필요하다고 생각하지 않습니다. 아마도 다른 스레드를 원할 것입니다. – SamB
수정 됨! 내 실수. –
두 번째 CreateWindow 호출에서 첫 번째 hwnd를 ovewriting합니다. 2 개의 창을 추적하고 표시하려면 2 개의 행 높이가 필요합니다. ;> – dthorpe