1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include "Dialog.h"
#include "IncStandard.h"
#include "IncStatus.h"
#include "Client.h"
#include "resource.h"
CDialog::CDialog(CClient* pClient, const std::string& strTargetUsername) : m_pClient(pClient)
{
CreateThisWindow();
}
void CDialog::CreateThisWindow()
{
//Create Message Thread
CreateThread(NULL, 0, _CreateThisWindow, (void*)this, 0, NULL);
}
INT_PTR CALLBACK CDialog::_DLGPROC(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CDialog *pThis; //Used to buffer the Dialog
if(uMsg == WM_INITDIALOG)
{
pThis = (CDialog*)lParam;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pThis);
pThis->m_hWnd = hWnd;
}
else
{
pThis = (CDialog*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
}
if(pThis)
return pThis->DLGPROC(hWnd, uMsg, wParam, lParam);
else
return DefDlgProc(hWnd, uMsg, wParam, lParam);
}
DWORD WINAPI _CreateThisWindow(void* v)
{
//Creation
CDialog *pWindow = (CDialog*)v;
//Create Window
pWindow->m_hWnd = CreateDialogParam(NULL, MAKEINTRESOURCE(IDD_CHATDIALOG), NULL, CDialog::_DLGPROC,(LPARAM)pWindow); //DLG Template IDD_CHATDIALOG for testing issue
if(pWindow->m_hWnd == NULL)
{
MessageBox(NULL, "Could Not Create Window", "ERROR", MB_ICONEXCLAMATION);
return 0;
}
//Show Window
ShowWindow(pWindow->m_hWnd, SW_SHOW);
//Message Loop
MSG msg;
while(GetMessage(&msg, NULL, 0,0) != 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
| |