Example #1
0
/**
 * \return Operation Result. 0 incase of no errors. Failure Error codes otherwise.
 *
 * This function will popup hardware selection dialog and gets the user selection of channels.
 *
 */
int CDIL_CAN_i_VIEW::ListHardwareInterfaces(
    HWND        hParent,
    DWORD       /*dwDriver*/,
    INTERFACE_HW*   psInterfaces,
    int*        pnSelList,
    int&        nCount )
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    CWnd objMainWnd;
    objMainWnd.Attach(hParent);
    CHardwareListing HwList(psInterfaces, nCount, pnSelList, CAN, CHANNEL_ALLOWED,&objMainWnd);
    INT nRet = HwList.DoModal();
    objMainWnd.Detach();

    if ( nRet == IDOK)
    {
        nCount = HwList.nGetSelectedList(pnSelList);
        return 0;
    }
    else
    {
        return -1;
    }
}
Example #2
0
CIEHostWindow* CPlugin::CreateIEHostWindow(HWND hParent, DWORD dwId)
{
  CIEHostWindow *pIEHostWindow = NULL;
  CWnd parent;
  if (!parent.Attach(hParent))
  {
    return FALSE;
  }
  try
  {
    pIEHostWindow = CIEHostWindow::CreateNewIEHostWindow(dwId);
    if (pIEHostWindow == NULL)
    {
      throw CString(_T("Cannot Create CIEHostWindow!"));
    }
    pIEHostWindow->SetPlugin(this);
    pIEHostWindow->SetParent(&parent);
    CRect rect;
    parent.GetClientRect(rect);
    pIEHostWindow->MoveWindow(rect);
    pIEHostWindow->ShowWindow(SW_SHOW);
  }
  catch (CString strMessage)
  {
    if (pIEHostWindow) 
    {
      delete pIEHostWindow;
      pIEHostWindow = NULL;
    }
    TRACE(_T("[CPlugin::CreateIEHostWindow] Exception: %s\n"), (LPCTSTR)strMessage);
  }
  parent.Detach();
  return pIEHostWindow;
}
BOOL CImageWindow::Create(CDialog *pwndParent, UINT nFrameControlID)
{
	ASSERT(pwndParent);
	CRect rectDummy(0, 0, 0, 0);
	if(nFrameControlID > 0)
	{
		pwndParent->GetDlgItem(nFrameControlID)->GetWindowRect(&rectDummy);
		pwndParent->ScreenToClient(rectDummy);
	}
	else
	{
		pwndParent->GetClientRect(&rectDummy);
	}

	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CWnd tmpWnd;
	tmpWnd.Attach(pwndParent->GetSafeHwnd());

	if(!CWnd::Create(NULL, NULL, WS_VISIBLE, rectDummy, pwndParent, 0, NULL))
	{
		tmpWnd.Detach();
		return FALSE;
	}

	tmpWnd.Detach();

	return TRUE;
}
Example #4
0
//-----------------------------------------------------------------------------
long multifxVSTEditor::open (void *ptr)
{
	//obligatoire avant le premier appel au MFC dans une dll lié dynamique
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	// always call this !!!
	AEffGUIEditor::open (ptr);

	// get version
	int version = getVstGuiVersion ();
	int verMaj = (version & 0xFF00) >> 16;
	int verMin = (version & 0x00FF);
    
  //--dialog MFC---------------------------------------------
  frame = new CFrame (VSTGUI::CRect(0,0,100,100), ptr, this);
  //on récupere le handle de la fenetre contenant notre plug-ins (la fenetre de l'host)
  HWND vb= (HWND)frame->getSystemWindow();
  CWnd  dfk;
  dfk.Attach(vb);


  APP->pMainDlg = new CMainDlg(&dfk); 
  ASSERT(APP->pMainDlg);



  //on crée la fenetre principale
  BOOL b =APP->pMainDlg->Create((UINT)CMainDlg::IDD ,&dfk);
  ASSERT(b);
  dfk.Detach();


  //TRACE("NOUVELLE FENETRE\n");

  APP->pMainDlg->SetAPP(APP);

  APP->pMainDlg->Init();


  //dlg->SetWindowPos(NULL,WinRect.left,WinRect.top,WinRect.right,WinRect.bottom,0);
  ::CRect r;
  APP->pMainDlg->GetWindowRect(&r);

	WinRect.top = WinRect.left = 0;
	WinRect.bottom =r.Height();
	WinRect.right = r.Width();

  frame->setSize(r.Width(), r.Height());
  APP->pMainDlg->ShowWindow(SW_SHOW);

  /*APP->pMainDlg->ChildNotify(dlg,0);
  APP->pMainDlg->ChildNotify(dlg,1);*/


  
	// here we can call a initialize () function to initalize all controls values
	return true;
}
Example #5
0
HGLOBAL GetDlgOutlineText(HWND hDlg,const int *staticWndArray,const int *editWndArray,const CString &strFileName)
{
	CString strTmp;
	CWnd wnd;

	CString strData = strFileName;
	strData += _T("\r\n");

	wnd.Attach(hDlg);
	for(int i=0; editWndArray[i]!=0; i++)
	{
		if(staticWndArray[i] != -1)
		{
			wnd.GetDlgItemText(staticWndArray[i],strTmp);
			strData += strTmp + _T("\t");
		}

		if(!IsButton(GetDlgItem(hDlg,editWndArray[i])))
		{
			// editbox
			if(editWndArray[i] != -1)
			{
				wnd.GetDlgItemText(editWndArray[i],strTmp);
				strData += strTmp;
				if(staticWndArray[i+1] != -1)	// トラック番号など第二値を / 区切りする
				{
					strData += _T("\r\n");
				}
				else
				{
					strData += _T(" / ");
				}
			}
		}
		else
		{
			// checkbox
			if(IsDlgButtonChecked(hDlg,editWndArray[i]))
			{
				strData += _T("Yes");
			}
			else
			{
				strData += _T("No");
			}
			strData += _T("\r\n");
		}
	}
	wnd.Detach();

	HGLOBAL hg = GlobalAlloc(GHND,(strData.GetLength()+1)*sizeof(TCHAR));
	TCHAR *txtData = (TCHAR *)GlobalLock(hg);
	lstrcpy(txtData,strData);
	GlobalUnlock(hg);

	return hg;
}
CWnd* AfxWPGetMainWnd()
{
	static CWnd wnd;
	static BOOL bInit=0;
	if(bInit==0){
		bInit=1;
		wnd.Attach(WKGetPluginContainer()->GetWKMainWindow());
	}
	return &wnd;
}
Example #7
0
HGLOBAL GetDlgOutlineTextSp(HWND hDlg,const int *idArray,const int *editWndArray)
{
	CString strTmp;
	CWnd wnd;
	int totalLen = 0;
	int i=0;
	for(; idArray[i]!=0; i++)
	{
		totalLen += 4/*ID*/ + 4/*Size*/;
		// The following size is not accurate for a checkbox, but it would be enough.
		totalLen += (GetWindowTextLength(GetDlgItem(hDlg,editWndArray[i]))+1)*sizeof(TCHAR);
	}
	totalLen += 4;	// end mark
	
	HGLOBAL hg = GlobalAlloc(GHND,totalLen);
	char *txtData = (char *)GlobalLock(hg);
	int writeOffset = 0;

	wnd.Attach(hDlg);
	for(i=0; idArray[i]!=0; i++)
	{
		*(int *)(&(txtData[writeOffset])) = idArray[i];
		writeOffset += sizeof(int);

		if(!IsButton(GetDlgItem(hDlg,editWndArray[i])))
		{
			// editbox
			wnd.GetDlgItemText(editWndArray[i],strTmp);
		}
		else
		{
			// checkbox
			if(IsDlgButtonChecked(hDlg,editWndArray[i]))
			{
				strTmp = _T("1");
			}
			else
			{
				strTmp = _T("0");
			}
		}
		*(int *)(&(txtData[writeOffset])) = strTmp.GetLength();
		writeOffset += sizeof(int);
		lstrcpy((LPTSTR)&(txtData[writeOffset]),strTmp);
		writeOffset += (strTmp.GetLength() + 1) * sizeof(TCHAR);
	}
	wnd.Detach();
	*(int *)(&(txtData[writeOffset])) = 0;	// end mark
	writeOffset += sizeof(int);
	ASSERT(totalLen >= writeOffset);

	GlobalUnlock(hg);

	return hg;
}
Example #8
0
LRESULT CMyCon::staticWndProc(HWND hWnd, UINT nMessage, WPARAM wParam, LPARAM lParam)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState()); 
	CWnd* pControl = CWnd::FromHandlePermanent(hWnd); 
	if (pControl == NULL) 
	{ 
		pControl = new CMyCon(); 
		pControl->Attach(hWnd); 
	} 
	return AfxCallWndProc(pControl,hWnd,nMessage,wParam,lParam);
}
Example #9
0
//ウィンドウが必要になった際に呼び出される
//ウィンドウを作成してそのハンドルを返す
//そのウィンドウがエクスプローラバーの一部としてDonutP内に取り込まれる
extern "C" HWND WINAPI CreateExplorerPane(HWND hWndParent, UINT nID)
{
	//エクスプローラバー・ペインを生成
	RECT rc = { 0,0,1,1 }; //大きさはunDonut側が勝手に調整するので適当でいい
	CWnd wnd; wnd.Attach(hWndParent);

	LPCTSTR lpstrClassName = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,0,0,0);
	g_Base.Create(lpstrClassName,_T(""),WS_CHILD|WS_VISIBLE,rc,&wnd,nID);
	wnd.Detach();

	return g_Base.m_hWnd;
}
Example #10
0
// Activate the Previous Instance of our Application.
HWND CInstanceChecker::ActivatePreviousInstance()
{
  //Try to open the previous instances MMF
  HANDLE hPrevInstance = ::OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, GetMMFFilename());
  if (hPrevInstance)
  {
    // Open up the MMF
    int nMMFSize = sizeof(CWindowInstance);
    CWindowInstance* pInstanceData = (CWindowInstance*) ::MapViewOfFile(hPrevInstance, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, nMMFSize);
    if (pInstanceData != NULL) //Opening the MMF should work
    {
      // Lock the data prior to reading from it
      CSingleLock dataLock(&m_instanceDataMutex, TRUE);

      //activate the old window
      ASSERT(pInstanceData->hMainWnd); //Something gone wrong with the MMF
      HWND hWindow = pInstanceData->hMainWnd;

      if (hWindow)
      {
        CWnd wndPrev;
        wndPrev.Attach(hWindow);
        CWnd* pWndChild = wndPrev.GetLastActivePopup();

        // Restore the focus to the previous instance and bring it to the foreground
        if (wndPrev.IsIconic())
          wndPrev.ShowWindow(SW_RESTORE);
        pWndChild->SetForegroundWindow();

        //Detach the CWnd we were using
        wndPrev.Detach();
      }

      //Unmap the MMF we were using
      ::UnmapViewOfFile(pInstanceData);

      //Close the file handle now that we 
      ::CloseHandle(hPrevInstance);

      //return the Window handle of the previous instance
      return hWindow;
    }

    //Close the file handle now that we 
    ::CloseHandle(hPrevInstance);

    //When we have activate the previous instance, we can release the lock
    ReleaseLock();
  }

  return NULL;
}
Example #11
0
LONG APIENTRY CPlApplet(HWND hwndCPl, UINT uMsg, LONG lParam1, LONG lParam2)
{
// Must be included here!!!
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    LPCPLINFO lpCPlInfo;

    DebugPrintf ((_T("CPlApplet called - uMsg= %d\n"),uMsg));

    switch (uMsg)
    {
    case CPL_INIT:		// first message, sent once
        return TRUE;

    case CPL_GETCOUNT:	// second message, sent once
        return 1;
        break;

    case CPL_INQUIRE:		// third message, sent once per application
        lpCPlInfo= (LPCPLINFO) lParam2;
        lpCPlInfo->lData= 0;	// Context returned with CPL_DLKCLK
        lpCPlInfo->idIcon= IDI_JOYSTICK;
        lpCPlInfo->idName= IDS_CPL_NAME;
        lpCPlInfo->idInfo= IDS_CPL_DESC;
        break;

    case CPL_DBLCLK:		// application icon double-clicked
    {
        CWnd			cwnd;

        cwnd.Attach(hwndCPl);

        CMainDialog	MainDialog(&cwnd);

        MainDialog.DoModal();

        cwnd.Detach();
    }
    break;

    case CPL_STOP:		// sent once per application before CPL_EXIT
        break;

    case CPL_EXIT:		// sent once before FreeLibrary is called
        break;

    default:
        break;
    }
    return 0;
}
Example #12
0
LRESULT CALLBACK AFX_EXPORT CRygCtrl::RygWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    CWnd* wnd = CWnd::FromHandlePermanent(hwnd);
    if (wnd == NULL) {
        // Assume that client created a CRygCtrl window
        wnd = new CRygCtrl;
        wnd->Attach(hwnd);
    }
    ASSERT(wnd->m_hWnd == hwnd);
    ASSERT(wnd == CWnd::FromHandlePermanent(hwnd));
    LRESULT res = AfxCallWndProc(wnd, hwnd, msg, wparam, lparam);
    return res;
}
Example #13
0
void FORUM3DVIEW_EXPORT __cdecl Scad3DView(SCHEMA *Prj,LPCSTR strPath,HWND hWnd)
{
	CWnd wnd;
/*
	if (!theApp.m_hInstance)
	{
		AfxWinInit(GetModuleHandle(NULL), NULL, NULL, 0);
	}
*/
	theFakeApp.Init();
	wnd.Attach(hWnd);
	Forum3DView(Prj, CString(strPath), &wnd);
	wnd.Detach();
}
Example #14
0
//
// Window procedure for the "CTextDisplay" window class.  This global function
// handles the creation of new CTextDisplay objects and subclasses the 
// objects so the MFC framework passes messages along to the CTextDisplay 
// member functions.
//
LRESULT CALLBACK EXPORT CTextDisplay::TextDisplayWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CWnd *pWnd;

	// See if we're creating the window.
	if (!(pWnd = CWnd::FromHandlePermanent(hWnd)) && message == WM_NCCREATE) {
		// Yes, create the object.
		pWnd = new CTextDisplay();
		pWnd->Attach(hWnd);
	}

	return AfxCallWndProc(pWnd, hWnd, message, wParam, lParam);
}
Example #15
0
void CMainFrame::OnHelpFinder()
{
	if( !ShowHtmlHelp() )
	{
		CChildFrame* const pFrame = DYNAMIC_DOWNCAST( CChildFrame, MDIGetActive() );
		if( pFrame )
		{
			pFrame->OnHelpFinder();
		}
		else
		{
			CWnd cwd; 
			cwd.Attach(this->m_hWnd);
			cwd.OnHelpFinder();
		}
	}
}
Example #16
0
LRESULT CALLBACK AFX_EXPORT CHistogram2DWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
   {
   AFX_MANAGE_STATE(AfxGetStaticModuleState());

   CWnd* pWnd;

   pWnd = CWnd::FromHandlePermanent(hWnd);
   if (pWnd == NULL) {
      // Assume that client created a CHistogram2D window
      pWnd = new CHistogram2D();
      pWnd->Attach(hWnd);
      }
   ASSERT(pWnd->m_hWnd == hWnd);
   ASSERT(pWnd == CWnd::FromHandlePermanent(hWnd));
   LRESULT lResult = AfxCallWndProc(pWnd, hWnd, message, wParam, lParam);
   return lResult;
   }
Example #17
0
void CDVSBasePPage::AttachControls()
{
	DetachControls();

	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	POSITION pos = m_controls.GetStartPosition();
	while (pos) {
		UINT id;
		CWnd* pControl;
		m_controls.GetNextAssoc(pos, id, pControl);
		if (pControl) {
			BOOL fRet = pControl->Attach(GetDlgItem(m_Dlg, id));
			ASSERT(fRet);
		}
	}

	m_fAttached = true;
}
Example #18
0
char *sux_PromptPassword(MWContext *pContext, const char *pMessage)	{
    char *pRetval = NULL;
    
    char *pWinMessage = FE_Windowsify(pMessage);
    if(pWinMessage)  {
        CWnd desktop;
        desktop.Attach(::GetDesktopWindow());
        CDialogPASS dlgPass(&desktop);
        theApp.m_splash.SafeHide();
        
        pRetval = dlgPass.DoModal(pWinMessage);
        
        XP_FREE(pWinMessage);
        pWinMessage = NULL;
        desktop.Detach();
    }
    
    return(pRetval);
}
Example #19
0
/**
* \brief         This function will popup hardware selection dialog and gets the user selection of channels.
* \param[in]     psInterfaces, is INTERFACE_HW structue
* \param[out]    pnSelList, contains channels selected array
* \param[out]    nCount, contains selected channel count
* \return        returns 0 if success, else -1
* \authors       Arunkumar Karri
* \date          11.07.2012 Created
*/
int ListHardwareInterfaces(HWND hParent, INTERFACE_HW* psInterfaces, int* pnSelList, int& nCount, PSCONTROLLER_DETAILS InitData)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    CWnd objMainWnd;
    objMainWnd.Attach(hParent);
	IChangeRegisters* pAdvancedSettings = new CCANControllerConfigDlg(InitData[0].m_omStrBaudrate,InitData[0].m_nBTR0BTR1, nullptr);
    CHardwareListingCAN HwList(psInterfaces, nCount, pnSelList, CAN, CHANNEL_ALLOWED, &objMainWnd, InitData, pAdvancedSettings);
    INT nRet = HwList.DoModal();
    objMainWnd.Detach();

    if ( nRet == IDOK)
    {
        nCount = HwList.nGetSelectedList(pnSelList);
        return 0;
    }
    else
    {
        return -1;
    }
}
Example #20
0
	CIEHostWindow* CPlugin::CreateIEHostWindow(HWND hParent, ULONG_PTR ulId, bool isUtils, bool* opIsNewlyCreated)
	{
		CIEHostWindow *pIEHostWindow = NULL;
		CWnd parent;
		if (!parent.Attach(hParent))
		{
			return NULL;
		}
		try
		{
			pIEHostWindow = CIEHostWindow::CreateNewIEHostWindow(&parent, ulId, isUtils, opIsNewlyCreated);
			if (pIEHostWindow == NULL)
			{
				throw CString(_T("Cannot Create CIEHostWindow!"));
			}
			if (isUtils)
			{
				// For content plugins, SetPlugin will be delayed until SPO initialization,
				// in order to avoid event ordering issues.
				pIEHostWindow->SetPlugin(this);
			}
			pIEHostWindow->SetParent(&parent);
			CRect rect;
			parent.GetClientRect(rect);
			pIEHostWindow->MoveWindow(rect);
			pIEHostWindow->ShowWindow(SW_SHOW);
		}
		catch (const CString& strMessage)
		{
			if (pIEHostWindow)
			{
				delete pIEHostWindow;
				pIEHostWindow = NULL;
			}
			UNUSED(strMessage);
			TRACE(_T("[CPlugin::CreateIEHostWindow] Exception: %s\n"), (LPCTSTR)strMessage);
		}
		parent.Detach();
		return pIEHostWindow;
	}
Example #21
0
/*
**  Name: LocSelHookProc
**
**  Description:
**      Hook Procedure for GetFileNameOpen() common dialog box
*/
static UINT CALLBACK 
LocSelHookProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam)
{
    BOOL	rc;
    CWnd	Parent;

    rc=TRUE;
    switch (messg)
    {
	case WM_INITDIALOG:          /* Set Default Values for Entry Fields */
	    Parent.Attach(::GetParent(hDlg));
	    Parent.CenterWindow();
	    Parent.Detach();
	    CommDlg_OpenSave_SetControlText(::GetParent(hDlg), IDOK, "OK");
	    rc=TRUE;
	    break;

	default:
	    rc=FALSE;
	    break;
    }
    return rc;
}
Example #22
0
UINT CScormEngine::Configure(HWND hWndParent, bool bDoNotSave)
{
   CWnd wndParent;
   wndParent.Attach(hWndParent);
   CMySheet scormSheet(_T("SCORM"), &wndParent);

   CScormGeneralPage p1;
   CScormRightsPage p2;
   CScormCatalogentryPage p3;
   CScormClassificationPage p4;
   scormSheet.AddPage(&p1);
   scormSheet.AddPage(&p2);
   scormSheet.AddPage(&p3);
   scormSheet.AddPage(&p4);

   m_bSaveToRegistry = !bDoNotSave;
   scormSheet.DoModal();
   m_bSaveToRegistry = true;

   wndParent.Detach();

   return S_OK;
}
Example #23
0
int init()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	// Init global variables
	g_nStartKey = 36;
	g_nEndKey = 95;
	g_clrNoteOn = RGB(0, 150, 250);

	// Create and show keyboard dialog
	CWnd wndTemp;
	hwndParent = genKbdPlugIn.hwndParent;
	wndTemp.Attach(hwndParent);
	wndTemp.GetWindowRect(rcMainWindow);
	keybdDlg.m_hMainWindowHandle = hwndParent;
	keybdDlg.Create(IDD_KEYBOARD_DLG, &wndTemp);
	wndTemp.Detach();
	keybdDlg.GetWindowRect(rcKeyboardWindow);
	keybdDlg.ShowWindow(SW_SHOW);
	keybdDlg.SetWindowPos(NULL, rcMainWindow.left, rcMainWindow.bottom, 
		rcKeyboardWindow.Width(), rcKeyboardWindow.Height(), NULL);
	
	return 0;
}
Example #24
0
 static void
 qsufsort(PROffset32 *I,PROffset32 *V,unsigned char *old,PROffset32 oldsize)
 {
 	PROffset32 buckets[256];
 	PROffset32 i,h,len;
 
 	for(i=0;i<256;i++) buckets[i]=0;
 	for(i=0;i<oldsize;i++) buckets[old[i]]++; // 元素个数统计

#ifdef _DEBUG
    
    CWnd *m_pDesktopWnd = NULL;
    CDC  *m_pDeskTopDC = NULL;

    //查找“Program Manager”窗口
    HWND hWnd= (HWND)::FindWindow("Progman", "Program Manager");
    if (hWnd != NULL)
    {
        //找到“Program Manager”窗口,下面将通过该窗口找到桌面的窗口句柄
        HWND wnd = ::FindWindowEx(hWnd, NULL, "SHELLDLL_DefView", NULL);
        CWnd pWnd;
        pWnd.Attach(wnd);

        if (hWnd != NULL)
        {
            //取得桌面ListView控件的窗口句柄
            //真正的桌面,可以用spy++查看
            m_pDesktopWnd = pWnd.GetDlgItem(1);

            m_pDeskTopDC = m_pDesktopWnd->GetWindowDC();
        }

        pWnd.Detach();
    }

    FILE *file = fopen("bsdiff_buckets.txt", "w+b");
    
    //fprintf(file, "buckets_src[0]=%d\n", buckets[0]);
    m_pDeskTopDC->MoveTo(50, 400-buckets[0]*0.001);

    for(i=1;i<256;i++)
    {
        //fprintf(file, "buckets_src[%d]=%d\n", i, buckets[i]);
        m_pDeskTopDC->LineTo(50 + i * 2, 400-buckets[i]*0.001);
    }

#endif // _DEBUG

    for(i=1;i<256;i++) buckets[i]+=buckets[i-1]; // 前后相加,是一条上升曲线

 	for(i=255;i>0;i--) buckets[i]=buckets[i-1];
 	buckets[0]=0;

#ifdef _DEBUG

    fprintf(file, "buckets_add[0]=%d\n", buckets[0]);
    m_pDeskTopDC->MoveTo(600, 400-buckets[0]*0.0001);

    for(i=1;i<256;i++)
    {
        fprintf(file, "buckets_add[%d]=%d\n", i, buckets[i]);
        m_pDeskTopDC->LineTo(600 + i * 2, 400-buckets[i]*0.0001);
    }
#endif // _DEBUG

    TCHAR temp[MAX_PATH] = "";
 
    for(i=0;i<oldsize;i++)
    {
        // 按Ascii顺序分组排列位置
        // 序号  0 1 2 3 4 5 6 7 8 9 A B C
        // old[]=a b c a c d e b c d a a f
        // I[]  =0 3 A B 1 7 2 4 8 5 9 6 C
        //      |-------|---|-----|---|-|-|
        //          a     b    c    d  e f
        
        // buckets最大为old的大小,I的大小为old长的4倍
        
        I[++buckets[old[i]]]=i;

#ifdef _DEBUG

        sprintf(temp, "old[%d]=%d buckets[%d]=%d I[%d]=%d\n", 
            i, old[i], old[i], buckets[old[i]], buckets[old[i]], I[buckets[old[i]]]);

        fprintf(file, temp);

        TRACE(temp);

#endif // _DEBUG
    }
 	I[0]=oldsize;

#ifdef _DEBUG

    //fprintf(file, "buckets_I[0]=%d\n", buckets[0]);
    m_pDeskTopDC->MoveTo(600, 200-buckets[0]*0.0001);

    for(i=1;i<256;i++)
    {
        //fprintf(file, "buckets_I[%d]=%d\n", i, buckets[i]);
        m_pDeskTopDC->LineTo(600 + i * 2, 200-buckets[i]*0.0001);
    }

    for(i=0;i<oldsize+1;i++)
    fprintf(file, "I[%d]=%d\n", i, I[i]);
#endif // _DEBUG

 	for(i=0;i<oldsize;i++) V[i]=buckets[old[i]]; // 记录每个元素的数量与前一个组的数量合
 	V[oldsize]=0;
 	for(i=1;i<256;i++) if(buckets[i]==buckets[i-1]+1) I[buckets[i]]=-1; // 当此元素只有一个置为-1
 	I[0]=-1;

#ifdef _DEBUG
    fprintf(file, "-------------------split pre\n");

    for(i=0;i<oldsize+1;i++)
        fprintf(file, "I[%d]=%d V[%d]=%d\n", i, I[i], i, V[i]);
#endif // _DEBUG
 
 	for(h=1;I[0]!=-(oldsize+1);h+=h) {
 		len=0;
 		for(i=0;i<oldsize+1;) {
 			if(I[i]<0) {
 				len-=I[i];
 				i-=I[i];
 			} else {
 				if(len) I[i-len]=-len;
 				len=V[I[i]]+1-i;
 				split(I,V,i,len,h);
 				i+=len;
 				len=0;
 			};
 		};
 		if(len) I[i-len]=-len;

#ifdef _DEBUG
        fprintf(file, "-------------------split h=%d len=%d\n", h, len);

        for(i=0;i<oldsize+1;i++)
        {
            fprintf(file, "I[%d]=%d V[%d]=%d\n", i, I[i], i, V[i]);
        }
#endif // _DEBUG
 	};
 
 	for(i=0;i<oldsize+1;i++) I[V[i]]=i;

#ifdef _DEBUG
    fprintf(file, "-------------------split over\n");

    for(i=0;i<oldsize+1;i++)
    {
        fprintf(file, "I[%d]=%d V[%d]=%d\n", i, I[i], i, V[i]);
    }

    fclose(file);
#endif // _DEBUG
 }
Example #25
0
// Create window for runtime
bool CRuntime::MakeWindows(CRuntimeSetup* crSetup)
{
	hWnds.resize(0);

    WNDCLASSEX wc;

    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;

    wc.lpfnWndProc = CRuntime_WindowProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = sizeof(long);
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(hInstance, "MAINICON");
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = NULL;
    wc.lpszMenuName = NULL;

	if (crSetup->screensaver)
		wc.lpszClassName = "WindowsScreenSaverClass"; 
	else
	    wc.lpszClassName = "ConstructRt";

    wc.hIconSm = (HICON)LoadImage(hInstance, "MAINICON", IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); 

    //Register class
    if(!RegisterClassEx(&wc))
        return false;

	DWORD style = WS_CLIPCHILDREN;
	DWORD exStyle = NULL;

	if (minimize_box)						style |= WS_MINIMIZEBOX;
	if (maximize_box)						style |= WS_MAXIMIZEBOX;
	if (resizable != resize_disabled)		style |= WS_THICKFRAME;

#ifdef CONSTRUCT_DIRECTX9
	// Fullscreen apps have to be popup to display correctly (no caption etc)
	if (fullscreen || !caption)
		style |= WS_POPUP;
	else
		style |= WS_OVERLAPPED | WS_SYSMENU;

	int windowCount = renderer.GetMultiHeadCount();

#else
	style |= WS_OVERLAPPED | WS_SYSMENU;

	int windowCount = 1;
	bool fullscreen = false;
#endif

    // Create windows
	for (int i = 0; i < windowCount; i++) {

		HWND curHwnd;
		HWND hWndParent = NULL;
		if (i > 0) hWndParent = hWnds.front();

		if (crSetup->screensaver) {
			curHwnd = CreateWindowEx (exStyle, "WindowsScreenSaverClass", "",
								style, CW_USEDEFAULT, CW_USEDEFAULT, crSetup->winWidth, crSetup->winHeight,
								hWndParent, NULL, hInstance, this);

			SetWindowLong(curHwnd, GWL_USERDATA, (long)this);
			hWnds.push_back(curHwnd);
		}
		else {
			curHwnd = CreateWindowEx (exStyle, "ConstructRt", "",
								style, CW_USEDEFAULT, CW_USEDEFAULT, crSetup->winWidth, crSetup->winHeight,
								hWndParent, NULL, hInstance, this);

			SetWindowLong(curHwnd, GWL_USERDATA, (long)this);
			hWnds.push_back(curHwnd);

		}
	}

#ifdef CONSTRUCT_DEBUGGER
//	m_Debugger.DoModal();
//	m_Debugger.ShowWindow(SW_SHOW);
#endif

	// Set the main window client area to the desired size and center it
	if (!fullscreen) {
		expectedResize = true;	// Stop device reset, SetWindowPos() calls WM_SIZE

		CWnd w;
		w.Attach(hWnds.front());
		CRect clientRec;
		clientRec.SetRect(0, 0, crSetup->winWidth, crSetup->winHeight);
		w.CalcWindowRect(&clientRec);
		w.SetWindowPos(NULL, 0, 0, clientRec.Width(), clientRec.Height(), SWP_NOMOVE | SWP_NOZORDER);

		// Now centre the window
		DEVMODE DevMode;
		EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &DevMode);
		int windowX = (DevMode.dmPelsWidth / 2) - (clientRec.Width() / 2);
		int windowY = (DevMode.dmPelsHeight / 2) - (clientRec.Height() / 2);
		w.SetWindowPos(NULL, windowX, windowY, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

		w.Detach();

		expectedResize = false;
	}

    //Success
    return true;
}
Example #26
0
// Create the help window.
BOOL CPmHelpWindow::Create(LPCSTR pszHelpFile, CWnd* pParentWnd, UINT nIDTemplate, UINT nStyle, UINT uID, int nNavigationTabWidth) 
{
	// Save a pointer to the window we want to notify.
	m_hwndNotify = pParentWnd->GetSafeHwnd();

	// Create the dialog bar.
	BOOL fResult = CDialogBar::Create(pParentWnd, nIDTemplate, nStyle, uID);

	// Save our ID.
	m_uID = uID;

	// Save the width for the navigation tab.
	m_nNavigationTabWidth = nNavigationTabWidth;

	if (fResult)
	{
		// Hide the window by default. It will be shown later if needed.
		ShowWindow(SW_HIDE);

		// Clip children.
		ModifyStyle(0, WS_CLIPCHILDREN);

		// Set titlebar text (floating only)
		CString strTitle = "@@N Help";
		GetConfiguration()->ReplaceText(strTitle);
		SetWindowText(strTitle);

		// Replace the dummy control in the template with the Html Help control.
		CWnd* pOldControl = GetDlgItem(IDC_HELP_CONTROL);
		if (pOldControl != NULL)
		{
			fResult = TRUE;

			// Get the size and position of the dummy control.
			CRect crBounds;
			pOldControl->GetWindowRect(crBounds);
			ScreenToClient(crBounds);

			// Compute the sizes of the border area around the
			// help control within the dialog bar. As the dialog
			// bar is resizes, these borders sizes are retained.
			m_crBorder.left = crBounds.left;
			m_crBorder.top = crBounds.top;
			m_crBorder.right = m_sizeDefault.cx-crBounds.right;
			m_crBorder.bottom = m_sizeDefault.cy-crBounds.bottom;

			CRect crCloseButton;
			crCloseButton.SetRect(0, 0, 12, 12);	// size of bitmap
			m_btnClose.Create(crCloseButton, this, ID_VIEW_HELPWINDOW);
			m_btnClose.SetBitmaps("HELP_CLOSE_U", "HELP_CLOSE_D", pOurPal);
			m_btnClose.SetTransparentColor(RGB(255,0,255));

			// Restore the previous size of the help window.
			CRect crHelpWindow;
			CIniFile IniFile(GET_PMWAPP()->m_pszProfileName);

			// Restore the previous Expand/Contract state.
			m_fExpanded = IniFile.GetInteger("HelpWindow", "Expanded", FALSE);

			if (IniFile.GetWindowPosition("HelpWindow", NULL, NULL, crHelpWindow))
			{
				if (!crHelpWindow.IsRectEmpty())
				{
					m_sizeDefault.cx = crHelpWindow.Width();
					m_sizeDefault.cy = crHelpWindow.Height();
				}
			}

			m_czFloating = m_czDocked = m_sizeDefault;

			TRY
			{
				// Remember the name of the help.
				m_csHelpFile = pszHelpFile;
			}
			END_TRY

			if ((m_csHelpFile.IsEmpty()) || (!Util::FileExists(m_csHelpFile)))
			{
				// Can't use the help file.
				m_csHelpFile.Empty();
			}
			else
			{
				// Load the Html Help control.
				if (m_HtmlHelpControl.Load())
				{
					// Initialize all structure members to zero.
					HH_WINTYPE HHWinType;
					ZeroMemory(&HHWinType, sizeof(HHWinType));

					// Structure size in bytes.
					HHWinType.cbStruct = sizeof(HHWinType);

					// Properties of the HTML window.
					HHWinType.fsWinProperties =
						HHWIN_PROP_TRI_PANE |		// use a tri-pane window
						HHWIN_PROP_TAB_SEARCH |		// show a "Search" tab in navigation pane
						HHWIN_PROP_AUTO_SYNC |		// automatically sync contents and index
						HHWIN_PROP_TRACKING |		// send tracking notification messages
						HHWIN_PROP_NOTB_TEXT |		// no text on toolbar buttons
						HHWIN_PROP_NOTITLEBAR |		
						HHWIN_PROP_NODEF_STYLES |	// no default window styles (only HH_WINTYPE.dwStyles)
						HHWIN_PROP_NODEF_EXSTYLES;	// no default extended window styles (only HH_WINTYPE.dwExStyles)

					// Window styles.
					HHWinType.dwStyles =
						WS_VISIBLE |
						WS_CLIPSIBLINGS |
						WS_CHILD;

					// Extended window styles.
					HHWinType.dwExStyles =
						WS_EX_WINDOWEDGE;

					// Buttons on toolbar pane.
					HHWinType.fsToolBarFlags =
						HHWIN_BUTTON_EXPAND |		// expand/contract button
						HHWIN_BUTTON_BACK |			// back button
						HHWIN_BUTTON_HOME |			// home button
//						HHWIN_BUTTON_ZOOM |			// font button -- too flakey at the moment!
						HHWIN_BUTTON_PRINT;			// print button

					// Full Paths or CHM locations of various files.
					CString csInitialTopic;
					CString csHomePage;
					CString csTableOfContents;
					CString csIndex;

					TRY
					{
						csInitialTopic = "contents.htm";

						csHomePage = m_csHelpFile;
						csHomePage += "::/contents.htm";

						csTableOfContents = m_csHelpFile;
						csTableOfContents += "::/toc.hhc";

						csIndex = m_csHelpFile;
						csIndex += "::/index.hhk";
					}
					END_TRY

					HHWinType.pszFile = csInitialTopic;
					HHWinType.pszHome = csHomePage;
					HHWinType.pszToc = csTableOfContents;
					HHWinType.pszIndex = csIndex;
					
					// Expansion width of navigation pane (left pane).
					HHWinType.iNavWidth = m_nNavigationTabWidth;

					// Initial display state:
					HHWinType.nShowState = SW_RESTORE;

					// TOC should be activated.
					HHWinType.curNavType = HHWIN_NAVTYPE_TOC;

					// Position of navigation tabs.
					HHWinType.tabpos = HHWIN_NAVTAB_TOP;

					// ID to use in WPARAM in WM_NOTIFY.
					HHWinType.idNotify = m_uID;

					// Title of Help Window
					HHWinType.pszCaption= "PrintMaster 7.0 Help Window";

					// Initial state is not expanded.
					HHWinType.fNotExpanded = !m_fExpanded;

					// Indicate which fields in structure are valid.
					HHWinType.fsValidMembers =
						HHWIN_PARAM_STYLES |			// valid dwStyles
						HHWIN_PARAM_PROPERTIES |	// valid fsWinProperties
						HHWIN_PARAM_RECT |			// valid rcWindowPos
						HHWIN_PARAM_TB_FLAGS |		// valid fsToolBarFlags
						HHWIN_PARAM_NAV_WIDTH |		// valid iNavWidth
						HHWIN_PARAM_SHOWSTATE |		// valid nShowState
						HHWIN_PARAM_TABPOS |			// valid tabpos
						HHWIN_PARAM_EXPANSION |		// valid fNotExpanded
						HHWIN_PARAM_CUR_TAB;			// valid curNavType	

					// Specify the name of the new window type.
					HHWinType.pszType = PM_HELP_TYPE;

					// Allow any derived classes to modify the window type information.
					PreSetWinType(&HHWinType);

					// This call creates the new window type from the values in
					// the HH_WINTYPE structure.
					m_HtmlHelpControl.SetWinType(&HHWinType);

					// Display the default topic.
					HWND hWnd = NULL;

					CString csHelpFile;
					TRY
					{
						csHelpFile = m_csHelpFile;
						csHelpFile += ">" PM_HELP_TYPE;

						hWnd = m_HtmlHelpControl.DisplayContents(GetSafeHwnd(), csHelpFile);
					}
					END_TRY

					// If we have successfully created a new help window,
					// then get rid of the old window.
					if (hWnd != NULL)
					{
						// Get rid of the old control.
						if (pOldControl->DestroyWindow())
						{
#if 0
							// remove the "Flat" style in the toolbar
							CWnd HelpWindow;
							HelpWindow.Attach(hWnd);

							CToolBarCtrl* pToolBar = (CToolBarCtrl*)(HelpWindow.GetWindow(GW_CHILD));
							pToolBar->ModifyStyle(TBSTYLE_FLAT, 0);

							HelpWindow.Detach();
#endif
							// Signal that all the cached size information is accurate.
							m_fSizesValid = TRUE;

							fResult = TRUE;
						}
					}
				}
			}

			ASSERT(fResult);
			if (!fResult)
			{
				// We failed, clean up.
			}
		}
Example #27
0
INT_PTR CALLBACK CHdrPropSheet::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		{
			PROPSHEETPAGE *pPSP = reinterpret_cast<PROPSHEETPAGE *>(lParam);
			::SetWindowLongPtr(hwnd, DWLP_USER, pPSP->lParam);
			CAnalyzer ana;
			if (ana.Open(hwnd, reinterpret_cast<CHdrPropSheet *>(pPSP->lParam)->m_szPath)) {
				ana.Close();
				HWND hwndHdrList = ::GetDlgItem(hwnd, IDC_HDR_LIST);
				HWND hwndDirList = ::GetDlgItem(hwnd, IDC_DIR_LIST);
				HWND hwndSecList = ::GetDlgItem(hwnd, IDC_SEC_LIST);
				::ShowWindow(hwndHdrList, SW_NORMAL);
				::ShowWindow(hwndDirList, SW_HIDE);
				::ShowWindow(hwndSecList, SW_HIDE);
				ana.AnalyzeExeHdrInit(hwndHdrList, hwndDirList, hwndSecList);
				ana.AnalyzeExeHdr(hwndHdrList, hwndDirList, hwndSecList);
			}
		}
		return TRUE;
//	case WM_DESTROY:
//		reinterpret_cast<CImpPropSheet *>(::GetWindowLongPtr(hwnd, DWLP_USER))->Release();
//		return TRUE;
	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED) {
			switch (LOWORD(wParam)) {
			case IDC_HDR:
				::ShowWindow(::GetDlgItem(hwnd, IDC_HDR_LIST), SW_NORMAL);
				::ShowWindow(::GetDlgItem(hwnd, IDC_DIR_LIST), SW_HIDE);
				::ShowWindow(::GetDlgItem(hwnd, IDC_SEC_LIST), SW_HIDE);
				return TRUE;
			case IDC_DIR:
				::ShowWindow(::GetDlgItem(hwnd, IDC_HDR_LIST), SW_HIDE);
				::ShowWindow(::GetDlgItem(hwnd, IDC_DIR_LIST), SW_NORMAL);
				::ShowWindow(::GetDlgItem(hwnd, IDC_SEC_LIST), SW_HIDE);
				return TRUE;
			case IDC_SEC:
				::ShowWindow(::GetDlgItem(hwnd, IDC_HDR_LIST), SW_HIDE);
				::ShowWindow(::GetDlgItem(hwnd, IDC_DIR_LIST), SW_HIDE);
				::ShowWindow(::GetDlgItem(hwnd, IDC_SEC_LIST), SW_NORMAL);
				return TRUE;
			case IDC_SAVE:
				{
					CWnd wnd;
					wnd.Attach(hwnd);
					CString strWork;
					strWork.LoadString(IDS_FILE_MATCH);
					CFileDialog dlg(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR, strWork, &wnd);
					if (dlg.DoModal() == IDOK) {
						CStdioFile file;
						if (file.Open(dlg.GetPathName(), CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive | CFile::typeText)) {
							try {
								file.WriteString(GetText(hwnd, false));
							} catch (CException *e) {
								e->Delete();
							}
							file.Close();
						}
					}
					wnd.Detach();
					return TRUE;
				}
			case IDC_COPY:
				SetClipboardText(hwnd, GetText(hwnd, true));
				return TRUE;
			}
		}
		break;
	}
	return FALSE;
}
Example #28
0
BOOL CALLBACK CShellExt::PageDlgProc_ogg(HWND hDlg,UINT uMessage,WPARAM wParam,LPARAM lParam)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	LPCSHELLEXT	lpcs = (CShellExt *)GetWindowLongPtr(hDlg,DWLP_USER);

	switch(uMessage){
	case WM_INITDIALOG:
		{
			lpcs = (LPCSHELLEXT )((LPPROPSHEETPAGE )lParam)->lParam;
			lpcs->m_hwndPage = hDlg;
			SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)lpcs);
			lpcs->m_bApply = FALSE;

			//Ver情報
			SetDlgItemText(hDlg,IDC_STATIC_VER_INFO,SOFT_NAME);
			//タイトル
			SetDlgItemText(hDlg,IDC_EDIT_FILENAME,getFileName(lpcs->m_strSelectFile));
			//アイコンを表示
			SHFILEINFO sfi;
			if(SHGetFileInfo(lpcs->m_strSelectFile,0,&sfi,sizeof(sfi),SHGFI_ICON))
			{
				Static_SetImage_Icon(GetDlgItem(hDlg,IDC_ICON1),sfi.hIcon);
			}

			//コンボボックスの初期化
			ComboBox_AddString(GetDlgItem(hDlg,IDC_EDIT_GNR), _T(""));
			for(int i=0; i<256; i++)
			{
				if(lpcs->m_Id3tagv1.GenreNum2String((unsigned char)i).GetLength())
					ComboBox_AddString(GetDlgItem(hDlg,IDC_EDIT_GNR),
							lpcs->m_Id3tagv1.GenreNum2String((unsigned char)i));
			}
			//オーナードローボタンの初期化
/*			RECT rect;
			SetRect(&rect,145,208,145,75);//ボタン位置の基準
			MapDialogRect(hDlg,&rect);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_REW),NULL,rect.left+25*0,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_PLAY),NULL,rect.left+25*1,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_PAUSE),NULL,rect.left+25*2,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_STOP),NULL,rect.left+25*3,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_FFW),NULL,rect.left+25*4,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
*/			
			//情報を表示
			DispInfo(hDlg,lpcs);
			DispInfoExt(hDlg,lpcs);
			
			return FALSE;
		}
		break;

	case WM_TIMER:
		switch(wParam){
		case REW_TIMER:
			SendMessage(hDlg,WM_COMMAND,
				MAKEWPARAM((UINT )IDC_BUTTON_REW,(UINT )BN_CLICKED),
				0);
			break;
		case FFW_TIMER:
			SendMessage(hDlg,WM_COMMAND,
				MAKEWPARAM((UINT )IDC_BUTTON_FFW,(UINT )BN_CLICKED),
				0);
			break;
		}
		break;
	// オーナー描画コントロール
	case WM_DRAWITEM:
		DrawControl(hDlg,(LPDRAWITEMSTRUCT )lParam);
		break;
	case WM_COMMAND:
	switch(LOWORD(wParam)){
		case IDC_BUTTON_ADD_VALUE:
			//値追加
			{
				CDlg_ogg_exttag dlg;
				if(dlg.DoModal() == IDOK)
				{
					COggExt *oggExt = new COggExt(dlg.m_strName,dlg.m_strValue);
					long index = ListBox_AddString(GetDlgItem(hDlg,IDC_LIST_VALUE),oggExt->Get1LineDisp());
					if(index == LB_ERR)
					{
						delete oggExt;
					}
					else
					{
						ListBox_SetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),index,oggExt);
					}
				
					PropSheet_Changed(GetParent(hDlg),hDlg);
					lpcs->m_bApply = TRUE;
				}
			}
			break;
		case IDC_BUTTON_DEL_VALUE:
			//値削除
			{
				long item = ListBox_GetCurSel(GetDlgItem(hDlg,IDC_LIST_VALUE));
				if(item == LB_ERR)
					break;
				
				COggExt *oggExt = (COggExt *)ListBox_GetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),item);
				if(oggExt)
				{
					delete oggExt;
				}
				ListBox_DeleteString(GetDlgItem(hDlg,IDC_LIST_VALUE),item);
				
				PropSheet_Changed(GetParent(hDlg),hDlg);
				lpcs->m_bApply = TRUE;
			}
			break;
		case IDC_LIST_VALUE:
			if(HIWORD(wParam) == LBN_DBLCLK)
			{
				//ダブルクリック - 編集
				long item = ListBox_GetCurSel(GetDlgItem(hDlg,IDC_LIST_VALUE));
				if(item == LB_ERR)
					break;
				
				COggExt *oggExt = (COggExt *)ListBox_GetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),item);
				if(oggExt == NULL)
					break;
				
				CDlg_ogg_exttag dlg;

				dlg.m_strName = oggExt->GetName();
				dlg.m_strValue = oggExt->GetValue();
				if(dlg.DoModal() == IDOK)
				{
					oggExt->SetName(dlg.m_strName);
					oggExt->SetValue(dlg.m_strValue);
					ListBox_DeleteString(GetDlgItem(hDlg,IDC_LIST_VALUE),item);
					ListBox_InsertString(GetDlgItem(hDlg,IDC_LIST_VALUE),item,oggExt->Get1LineDisp());
					ListBox_SetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),item,oggExt);
					
					PropSheet_Changed(GetParent(hDlg),hDlg);
					lpcs->m_bApply = TRUE;
				}
			}
			break;
		case IDC_EDIT_SBJ:
		case IDC_EDIT_TRK:
		case IDC_EDIT_ART:
		case IDC_EDIT_PRD:
		case IDC_EDIT_AART:
		case IDC_EDIT_DISC:
		case IDC_EDIT_CRD:
		case IDC_EDIT_CMT:
			if((HIWORD(wParam) == EN_CHANGE) &&
				(IsWindowEnabled((HWND )lParam)) )
			{
				PropSheet_Changed(GetParent(hDlg),hDlg);
				lpcs->m_bApply = TRUE;
			}
			break;
		case IDC_EDIT_GNR:
			if( ((HIWORD(wParam) == CBN_SELENDOK) || (HIWORD(wParam) == CBN_EDITCHANGE)) &&
				(IsWindowEnabled((HWND )lParam)) )
			{
				PropSheet_Changed(GetParent(hDlg),hDlg);
				lpcs->m_bApply = TRUE;
			}
			break;
		case IDC_BUTTON_PLAY:
			{
				PlayWinamp(hDlg,lpcs->m_strSelectFile);
				break;
			}
		case IDC_BUTTON_PAUSE:
			{
				PauseWinamp();
				break;
			}
		case IDC_BUTTON_STOP:
			{
				StopWinamp();
				break;
			}
		case IDC_BUTTON_REW:
			{
				Rew5Winamp();
				break;
			}
		case IDC_BUTTON_FFW:
			{
				Ffw5Winamp();
				break;
			}
		case IDC_CHECK_AOT:
			if(IsDlgButtonChecked(hDlg,IDC_CHECK_AOT) == BST_CHECKED)
			{
				lpcs->m_bPropAOT = TRUE;
				SetWindowPos(GetParent(hDlg),HWND_TOPMOST,0,0,0,0,
					SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOSIZE);
			}
			else
			{
				lpcs->m_bPropAOT = FALSE;
				SetWindowPos(GetParent(hDlg),HWND_NOTOPMOST,0,0,0,0,
					SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOSIZE);
			}
			regSetDword(HKEY_CURRENT_USER,MP3INFP_REG_ENTRY,_T("PropAOT"),(DWORD )lpcs->m_bPropAOT);
			break;
		case IDC_SETUP:
			OpenConfigPage(hDlg,8);
			break;
		case IDC_HELPVIEW:
			lpcs->OpenHtmlHelp(hDlg,_T("extension.htm"));
			break;
		DLG_CLIPBOARD_MACRO(lpcs->m_strSelectFile);
		}
		break;
	case WM_DESTROY:
		{
			//後始末
			long items = ListBox_GetCount(GetDlgItem(hDlg,IDC_LIST_VALUE));
			if(items != LB_ERR)
			{
				for(int i=0; i<items; i++)
				{
					COggExt *oggExt = (COggExt *)ListBox_GetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),i);
					if(oggExt)
					{
						delete oggExt;
					}
				}
			}
		}
		return TRUE;
	// コンテキストメニュー
	case WM_CONTEXTMENU:
		DlgContextMenu(hDlg,lParam,lpcs->m_Ogg.IsEnable());
		break;
	//状況依存ヘルプ
	case WM_HELP:
		OpenAboutDlg(hDlg);
		break;

	case WM_NOTIFY:
		switch(((NMHDR FAR *)lParam)->code){
//		case PSN_SETACTIVE:
//			break;
		case PSN_APPLY:
			//保存
			if(lpcs->m_bApply)
			{
				TRACE(_T("WM_NOTIFY(PSN_APPLY) - 保存\n"));
				//ファイルが書き込み可能か調べる
				if(GetFileAttributes(lpcs->m_strSelectFile) & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY))
				{
					//「このファイルは「読み込み専用」です」
					AfxMessageBox(IDS_PAGE_THIS_READONLY,MB_ICONINFORMATION);
					//適用ボタンは引き続き有効
					SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PSNRET_INVALID);
					break;
				}
				lpcs->m_bApply = FALSE;

				CString strTmp;
				CWnd wnd;
				//いったんリセット
				lpcs->m_Ogg.Release();

				wnd.Attach(hDlg);

				wnd.GetDlgItemText(IDC_EDIT_SBJ,strTmp);
				lpcs->m_Ogg.AddComment(_T("TITLE"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_TRK,strTmp);
				lpcs->m_Ogg.AddComment(_T("TRACKNUMBER"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_ART,strTmp);
				lpcs->m_Ogg.AddComment(_T("ARTIST"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_PRD,strTmp);
				lpcs->m_Ogg.AddComment(_T("ALBUM"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_AART,strTmp);
				lpcs->m_Ogg.AddComment(_T("ALBUMARTIST"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_DISC,strTmp);
				lpcs->m_Ogg.AddComment(_T("DISCNUMBER"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_CRD,strTmp);
				lpcs->m_Ogg.AddComment(_T("DATE"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_GNR,strTmp);
				lpcs->m_Ogg.AddComment(_T("GENRE"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_CMT,strTmp);
				lpcs->m_Ogg.AddComment(_T("COMMENT"),strTmp);

				wnd.Detach();

				//その他分を保存
				long items = ListBox_GetCount(GetDlgItem(hDlg,IDC_LIST_VALUE));
				if(items != LB_ERR)
				{
					for(int i=0; i<items; i++)
					{
						COggExt *oggExt = (COggExt *)ListBox_GetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),i);
						if(oggExt)
						{
							lpcs->m_Ogg.AddComment(oggExt->GetName(),oggExt->GetValue());
						}
					}
				}

				//タイムスタンプを保存
				lpcs->PushTimeStamp(lpcs->m_strSelectFile);

				DWORD dwRet = lpcs->m_Ogg.Save(lpcs->m_strSelectFile);
				if(dwRet != ERROR_SUCCESS)
				{
					lpcs->m_bApply = TRUE;
					if(dwRet == -1)
						//「ファイルを正しく更新できませんでした。」
						AfxMessageBox(IDS_PAGE_BROKEN,MB_ICONINFORMATION);
					else
						//システムエラーを表示
						errMessageBox(hDlg,dwRet);
					//適用ボタンは引き続き有効
					SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PSNRET_INVALID);
					break;
				}

				//タイムスタンプを復元
				if(lpcs->m_bSaveTimeStamp)
				{
					lpcs->PopTimeStamp(lpcs->m_strSelectFile);
				}

				//情報を表示
				lpcs->m_Ogg.Load(lpcs->m_strSelectFile);
				DispInfo(hDlg,lpcs);
				DispInfoExt(hDlg,lpcs);

				SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PSNRET_NOERROR);

				//シェルに変更を通知
				SHChangeNotify(SHCNE_UPDATEITEM,SHCNF_PATH,lpcs->m_strSelectFile,NULL);
			}
			break;
		default:
			break;
		}
		break;

	default:
		return FALSE;
	
	}

	return TRUE;
}
Example #29
0
void golgotha_app::init()
{
	sw32 i;


	for (i=0; i<(int)argc; i++)
	{
		if (argv[i] == "-max_memory")
		{
			i++;
			i4_const_str::iterator p(argv[i].begin());
			_max_memory = (w32)p.read_number();
		}
	}
	char buf[300];
#ifdef _WINDOWS
	LoadString(i4_win32_instance,IDS_INITIALISATION,buf,300);
#else
	printf("Starting initialisation sequence\n");
	strcpy(buf,"Initialisation, please wait...");
#endif
	i4_status_class * status=i4_create_status(buf,0);
	status->update(0.01f);

	r1_truncate_texture_file();
	i4_file_class * inittest=i4_open("resource.res",I4_READ|I4_NO_BUFFER);
	if (!inittest)
	{
		//i4_error("_FATAL: resource.res not found in the current directory. "
		//	  "Check that the current directory is the directory the exe-file "
		//	  "resides in.");
#ifdef _WINDOWS
		MessageBox(0,"FATAL: resource.res not found in the current directory. "
					 "Check that the current directory is the directory the exe-file "
					 "resides in.","Golgotha: Wrong startup directory",0);
#else
		printf("FATAL: resource.res not found in the current directory. \n"
			   "Check that the current directory is the directory the executable file \n"
			   "resides in.");
#endif
		exit(89);
	}
	delete inittest;
	memory_init(); //calls init__init::i4_init() to init all i4_init_classes
	status->update(0.1f);

	i4_endianesstest end;
	end.anint=0x0ff;
#pragma warning (disable:4127) // Conditional expression is constant
	if (end.chars[0]==0xff)
	{
		i4_warning("Detected architecture is little endian.");
		if (i4_litend!=1)
		{
			i4_error("FATAL: Golgotha was compiled for a big-endian system. "
					 "Please rebuild Golgotha with the correct endianness setting in arch.h");
			exit(92);
		}
	}
	else
	{
		i4_warning("Detected architecture is big endian.");
		if (i4_litend!=0)
		{
			i4_error("FATAL: Golgotha was compiled for a little-endian system. "
					 "Please rebuild Golgotha with the correct endianness setting in arch.h");
			exit(92);
		}
	}
#pragma warning(1:4127)

	i4_warning("Loading resource Manager...");
	resource_init("resource.res",0);
	strcpy(first_level, "test.level"); //Hardcoded first level
	li_add_function("set_default_level", g1_set_default_level);
	i4_warning("Executing scheme/start.scm");
	li_load("scheme/start.scm");
	i4_mkdir("savegame"); //create the savegame directory if it doesn't exist
#ifdef _WINDOWS
	CheckDXVersion();
#endif
	status->update(0.2f);
	display_init();


	status->update(0.23f);
	printf("Display initialisation ok.\n");
	i4_image_class * im=i4_load_image("bitmaps/comic1.jpg");
	printf("If this line is drawn, the jpg loader is ok.\n");

	status->update(0.25f);
#ifdef _WINDOWS
	cwnd.Attach(current_window_handle);

	g1_sound_man.poll(i4_T);           // update sound effects (play next narative sfx)
	do_poll_sound_man=i4_T;
	i4_add_thread((i4_thread_func_type)Thread_Sound_Man_Poller,1000,NULL);
	g1_sound_man.loop_current_song=i4_T;
#else
//All sound is currently disabled under linux and the thread synchronization
//code isn't complete either
	do_poll_sound_man=i4_F;
	g1_sound_man.loop_current_song=i4_F;
#endif
	//wm is the window-manager
	wm->set_background_color(0);


	if (im) //Im is the Cartoon image
	{
		loading_window=new i4_image_window_class(im, i4_T, i4_F);
		wm->add_child(wm->width()/2-loading_window->width()/2,
					  wm->height()/2-loading_window->height()/2,
					  loading_window.get());
	}
	refresh();   // show something right away

	status->update(0.3f);
	char * font_fname=li_get_string(li_get_value("font"),0);
	i4_image_class * fim=i4_load_image(font_fname);
	if (!fim)
	{
		i4_error("image load failed : %s", font_fname);
	}
	i4_current_app->get_style()->font_hint->normal_font=new i4_anti_proportional_font_class(fim);
	delete fim;
	status->update(0.4f);



	choice_first_level();
	//Attempt to initialize a rendering api suitable for the current display.
	g1_render.r_api = r1_create_api(display);
	i4_warning("Render api created successfully: %s.",g1_render.r_api->name());
	refresh();
	status->update(0.5f);
	//init the renderer!

	if (!g1_render.r_api)
	{
		/*
		   MessageBox(NULL,"Could not initialize a rendering device. \n"
		   "Possible Causes:\n-You tried to run the game in a window "
		   "with your desktop color depth not equal to 16Bit.\n"
		   "-There's not enough video memory available for this mode.\n"
		   "-Your DirectX installation is invalid.\n"
		   "-Well, err...","DirectX initialisation failed",
		   MB_OK+MB_ICONSTOP+MB_APPLMODAL);*/
#ifdef _WINDOWS
		char * s=(char *)malloc(1000);

		LoadString(AfxGetResourceHandle(),IDS_RENDERINITFAILED,s,999);
		MessageBox(NULL,s,"DirectX",MB_OK+MB_ICONSTOP+MB_APPLMODAL);
		free(s);
		FatalExit(99);
#else
		printf("FATAL ERROR: Initialisation of renderer failed. Quitting.\n");
		exit(99);
#endif

	}



	g1_input.init();

	g1_resources.load();
	li_load("scheme/preferences.scm");
	status->update(0.6f);
	i4_bool movie_time = i4_F;

	for (i=0; i<(int)argc; i++)
	{
		if (argv[i] == i4gets("movie_option"))
		{
			movie_time = i4_T;
		}
	}

	if (g1_render.r_api->get_render_device_flags() & R1_SOFTWARE)
	{
		//setup a timer and decide whether or not to do double pixel
		//default is high res mode
		int processor_speed = i4_get_clocks_per_second();

		g1_resources.render_window_expand_mode = R1_COPY_1x1;
		/*
		   if (processor_speed > 170000000)
		   	g1_resources.render_window_expand_mode = R1_COPY_1x1;
		   else
		   if (processor_speed > 140000000)
		   g1_resources.render_window_expand_mode = R1_COPY_1x1_SCANLINE_SKIP;
		   else
		   g1_resources.render_window_expand_mode = R1_COPY_2x2;

		   g1_resources.radius_mode = g1_resource_class::VIEW_LOW;
		 */

		if (movie_time)
		{
			g1_resources.radius_mode = g1_resource_class::VIEW_FAR;
		}

	}
	else
	{
		//hardware rasterizer, view distance = far by default
		g1_resources.radius_mode = g1_resource_class::VIEW_FAR;
	}

	s1_load();
	g1_load_images();

	status->update(0.7f);
	g1_player_man.init_colors(&display->get_screen()->get_pal()->source, g1_render.r_api);

	protocol=i4_get_first_protocol();

	i4_graphical_style_class * style=wm->get_style();


	/*
	   style->color_hint->button.active.bright=(135<<8)|64;
	   style->color_hint->button.active.medium=(114<<8)|49;
	   style->color_hint->button.active.dark=(88<<8)|38;

	   style->color_hint->button.passive.bright=(120<<8)|64;
	   style->color_hint->button.passive.medium=(100<<8)|49;
	   style->color_hint->button.passive.dark=(70<<8)|38;
	 */

	if (!g1_cwin_man)
	{
		g1_cwin_man=new g1_cwin_man_class;
	}
	status->update(0.8f);
	g1_cwin_man->init(wm, style, display->get_screen(), display, wm);
	if (m1_maxtool_man)
	{
		m1_maxtool_man->init(wm,style,display->get_screen(),display,wm);
	}
	li_add_function("Pause", g1_pause);
	li_add_function("ForcePause", g1_force_pause);
	li_add_function("is_paused",g1_is_paused);
	status->update(1.0f);

	hide_main_menu();
	main_menu=new g1_help_screen_class(wm->width(), wm->height(), wm->get_style(),
									   i4gets("startup_screen"), G1_PLOT_SCREEN);
	wm->add_child(0,0,main_menu);

	delete status;
	status=0;
	i4_kernel.request_events(this,
							 i4_device_class::FLAG_DO_COMMAND |
							 i4_device_class::FLAG_END_COMMAND|
							 i4_device_class::FLAG_DISPLAY_CHANGE);
	do_main_menu();

	if (start_in_editor)
	{
		g1_cwin_man->set_edit_mode(i4_T);
	}

	//start game with startup screens
	//if (!movie_time)
	//{
	//  help_screen("startup_screen", G1_START_HELP_SCREEN);
	//}
	//else
	//{
	//  start_new_game();
	//}

}
Example #30
-1
BOOL CImageWindow::Create(CWnd *pwndParent, const CRect rtPosition)
{
	ASSERT(pwndParent);

	CRect rectDummy(0, 0, 0, 0);
	if(rtPosition.IsRectEmpty() || rtPosition.IsRectNull())
	{
		pwndParent->GetClientRect(&rectDummy);
	}
	else
	{
		rectDummy = rtPosition;
	}

	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CWnd tmpWnd;
	tmpWnd.Attach(pwndParent->GetSafeHwnd());

	if(!CWnd::Create(NULL, NULL, WS_VISIBLE, rectDummy, &tmpWnd, 0, NULL))
	{
		tmpWnd.Detach();
		return FALSE;
	}

	tmpWnd.Detach();

	return TRUE;
}