home *** CD-ROM | disk | FTP | other *** search
- /*
- Company: Sensaura Ltd
- Copyright: (C) 2000
-
- File Name: mainwnd.cpp
- File Description: Source file for implementation of MainWnd class
- Author: Adam Philp
- Last Update: 04-JAN-00
-
- Target Compiler: Microsoft Visual C++ Version 5.0
- */
-
- /////////////////////// Included files ////////////////////////////////////////////////////////////
-
- #include <windows.h>
- #include <stddef.h>
- #include <string.h>
-
- #include "mainwnd.h"
- #include "applicat.h"
- #include "aboutbox.h"
- #include "buffrdlg.h"
- #include "lstnrdlg.h"
- #include "directx.h"
- #include "debug.h"
- #include "resource.h"
-
- /////////////////////// Definitions ///////////////////////////////////////////////////////////////
-
- #define TIMERPERIOD 500 // 1/2 second
-
- /////////////////////// Local type definitions ////////////////////////////////////////////////////
-
- typedef LRESULT (CALLBACK *ThunkProc)(HWND, UINT, WPARAM, LPARAM);
-
- #pragma pack(1)
-
- struct InstanceThunk
- {
- BYTE Call;
- int Offset;
- ThunkProc Proc;
- MainWnd* MainWnd;
- BYTE Code[6];
- };
- #pragma pack()
-
- /////////////////////// Constants /////////////////////////////////////////////////////////////////
-
- static const int CodeOffset = offsetof(InstanceThunk, Code)-offsetof(InstanceThunk, Proc);
-
- /////////////////////// Local variables ///////////////////////////////////////////////////////////
-
- MainWnd* g_ThunkWindow = NULL;
-
- /////////////////////// Local functions ///////////////////////////////////////////////////////////
-
- /*
- The following functions handle setting the pThunk for our window object to enable us to use a
- C++ class to handle Windows messages
- */
-
- WNDPROC CreateInstanceThunk(MainWnd* w, ThunkProc thunkProc)
- {
- InstanceThunk* pThunk;
-
- pThunk = new InstanceThunk;
-
- pThunk->Call = 0xE8u; // CALL rel32
- pThunk->Offset = CodeOffset; // relative displacement to Code[5]
- pThunk->Proc = thunkProc;
- pThunk->MainWnd = w;
-
- // POP ECX
- //
- // pop return address of call into ecx (address of member "Proc")
- //
- pThunk->Code[0] = 0x59u;
-
- // MOV EAX,[ECX+4]
- //
- // load "MainWnd" into ebx
- //
- pThunk->Code[1] = 0x8Bu; // MOV r32,r/m32
- pThunk->Code[2] = 0x41u; // eax,disp8[ECX]
- pThunk->Code[3] = 0x04u; // +4
-
- // JMP [ECX]
- //
- // jump to window function provided
- //
- pThunk->Code[4] = 0xFFu; // JMP r/m32
- pThunk->Code[5] = 0x21u; // [ECX]
-
- return (WNDPROC)pThunk;
- }
-
- void FreeInstanceThunk(WNDPROC proc)
- {
- delete (InstanceThunk*)proc;
- }
-
- void SetWindowToThunk(MainWnd* w)
- {
- g_ThunkWindow = w;
- }
-
- MainWnd* GetWindowToThunk()
- {
- return g_ThunkWindow;
- }
-
- LRESULT CALLBACK InitWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- WNDPROC pThunk;
-
- if(!g_ThunkWindow)
- return DefWindowProc(hwnd, message, wParam, lParam);
- g_ThunkWindow->m_hWnd = hwnd;
- g_ThunkWindow->SetDefaultProc((WNDPROC)GetProcAddress((HINSTANCE)GetModuleHandle("USER32"),
- "DefWindowProcA"));
- pThunk = g_ThunkWindow->GetThunk();
- g_ThunkWindow = NULL;
-
- SetWindowLong(hwnd, GWL_WNDPROC, (long)pThunk);
- return (*(WNDPROC)(pThunk))(hwnd, message, wParam, lParam);
- }
-
- /////////////////////// MainWnd class implementation ///////////////////////////////////////////////
-
- MainWnd::MainWnd(LPCSTR pCaption, Application* pApp)
- {
- m_pApp = pApp;
- m_hWnd = NULL;
- m_DefaultProc = NULL;
- m_Thunk = CreateInstanceThunk(this, StdWndProc);
-
- m_xNextPos = 0;
- m_yNextPos = 0;
-
- m_pDirectSound = NULL;
- m_pPrimary = NULL;
- m_pListener = NULL;
-
- m_bCanDoZoomFX = false;
- m_bZoomFX = false;
-
- m_dwTimer = 0;
- m_hbmZoomFX = NULL;
- memset(&m_dsCaps, 0, sizeof(m_dsCaps));
- m_dsCaps.dwSize = sizeof(m_dsCaps);
-
- m_pListenerDlg = NULL;
- m_pBufferDlgs = NULL;
-
- }
-
- MainWnd::~MainWnd()
- {
- if(m_hWnd)
- DestroyWindow(); // Destroy MS-MainWnd
-
- FreeInstanceThunk(m_Thunk);
- }
-
- /////////////////////// MainWnd public member functions ///////////////////////////////////////////
-
- int MainWnd::GetClassName(LPSTR className, int maxCount) const
- {
- return ::GetClassName(m_hWnd, className, maxCount);
- }
-
- LPSTR MainWnd::GetClassName() const
- {
- return "MainWnd";
- }
-
- LPCSTR MainWnd::GetCaption() const
- {
- return m_pApp->GetName();
- }
-
- void MainWnd::GetWindowClass(WNDCLASS& wc) const
- {
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = m_pApp->GetInstance();
- wc.hIcon = LoadIcon(m_pApp->GetInstance(), MAKEINTRESOURCE(IDI_SENSAURA));
- wc.hCursor = ::LoadCursor(0, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
- wc.lpszMenuName = MAKEINTRESOURCE(IDM_MAINMENU);
- wc.lpszClassName = GetClassName();
- wc.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
- wc.lpfnWndProc = InitWndProc;
- }
-
- bool MainWnd::Create()
- {
- BITMAP bm;
- LPDIRECTSOUNDBUFFER pBuffer;
- LPDIRECTSOUND3DBUFFER p3dBuffer;
- LPKSPROPERTYSET pKsPropertySet;
- unsigned long ulSupport;
- WAVEFORMATEX wfx;
- DSBUFFERDESC dsbd;
-
- TRY_DS(DirectSoundCreate(NULL, &m_pDirectSound, NULL))
-
- m_hbmZoomFX = LoadBitmap(m_pApp->GetInstance(), MAKEINTRESOURCE(IDB_ZOOMFX));
- if(m_hbmZoomFX == NULL)
- return false;
- GetObject(m_hbmZoomFX, sizeof(bm), &bm);
-
- if(Register())
- {
- SetWindowToThunk(this);
-
- m_hWnd = CreateWindowEx(0, GetClassName(), GetCaption(),
- WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_MINIMIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT,
- bm.bmWidth+2*GetSystemMetrics(SM_CXBORDER),
- bm.bmHeight+2*GetSystemMetrics(SM_CYBORDER)+GetSystemMetrics(SM_CYMENU)+GetSystemMetrics(SM_CYCAPTION),
- NULL, NULL, m_pApp->GetInstance(), NULL);
- }
- if(GetWindowToThunk() == this)
- SetWindowToThunk(NULL);
-
- if(m_hWnd == NULL)
- return false;
-
- TRY_DS(m_pDirectSound->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL))
-
- dsbd.dwSize = sizeof(DSBUFFERDESC); // Set primary buffer properties
- dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
- dsbd.dwBufferBytes = 0;
- dsbd.dwReserved = 0;
- dsbd.lpwfxFormat = NULL;
-
- TRY_DS(m_pDirectSound->CreateSoundBuffer(&dsbd, &m_pPrimary, NULL))
- if(m_pPrimary->QueryInterface(IID_IDirectSound3DListener, (void**)&m_pListener) != S_OK)
- return false;
-
- wfx.wFormatTag = WAVE_FORMAT_PCM; // Create a temp secondary buffer
- wfx.nChannels = 1;
- wfx.nSamplesPerSec = 11025;
- wfx.nAvgBytesPerSec = 11025;
- wfx.nBlockAlign = 1;
- wfx.wBitsPerSample = 8;
- wfx.cbSize = 0;
-
- dsbd.dwSize = sizeof(DSBUFFERDESC); // First, set up the DirectSound buffer description
- dsbd.dwFlags = DSBCAPS_CTRL3D|DSBCAPS_LOCHARDWARE;
- dsbd.dwBufferBytes = 256;
- dsbd.dwReserved = 0;
- dsbd.lpwfxFormat = &wfx;
-
- TRY_DS(m_pDirectSound->CreateSoundBuffer(&dsbd, &pBuffer, NULL))
- if(pBuffer->QueryInterface(IID_IDirectSound3DBuffer, (void**)&p3dBuffer) != S_OK)
- {
- pBuffer->Release();
- return false;
- }
- if(pBuffer->QueryInterface(IID_IKsPropertySet, (void**)&pKsPropertySet))
- {
- p3dBuffer->Release();
- pBuffer->Release();
- return false;
- }
- m_bCanDoZoomFX = false;
- if(pKsPropertySet->QuerySupport(DSPROPSETID_ZOOMFX_BufferProperties, DSPROPERTY_ZOOMFXBUFFER_ALL, &ulSupport) == S_OK)
- {
- if(ulSupport == (KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET))
- {
- m_bCanDoZoomFX = true; // Set status flag
- m_bZoomFX = true; // ZoomFX on by default
- }
- }
- pKsPropertySet->Release();
- p3dBuffer->Release();
- pBuffer->Release();
-
- if(!m_bCanDoZoomFX) // Allow the program to continue if ZoomFX not present
- MessageBox("ZoomFX extensions are not supported", GetCaption(), MB_OK|MB_ICONEXCLAMATION);
-
- if((m_dwTimer = SetTimer(m_hWnd, 1, TIMERPERIOD, NULL)) == 0)
- { // Quit the app if we can't get a timer
- MessageBox("Cannot allocate timer, aborting", GetCaption(), MB_OK|MB_ICONSTOP);
- return false;
- }
- return true;
-
- DS_ERROR:
- return false;
-
- }
-
- bool MainWnd::ShowWindow(int nCmdShow)
- {
- if(m_hWnd)
- return ::ShowWindow(m_hWnd, nCmdShow) ? true : false;
- return false;
- }
-
- void MainWnd::Paint(HDC hdc, RECT& rect, bool bErase)
- {
- RECT rcClient;
- TCHAR szText[128];
- SIZE sizeExtent;
- COLORREF clrOld;
-
- GetClientRect(m_hWnd, &rcClient);
- SetBkMode(hdc, TRANSPARENT);
- clrOld = GetTextColor(hdc);
- SetTextColor(hdc, RGB(0, 128, 64));
-
- wsprintf(szText, "Free HW Mem: %luKb", m_dsCaps.dwFreeHwMemBytes / 1024);
- GetTextExtentPoint32(hdc, szText, lstrlen(szText), &sizeExtent);
- DrawText(hdc, szText, -1, &rcClient, DT_TOP | DT_LEFT);
-
- wsprintf(szText, "Free HW Mixing Buffers: %lu", m_dsCaps.dwFreeHwMixingStaticBuffers);
- rcClient.top += sizeExtent.cy;
- DrawText(hdc, szText, -1, &rcClient, DT_TOP | DT_LEFT);
-
- wsprintf(szText, "Free HW 3D Buffers: %lu", m_dsCaps.dwFreeHw3DStaticBuffers);
- rcClient.top += sizeExtent.cy;
- DrawText(hdc, szText, -1, &rcClient, DT_TOP | DT_LEFT);
-
- wsprintf(szText, "ZoomFX extensions: %s", !m_bCanDoZoomFX ? "NOT PRESENT" : m_bZoomFX ? "ON" : "OFF");
- rcClient.top += sizeExtent.cy;
- DrawText(hdc, szText, -1, &rcClient, DT_TOP | DT_LEFT);
-
- SetTextColor(hdc, clrOld);
- }
-
- LRESULT MainWnd::EvCommand(UINT id, HWND hwndCtl, UINT notifyCode)
- {
- BufferList* pBuffer;
-
- switch(id)
- {
- case CM_FILE_OPEN:
- OpenFile(NULL);
- break;
-
- case CM_FILE_EXIT:
- SendMessage(WM_CLOSE);
- break;
-
- case CM_BUFFERS_MINIMIZEALL:
- pBuffer = m_pBufferDlgs;
- while(pBuffer)
- {
- ::ShowWindow(pBuffer->pDlg->m_hWnd, SW_MINIMIZE);
- pBuffer = pBuffer->pNext;
- }
- break;
-
- case CM_BUFFERS_RESTOREALL:
- pBuffer = m_pBufferDlgs;
- while(pBuffer)
- {
- ::SendMessage(pBuffer->pDlg->m_hWnd, WM_SYSCOMMAND, SC_RESTORE, 0L);
- pBuffer = pBuffer->pNext;
- }
- break;
-
- case CM_BUFFERS_CASCADE:
- pBuffer = m_pBufferDlgs;
- if(pBuffer)
- ResetCascade();
-
- while(pBuffer)
- {
- CascadeWindow(pBuffer->pDlg->m_hWnd);
- pBuffer = pBuffer->pNext;
- }
- break;
-
- case CM_BUFFERS_CLOSEALL:
- while(m_pBufferDlgs)
- {
- pBuffer = m_pBufferDlgs->pNext;
- ::SendMessage(m_pBufferDlgs->pDlg->m_hWnd, WM_COMMAND, MAKELONG(IDCANCEL, 0), 0L);
- m_pBufferDlgs = pBuffer;
- }
- EnableMenuItem(GetMenu(m_hWnd), 1, MF_BYPOSITION|MF_GRAYED);
- DrawMenuBar(m_hWnd);
- break;
-
- case CM_HELP_ABOUT:
- AboutBox(m_hWnd, m_pApp->GetInstance());
- break;
- }
- return 0;
- }
-
- void MainWnd::DestroyChild(HWND hwndChild)
- {
- BufferList* pBuffer = m_pBufferDlgs;
- BufferList* pPrev = NULL;
-
- while(pBuffer)
- {
- if(pBuffer->pDlg->m_hWnd == hwndChild) // Here it is
- {
- if(pBuffer == m_pBufferDlgs)
- m_pBufferDlgs = m_pBufferDlgs->pNext;
- if(pPrev)
- pPrev->pNext = pBuffer->pNext;
- delete pBuffer->pDlg;
- delete pBuffer; // Not our job to destroy the actual object
-
- pBuffer = NULL;
- pBuffer = NULL;
- }
- else // On to the next entry
- {
- pPrev = pBuffer;
- pBuffer = pBuffer->pNext;
- }
- }
- }
-
- void MainWnd::Invalidate(bool bErase)
- {
- if(m_hWnd)
- {
- RECT rc;
- GetClientRect(m_hWnd, &rc);
- InvalidateRect(m_hWnd, &rc, bErase ? TRUE : FALSE);
- }
- }
-
- int MainWnd::MessageBox(LPCSTR message, LPCSTR pCaption, UINT uStyle) const
- {
- return ::MessageBox(m_hWnd, message, pCaption, uStyle);
- }
-
- void MainWnd::ResetCascade()
- {
- POINT ptParent;
-
- ptParent.x = ptParent.y = 0;
- ClientToScreen(m_hWnd, &ptParent);
- m_xNextPos = ptParent.x;
- m_yNextPos = ptParent.y;
- }
-
- void MainWnd::CascadeWindow(HWND hWnd)
- {
- RECT rc;
- int nStep;
-
- // Don't move minimized windows
- if(IsIconic(hWnd))
- return;
-
- GetWindowRect(hWnd, &rc);
-
- if(m_xNextPos+(rc.right-rc.left) > GetSystemMetrics(SM_CXSCREEN))
- ResetCascade();
- else if(m_yNextPos+(rc.bottom-rc.top) > GetSystemMetrics(SM_CYSCREEN))
- ResetCascade();
-
- SetWindowPos(hWnd, NULL, m_xNextPos, m_yNextPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
- // Move diagonally by the height of the title bar
- nStep = GetSystemMetrics(SM_CYCAPTION);
- m_xNextPos += nStep;
- m_yNextPos += nStep;
- }
-
- /////////////////////// MainWnd protected member functions /////////////////////////////////////////
-
- bool MainWnd::Register()
- {
- WNDCLASS wc;
-
- if(!GetClassInfo(m_pApp->GetInstance(), GetClassName(), &wc))
- {
- GetWindowClass(wc);
- return ::RegisterClass(&wc) ? true : false;
- }
- return true;
- }
-
- bool MainWnd::OpenFile(LPTSTR lpszPath)
- {
- TCHAR szFileName[MAX_PATH];
- LPTSTR lpszFileName;
- int nFileIndex;
- BufferListEntry pBuffer;
-
- PTRACE("MainWnd::OpenFile(%s)", lpszPath);
-
- if(m_dsCaps.dwFreeHw3DStaticBuffers <= 0)
- {
- MessageBox("No more 3D buffers available for ZoomFX", GetCaption(), MB_ICONSTOP|MB_OK);
- return false;
- }
-
- if(lpszPath != NULL)
- {
- lpszFileName = strrchr(lpszPath, '\\');
- if(lpszFileName == NULL)
- nFileIndex = 0;
- else
- nFileIndex = lpszFileName-lpszPath+sizeof(TCHAR);
- lstrcpy(szFileName, lpszPath);
- }
- else
- {
- if(!OpenFileDialog(szFileName, &nFileIndex))
- return false;
- }
- if(m_pListenerDlg == NULL) // This is the first buffer
- {
- ResetCascade();
-
- m_pListenerDlg = new ListenerDlg;
- if(m_pListenerDlg == NULL)
- {
- MessageBox("Cannot create listener dialog object", GetCaption(), MB_ICONSTOP|MB_OK);
- return false;
- }
- if(!m_pListenerDlg->Create(m_pApp, m_pListener))
- return false;
- }
- pBuffer = new BufferList;
- if(pBuffer == NULL)
- {
- MessageBox("No memory for buffer", GetCaption(), MB_ICONSTOP|MB_OK);
- return false;
- }
- pBuffer->pDlg = new BufferDlg;
- if(pBuffer->pDlg == NULL)
- {
- MessageBox("No memory for dialog", GetCaption(), MB_ICONSTOP|MB_OK);
- return false;
- }
- if(!pBuffer->pDlg->Create(m_pApp, szFileName, m_pDirectSound))
- {
- MessageBox("Unable to create buffer", GetCaption(), MB_ICONSTOP|MB_OK);
- return false;
- }
-
- pBuffer->pNext = m_pBufferDlgs;
- m_pBufferDlgs = pBuffer;
-
- EnableMenuItem(GetMenu(m_hWnd), 1, MF_BYPOSITION);
- DrawMenuBar(m_hWnd);
-
- return true;
- }
-
- bool MainWnd::OpenFileDialog(LPTSTR pszFileName, int* pnFileName)
- {
- bool fReturn;
- OPENFILENAME ofn;
-
- pszFileName[0] = 0;
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = m_hWnd;
- ofn.hInstance = m_pApp->GetInstance();
- ofn.lpstrFilter = "Wave Files\0*.wav\0All Files\0*.*\0\0";
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = pszFileName;
- ofn.nMaxFile = MAX_PATH;
- ofn.lpstrFileTitle = NULL;
- ofn.nMaxFileTitle = 0;
- ofn.lpstrInitialDir = /*grs.szInitialDir*/NULL;
- ofn.lpstrTitle = "File Open";
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_HIDEREADONLY;
- ofn.nFileOffset = 0;
- ofn.nFileExtension = 0;
- ofn.lpstrDefExt = "wav";
- ofn.lCustData = 0;
- ofn.lpfnHook = NULL;
- ofn.lpTemplateName = NULL;
-
- fReturn = GetOpenFileName(&ofn) ? true : false;
-
- return fReturn;
- }
-
- void MainWnd::DestroyWindow(int)
- {
- if(m_pListenerDlg)
- {
- delete m_pListenerDlg;
- m_pListenerDlg = NULL;
- }
- if(m_dwTimer)
- {
- KillTimer(m_hWnd, m_dwTimer);
- m_dwTimer = 0;
- }
-
- if(m_hWnd)
- ::DestroyWindow(m_hWnd);
-
- RELEASE(m_pListener)
- RELEASE(m_pPrimary)
- RELEASE(m_pDirectSound)
-
- if(m_hbmZoomFX)
- {
- DeleteObject(m_hbmZoomFX);
- m_hbmZoomFX = NULL;
- }
- }
-
- void MainWnd::CloseWindow(int ret)
- {
- DestroyWindow(ret);
- }
-
- LRESULT MainWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch(message)
- {
- case WM_COMMAND:
- return EvCommand((UINT)LOWORD (wParam), (HWND)LOWORD (lParam), (UINT) HIWORD(wParam));
-
- case WM_PAINT:
- EvPaint();
- return 0;
-
- case WM_DESTROY:
- EvDestroy();
- break;
-
- case WM_CLOSE:
- EvClose();
- return 0;
-
- case WM_INITMENU:
- return EvInitMenu((HMENU)wParam);
-
- case WM_ERASEBKGND:
- return EvEraseBkgnd((HDC)wParam);
-
- case WM_TIMER:
- return EvTimer(wParam);
- }
- return DefWindowProc(m_hWnd, message, wParam, lParam);
- }
-
- void MainWnd::EvPaint()
- {
- PAINTSTRUCT ps;
-
- BeginPaint(m_hWnd, &ps);
- Paint(ps.hdc, ps.rcPaint, ps.fErase ? true : false);
- EndPaint(m_hWnd, &ps);
- }
-
- void MainWnd::EvClose()
- {
- CloseWindow();
- }
-
- void MainWnd::EvDestroy()
- {
- if(m_pApp)
- if(m_pApp->GetMainWindow() == this)
- PostQuitMessage(0);
-
- m_hWnd = NULL;
- }
-
- LRESULT MainWnd::EvInitMenu(HMENU hMenu)
- {
- if(hMenu == GetMenu(m_hWnd))
- {
- EnableMenuItem(hMenu, CM_FILE_OPEN, MF_BYCOMMAND|(m_dsCaps.dwFreeHw3DStaticBuffers == 0 ? MF_GRAYED : 0));
- DrawMenuBar(m_hWnd);
- }
- return 0;
- }
-
- LRESULT MainWnd::EvEraseBkgnd(HDC hdc)
- {
- HDC hdcMem;
- HGDIOBJ hbmOld;
-
- hdcMem = CreateCompatibleDC(hdc);
- if(hdcMem == NULL)
- return 0;
-
- hbmOld = SelectObject(hdcMem, m_hbmZoomFX);
- BitBlt(hdc, 0, 0, 256, 256, hdcMem, 0, 0, SRCCOPY);
-
- SelectObject(hdcMem, hbmOld);
- DeleteDC(hdcMem);
-
- return 1;
- }
-
- LRESULT MainWnd::EvTimer(WORD)
- {
- DSCAPS dsCaps;
- BufferList* pBuffer;
-
- dsCaps.dwSize = sizeof(dsCaps);
- m_pDirectSound->GetCaps(&dsCaps);
- if(memcmp(&dsCaps, &m_dsCaps, sizeof(m_dsCaps)))
- {
- memcpy(&m_dsCaps, &dsCaps, sizeof(m_dsCaps));
- Invalidate(true);
- }
-
- pBuffer = m_pBufferDlgs;
- while(pBuffer)
- {
- pBuffer->pDlg->Update();
- pBuffer = pBuffer->pNext;
- }
- return 0;
- }
- /////////////////////// MainWnd private member functions ///////////////////////////////////////////
-
- void MainWnd::InstallWindowProc()
- {
- DWORD processId;
-
- if(m_hWnd)
- {
- GetWindowThreadProcessId(m_hWnd, &processId);
- if(processId == GetCurrentProcessId())
- m_DefaultProc = (WNDPROC)SetWindowLong(m_hWnd, GWL_WNDPROC, (long)GetThunk());
- }
- }
-
- LRESULT CALLBACK MainWnd::StdWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- MainWnd* w;
-
- _asm mov w, eax
- return w->WindowProc(message, wParam, lParam);
- }
-