DLL winapi gui

07/31/2018 16:26 KaMeR1337#1
when MessageBox popup i can't close it, why?

Code:
INT_PTR CALLBACK DialogFunc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_COMMAND:
	{
		switch (LOWORD(wParam))
		{
		case IDC_BUTTON1:
			MessageBox(NULL, "ddd", "aa", MB_OK);
			break;
		}
		break;
	}
	case WM_CLOSE:
		DestroyWindow(hDlg);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(hDlg, uMsg, wParam, lParam);
	}

	return 0;
}

HMODULE hMod;

int NewThread1()
{
	HWND hDlg;
	hDlg = CreateDialog(hMod, MAKEINTRESOURCE(IDD_DIALOG1), 0, (DLGPROC)DialogFunc);

	ShowWindow(hDlg, SW_SHOW);
	UpdateWindow(hDlg);

	MSG Msg;
	while (GetMessage(&Msg, hDlg, 0, 0))
	{
		if (!IsDialogMessage(hDlg, &Msg))
		{
			TranslateMessage(&Msg);
			DispatchMessage(&Msg);
		}
	}

	return Msg.wParam;
}
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
	{
		hMod = hModule;
		if (CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)NewThread1, NULL, 0, NULL) == NULL) {
			return FALSE;
		}
		break;
	}
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}
EDIT: never mind i should return 0 insted of DefWindowProc, and it resolved the issue. thread can be closed.
07/31/2018 18:45 Serraniel#2
Quote:
Originally Posted by KaMeR1337 View Post
EDIT: never mind i should return 0 insted of DefWindowProc, and it resolved the issue. thread can be closed.
#Closed (on request)