Esempio n. 1
1
LRESULT COption::ExtractProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
	static CFolderDialog FolderDlg;
	static SOption* pOption = &m_option_tmp;

	// Extraction Settings

	static constexpr std::array<LPCTSTR, 3> ExtractCheckText{{
		_T("Extract each folder"),
		_T("Fix the CRC of OGG files upon extraction"),
		_T("Enable simple decoding")
	}};

	static const std::array<BOOL*, 4> ExtractCheckFlag{{
		&pOption->bCreateFolder, &pOption->bFixOgg, &pOption->bEasyDecrypt, &pOption->bRenameScriptExt
	}};

	static std::array<CCheckBox, ExtractCheckText.size()> ExtractCheck;
	static CCheckBox ExtractCheckAlpha;
	static CLabel ExtractLabelPng, ExtractLabelAlpha, ExtractLabelBuf, ExtractLabelTmp;
	static CRadioBtn ExtractRadioImage, ExtractRadioSave;
	static CUpDown ExtractUpDownPng;
	static CEditBox ExtractEditPng, ExtractEditAlpha, ExtractEditSave, ExtractEditBuf, ExtractEditTmp;
	static CButton ExtractBtnSave, ExtractBtnTmp;
	static CGroupBox ExtractGroupImage, ExtractGroupSave;

	switch (msg)
	{
		case WM_INITDIALOG:
		{
			UINT ID = 10000;
			const int x = 10;
			const int xx = 15;
			int y = 0;

			// Extraction Settings

			for (size_t i = 0; i < ExtractCheckText.size(); i++)
			{
				ExtractCheck[i].Create(hWnd, ExtractCheckText[i], ID++, x, y += 20, 230, 20);
				ExtractCheck[i].SetCheck(*ExtractCheckFlag[i]);
			}

			//

			int y_image = y;
			ExtractGroupImage.Create(hWnd, _T("Output image format"), ID++, x, y_image += 34, 240, 110);
			ExtractRadioImage.Close();
			ExtractRadioImage.Create(hWnd, _T("BMP"), ID++, x + xx, y_image += 18, 50, 20);
			ExtractRadioImage.Create(hWnd, _T("PNG"), ID++, x + xx, y_image += 20, 50, 20);
			ExtractRadioImage.SetCheck(0, pOption->bDstBMP);
			ExtractRadioImage.SetCheck(1, pOption->bDstPNG);
			ExtractLabelPng.Create(hWnd, _T("Compression Level"), ID++, x + xx + 50, y_image + 3, 100, 20);
			ExtractEditPng.Create(hWnd, _T(""), ID++, x + xx + 150, y_image, 40, 22);
			ExtractEditPng.SetLimit(1);
			ExtractUpDownPng.Create(hWnd, ExtractEditPng.GetCtrlHandle(), pOption->CmplvPng, ID++, 9, 0);

			//

			ExtractCheckAlpha.Create(hWnd, _T("Enable alpha blending"), ID++, x + xx, y_image += 22, 140, 20);
			ExtractCheckAlpha.SetCheck(pOption->bAlphaBlend);
			ExtractLabelAlpha.Create(hWnd, _T("Background color"), ID++, x + xx * 2 + 4, y_image += 24, 100, 20);
			ExtractEditAlpha.Create(hWnd, pOption->szBgRGB, ID++, x + xx * 2 + 100, y_image - 4, 100, 22);
			ExtractEditAlpha.SetLimit(6);
			ExtractEditAlpha.Enable(pOption->bAlphaBlend);

			//

			const int x_save = x + 200;
			int y_save = y;

			ExtractGroupSave.Create(hWnd, _T("Destination"), ID++, x_save + 50, y_save += 34, 290, 110);
			ExtractRadioSave.Close();
			ExtractRadioSave.Create(hWnd, _T("Specify each time"), ID++, x_save + xx + 50, y_save += 18, 220, 20);
			ExtractRadioSave.Create(hWnd, _T("Same folder as input source"), ID++, x_save + xx + 50, y_save += 20, 200, 20);
			ExtractRadioSave.Create(hWnd, _T("The following folder"), ID++, x_save + xx + 50, y_save += 20, 200, 20);
			ExtractRadioSave.SetCheck(0, pOption->bSaveSel);
			ExtractRadioSave.SetCheck(1, pOption->bSaveSrc);
			ExtractRadioSave.SetCheck(2, pOption->bSaveDir);
			ExtractEditSave.Create(hWnd, pOption->SaveDir, ID++, x_save + xx * 2 + 40, y_save += 20, 200, 22);
			ExtractEditSave.Enable(pOption->bSaveDir);
			ExtractBtnSave.Create(hWnd, _T("Browse"), ID++, x_save + xx * 2 + 250, y_save + 1, 50, 20);
			ExtractBtnSave.Enable(pOption->bSaveDir);

			//

			y = (y_image > y_save) ? y_image : y_save;
			ExtractLabelBuf.Create(hWnd, _T("Buffer Size(KB)"), ID++, x, y += 44, 100, 20);
			ExtractEditBuf.Create(hWnd, pOption->BufSize, ID++, x + 100, y - 4, 110, 22);

			//

			ExtractLabelTmp.Create(hWnd, _T("Temporary Folder"), ID++, x, y += 24, 100, 20);
			ExtractEditTmp.Create(hWnd, pOption->TmpDir, ID++, x + 100, y - 4, 200, 22);
			ExtractBtnTmp.Create(hWnd, _T("Browse"), ID++, x + 310, y - 3, 50, 20);

			break;
		}

		case WM_COMMAND:
			// Checkbox
			if (LOWORD(wp) >= ExtractCheck.front().GetID() && LOWORD(wp) <= ExtractCheck.back().GetID())
			{
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// Alpha blend check box
			if (LOWORD(wp) == ExtractCheckAlpha.GetID())
			{
				ExtractEditAlpha.Enable(ExtractCheckAlpha.GetCheck());
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			//Output image format radio button
			if (LOWORD(wp) >= ExtractRadioImage.GetID(0) && LOWORD(wp) <= ExtractRadioImage.GetID(1))
			{
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// Destination radio button
			if (LOWORD(wp) >= ExtractRadioSave.GetID(0) && LOWORD(wp) <= ExtractRadioSave.GetID(2))
			{
				ExtractEditSave.Enable(ExtractRadioSave.GetCheck(2));
				ExtractBtnSave.Enable(ExtractRadioSave.GetCheck(2));
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// Output folder browse
			if (LOWORD(wp) == ExtractBtnSave.GetID())
			{
				TCHAR szSaveDir[_MAX_DIR];
				ExtractEditSave.GetText(szSaveDir, sizeof(szSaveDir));
				if (FolderDlg.DoModal(hWnd, _T("Select the output folder"), szSaveDir))
					ExtractEditSave.SetText(szSaveDir);
				break;
			}

			// Temporary folder browse
			if (LOWORD(wp) == ExtractBtnTmp.GetID())
			{
				TCHAR szTmpDir[_MAX_DIR];
				ExtractEditTmp.GetText(szTmpDir, sizeof(szTmpDir));
				if (FolderDlg.DoModal(hWnd, _T("Select a temporary folder"), szTmpDir))
					ExtractEditTmp.SetText(szTmpDir);
				break;
			}

			// Contents of the edit box have been changed
			if (HIWORD(wp) == EN_CHANGE)
			{
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}
			break;

		case WM_NOTIFY:
		{
			const auto* const hdr = reinterpret_cast<LPNMHDR>(lp);
			switch (hdr->code)
			{
				// OK/Apply, Tabbing
				case PSN_APPLY:
				case PSN_KILLACTIVE:
					// Extraction Settings
					for (size_t i = 0; i < ExtractCheck.size(); i++)
						*ExtractCheckFlag[i] = ExtractCheck[i].GetCheck();
					//
					pOption->bDstBMP = ExtractRadioImage.GetCheck(0);
					pOption->bDstPNG = ExtractRadioImage.GetCheck(1);
					ExtractEditPng.GetText(&pOption->CmplvPng, FALSE);
					//
					pOption->bAlphaBlend = ExtractCheckAlpha.GetCheck();
					ExtractEditAlpha.GetText(&pOption->BgRGB, TRUE);
					_stprintf(pOption->szBgRGB, _T("%06x"), pOption->BgRGB);
					//
					pOption->bSaveSel = ExtractRadioSave.GetCheck(0);
					pOption->bSaveSrc = ExtractRadioSave.GetCheck(1);
					pOption->bSaveDir = ExtractRadioSave.GetCheck(2);
					ExtractEditSave.GetText(pOption->SaveDir);
					//
					ExtractEditBuf.GetText(&pOption->BufSize, FALSE);
					//
					ExtractEditTmp.GetText(pOption->TmpDir);
					// OK/Apply
					if (hdr->code == PSN_APPLY)
						Apply();
					return TRUE;
			}
			break;
		}
	}

	return FALSE;
}
Esempio n. 2
0
// Add a new column to current tab's list and
// a button for the column.
void CLoungeDlg::addColumn(LPCTSTR coltitle, int totalcolumns, BOOL inQueue)
{
  const int BtnSizeY = (1.6f * Global::GetCharHeight());
  int btnId = IDC_LD_BUTTONIDBASE;
  CRect r;
  listCtrl_.GetWindowRect(&r);
  int i = listCtrl_.GetHeaderCtrl()->GetItemCount();
  int width = float(r.Width()) / float(totalcolumns);

  // force width between min and max
  width = min(width, MaxColumnWidth);
  width = max(width, MinColumnWidth);

  listCtrl_.InsertColumn(i, coltitle, LVCFMT_LEFT, width, i);
  if (buttons_.size() < (i + 1))
  {
    CButton* pBtn = new CButton();
    if (pBtn)
    {
      CRect rectBtn(r.left, r.bottom + 5, r.left + width, r.bottom + 5 + BtnSizeY);
      ScreenToClient(&rectBtn);
      rectBtn.OffsetRect(i * width, 0);
        
      UINT style = WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON;
      if (inQueue)
        pBtn->Create(g_szRemoveFromQueue, style, rectBtn, this, btnId + i);
      else
        pBtn->Create(g_szAddToQueue, style, rectBtn, this, btnId + i);
      pBtn->SetFont(CFont::FromHandle(
                     (HFONT)::GetStockObject(DEFAULT_GUI_FONT)));

      buttons_.push_back(pBtn);
    }
  }
}
Esempio n. 3
0
void CdynControlDlg::CreateSpeedBundle(cJSON *json, int x, int y, int w, int h)
{
    int idx = cJSON_GetObjectItem(json, "id")->valueint;
    int speed = cJSON_GetObjectItem(json, "speed")->valueint;
    int ptx = x;
    int width = w - SPEEDBTN_WIDTH - LOCKBTN_WIDTH;
    CString str;

    CEdit *edit = new CEdit();
    edit->Create(WS_CHILD | WS_VISIBLE | BS_TOP,
        CRect(ptx, y, ptx + width, y + h),
        this,
        SPEED_ID_OFFSET + idx);
    str.Format(_T("%d"), speed);
    edit->SetWindowText(str);

    ptx += width;
    width = SPEEDBTN_WIDTH;
    CButton *btn = new CButton();
    btn->Create(_T("set"), WS_CHILD | WS_VISIBLE | BS_TOP,
        CRect(ptx, y, ptx + width, y + h),
        this,
        SPEEDBTN_ID_OFFSET + idx);

    ptx += width;
    width = LOCKBTN_WIDTH;
    btn = new CButton();
    btn->Create(_T("lock"), WS_CHILD | WS_VISIBLE | BS_TOP,
        CRect(ptx, y, ptx + width, y + h),
        this,
        LOCKBTN_ID_OFFSET + idx);
}
void CGestionMineralesDlg::NuevoGrupoControles(int nIndice) 
{
    const unsigned __int8 nFilasMax = 20;
    const unsigned __int8 nTamCheck = 15;
    const unsigned __int8 nEspaciado = 25;
    const unsigned __int8 nDistanciaColumnas = 200;
    const unsigned __int8 nSangriaInicial = 40;
    const unsigned __int8 nTamBotones = 15;
    const unsigned __int8 nEspaciadoBotones = 25;

    // lista para enlazar los indices iniciales con los reales de los vectores
    //m_vecMap.push_back(nIndice);
    
    unsigned int fila, columna;
    CButton* pButton;
    CString csInfo;

    HBITMAP hBitmapEditar= (HBITMAP) m_bitmapEditar.GetSafeHandle();
    HBITMAP hBitmapBorrar= (HBITMAP) m_bitmapBorrar.GetSafeHandle();

    fila = nIndice % nFilasMax;
    columna = nIndice / nFilasMax;
    csInfo.Format("%-4s - %s",theApp.m_minerales.GetAbreviatura(nIndice), theApp.m_minerales.GetNombre(nIndice));

    // Delete
    pButton = new CButton;
    pButton->Create("x",WS_CHILD | WS_VISIBLE |BS_BITMAP/*| BS_LEFTTEXT*/, 
        CRect(nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2), 
              m_rect.bottom + nEspaciado*fila, 
              nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2) + nTamBotones, 
              m_rect.bottom + nEspaciado*fila + nTamBotones ), this, CONTROLES_DINAMICOS_MIN + nIndice*3 +2);
    pButton->SetBitmap(hBitmapBorrar);
    m_vecDelete.push_back(pButton);

    //Edit
    pButton = new CButton;
    pButton->Create("e",WS_CHILD | WS_VISIBLE |BS_BITMAP  /*| BS_LEFTTEXT*/, 
        CRect(nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones, 
              m_rect.bottom + nEspaciado*fila, 
              nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones + nTamBotones, 
              m_rect.bottom + nTamBotones + nEspaciado*fila), this, CONTROLES_DINAMICOS_MIN + nIndice*3 +1);
    pButton->SetBitmap(hBitmapEditar);
    m_vecEdit.push_back(pButton);

    //Check
    pButton = new CButton;
    pButton->Create(csInfo,WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX /*| BS_LEFTTEXT*/, 
        CRect(nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones*2, 
              m_rect.bottom + nEspaciado*fila, 
              nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones*2 + nDistanciaColumnas, 
              m_rect.bottom + nTamCheck + nEspaciado*fila), this, CONTROLES_DINAMICOS_MIN + nIndice*3);
    pButton->SetCheck(theApp.m_minerales.m_list[nIndice]->m_bActivo);
    m_vecCheck.push_back(pButton);

    this->SetWindowPos(NULL,0,0,max(nSangriaInicial + columna*(nDistanciaColumnas+nEspaciadoBotones*2)+ nEspaciadoBotones*2 + nDistanciaColumnas + 50, m_rect.right),
                                m_rect.bottom + nTamCheck + nEspaciado*nFilasMax + 50, SWP_NOMOVE | SWP_NOZORDER); //+50 para el menu y barra de titulo
}
Esempio n. 5
0
//---------------------------------------------------------------------------
// Function name	: _InsertPage
// Description	  : Called by InsertPage(...) methods
//									Return -1 if an error occurs
//---------------------------------------------------------------------------
int CRollupCtrl::_InsertPage(const TCHAR* caption, CDialog* pwndTemplate, int idx, BOOL bAutoDestroyTpl)
{
	ASSERT(pwndTemplate!=NULL);
	ASSERT(pwndTemplate->m_hWnd!=NULL);

 	//Get client rect
	CRect r; GetClientRect(r);

	//Create GroupBox
	CButton* groupbox = new CButton;
	groupbox->Create(_T(""), WS_CHILD|BS_GROUPBOX, r, this, 0 );

	//Create Button
	CButton* but = new CButton;
	but->Create(caption, WS_CHILD|BS_AUTOCHECKBOX|BS_PUSHLIKE|BS_FLAT, r, this, 0 );

	//Change Button's font
	HFONT hfont= (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
	CFont* font = CFont::FromHandle(hfont);
	but->SetFont(font);

	//Add page at pagelist
	RC_PAGEINFO* pi			= new RC_PAGEINFO;
	pi->cstrCaption			= caption;
	pi->bExpanded				= FALSE;
	pi->bEnable					= TRUE;
	pi->pwndTemplate		= pwndTemplate;
	pi->pwndButton			= but;
	pi->pwndGroupBox		= groupbox;
	pi->pOldDlgProc			= (WNDPROC)::GetWindowLong(pwndTemplate->m_hWnd, DWL_DLGPROC);
	pi->pOldButProc			= (WNDPROC)::GetWindowLong(but->m_hWnd, GWL_WNDPROC);
	pi->bAutoDestroyTpl	= bAutoDestroyTpl;

	int newidx;
	if (idx<0)	newidx = (int)m_PageList.Add(pi);
	else	{	m_PageList.InsertAt(idx, pi); newidx=idx; }

	//Set Dlg Window datas
	::SetWindowLong(pwndTemplate->m_hWnd, GWL_USERDATA,	(LONG)m_PageList[newidx]);
	::SetWindowLong(pwndTemplate->m_hWnd, DWL_USER,		(LONG)this);

	//Set But Window data
	::SetWindowLong(but->m_hWnd, GWL_USERDATA,	(LONG)m_PageList[newidx]);

	//SubClass Template window proc
	::SetWindowLong(pwndTemplate->m_hWnd, DWL_DLGPROC, (LONG)CRollupCtrl::DlgWindowProc);

	//SubClass Button window proc
	::SetWindowLong(but->m_hWnd, GWL_WNDPROC, (LONG)CRollupCtrl::ButWindowProc);

	//Update
	m_PageHeight+=RC_PGBUTTONHEIGHT+(RC_GRPBOXINDENT/2);
	RecalLayout();

	return newidx;
}
Esempio n. 6
0
void CScroll::MoveAdjust()
{
    CButton*    pc;
    Math::Point     pos, dim;

    if ( m_dim.y < m_dim.x*2.0f )  // very short lift?
    {
        delete m_buttonUp;
        m_buttonUp = 0;

        delete m_buttonDown;
        m_buttonDown = 0;
    }
    else
    {
        if ( m_buttonUp == 0 )
        {
            m_buttonUp = new CButton();
            pc = m_buttonUp;
            pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 49, EVENT_NULL);
            pc->SetRepeat(true);
            m_eventUp = pc->GetEventType();
        }

        if ( m_buttonDown == 0 )
        {
            m_buttonDown = new CButton();
            pc = m_buttonDown;
            pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 50, EVENT_NULL);
            pc->SetRepeat(true);
            m_eventDown = pc->GetEventType();
        }
    }

    if ( m_buttonUp != 0 )
    {
        pos.x = m_pos.x;
        pos.y = m_pos.y+m_dim.y-m_dim.x/0.75f;
        dim.x = m_dim.x;
        dim.y = m_dim.x/0.75f;
        m_buttonUp->SetPos(pos);
        m_buttonUp->SetDim(dim);
    }

    if ( m_buttonDown != 0 )
    {
        pos.x = m_pos.x;
        pos.y = m_pos.y;
        dim.x = m_dim.x;
        dim.y = m_dim.x/0.75f;
        m_buttonDown->SetPos(pos);
        m_buttonDown->SetDim(dim);
    }

    AdjustGlint();
}
Esempio n. 7
0
void COptionSheet::AddButton(wchar_t *txt, int x, int w, UINT id, BOOL showButton)
{
	CButton *btn;
	CRect rect;
	CRect rcClient;

	GetClientRect(rcClient);

	rect.left = x;
	rect.right = x + w;
	rect.top = rcClient.Height() - (PAGE_SPACING2 + m_ButtonHeight);
	rect.bottom = rect.top + m_ButtonHeight;

	btn = new CButton();

	DWORD style = WS_TABSTOP | BS_DEFPUSHBUTTON;

	if(TRUE == showButton) {
		style |= WS_VISIBLE;
	}

	btn->Create(txt, style, rect, this, id);
	btn->SetFont(&m_Font);
	m_Buttons.AddTail(btn);
}
void CDBSchemaTableView::CreateButton(CButton& btn, UINT id, CWnd* pParent, LPCTSTR lpTitle, UINT width, UINT height, DWORD dwStyle, CFont* pFont)
{
	static CFont* pDefaultFont = 0;

	if(!pDefaultFont)
	{
		pDefaultFont = new CFont;
		pDefaultFont->CreateFont(16,		//   nHeight
			0,								//   nWidth
			0,								//   nEscapement
			0,								//   nOrientation
			0,								//   nWeight
			FALSE,							//   bItalic
			FALSE,							//   bUnderline
			0,								//   cStrikeOut
			ANSI_CHARSET,					//   nCharSet
			OUT_DEFAULT_PRECIS,				//   nOutPrecision
			CLIP_DEFAULT_PRECIS,			//   nClipPrecision
			DEFAULT_QUALITY,				//   nQuality
			DEFAULT_PITCH   |   FF_SWISS,	//   nPitchAndFamily
			_T( "Arial "));					//   lpszFac 
	}

	RECT rect = {0, 0, width, height};
	btn.Create(lpTitle, dwStyle, rect, pParent, id);
	if(!pFont) pFont = pDefaultFont;
	btn.SetFont(pFont);
	btn.ShowWindow(SW_SHOW);
}
Esempio n. 9
0
BOOL CToolMonsterShow::OnInitDialog() 
{
	CDialog::OnInitDialog();
	skin.SetButtonSkin(	m_OK);
	
	int x;
	int y;

	for (x=0;x<2*10+1;x++)
	{
		for (y=0;y<2*8+1;y++)
		{

			CButton *but = new CMonsterButton(x,y);
			RECT rect;
			rect.top=29+y*20;
			rect.left=20+x*20;
			rect.right=rect.left+14;
			rect.bottom=rect.top+14;
			
			but->Create("test",WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON|BS_FLAT|BS_3STATE,rect,this,IDC_MONSTERSHOW_FIRSTBUTTON);				
						
			m_monsterButtons[x][y]=but;
		}
	}

	refreshVisibleCreatures();

	SetTimer(1001,500,NULL);
	
	return TRUE;  
}
Esempio n. 10
0
int CPicContainer::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	//创建按钮
	CRect ClientRect;
	GetClientRect(&ClientRect);
	CRect rect;
	long lButtonSizeX=70;
	long lButtonSizeY=60;
	long lDelta =20;
	int PosX,PosY;
	for(size_t i=0;i<m_ButtonInfo.size();i++)
	{
		CButton *pButton =new CButton;

		rect.left =lDelta*(i+1)+lButtonSizeX*i;
		rect.top =ClientRect.Height()-lDelta-lButtonSizeY;
		rect.bottom =rect.top+lButtonSizeY;
		rect.right =rect.left+lButtonSizeX;
		m_ButtonInfo[i].rect =rect;
		pButton->Create(NULL, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON/*|BS_OWNERDRAW*/ , rect, this, ID_FB+i);
		m_buttons.push_back(pButton);
	}

	return 0;
}
Esempio n. 11
0
int CControlPanel::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  여기에 특수화된 작성 코드를 추가합니다.
	CRect rect;
	GetWindowRect(&rect);

	list<GroundControl::Node*>& nodelist = GroundControlManager.getNodeList();

	int idx = 0;

	for (list<GroundControl::Node*>::iterator iter = nodelist.begin(); iter != nodelist.end(); ++iter)
	{
		GroundControl::Node* node = *iter;
		m_nodelist.push_back(node);
		CButton* rButton = new CButton();
			
		wstring wstr = wstring(node->name().begin(), node->name().end());

		rButton->Create(wstr.c_str(), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, CRect(rect.left + 20, rect.top + 20 * (idx + 1), rect.left + 20 + 100, rect.top + 20 * (idx + 1) + 20), this, ID_NODE_LIST_BTN_BASE+idx);
		if (idx == 0)
		{
			rButton->SetCheck(BST_CHECKED);
			m_curnode = node;

		}
		else
		{
			rButton->SetCheck(BST_UNCHECKED);
		}
		m_nodelistBtn.push_back(rButton);
		idx++;
	}

	m_rnoneBtn.Create(_T("None"), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, CRect(rect.left + 160, rect.top + 20, rect.left + 160 + 100, rect.top + 20 + 20), this, ID_CONTROLLER_BTN_BASE);
	m_rmouseBtn.Create(_T("Mouse"), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, CRect(rect.left + 160, rect.top + 40, rect.left + 160 + 100, rect.top + 40 + 20), this, ID_CONTROLLER_BTN_BASE+1);
	m_rjoystickBtn.Create(_T("Joystick"), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, CRect(rect.left + 160, rect.top + 60, rect.left + 160 + 100, rect.top + 60 + 20), this, ID_CONTROLLER_BTN_BASE+2);
	m_rnoneBtn.SetCheck(BST_UNCHECKED);
	m_rmouseBtn.SetCheck(BST_CHECKED);
	m_rjoystickBtn.SetCheck(BST_UNCHECKED);

	m_goForwardBtn.Create(_T("전진"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 110, rect.top + 100, rect.left + 110 + BUTTON_SIZE_X, rect.top + 100 + BUTTON_SIZE_Y), this, ID_GO_FORWARD_BTN);
	m_stopBtn.Create(_T("정지"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 110, rect.top + 200, rect.left + 110 + BUTTON_SIZE_X, rect.top + 200 + BUTTON_SIZE_Y), this, ID_STOP_BTN);
	m_goBackwardBtn.Create(_T("후진"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 110, rect.top + 300, rect.left + 110 + BUTTON_SIZE_X, rect.top + 300 + BUTTON_SIZE_Y), this, ID_GO_BACKWARD_BTN);
	m_goLeftBtn.Create(_T("좌회전"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 10, rect.top + 200, rect.left + 10 + BUTTON_SIZE_X, rect.top + 200 + BUTTON_SIZE_Y), this, ID_GO_LEFT_BTN);
	m_goRightBtn.Create(_T("우회전"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(rect.left + 210, rect.top + 200, rect.left + 210 + BUTTON_SIZE_X, rect.top +200 + BUTTON_SIZE_Y), this, ID_GO_RIGHT_BTN);

	m_mouseControlPanel.Create( NULL, NULL, WS_CHILD | WS_VISIBLE | SS_NOTIFY | WS_BORDER, CRect(rect.left + 310, rect.top + 0, rect.left + 310 + 400, rect.top + 0 + 400), this, ID_MOUSE_CONTROL_PANEL);
	
	SetTimer(100, 30, NULL);

	m_curController = &m_mouseControlPanel;
	return 0;
}
Esempio n. 12
0
BOOL CExampleDemoDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	
	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	// 设置窗口为屏幕宽高
	MoveWindow(0, 0, GetSystemMetrics(SM_CXFULLSCREEN), GetSystemMetrics(SM_CYFULLSCREEN));
	SetDlgItemInt(ID_MSG, 0);
	m_tempplate=LoadTemplateImg("template");



//1、动态创建进入下一张图片按钮
	CRect rcBtn(20, 0, 120, 15);   //按钮高度为15,间隔高度为10  
	DWORD dwStyle = WS_CHILD | BS_PUSHBUTTON;
	m_nextimageb = new CButton();
	m_nextimageb->Create("下一张", dwStyle, rcBtn, this, IDC_NEXT_BUTTON);

//2、动态创建单选框按钮
	
	for (int i = 0; i < m_tempplate.size(); i++)
	{
		DWORD dwStyle = WS_CHILD | BS_AUTORADIOBUTTON;
		rcBtn.top += 25;
		rcBtn.bottom += 25;
		CButton *pButton = new CButton();
		if (0 == i)
		{
			dwStyle |= WS_GROUP;    //第一个按钮时添加分组风格  
		}
		CString index;
		index.Format("%d", i);
		pButton->Create(index, dwStyle, rcBtn, this, IDC_GROUP_BUTTON + i);

		pButton->SetFont(GetFont()); //设置为父窗口的字体  
		m_radioList.push_back(pButton);
		

	}







	::SetWindowPos(this->m_hWnd, HWND_BOTTOM, 200, 0, 1400, 1000, SWP_NOZORDER);

	return TRUE;  // return TRUE  unless you set the focus to a control
}
Esempio n. 13
0
CRDdialog::CRDdialog(std::vector<string> ids):_ids(ids),RDbuttons()
{
	
	int id =0;
	for(std::vector<string>::iterator it=_ids.begin();it!=_ids.end();++it)
	{
		CButton rd;
		rd.Create(_T((*it).c_str()), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON, 
			CRect(10,40,100,70), this, id++);
		RDbuttons.push_back(&rd);

	}
}
Esempio n. 14
0
void CMyGroupBox::NewRadio(CString sCaption, UINT nID)
{
	CFont* font = GetFont();
	CButton* pBtn = new CButton();
	int nCount = GetRadioCount();
	int t = 20 + m_nRadioHeight * nCount;
	pBtn->Create(sCaption, WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, CRect(10, t, 400, t + m_nRadioHeight), this, nID);
	if (nCount == 0)
	{
		pBtn->SetCheck(1);
	}
	pBtn->SetFont(font);
	m_RadioList.Add(pBtn);
}
Esempio n. 15
0
// add a check box at the specified column
void CCustomListRowWnd::AddCheck(INT32 col)
{
    CButton* pBut = new CButton();
    m_ColumnObjects[col] = pBut ;

    CRect cr;
    GetClientRect(&cr);
    ASSERT(cr.Height() == CCustomList::ROWHEIGHT);

    CRect rect;
    rect.left	=	m_Parent->m_Parent->m_ColumnOffsetsArray[col] ;
    rect.right	=	rect.left + GetSystemMetrics(SM_CXMENUCHECK);
    rect.top	= (CCustomList::ROWHEIGHT - GetSystemMetrics(SM_CYMENUCHECK))/2;
    rect.bottom = rect.top + GetSystemMetrics(SM_CYMENUCHECK)  ;
    pBut->Create(NULL, WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, rect, this, 4);
}
Esempio n. 16
0
void CdynControlDlg::CreatePositionBundle(cJSON *json, int x, int y, int w, int h)
{   
    int idx = cJSON_GetObjectItem(json, "id")->valueint;
    ids.push_back(idx);

    CString str;
    char *name = cJSON_GetObjectItem(json, "name")->valuestring;

    int min = cJSON_GetObjectItem(json, "min")->valueint;
    int max = cJSON_GetObjectItem(json, "max")->valueint;

    str.Format(_T("0x%x: %s\n    [%d, %d]"), idx, charTotchar(name), min, max);

    CButton *checkBox = new CButton();
    checkBox->Create(str, 
        WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE,
                     CRect(x, y, x + CHECK_WIDTH, y + h), 
                     this, 
                     CHECK_ID_OFFSET + idx);    
    checkBox->SetCheck(BST_CHECKED);

    CSliderCtrl *slider = new CSliderCtrl();
    int width = w - (CHECK_WIDTH + VIEW_WIDTH);
    int ptx = x + CHECK_WIDTH;    

    slider->Create(WS_CHILD | WS_VISIBLE | BS_TOP,
                   CRect(ptx, y, ptx + width, y + h),
                   this, 
                   SLIDER_ID_OFFSET + idx);                   
    slider->SetRange(min, max);
    slider->SetTicFreq(1);
    int initPos = cJSON_GetObjectItem(json, "init")->valueint;    
    slider->SetPos(initPos);
    
    CEdit *edit = new CEdit();    
    ptx += width;
    width = VIEW_WIDTH;

    edit->Create(WS_CHILD | WS_VISIBLE | BS_TOP, 
                 CRect(ptx, y, ptx + width, y + 30), 
                 this, 
                 VIEW_ID_OFFSET + idx);
    str.Format(_T("%d"), initPos);
    edit->SetWindowText(str);
}
Esempio n. 17
0
int myframe::OnCreate(LPCREATESTRUCT lp)
{
	if (CWnd::OnCreate (lp) == -1)
        return -1;

	CClientDC dc (this);
	CButton *but;
	but=new CButton;
	but->Create("Show fonts",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(10,10,100,50),this,10);
	fonttitle.Create("",WS_VISIBLE | WS_CHILD,CRect(50,100,500,500),this);

    TEXTMETRIC tm;
    dc.GetTextMetrics (&tm);
    m_cxChar = tm.tmAveCharWidth;
    m_cyChar = tm.tmHeight + tm.tmExternalLeading;
   	
	return 0;
}
Esempio n. 18
0
	BOOL	OnCreate( LPCREATESTRUCT lpCreateStruct ){
		m_pWorkItem	= CreateThreadpoolWork( WorkerThread, this, NULL );
		if( m_pWorkItem == NULL ){
			return FALSE;
		}

		m_btnStart.Create(this, 10, 10, 100, 25, IDC_START_BTN, _T("START"));
		m_btnStart.SetFont();

		m_ListBox.Create(this, 10, 30, 200, 200, IDC_LISTBOX);
		m_ListBox.SetFont();

		cmd.Initialize( this );
		cmd.Register( IDC_START_BTN, &CMainForm::OnStartBatch );

		msg.Initialize( this );
		msg.Register( WM_APP_COMPLETED, &CMainForm::OnCompleted );

		return TRUE;
	}
Esempio n. 19
0
void CGeneralMsgBox::CreateBtns()
{
  // The minimum button's dimension
  m_dimBtn = CSize(FromDlgX(m_aMetrics[CX_MIN_BTN]), 0);

  // DC and Font for use in some dimension calculations
  CClientDC dc(this);

  CFont *pWndFont = GetFont();
  CFont *poldFont = dc.SelectObject(pWndFont);

  CRect rcDummy; // dimesion doesn't matter here

  INT_PTR cBtns = m_aBtns.GetSize();

  for (int i = 0; i < cBtns; ++i) {
    BTNDATA &btndata = m_aBtns[i];

    // Finding the minimum dimension needed to properly show any button
    CSize dimBtn = dc.GetTextExtent(btndata.strBtn);

    m_dimBtn.cx = max(m_dimBtn.cx, dimBtn.cx);
    m_dimBtn.cy = max(m_dimBtn.cy, dimBtn.cy);

    // Creating the button with MFC's CButton help.
    CButton btnCtrl;

    btnCtrl.Create(btndata.strBtn,
                   WS_CHILD|WS_VISIBLE|WS_TABSTOP,
                   rcDummy, this, btndata.uiIDC);
    btnCtrl.SetFont(pWndFont);
    btnCtrl.UnsubclassWindow();
  }

  dc.SelectObject(poldFont);

  // Add the button margins
  m_dimBtn.cx += 2 * FromDlgX(m_aMetrics[CX_BTN_BORDER]);
  m_dimBtn.cy += 2 * FromDlgY(m_aMetrics[CY_BTN_BORDER]);
}
Esempio n. 20
0
LRESULT CFolderInputDialog::WndProc(HWND window, UINT msg, WPARAM wp, LPARAM lp)
{
	static CButton btn_dir, btn_ok, btn_cancel;
	static CEditBox edit_dir;
	static CLabel label_dir;

	switch (msg)
	{
		case WM_INITDIALOG:
		{
			// Allow D&D (Drag & Drop)
			DragAcceptFiles(window, TRUE);

			UINT id = 10000;
			int x = 10;
			int y = -10;

			SetWindowText(window, _T("Select a destination"));

			label_dir.Create(window, _T("Input folder name"), id++, x, y += 20, 100, 20);
			edit_dir.Create(window, m_save_dir, id++, x, y += 20, 300, 22);
			btn_dir.Create(window, _T("Browse"), id++, x + 300, y + 1, 40, 20);

			btn_ok.Create(window, _T("OK"), IDOK, 110, y += 30, 70, 23);
			btn_cancel.Create(window, _T("Cancel"), IDCANCEL, 190, y, 70, 23);

			edit_dir.SetFocus();
			btn_ok.SetDef();

			Init(380, y + 60);

			return FALSE;
		}

		case WM_DROPFILES:
		{
			TCHAR save_dir[_MAX_DIR];
			HDROP drop = reinterpret_cast<HDROP>(wp);
			DragQueryFile(drop, 0, save_dir, sizeof(save_dir));
			edit_dir.SetText(save_dir);
			return FALSE;
		}

		case WM_COMMAND:

			//  Browse button is pressed
			if (LOWORD(wp) == btn_dir.GetID())
			{
				TCHAR save_dir[_MAX_DIR];
				lstrcpy(save_dir, m_save_dir);
				CFolderDialog folder_dialog;
				if (folder_dialog.DoModal(window, _T("Select a folder"), save_dir) == TRUE)
					edit_dir.SetText(save_dir);
				return FALSE;
			}

			// OK button is pressed
			if (LOWORD(wp) == IDOK)
			{
				edit_dir.GetText(m_save_dir, _MAX_DIR);
				PathRemoveBackslash(m_save_dir);
				EndDialog(window, IDOK);
				return TRUE;
			}

			// Cancel button is pressed
			if (LOWORD(wp) == IDCANCEL)
			{
				EndDialog(window, IDCANCEL);
				return TRUE;
			}

			return FALSE;
	}

	return FALSE;
}
Esempio n. 21
0
//creates the appropriate controls for a property
void CPropertyWnd::CreatePropertyControls(CPackerProperty* pProp, uint32 nProp, uint32 nID, const CRect& rOrigArea)
{
	ASSERT(pProp);

	//flags for all controls
	DWORD nBaseFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;

	//a working area rectangle
	CRect rArea(rOrigArea);

	switch(pProp->GetType())
	{
	case PROPERTY_REAL:
		{
			//create the edit box for editing the number
			CEdit* pNewEdit = new CEdit;
			if(pNewEdit)
			{
				pNewEdit->CreateEx(WS_EX_CLIENTEDGE, "Edit", "", nBaseFlags | ES_AUTOHSCROLL, 
									rArea.left, rArea.top, rArea.Width(), rArea.Height(),
									GetSafeHwnd(), (HMENU)nID);

				CPackerRealProperty* pReal = (CPackerRealProperty*)pProp;

				//set the default
				CString sText;
				sText.Format((pReal->IsInteger()) ? "%.0f" : "%.2f", pReal->GetValue());
				pNewEdit->SetWindowText(sText);

				//save it in the list
				m_pPropControl[nProp][0] = pNewEdit;

				//setup the tooltip
				m_ToolTip.AddWindowTool(pNewEdit, pProp->GetHelp());
			}
		}
		break;
	case PROPERTY_STRING:
		{
			CPackerStringProperty* pString = (CPackerStringProperty*)pProp;

			//rectangle for the edit control
			CRect rEditArea(rArea);

			//see if this is going to be a filename
			if(pString->IsFilename())
			{
				rEditArea.DeflateRect(0, 0, BROWSE_BUTTON_WIDTH, 0);
			}

			//create the edit box for editing the string
			CEdit* pNewEdit = new CEdit;
			if(pNewEdit)
			{
				pNewEdit->CreateEx(WS_EX_CLIENTEDGE, "Edit", "", nBaseFlags | ES_AUTOHSCROLL, 
									rEditArea.left, rEditArea.top, 
									rEditArea.Width(), rEditArea.Height(),
									GetSafeHwnd(), (HMENU)nID);

				//set the default
				pNewEdit->SetWindowText(pString->GetValue());

				//save it in the list
				m_pPropControl[nProp][0] = pNewEdit;
			}

			//setup the tooltip
			m_ToolTip.AddWindowTool(pNewEdit, pProp->GetHelp());

			//create the browse button if needed
			if(pString->IsFilename())
			{
				CButton* pNewButton = new CButton;
				if(pNewButton)
				{
					pNewButton->Create("...", nBaseFlags, CRect(rEditArea.right, rArea.top, rArea.right, rArea.bottom), this, nID + 1);
					m_pPropControl[nProp][1] = pNewButton;

					//setup the button's tooltip
					m_ToolTip.AddWindowTool(pNewButton, IDS_TOOLTIP_BROWSE_FOR_FILE);
				}					
			}
		}
		break;
	case PROPERTY_ENUM:
		{
			//create the combo box for the drop down of selections
			CComboBox* pNewCombo = new CComboBox;
			if(pNewCombo)
			{
				CPackerEnumProperty* pEnum = (CPackerEnumProperty*)pProp;

				CRect rFullArea(rArea);
				rFullArea.InflateRect(0, 0, 0, PROPERTY_HEIGHT * min(3, pEnum->GetNumItems()));

				pNewCombo->Create(nBaseFlags | CBS_DROPDOWNLIST, rFullArea, this, nID);

				//add the items
				for(uint32 nCurrItem = 0; nCurrItem < pEnum->GetNumItems(); nCurrItem++)
				{
					pNewCombo->InsertString(nCurrItem, pEnum->GetItem(nCurrItem));
				}

				//select the item
				pNewCombo->SetCurSel(pEnum->GetSelection());

				//save it in the list
				m_pPropControl[nProp][0] = pNewCombo;

				//setup the tooltip
				m_ToolTip.AddWindowTool(pNewCombo, pProp->GetHelp());
			}
		}
		break;
	case PROPERTY_BOOL:
		{
			//create a check box for checking/unchecking items
			CButton* pNewButton = new CButton;
			if(pNewButton)
			{
				pNewButton->Create("", nBaseFlags | BS_AUTOCHECKBOX, rArea, this, nID); 
				m_pPropControl[nProp][0] = pNewButton;

				//init the default value
				CPackerBoolProperty* pBoolProp = (CPackerBoolProperty*)pProp;
				pNewButton->SetCheck(pBoolProp->GetValue() ? 1 : 0);
		
				//setup the tooltip
				m_ToolTip.AddWindowTool(pNewButton, pProp->GetHelp());
			}
		}
		break;
	case PROPERTY_INTERFACE:
		{
			CPackerInterfaceProperty* pIntf = (CPackerInterfaceProperty*)pProp;

			DWORD nTextStyle	= 0;
			bool  bDisplayName	= true;

			switch(pIntf->GetInterfaceType())
			{
			case CPackerInterfaceProperty::TEXT_LEFT:
				nTextStyle = SS_LEFT;
				break;
			case CPackerInterfaceProperty::TEXT_RIGHT:
				nTextStyle = SS_RIGHT;
				break;
			case CPackerInterfaceProperty::TEXT_CENTER:
				nTextStyle = SS_CENTER;
				break;
			case CPackerInterfaceProperty::SEPARATOR:
				nTextStyle = SS_GRAYFRAME;
				bDisplayName = false;
				rArea.bottom -= rArea.Height() * 3 / 4;
				break;
			default:
				break;
			}

			if(pIntf->GetInterfaceType() != CPackerInterfaceProperty::BLANK)
			{
				CStatic* pStatic = new CStatic;
				if(pStatic)
				{
					if(bDisplayName)
					{
						rArea.top = rArea.bottom - GetAbsoluteFontHeight();
					}

					pStatic->Create(bDisplayName ? pProp->GetName() : "", nBaseFlags | nTextStyle, rArea, this, nID); 
					m_pPropControl[nProp][0] = pStatic;
				}
			}
		}
		break;
	default:
		ASSERT(FALSE);
		break;
	}

	//setup the fonts for all the new properties
	for(uint32 nCurrCtrl = 0; nCurrCtrl < MAX_CONTROLS_PER_PROP; nCurrCtrl++)
	{
		if(m_pPropControl[nProp][nCurrCtrl])
		{
			m_pPropControl[nProp][nCurrCtrl]->SetFont(&m_Font);
		}
	}
}
Esempio n. 22
0
LRESULT COption::SusieProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
	static CFolderDialog FolderDlg;
	static SOption* pOption = &m_option_tmp;

	static CCheckBox SusieCheckUse, SusieCheckFirst;
	static CLabel SusieLabelDir;
	static CEditBox SusieEditDir;
  static CButton SusieBtnDir, SusieBtnUpdate;
  static std::array<CButton, 2> SusieBtn;
	static CSusieListView SusieListView;
	static CSusie susie;

	switch (msg)
	{
		case WM_INITDIALOG:
		{
			UINT ID = 10000;
			const int x = 10;
			const int xx = 15;
			int y = 0;

			SusieCheckUse.Create(hWnd, _T("Use Susie Plugins"), ID++, x + 15, y += 20, 200, 20);
			SusieCheckUse.SetCheck(pOption->bSusieUse);

			SusieLabelDir.Create(hWnd, _T("Susie Folder"), ID++, x + xx, y += 24, 75, 20);
			SusieEditDir.Create(hWnd, pOption->SusieDir, ID++, x + xx + 75, y - 4, 200, 22);
			SusieEditDir.Enable(pOption->bSusieUse);
			SusieBtnDir.Create(hWnd, _T("Browse"), ID++, x + xx + 280, y - 3, 50, 20);
			SusieBtnDir.Enable(pOption->bSusieUse);

			SusieCheckFirst.Create(hWnd, _T("Give Susie plugins priority when decoding"), ID++, x + xx, y += 20, 250, 20);
			SusieCheckFirst.SetCheck(pOption->bSusieFirst);
			SusieCheckFirst.Enable(pOption->bSusieUse);

			SusieListView.Create(hWnd, *pOption, x + xx, y += 30, 500, 190);
			SusieListView.Close();
			SusieListView.Enable(pOption->bSusieUse);
			SusieListView.Show();

			SusieBtnUpdate.Create(hWnd, _T("Update"), ID++, x + 290, y += 200, 50, 20);
			SusieBtnUpdate.Enable(pOption->bSusieUse);
			SusieBtn[0].Create(hWnd, _T("All ON"), ID++, x + 350, y, 80, 20);
			SusieBtn[0].Enable(pOption->bSusieUse);
			SusieBtn[1].Create(hWnd, _T("All OFF"), ID++, x + 430, y, 80, 20);
			SusieBtn[1].Enable(pOption->bSusieUse);

			break;
		}

		case WM_COMMAND:
			// Use Susie plugins
			if (LOWORD(wp) == SusieCheckUse.GetID())
			{
				const BOOL flag = SusieCheckUse.GetCheck();
				SusieEditDir.Enable(flag);
				SusieBtnDir.Enable(flag);
				SusieCheckFirst.Enable(flag);
				SusieListView.Enable(flag);
				SusieBtnUpdate.Enable(flag);
				SusieBtn[0].Enable(flag);
				SusieBtn[1].Enable(flag);
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				// Click here to show / hide the list of checkboxes, de-selected state
				pOption->bSusieUse = flag;
				SusieListView.SetItemSelAll(0);
				break;
			}

			// Susie Folder Browse
			if (LOWORD(wp) == SusieBtnDir.GetID())
			{
				TCHAR szSusieDir[_MAX_DIR];
				SusieEditDir.GetText(szSusieDir, sizeof(szSusieDir));
				if (FolderDlg.DoModal(hWnd, _T("Select the Susie folder"), szSusieDir))
					SusieEditDir.SetText(szSusieDir);
			}

			// Give Susie plugins priority on decoding
			if (LOWORD(wp) == SusieCheckFirst.GetID())
			{
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// Update
			if (LOWORD(wp) == SusieBtnUpdate.GetID())
			{
				susie.LoadSpi(pOption->SusieDir);
				susie.Init();
				SusieListView.Show();
				SusieListView.Update();
				break;
			}

			// All ON
			if (LOWORD(wp) == SusieBtn[0].GetID())
			{
				SusieListView.SetCheckAll(true);
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// All OFF
			if (LOWORD(wp) == SusieBtn[1].GetID())
			{
				SusieListView.SetCheckAll(false);
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}

			// Settings
			if (LOWORD(wp) == IDM_SUSIE_SET)
			{
				const SSusieInfo* const susie_info = SusieListView.GetFocusSusieInfo();

				// Get ConfigurationDlg()
				const auto ConfigurationDlg = reinterpret_cast<ConfigurationDlgProc>(susie_info->plugin.GetProcAddress(_T("ConfigurationDlg")));

				if (ConfigurationDlg == nullptr)
					break;

				// Call settings
				ConfigurationDlg(hWnd, 1);

				break;
			}

			// Contents of the editbox have changed
			if (HIWORD(wp) == EN_CHANGE)
			{
				PropSheet_Changed(::GetParent(hWnd), hWnd);
				break;
			}
			break;

		case WM_NOTIFY:
		{
			const auto* const hdr = reinterpret_cast<LPNMHDR>(lp);

			switch (hdr->code)
			{
				// OK/Apply, Tabbing
				case PSN_APPLY:
				case PSN_KILLACTIVE:
					pOption->bSusieUse = SusieCheckUse.GetCheck();
					pOption->bSusieFirst = SusieCheckFirst.GetCheck();
					SusieEditDir.GetText(pOption->SusieDir);
					SusieListView.SaveIni();
					// OK/Apply
					if (hdr->code == PSN_APPLY)
					{
						const bool update = m_option.SusieDir == pOption->SusieDir;
						Apply();
						// Re-acquire plugin folder only when Susie has been changed
						if (pOption->bSusieUse && update)
						{
							susie.LoadSpi(pOption->SusieDir);
							susie.Init();
							SusieListView.Show();
							SusieListView.Update();
						}
					}
					return TRUE;
				// Check processing
				case NM_CLICK:
				case NM_DBLCLK:
					if (hdr->idFrom == idsSusieList)
					{
						if (SusieListView.SetCheck())
							PropSheet_Changed(::GetParent(hWnd), hWnd);
						break;
					}
			}

			// List view
			if (wp == idsSusieList)
			{
				const auto* const plv = reinterpret_cast<LPNMLISTVIEW>(lp);
				switch (plv->hdr.code)
				{
					// Custom draw
					case NM_CUSTOMDRAW:
						return SusieListView.CustomDraw(reinterpret_cast<LPNMLVCUSTOMDRAW>(lp));
					// Show tool tip
					case LVN_GETINFOTIP:
						SusieListView.ShowTip(reinterpret_cast<LPNMLVGETINFOTIP>(lp));
						break;
					// View
					case LVN_GETDISPINFO:
						SusieListView.Show(reinterpret_cast<NMLVDISPINFO*>(lp));
						break;
				}
			}

			break;
		}

		case WM_MOUSEWHEEL:
		{
			POINT pos;
			GetCursorPos(&pos);
			HWND pWnd = WindowFromPoint(pos);
			if (pWnd == SusieListView.GetHandle())
				SendMessage(pWnd, WM_MOUSEWHEEL, wp, lp);
			break;
		}

		// Right-click menu (Context menu)
		case WM_CONTEXTMENU:
		{
			if (wp == reinterpret_cast<WPARAM>(SusieListView.GetHandle()))
				SusieListView.CreateMenu(lp);
			break;
		}
	}

	return FALSE;
}
Esempio n. 23
0
void CRoom::draw()
{
	POSITION pos;
	CButton* Button;
	CStatic* staticText;
	CString btnText[2];
	CDevice* tmpDevice;
	int top = 10;
	int bottom = 30;
	int i = 0;
	int countButtonID = 3001;
	int countStaticID = 2001;
	CObList* list = phandleData->get_deviceList();
	for (pos = list->GetHeadPosition(); pos != NULL;)
	{	
		tmpDevice = (CDevice*)list->GetNext(pos);
		if(tmpDevice->get_room() != room)
			continue;
		if(tmpDevice->get_typ() == _T("fs20rsu"))
		{
			btnText[0] = _T("Auf");
			btnText[1] = _T("Ab");
		}
		else
		{
			btnText[0] = _T("An");
			btnText[1] = _T("Aus");
		}
		staticText = new CStatic();
		DWORD dwStyleStatic  = WS_EX_STATICEDGE;
		staticText->Create(tmpDevice->get_name(),dwStyleStatic,CRect(10,top,260,bottom),this,countStaticID);
		staticText->ShowWindow(TRUE);

		Button = new CButton();
		DWORD dwStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
		Button->Create(btnText[0], dwStyle, CRect(300,top,340,bottom), this, countButtonID);
		Button->ShowWindow(TRUE);
		Button = NULL;
		buttonIDs[i][i] = countButtonID;
		countButtonID++;

		Button = new CButton();
		Button->Create(btnText[1], dwStyle, CRect(360,top,400,bottom), this, countButtonID);
		Button->ShowWindow(TRUE);
		Button = NULL;
		buttonIDs[i][i+1] = countButtonID;
		countButtonID++;

		Button = new CButton();
		Button->Create(_T("Details"), dwStyle, CRect(420,top,480,bottom), this, countButtonID);
		Button->ShowWindow(TRUE);
		Button = NULL;
		buttonIDs[i][i+2] = countButtonID;

		top += 30;
		bottom += 30;
		staticText = NULL;
		countButtonID++;
		countStaticID++;
		i++;
	}
}
Esempio n. 24
0
BOOL CBaseDlg::OnInitDialog()
{
	//CDialog::OnInitDialog();
	if (m_hIcon)
	{
		SetIcon(m_hIcon, TRUE);   // 设置大图标
		SetIcon(m_hIcon, FALSE);  // 设置小图标
	}

	m_bInit = TRUE;

	for (int i = 0; i < m_vecCtrl.size(); i++)
	{
		switch (m_vecCtrl[i].type)
		{
		case BASE_BUTTON:
		case BASE_CHECK_BUTTON:
		{
			CButton* pCtrl = (CButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_COMMOM_BUTTON:
		{
			CCommonButton* pCtrl = (CCommonButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_STATIC:
		{
			CStatic* pCtrl = (CStatic*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_MY_CHECK_BUTTON:
		{
			CMyCheckButton* pCtrl = (CMyCheckButton*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_INDICATOR:
		{
			CIndicator* pCtrl = (CIndicator*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_GROUPBOX:
		{
			CGroupBox* pCtrl = (CGroupBox*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_EDIT_CSTRING:
		case BASE_EDIT_DOUBLE:
		{
			CEdit* pCtrl = (CEdit*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			break;
		}
		case BASE_COLOR_TEXT:
		{
			CColorText* pCtrl = (CColorText*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle,
				m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_DRAWVIEW:
		{
			CDrawView* pCtrl = (CDrawView*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_LIST:
		{
			CListCtrl* pCtrl = (CListCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_TABVIEW:
		{
			CTabViewCtrl* pCtrl = (CTabViewCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_GRADIENT_BACKGROUND:
		{
			CGradientBackground* pCtrl = (CGradientBackground*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			break;
		}
		case BASE_COMBOBOX:
		{
			CComboBox* pCtrl = (CComboBox*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			pCtrl->SetFont(&mFont);
			CString caption = m_vecCtrl[i].sCaption;
			for (int j = 0; j < m_vecCtrl[i].nDataCount; j++)
			{
				int endpos = caption.Find(L"\n");
				CString item = caption.Mid(0, endpos);
				pCtrl->AddString(item);
				caption = caption.Right(caption.GetLength()-endpos-1);
			}
			pCtrl->SetCurSel(0);
			break;
		}
		case BASE_PROGRESS:
		{
			CProgressCtrl* pCtrl = (CProgressCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData != NULL)
			{
				pCtrl->SetRange32((int)m_vecCtrl[i].dMinVal,(int)m_vecCtrl[i].dMaxVal);
			}
			break;
		}
		case BASE_SLIDER:
		{
			CSliderCtrl* pCtrl = (CSliderCtrl*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData != NULL)
			{
				pCtrl->SetRangeMax((int)m_vecCtrl[i].dMaxVal);
				pCtrl->SetRangeMin((int)m_vecCtrl[i].dMinVal);
			}
			break;
		}
		case BASE_SLIDER_GROUP:
		{
			CSliderGroup* pCtrl = (CSliderGroup*)m_vecCtrl[i].pCtrl;
			pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID);
			if (m_vecCtrl[i].pInOutData!=NULL)
			{
				pCtrl->GetSlider()->SetRangeMax((int)m_vecCtrl[i].dMaxVal);
				pCtrl->GetSlider()->SetRangeMin((int)m_vecCtrl[i].dMinVal);
			}
			break;
		}
		default:
			break;
		}
	}
	UpdateData(FALSE);
	return TRUE;
}
Esempio n. 25
0
LRESULT EmoticonsDlg::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	ShowWindow(SW_HIDE);
	WNDPROC temp = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(EmoticonsDlg::m_hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(NewWndProc)));
	if (!g_MFCWndProc)
		g_MFCWndProc = temp;
	g_pDialog = this;
	::EnableWindow(WinUtil::g_mainWnd, true);
	
	bool bUseAnimation = BOOLSETTING(SMILE_SELECT_WND_ANIM_SMILES);
	
	if (CAGEmotionSetup::g_pEmotionsSetup)
	{
		const CAGEmotion::Array& Emoticons = CAGEmotionSetup::g_pEmotionsSetup->getEmoticonsArray();
		unsigned int pocet = 0;
		int l_count_emotion = 0;
		string lastEmotionPath, lastAnimEmotionPath;
		for (auto pEmotion = Emoticons.cbegin();
		        pEmotion != Emoticons.cend() && l_count_emotion < CAGEmotionSetup::g_pEmotionsSetup->m_CountSelEmotions;
		        ++pEmotion, ++l_count_emotion)
		{
			if (bUseAnimation)
			{
				if ((*pEmotion)->getEmotionBmpPath() != lastEmotionPath || (*pEmotion)->getEmotionGifPath() != lastAnimEmotionPath)
					pocet++;
					
				lastEmotionPath = (*pEmotion)->getEmotionBmpPath();
				lastAnimEmotionPath = (*pEmotion)->getEmotionGifPath();
			}
			else
			{
				if ((*pEmotion)->getEmotionBmpPath() != lastEmotionPath)
					pocet++;
				lastEmotionPath = (*pEmotion)->getEmotionBmpPath();
			}
		}
		
		// x, y jen pro for cyklus
		const unsigned int l_Emoticons_size = CAGEmotionSetup::g_pEmotionsSetup->m_CountSelEmotions;
		unsigned int i = (unsigned int)sqrt(double(l_Emoticons_size));
		unsigned int nXfor = i;
		unsigned int nYfor = i;
		
		if ((i * i) != l_Emoticons_size) //[+]PPA
		{
			nXfor = i + 1;
			if ((i * nXfor) < l_Emoticons_size) nYfor = i + 1;
			else nYfor = i;
		}
		// x, y pro korektni vkladani ikonek za sebou
		i = (unsigned int)sqrt((double)pocet);
		unsigned int nX = i;
		unsigned int nY = i;
		if ((i * i) != pocet) //[+]PPA
		{
			nX = i + 1;
			if ((i * nX) < pocet) nY = i + 1;
			else nY = i;
		}
		if (Emoticons.empty() || !*Emoticons.begin()) //[+]PPA
			return 0;
			
		// [~] brain-ripper
		// If first icon failed to load, h_bm will be zero, and all icons will be drawn extremely small.
		// So cycle through Emoticons and find first loaded icon.
		//HBITMAP h_bm = (*Emoticons.begin())->getEmotionBmp(GetSysColor(COLOR_BTNFACE));
		
		DWORD iSW = 0, iSH = 0, dwCount = 0;
		l_count_emotion = 0;
		for (auto i = Emoticons.cbegin(); i != Emoticons.cend() && l_count_emotion < CAGEmotionSetup::g_pEmotionsSetup->m_CountSelEmotions; ++i, ++l_count_emotion)
		{
			int w = 0, h = 0;
			CGDIImage *pImage = nullptr;
			
			if (bUseAnimation)
				pImage = (*i)->getAnimatedImage(MainFrame::getMainFrame()->m_hWnd, WM_ANIM_CHANGE_FRAME);
				
			if (pImage)
			{
				w = pImage->GetWidth();
				h = pImage->GetHeight();
				dwCount++;
			}
			else
			{
				if ((*i)->getDimensions(&w, &h))
				{
					if (bUseAnimation)
						dwCount++;
					else
					{
						iSW = w;
						iSH = h;
						break;
					}
				}
			}
			
			iSW += w * w;
			iSH += h * h;
		}
		
		if (bUseAnimation && dwCount)
		{
			// Get mean square of all icon dimensions
			iSW = DWORD(sqrt(float(iSW / dwCount)));
			iSH = DWORD(sqrt(float(iSH / dwCount)));
		}
		
		pos.bottom = pos.top - 3;
		pos.left = pos.right - nX * (iSW + EMOTICONS_ICONMARGIN) - 2;
		pos.top = pos.bottom - nY * (iSH + EMOTICONS_ICONMARGIN) - 2;
		
		// [+] brain-ripper
		// Fit window in screen's work area
		RECT rcWorkArea;
		SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
		if (pos.right > rcWorkArea.right)
		{
			pos.left -= pos.right - rcWorkArea.right;
			pos.right = rcWorkArea.right;
		}
		if (pos.bottom > rcWorkArea.bottom)
		{
			pos.top -= pos.bottom - rcWorkArea.bottom;
			pos.bottom = rcWorkArea.bottom;
		}
		if (pos.left < rcWorkArea.left)
		{
			pos.right += rcWorkArea.left - pos.left;
			pos.left = rcWorkArea.left;
		}
		if (pos.top < rcWorkArea.top)
		{
			pos.bottom += rcWorkArea.top - pos.top;
			pos.top = rcWorkArea.top;
		}
		
		MoveWindow(pos);
		
		lastEmotionPath.clear();
		lastAnimEmotionPath.clear();
		
		m_ctrlToolTip.Create(EmoticonsDlg::m_hWnd, rcDefault, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_BALLOON, WS_EX_TOPMOST);
		m_ctrlToolTip.SetDelayTime(TTDT_AUTOMATIC, 1000);
		
		pos.left = 0;
		pos.right = iSW + EMOTICONS_ICONMARGIN;
		pos.top = 0;
		pos.bottom = iSH + EMOTICONS_ICONMARGIN;
		
		cleanHandleList();
		auto l_Emotion = Emoticons.begin();
		for (unsigned int iY = 0; iY < nYfor; iY++)
			for (unsigned int iX = 0; iX < nXfor; iX++)
			{
				if (l_Emotion != Emoticons.end()) // TODO - merge
				{
				
					const auto i = *l_Emotion;
					if ((iY * nXfor) + iX + 1 > l_Emoticons_size) break;
					
					bool bNotDuplicated = (bUseAnimation ?
					                       (i->getEmotionBmpPath() != lastEmotionPath ||
					                        i->getEmotionGifPath() != lastAnimEmotionPath) :
					                       i->getEmotionBmpPath() != lastEmotionPath);
					                       
					                       
					// dve stejne emotikony za sebou nechceme
					if (bNotDuplicated)
					{
						bool bCreated = false;
						CGDIImage *pImage = nullptr;
						
						if (bUseAnimation)
							pImage = i->getAnimatedImage(MainFrame::getMainFrame()->m_hWnd, WM_ANIM_CHANGE_FRAME);
							
						if (pImage)
						{
							const tstring smajl = i->getEmotionText();
							CAnimatedButton *pemoButton = new CAnimatedButton(pImage);
							m_BtnList.push_back(pemoButton);
							pemoButton->Create(EmoticonsDlg::m_hWnd, pos, smajl.c_str(), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_FLAT | BS_BITMAP, WS_EX_TRANSPARENT);
							m_ctrlToolTip.AddTool(*pemoButton, smajl.c_str());
							bCreated = true;
						}
						else
						{
							if (const HBITMAP l_h_bm = i->getEmotionBmp(GetSysColor(COLOR_BTNFACE)))
							{
								CButton emoButton;
								const tstring smajl = i->getEmotionText();
								emoButton.Create(EmoticonsDlg::m_hWnd, pos, smajl.c_str(), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_FLAT | BS_BITMAP | BS_CENTER);
								m_HandleList.push_back(l_h_bm);
								emoButton.SetBitmap(l_h_bm);
								m_ctrlToolTip.AddTool(emoButton, smajl.c_str());
								DeleteObject((HGDIOBJ)emoButton);
								bCreated = true;
							}
						}
						
						if (bCreated)
						{
							// Calculate position of next button
							pos.left = pos.left + iSW + EMOTICONS_ICONMARGIN;
							pos.right = pos.left + iSW + EMOTICONS_ICONMARGIN;
							if (pos.left >= (LONG)(nX * (iSW + EMOTICONS_ICONMARGIN)))
							{
								pos.left = 0;
								pos.right = iSW + EMOTICONS_ICONMARGIN;
								pos.top = pos.top + iSH + EMOTICONS_ICONMARGIN;
								pos.bottom = pos.top + iSH + EMOTICONS_ICONMARGIN;
							}
						}
					}
					
					lastEmotionPath = i->getEmotionBmpPath();
					
					if (bUseAnimation)
						lastAnimEmotionPath = i->getEmotionGifPath();
					++l_Emotion;
				}
			}
			
		pos.left = -128;
		pos.right = pos.left;
		pos.top = -128;
		pos.bottom = pos.top;
		CButton emoButton;
		emoButton.Create(EmoticonsDlg::m_hWnd, pos, _T(""), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_FLAT);
		emoButton.SetFocus();
		DeleteObject((HGDIOBJ)emoButton);
		ShowWindow(SW_SHOW);
		
		for (auto i = m_BtnList.cbegin(); i != m_BtnList.cend(); ++i)
		{
			(*i)->Update();
		}
	}
	else PostMessage(WM_CLOSE);
	
	return 0;
}