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
}
예제 #2
0
BOOL CQSV2FLVDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码
	CString szTitle = _T("QSV2FLV ");
	szTitle += STR_VERSION;
	SetWindowText(szTitle);
	m_bmpFold.LoadBitmap(IDB_BITMAP1);
	CButton* pCtrl = (CButton*)GetDlgItem(IDC_BTN_PATH);
	pCtrl->SetBitmap(m_bmpFold);

	//设置列表
	m_ctrlList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
	//插入列,序号,名称,对齐,列宽
	m_ctrlList.InsertColumn(1,_T("序号"),LVCFMT_CENTER, 36);  
	m_ctrlList.InsertColumn(1,_T("文件"),LVCFMT_LEFT,400);  
	m_ctrlList.InsertColumn(2,_T("状态"),LVCFMT_LEFT,80);

	//初始化工作线程
	m_pWorkThread = ::GetWorkThread();
	m_pWorkThread->SetHandleWnd(this);

	SetWindowPos(&CWnd::wndTopMost, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);

	PostMessage(WM_TIMER, 0, 0);
	return TRUE;
}
예제 #3
0
BOOL CPasswordSubsetDlg::OnInitDialog()
{
  CPWDialog::OnInitDialog();
  
  Fonts::GetInstance()->ApplyPasswordFont(GetDlgItem(IDC_SUBSETRESULTS));

  // Place dialog where user had it last
  CRect rect, dlgRect;
  GetWindowRect(&dlgRect);
  PWSprefs::GetInstance()->GetPrefPSSRect(rect.top, rect.bottom, 
                                          rect.left, rect.right);

  HRGN hrgnWork = GetWorkAreaRegion();
  // also check that window will be visible
  if ((rect.top == -1 && rect.bottom == -1 && rect.left == -1 && rect.right == -1) || !RectInRegion(hrgnWork, rect)){
    rect = dlgRect;
  }
  ::DeleteObject(hrgnWork);
  // Ignore size just set position
  SetWindowPos(NULL, rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

  m_pToolTipCtrl = new CToolTipCtrl;
  if (!m_pToolTipCtrl->Create(this, TTS_BALLOON | TTS_NOPREFIX)) {
    pws_os::Trace(L"Unable To create CManagePSWDPols Dialog ToolTip\n");
    delete m_pToolTipCtrl;
    m_pToolTipCtrl = NULL;
  } else {
    EnableToolTips(TRUE);

    // Delay initial show & reshow
    int iTime = m_pToolTipCtrl->GetDelayTime(TTDT_AUTOPOP);
    m_pToolTipCtrl->SetDelayTime(TTDT_AUTOPOP, iTime * 4);
    m_pToolTipCtrl->Activate(TRUE);
    m_pToolTipCtrl->SetMaxTipWidth(500);
    AddTool(IDC_COPYPASSWORD, IDS_CLICKTOCOPYGENPSWD);
  }

  // Load bitmap
  UINT nImageID = PWSprefs::GetInstance()->GetPref(PWSprefs::UseNewToolbar) ?
                     IDB_COPYPASSWORD_NEW : IDB_COPYPASSWORD_CLASSIC;

  BOOL brc = m_CopyPswdBitmap.Attach(::LoadImage(
                                                 ::AfxFindResourceHandle(MAKEINTRESOURCE(nImageID), RT_BITMAP),
                                                 MAKEINTRESOURCE(nImageID), IMAGE_BITMAP, 0, 0,
                                                 (LR_DEFAULTSIZE | LR_CREATEDIBSECTION | LR_SHARED)));

  ASSERT(brc);
  if (brc) {
    FixBitmapBackground(m_CopyPswdBitmap);

    CButton *pBtn = (CButton *)GetDlgItem(IDC_COPYPASSWORD);
    ASSERT(pBtn != NULL);
    if (pBtn != NULL)
      pBtn->SetBitmap(m_CopyPswdBitmap);
  }
  ShowWindow(SW_SHOW);
  return TRUE;
}
예제 #4
0
파일: Dialog.cpp 프로젝트: ch3n2k/rss
BOOL CCanvasRotateDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

		
	BmpAnti90.LoadBitmap(IDB_BITMAP_ANTI90);
	Bmp180.LoadBitmap(IDB_BITMAP_180);
	BmpClock90.LoadBitmap(IDB_BITMAP_CLOCK90);
	CButton *pButton = (CButton*)GetDlgItem(IDC_BUTTON_ANTI90);
	pButton->SetBitmap((HBITMAP)BmpAnti90.GetSafeHandle());
	pButton = (CButton*)GetDlgItem(IDC_BUTTON_CLOCK90);
	pButton->SetBitmap((HBITMAP)BmpClock90.GetSafeHandle());
	pButton = (CButton*)GetDlgItem(IDC_BUTTON_180);
	pButton->SetBitmap((HBITMAP)Bmp180.GetSafeHandle());

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
예제 #5
0
void CImageViewerBar::InitButtonBitmap()
	{
		UINT i = 0;
		CButton *pBut = NULL;
		for (i = 0; i < 6; i++)
		{
			pBut = (CButton *)GetDlgItem(IDC_BUT1+i);
			ASSERT(NULL != pBut);
			pBut->SetBitmap(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1+i)));
		}
	}
예제 #6
0
void CLightDlg::ColorButtons() {
	CRect r;

	CClientDC dc(this);
	
	CButton *pBtn = (CButton *)GetDlgItem(IDC_BTN_COLOR);
	pBtn->GetClientRect(&r);
	colorBitmap.DeleteObject();
	colorBitmap.CreateCompatibleBitmap(&dc, r.Width(), r.Height());
	CDC MemDC;
	MemDC.CreateCompatibleDC(&dc);
	CBitmap *pOldBmp = MemDC.SelectObject(&colorBitmap);
	{
		CBrush br(RGB(color[0], color[1], color[2])); 
		MemDC.FillRect(r,&br);
	}
	dc.SelectObject(pOldBmp);
	pBtn->SetBitmap(HBITMAP(colorBitmap)); 
}
예제 #7
0
BOOL CAVCameraDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标


	CButton* pButton = (CButton*)GetDlgItem(IDC_BUTTON_START);
	ASSERT(pButton);
	pButton->ModifyStyle(0, BS_BITMAP);
	pButton->SetBitmap(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_PNG_START)));

	// TODO: 在此添加额外的初始化代码
	_dc = GetDlgItem(IDC_VIDEO_PLAYBACK)->GetDC();

	_camera.refresh_sign.connect(boost::bind(&CAVCameraDlg::UpdateVideoFrame, this));
	UpdateStatus(VideoMgr::CREATED);

	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
예제 #8
0
BOOL CAddEdit_Basic::OnInitDialog()
{
  CAddEdit_PropertyPage::OnInitDialog();

  ModifyStyleEx(0, WS_EX_CONTROLPARENT);

  Fonts *pFonts = Fonts::GetInstance();
  pFonts->ApplyPasswordFont(GetDlgItem(IDC_PASSWORD));
  pFonts->ApplyPasswordFont(GetDlgItem(IDC_PASSWORD2));

  // Get Add/Edit font
  CFont *pFont = pFonts->GetAddEditFont();

  // Change font size of the group, title, username, URL & email fields
  m_ex_group.SetFont(pFont);
  m_ex_title.SetFont(pFont);
  m_ex_username.SetFont(pFont);
  m_ex_URL.SetFont(pFont);
  m_ex_email.SetFont(pFont);

  // Need to get change notifications
  m_ex_notes.SetEventMask(ENM_CHANGE | m_ex_notes.GetEventMask());

  // Set plain text - not that it seems to do much!
  m_ex_notes.SetTextMode(TM_PLAINTEXT);

  PWSprefs *prefs = PWSprefs::GetInstance();

  // Set Notes font!
  if (prefs->GetPref(PWSprefs::NotesFont).empty()) {
    m_ex_notes.SetFont(pFonts->GetCurrentFont());
  } else {
    m_ex_notes.SetFont(pFonts->GetNotesFont());
  }

  if (M_uicaller() != IDS_ADDENTRY) {
    InitToolTip();

    AddTool(IDC_STATIC_GROUP,    IDS_CLICKTOCOPY);
    AddTool(IDC_STATIC_TITLE,    IDS_CLICKTOCOPY);
    AddTool(IDC_STATIC_USERNAME, IDS_CLICKTOCOPY);
    AddTool(IDC_STATIC_PASSWORD, IDS_CLICKTOCOPY);
    AddTool(IDC_STATIC_NOTES,    IDS_CLICKTOCOPY);
    AddTool(IDC_STATIC_URL,      IDS_CLICKTOCOPY);
    AddTool(IDC_COPYPASSWORD,    IDS_CLICKTOCOPY);
    AddTool(IDC_STATIC_EMAIL,    IDS_CLICKTOCOPYPLUS1);
    AddTool(IDC_LAUNCH,          IDS_CLICKTOGOPLUS);
    AddTool(IDC_SENDEMAIL,       IDS_CLICKTOSEND);

    if (M_uicaller() == IDS_EDITENTRY && M_protected() != 0) {
      AddTool(IDC_STATIC_TUTORIAL, IDS_UNPROTECT);
    }

    ActivateToolTip();

    m_stc_group.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
    m_stc_title.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
    m_stc_username.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
    m_stc_password.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
    m_stc_notes.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
    m_stc_URL.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
    m_stc_email.SetHighlight(true, CAddEdit_PropertyPage::crefWhite);
  }

  m_ex_group.ChangeColour();
  GetDlgItem(IDC_LAUNCH)->EnableWindow(M_URL().IsEmpty() ? FALSE : TRUE);
  GetDlgItem(IDC_SENDEMAIL)->EnableWindow(M_email().IsEmpty() ? FALSE : TRUE);

  if (M_uicaller() == IDS_VIEWENTRY ||
      (M_uicaller() == IDS_EDITENTRY && M_protected() != 0)) {
    // Change 'OK' to 'Close' and disable 'Cancel'
    // "CancelToClose" disables the System Command SC_CLOSE
    // from clicking X on PropertySheet so have implemented
    // CAddEdit_PropertySheet::OnSysCommand to deal with it.
    CancelToClose();

    // Disable Group Combo
    GetDlgItem(IDC_GROUP)->EnableWindow(FALSE);

    // Disable normal Edit controls
    GetDlgItem(IDC_TITLE)->SendMessage(EM_SETREADONLY, TRUE, 0);
    GetDlgItem(IDC_USERNAME)->SendMessage(EM_SETREADONLY, TRUE, 0);
    GetDlgItem(IDC_PASSWORD)->SendMessage(EM_SETREADONLY, TRUE, 0);
    GetDlgItem(IDC_PASSWORD2)->SendMessage(EM_SETREADONLY, TRUE, 0);
    GetDlgItem(IDC_NOTES)->SendMessage(EM_SETREADONLY, TRUE, 0);
    GetDlgItem(IDC_URL)->SendMessage(EM_SETREADONLY, TRUE, 0);
    GetDlgItem(IDC_EMAIL)->SendMessage(EM_SETREADONLY, TRUE, 0);

    // Disable Button
    GetDlgItem(IDC_GENERATEPASSWORD)->EnableWindow(FALSE);
  }

  // Populate the combo box
  m_ex_group.ResetContent(); // groups might be from a previous DB (BR 3062758)

  // The core function "GetUniqueGroups(vGroups)" returns the group list by
  // going through the entries in the database. This will not include empty
  // groups.  However, we already maintain this list in the UI to save the
  // display status, so use this instead.
  std::vector<std::wstring> vGroups;
  GetMainDlg()->GetAllGroups(vGroups);

  for (std::vector<std::wstring>::iterator iter = vGroups.begin();
       iter != vGroups.end(); ++iter) {
    m_ex_group.AddString(iter->c_str());
  }

  // Make sure Group combobox is wide enough
  SetGroupComboBoxWidth();

  size_t num_unkwn(0);
  if (M_uicaller() != IDS_ADDENTRY)
    num_unkwn = M_pci()->NumberUnknownFields();

  if (num_unkwn > 0) {
    CString cs_text;
    cs_text.Format(IDS_RECORDUNKNOWNFIELDS, num_unkwn);
    GetDlgItem(IDC_RECORDUNKNOWNFIELDS)->SetWindowText(cs_text);
    GetDlgItem(IDC_RECORDUNKNOWNFIELDS)->ShowWindow(SW_SHOW);
    GetDlgItem(IDC_STATIC_RECORDUNKNOWNFIELDS)->ShowWindow(SW_SHOW);
    GetDlgItem(IDC_STATICGROUPRUNKNFLDS)->ShowWindow(SW_SHOW);
  } else {
    GetDlgItem(IDC_RECORDUNKNOWNFIELDS)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_STATIC_RECORDUNKNOWNFIELDS)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_STATICGROUPRUNKNFLDS)->ShowWindow(SW_HIDE);
  }

  // Note shortcuts have their own dialog for edit.
  CString cs_text;
  if (M_original_entrytype() == CItemData::ET_ALIASBASE ||
      M_original_entrytype() == CItemData::ET_SHORTCUTBASE) {
    // Show button to allow users to view dependents
    cs_text.LoadString(M_original_entrytype() == CItemData::ET_ALIASBASE ?
                       IDS_VIEWALIASESBTN : IDS_VIEWSHORTCUTSBTN);
    GetDlgItem(IDC_VIEWDEPENDENTS)->SetWindowText(cs_text);
    GetDlgItem(IDC_VIEWDEPENDENTS)->ShowWindow(SW_SHOW);

    cs_text.LoadString(M_original_entrytype() == CItemData::ET_ALIASBASE ?
                       IDS_ISANALIASBASE : IDS_ISASHORTCUTBASE);
    GetDlgItem(IDC_STATIC_ISANALIAS)->SetWindowText(cs_text);
    GetDlgItem(IDC_STATIC_ISANALIAS)->ShowWindow(SW_SHOW);
    GetDlgItem(IDC_MYBASE)->ShowWindow(SW_HIDE);
  } else if (M_original_entrytype() == CItemData::ET_ALIAS) {
    // Update password to alias form
    // Show text stating that it is an alias
    M_realpassword() = M_oldRealPassword() = m_password = m_password2 = M_base();
    GetDlgItem(IDC_VIEWDEPENDENTS)->ShowWindow(SW_HIDE);

    GetDlgItem(IDC_MYBASE)->SetWindowText(M_base());
    GetDlgItem(IDC_STATIC_ISANALIAS)->ShowWindow(SW_SHOW);
    GetDlgItem(IDC_MYBASE)->ShowWindow(SW_SHOW);
  } else if (M_original_entrytype() == CItemData::ET_NORMAL) {
    // Normal - do none of the above
    GetDlgItem(IDC_VIEWDEPENDENTS)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_STATIC_ISANALIAS)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_MYBASE)->ShowWindow(SW_HIDE);
  }

  if (prefs->GetPref(PWSprefs::ShowPWDefault)) {
    ShowPassword();
  } else {
    HidePassword();
  }

  if (prefs->GetPref(PWSprefs::ShowNotesDefault)) {
    ShowNotes();
  } else {
    HideNotes();
    m_ex_notes.EnableMenuItem(PWS_MSG_CALL_NOTESZOOMIN, false);
    m_ex_notes.EnableMenuItem(PWS_MSG_CALL_NOTESZOOMOUT, false);
  }

  CHARFORMAT cf = {0};
  cf.cbSize = sizeof(cf);

  m_ex_notes.SetSel(0, -1);
  m_ex_notes.SendMessage(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
  m_iPointSize = cf.yHeight / 20;

  // Set initial Word Wrap
  m_ex_notes.SetTargetDevice(NULL, m_bWordWrap ? 0 : 1);
  m_ex_notes.UpdateState(PWS_MSG_EDIT_WORDWRAP, m_bWordWrap);

  // Load copy password bitmap
  UINT nImageID = PWSprefs::GetInstance()->GetPref(PWSprefs::UseNewToolbar) ?
    IDB_COPYPASSWORD_NEW : IDB_COPYPASSWORD_CLASSIC;
  BOOL brc = m_CopyPswdBitmap.Attach(::LoadImage(
                                                 ::AfxFindResourceHandle(MAKEINTRESOURCE(nImageID), RT_BITMAP),
                                                 MAKEINTRESOURCE(nImageID), IMAGE_BITMAP, 0, 0,
                                                 (LR_DEFAULTSIZE | LR_CREATEDIBSECTION | LR_SHARED)));
  ASSERT(brc);
  if (brc) {
    FixBitmapBackground(m_CopyPswdBitmap);
    CButton *pBtn = (CButton *)GetDlgItem(IDC_COPYPASSWORD);
    ASSERT(pBtn != NULL);
    if (pBtn != NULL)
      pBtn->SetBitmap(m_CopyPswdBitmap);
  }
  UpdateData(FALSE);
  m_bInitdone = true;
  return TRUE;
}
예제 #9
0
BOOL CManagePSWDPols::OnInitDialog()
{
  CPWDialog::OnInitDialog();

  if (m_bReadOnly) {
    GetDlgItem(IDC_NEW)->EnableWindow(FALSE);
    GetDlgItem(IDC_DELETE)->EnableWindow(FALSE);

    // Hide cancel button & change OK button text
    GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
    GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);

    // Change button text
    CString cs_text(MAKEINTRESOURCE(IDS_CLOSE));
    GetDlgItem(IDOK)->SetWindowText(cs_text);
    cs_text.LoadString(IDS_VIEW);
    GetDlgItem(IDC_EDIT)->SetWindowText(cs_text);
  }

  m_pToolTipCtrl = new CToolTipCtrl;
  if (!m_pToolTipCtrl->Create(this, TTS_BALLOON | TTS_NOPREFIX)) {
    pws_os::Trace(L"Unable To create CManagePSWDPols Dialog ToolTip\n");
    delete m_pToolTipCtrl;
    m_pToolTipCtrl = NULL;
  } else {
    EnableToolTips(TRUE);

    // Delay initial show & reshow
    int iTime = m_pToolTipCtrl->GetDelayTime(TTDT_AUTOPOP);
    m_pToolTipCtrl->SetDelayTime(TTDT_AUTOPOP, iTime * 4);
    m_pToolTipCtrl->Activate(TRUE);
    m_pToolTipCtrl->SetMaxTipWidth(500);

    CString cs_ToolTip(MAKEINTRESOURCE(IDS_NEWPOLICY));
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_NEW), cs_ToolTip);
    cs_ToolTip.LoadString(IDS_DELETEPOLICY);
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_DELETE), cs_ToolTip);
    cs_ToolTip.LoadString(IDS_EDITPOLICY);
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_EDIT), cs_ToolTip);
    cs_ToolTip.LoadString(IDS_UNDOPOLICY);
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_UNDO), cs_ToolTip);
    cs_ToolTip.LoadString(IDS_REDOPOLICY);
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_REDO), cs_ToolTip);
    cs_ToolTip.LoadString(IDS_LISTPOLICY);
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_LIST_POLICYENTRIES), cs_ToolTip);
    cs_ToolTip.LoadString(IDS_TESTPOLICY);
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_GENERATEPASSWORD), cs_ToolTip);
    cs_ToolTip.LoadString(IDS_CLICKTOCOPYGENPSWD);
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_COPYPASSWORD), cs_ToolTip);
    cs_ToolTip.LoadString(IDS_CLICKTOLISTENTRIES);
    m_pToolTipCtrl->AddTool(GetDlgItem(IDC_POLICYLIST), cs_ToolTip);

    if (!m_bReadOnly) {
      cs_ToolTip.LoadString(IDS_CANCELPOLICYCHANGES);
      m_pToolTipCtrl->AddTool(GetDlgItem(IDCANCEL), cs_ToolTip);
      cs_ToolTip.LoadString(IDS_SAVEPOLICYCHANGES);
      m_pToolTipCtrl->AddTool(GetDlgItem(IDOK), cs_ToolTip);
    }
  }

  DWORD dwStyle = m_PolicyNames.GetExtendedStyle();
  dwStyle |= (LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
  m_PolicyNames.SetExtendedStyle(dwStyle);

  dwStyle = m_PolicyEntries.GetExtendedStyle();
  dwStyle |= (LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
  m_PolicyEntries.SetExtendedStyle(dwStyle);

  // Override default HeaderCtrl ID of 0
  m_PolicyNames.GetHeaderCtrl()->SetDlgCtrlID(IDC_POLICYNAMES_HEADER);
  m_PolicyEntries.GetHeaderCtrl()->SetDlgCtrlID(IDC_POLICYENTRIES_HEADER);

  // BR1108 - Allow user to config these fonts as well
  // Currently use same font as specified for list/tree view
  m_PolicyNames.SetFont(Fonts::GetInstance()->GetCurrentFont());
  m_PolicyDetails.SetFont(Fonts::GetInstance()->GetCurrentFont());

  CString cs_text;

  // Add columns
  cs_text.LoadString(IDS_POLICYNAME);
  m_PolicyNames.InsertColumn(0, cs_text);
  cs_text.LoadString(IDS_USECOUNT);
  m_PolicyNames.InsertColumn(1, cs_text, LVCFMT_CENTER);

  UpdateNames();

  // Select default == current database
  m_iSelectedItem = 0;
  m_PolicyNames.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);

  // Add columns to policy details CListCtrl - Name and value
  cs_text.LoadString(IDS_POLICYFIELD);
  m_PolicyDetails.InsertColumn(0, cs_text, LVCFMT_CENTER);
  cs_text.LoadString(IDS_VALUE);
  m_PolicyDetails.InsertColumn(1, cs_text, LVCFMT_LEFT);

  // Add columns to policy entries CListCtrl - Group, Title, Username
  cs_text.LoadString(IDS_GROUP);
  m_PolicyEntries.InsertColumn(0, cs_text, LVCFMT_CENTER);
  cs_text.LoadString(IDS_TITLE);
  m_PolicyEntries.InsertColumn(1, cs_text, LVCFMT_LEFT);
  cs_text.LoadString(IDS_USERNAME);
  m_PolicyEntries.InsertColumn(2, cs_text, LVCFMT_LEFT);

  m_bViewPolicy = true;

  // Show its details
  UpdateDetails(); 

  // Since we select the default, disable List & Delete
  GetDlgItem(IDC_LIST_POLICYENTRIES)->EnableWindow(FALSE);
  GetDlgItem(IDC_DELETE)->EnableWindow(FALSE);
  
  Fonts::GetInstance()->ApplyPasswordFont(GetDlgItem(IDC_PASSWORD));
  m_ex_password.SetSecure(false);

  // Remove password character so that the password is displayed
  m_ex_password.SetPasswordChar(0);

  // Max. of 255 policy names allowed - only 2 hex digits used for number
  if (m_MapPSWDPLC.size() >= 255)
    GetDlgItem(IDC_NEW)->EnableWindow(FALSE);

  // Load bitmap
  BOOL brc;
  UINT nImageID = PWSprefs::GetInstance()->GetPref(PWSprefs::UseNewToolbar) ?
        IDB_COPYPASSWORD_NEW : IDB_COPYPASSWORD_CLASSIC;
  brc = m_CopyPswdBitmap.Attach(::LoadImage(
                  ::AfxFindResourceHandle(MAKEINTRESOURCE(nImageID), RT_BITMAP),
                  MAKEINTRESOURCE(nImageID), IMAGE_BITMAP, 0, 0,
                  (LR_DEFAULTSIZE | LR_CREATEDIBSECTION | LR_SHARED)));
  ASSERT(brc);
  if (brc) {
    FixBitmapBackground(m_CopyPswdBitmap);
    CButton *pBtn = (CButton *)GetDlgItem(IDC_COPYPASSWORD);
    ASSERT(pBtn != NULL);
    if (pBtn != NULL)
      pBtn->SetBitmap(m_CopyPswdBitmap);
  }
  // No changes yet
  GetDlgItem(IDC_UNDO)->EnableWindow(FALSE);
  GetDlgItem(IDC_REDO)->EnableWindow(FALSE);

  // Set focus on the policy names CListCtrl and so return FALSE
  m_PolicyNames.SetFocus();
  return FALSE;
}
예제 #10
0
BOOL CPasswordPolicyDlg::OnInitDialog()
{
  CPWDialog::OnInitDialog();

  // If started with Tall and won't fit - return to be called again with Wide
  if (m_bLongPPs && !GetMainDlg()->LongPPs(this)) {
    EndDialog(-1);
    return FALSE;
  }
  
  if (m_bReadOnly && m_uicaller != IDS_GENERATEPASSWORD) {
    // Change OK button test
    CString cs_close(MAKEINTRESOURCE(IDS_CLOSE));
    GetDlgItem(IDOK)->SetWindowText(cs_close);

    // Hide the Cancel button
    GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
    GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
  }

  CString cs_title;
  switch (m_uicaller) {
  case IDS_OPTIONS:
    // Set correct window title
    cs_title.LoadString(IDS_EDIT_DEFAULT_POLICY);
    SetWindowText(cs_title);

    // These are only used in Manage -> Generate Password or Add/Edit Policy names
    GetDlgItem(IDC_GENERATEPASSWORD)->EnableWindow(FALSE);
    GetDlgItem(IDC_GENERATEPASSWORD)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_COPYPASSWORD)->EnableWindow(FALSE);
    GetDlgItem(IDC_COPYPASSWORD)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_PASSWORD)->EnableWindow(FALSE);
    GetDlgItem(IDC_PASSWORD)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_POLICYNAME)->EnableWindow(FALSE);
    GetDlgItem(IDC_POLICYNAME)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_POLICYLIST)->EnableWindow(FALSE);
    GetDlgItem(IDC_POLICYLIST)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_USENAMED_POLICY)->EnableWindow(FALSE);
    GetDlgItem(IDC_USENAMED_POLICY)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_STATIC_NAMEDPOLICY)->ShowWindow(SW_HIDE);
    break;
  case IDS_GENERATEPASSWORD:
    {
      // Set correct window title
      cs_title.LoadString(IDS_GENERATEPASSWORD);
      SetWindowText(cs_title);

      // These are only used in Manage -> Add/Edit Policy names
      GetDlgItem(IDC_POLICYNAME)->EnableWindow(FALSE);
      GetDlgItem(IDC_POLICYNAME)->ShowWindow(SW_HIDE);

      // Used to generate passwords
      GetDlgItem(IDC_POLICYLIST)->ShowWindow(SW_SHOW);
      GetDlgItem(IDC_USENAMED_POLICY)->EnableWindow(TRUE);
      GetDlgItem(IDC_USENAMED_POLICY)->ShowWindow(SW_SHOW);
      GetDlgItem(IDC_STATIC_NAMEDPOLICY)->ShowWindow(SW_HIDE);

      // Populate the combo box
      m_cbxPolicyNames.ResetContent();

      // Get all password policy names
      std::vector<std::wstring> vNames;
      GetMainDlg()->GetPolicyNames(vNames);

      // Add Default
      const CString cs_default(MAKEINTRESOURCE(IDSC_DEFAULT_POLICY));
      m_cbxPolicyNames.AddString(cs_default);

      for (std::vector<std::wstring>::iterator iter = vNames.begin();
           iter != vNames.end(); ++iter) {
        m_cbxPolicyNames.AddString(iter->c_str());
      }

      // Select Default
      m_cbxPolicyNames.SelectString(-1, cs_default);

      // and check the box
      ((CButton *)GetDlgItem(IDC_USENAMED_POLICY))->SetCheck(BST_CHECKED);

      // Centre the OK button & change its text
      RECT rc, rcOK;
      CWnd *pOK = GetDlgItem(IDOK);

      GetClientRect(&rc);
      pOK->GetWindowRect(&rcOK);
      ScreenToClient(&rcOK);
      int top = rcOK.top;
      pOK->GetClientRect(&rcOK);
      int left = (rc.right - rcOK.right) / 2;
      pOK->MoveWindow(left, top, rcOK.right, rcOK.bottom);

      CString cs_close(MAKEINTRESOURCE(IDS_CLOSE));
      pOK->SetWindowText(cs_close);

      // Hide the Cancel & Help buttons
      GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
      GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
      GetDlgItem(ID_HELP)->EnableWindow(FALSE);
      GetDlgItem(ID_HELP)->ShowWindow(SW_HIDE);

      Fonts::GetInstance()->ApplyPasswordFont(GetDlgItem(IDC_PASSWORD));
      m_ex_password.SetSecure(false);

      // Remove password character so that the password is displayed
      m_ex_password.SetPasswordChar(0);

      // Load bitmap
      UINT nImageID = PWSprefs::GetInstance()->GetPref(PWSprefs::UseNewToolbar) ?
        IDB_COPYPASSWORD_NEW : IDB_COPYPASSWORD_CLASSIC;
      BOOL brc = m_CopyPswdBitmap.Attach(::LoadImage(
                                                     ::AfxFindResourceHandle(MAKEINTRESOURCE(nImageID), RT_BITMAP),
                                                     MAKEINTRESOURCE(nImageID), IMAGE_BITMAP, 0, 0,
                                                     (LR_DEFAULTSIZE | LR_CREATEDIBSECTION | LR_SHARED)));
      ASSERT(brc);

      FixBitmapBackground(m_CopyPswdBitmap);
      CButton *pBtn = (CButton *)GetDlgItem(IDC_COPYPASSWORD);
      pBtn->SetBitmap(m_CopyPswdBitmap);

      break;
    }
  case IDS_PSWDPOLICY:
    // Set correct window title
    cs_title.LoadString(m_policyname.IsEmpty() ? IDS_ADD_NAMED_POLICY : IDS_EDIT_NAMED_POLICY);
    SetWindowText(cs_title);

    // These are only used in Manage -> Password Policy
    GetDlgItem(IDC_GENERATEPASSWORD)->EnableWindow(FALSE);
    GetDlgItem(IDC_GENERATEPASSWORD)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_COPYPASSWORD)->EnableWindow(FALSE);
    GetDlgItem(IDC_COPYPASSWORD)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_PASSWORD)->EnableWindow(FALSE);
    GetDlgItem(IDC_PASSWORD)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_POLICYLIST)->EnableWindow(FALSE);
    GetDlgItem(IDC_POLICYLIST)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_USENAMED_POLICY)->EnableWindow(FALSE);
    GetDlgItem(IDC_USENAMED_POLICY)->ShowWindow(SW_HIDE);
    GetDlgItem(IDC_STATIC_NAMEDPOLICY)->ShowWindow(SW_SHOW);

    if (!m_policyname.IsEmpty() && m_iter->second.usecount > 0) {
      // Cannot edit the policy 'Name' if it is present and use count > 0
      m_PolicyNameEdit.SetReadOnly(TRUE);
      m_PolicyNameEdit.EnableWindow(FALSE);
    }

    m_PolicyNameEdit.SetWindowText(m_policyname);
    // Max. length of policy name is 255 - only one byte used for length
    // in database header
    m_PolicyNameEdit.SetLimitText(255);
    break;
  }

  setupBuddy(this, IDC_PWLENSPIN, IDC_DEFPWLENGTH, m_PWDefaultLength, 4);
  setupBuddy(this, IDC_SPINDIGITS, IDC_MINDIGITLENGTH, m_PWDigitMinLength);
  setupBuddy(this, IDC_SPINLOWERCASE, IDC_MINLOWERLENGTH, m_PWLowerMinLength);
  setupBuddy(this, IDC_SPINUPPERCASE, IDC_MINUPPERLENGTH, m_PWUpperMinLength);
  setupBuddy(this, IDC_SPINSYMBOLS, IDC_MINSYMBOLLENGTH, m_PWSymbolMinLength);

  m_save[SAVE_LOWERCASE] = m_PWUseLowercase;
  m_save[SAVE_UPPERCASE] = m_PWUseUppercase;
  m_save[SAVE_DIGITS] = m_PWUseDigits;
  m_save[SAVE_SYMBOLS] = m_PWUseSymbols;
  m_save[SAVE_EASYVISION] = m_PWEasyVision;
  m_save[SAVE_PRONOUNCEABLE] = m_PWMakePronounceable;

  m_savelen[SAVE_LOWERCASE] = m_PWLowerMinLength;
  m_savelen[SAVE_UPPERCASE] = m_PWUpperMinLength;
  m_savelen[SAVE_DIGITS] = m_PWDigitMinLength;
  m_savelen[SAVE_SYMBOLS] = m_PWSymbolMinLength;

  // Set up the correct controls (enabled/disabled)
  do_hex(m_PWUseHexdigits == TRUE);

  int iSet = EVPR_NONE;
  if (m_PWEasyVision == TRUE)
    iSet = EVPR_EV;
  else
    if (m_PWMakePronounceable == TRUE)
      iSet = EVPR_PR;
  do_easyorpronounceable(iSet);

  GetDlgItem(IDC_OWNSYMBOLS)->EnableWindow(m_PWUseSymbols);
  GetDlgItem(IDC_RESET_SYMBOLS)->EnableWindow(m_PWUseSymbols);

  m_SymbolsEdit.SetWindowText(m_Symbols);

  if (m_uicaller == IDS_GENERATEPASSWORD) {
    // Disable Specific policy controls as default is to use a named policy (database default)
    SetSpecificPolicyControls(FALSE);

    m_pToolTipCtrl = new CToolTipCtrl;
    if (!m_pToolTipCtrl->Create(this, TTS_ALWAYSTIP | TTS_BALLOON | TTS_NOPREFIX)) {
      pws_os::Trace(L"Unable To create Advanced Dialog ToolTip\n");
      delete m_pToolTipCtrl;
      m_pToolTipCtrl = NULL;
      return TRUE;
    }

    // Tooltips
    EnableToolTips();

    // Activate the tooltip control.
    m_pToolTipCtrl->Activate(TRUE);
    m_pToolTipCtrl->SetMaxTipWidth(300);
    // Quadruple the time to allow reading by user
    int iTime = m_pToolTipCtrl->GetDelayTime(TTDT_AUTOPOP);
    m_pToolTipCtrl->SetDelayTime(TTDT_AUTOPOP, 4 * iTime);

    AddTool(IDC_COPYPASSWORD, IDS_CLICKTOCOPY);
  }

  // Set appropriate focus
  GetDlgItem(m_uicaller == IDS_GENERATEPASSWORD ? IDC_GENERATEPASSWORD : IDCANCEL)->SetFocus();
  return FALSE;
}
예제 #11
0
LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// center the dialog on the screen
	CenterWindow();

	// set icons
	HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
	SetIcon(hIcon, TRUE);
	HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
	SetIcon(hIconSmall, FALSE);

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	UIAddChildWindowContainer(m_hWnd);

	gen1Frq = GetDlgItem(IDC_CAR_FREQ);
	gen1Atk = GetDlgItem(IDC_CAR_ATTACK);
	gen1Dec = GetDlgItem(IDC_CAR_DECAY);
	gen1Vol = GetDlgItem(IDC_CAR_VOLUME);
	gen1Sus = GetDlgItem(IDC_CAR_SUSTAIN);
	gen1Rel = GetDlgItem(IDC_CAR_RELEASE);
	gen1FrqEd = GetDlgItem(IDC_CFRQ_EDIT);
	gen1AtkEd = GetDlgItem(IDC_CATK_EDIT);
	gen1DecEd = GetDlgItem(IDC_CDEC_EDIT);
	gen1VolEd = GetDlgItem(IDC_CVOL_EDIT);
	gen1SusEd = GetDlgItem(IDC_CSUS_EDIT);
	gen1RelEd = GetDlgItem(IDC_CREL_EDIT);

	InitValue(gen1Frq, gen1FrqEd, 0, 120, 12);
	PutSetting(gen1Frq, gen1FrqEd, 48.0, 1, 120);
	InitValue(gen1Vol, gen1VolEd, 0, 100, 10);
	InitValue(gen1Sus, gen1SusEd, 0, 100, 10);
	InitValue(gen1Atk, gen1AtkEd, 0, 4000, 400);
	InitValue(gen1Dec, gen1DecEd, 0, 4000, 400);
	InitValue(gen1Rel, gen1RelEd, 0, 4000, 400);

	gen2Mul = GetDlgItem(IDC_MOD1_MULT);
	gen2Ndx = GetDlgItem(IDC_MOD1_START);
	gen2Atk = GetDlgItem(IDC_MOD1_ATTACK);
	gen2Pck = GetDlgItem(IDC_MOD1_PEAK);
	gen2Dec = GetDlgItem(IDC_MOD1_DECAY);
	gen2Sus = GetDlgItem(IDC_MOD1_SUSTAIN);
	gen2Rel = GetDlgItem(IDC_MOD1_RELEASE);
	gen2End = GetDlgItem(IDC_MOD1_END);
	gen2MulEd = GetDlgItem(IDC_M1M_EDIT);
	gen2NdxEd = GetDlgItem(IDC_M1I_EDIT);
	gen2AtkEd = GetDlgItem(IDC_M1A_EDIT);
	gen2PckEd = GetDlgItem(IDC_M1P_EDIT);
	gen2DecEd = GetDlgItem(IDC_M1D_EDIT);
	gen2SusEd = GetDlgItem(IDC_M1S_EDIT);
	gen2RelEd = GetDlgItem(IDC_M1R_EDIT);
	gen2EndEd = GetDlgItem(IDC_M1E_EDIT);

	InitValue(gen2Mul, gen2MulEd, 0,  100,  10);
	InitValue(gen2Ndx, gen2NdxEd, 0,  500,  50);
	InitValue(gen2Pck, gen2PckEd, 0,  500,  50);
	InitValue(gen2Sus, gen2SusEd, 0,  500,  50);
	InitValue(gen2End, gen2EndEd, 0,  500,  50);
	InitValue(gen2Atk, gen2AtkEd, 0, 4000, 400);
	InitValue(gen2Dec, gen2DecEd, 0, 4000, 400);
	InitValue(gen2Rel, gen2RelEd, 0, 4000, 400);

	gen3Mul = GetDlgItem(IDC_MOD2_MULT);
	gen3Ndx = GetDlgItem(IDC_MOD2_START);
	gen3Atk = GetDlgItem(IDC_MOD2_ATTACK);
	gen3Pck = GetDlgItem(IDC_MOD2_PEAK);
	gen3Dec = GetDlgItem(IDC_MOD2_DECAY);
	gen3Sus = GetDlgItem(IDC_MOD2_SUSTAIN);
	gen3Rel = GetDlgItem(IDC_MOD2_RELEASE);
	gen3End = GetDlgItem(IDC_MOD2_END);
	gen3MulEd = GetDlgItem(IDC_M2M_EDIT);
	gen3NdxEd = GetDlgItem(IDC_M2I_EDIT);
	gen3AtkEd = GetDlgItem(IDC_M2A_EDIT);
	gen3PckEd = GetDlgItem(IDC_M2P_EDIT);
	gen3DecEd = GetDlgItem(IDC_M2D_EDIT);
	gen3SusEd = GetDlgItem(IDC_M2S_EDIT);
	gen3RelEd = GetDlgItem(IDC_M2R_EDIT);
	gen3EndEd = GetDlgItem(IDC_M2E_EDIT);

	InitValue(gen3Mul, gen3MulEd, 0,  100,  10);
	InitValue(gen3Ndx, gen3NdxEd, 0,  500,  50);
	InitValue(gen3Pck, gen3PckEd, 0,  500,  50);
	InitValue(gen3Sus, gen3SusEd, 0,  500,  50);
	InitValue(gen3End, gen3EndEd, 0,  500,  50);
	InitValue(gen3Atk, gen3AtkEd, 0, 4000, 400);
	InitValue(gen3Dec, gen3DecEd, 0, 4000, 400);
	InitValue(gen3Rel, gen3RelEd, 0, 4000, 400);

	durValEd = GetDlgItem(IDC_DUR_EDIT);
	durValEd.SetWindowText("4.0");
	volValEd = GetDlgItem(IDC_VOL);
	volValEd.SetWindowText("0.707");

	btnPlay = GetDlgItem(IDC_PLAY);
	btnLoop = GetDlgItem(IDC_LOOP);
	btnStop = GetDlgItem(IDC_STOP);
	RECT btnrc;
	btnPlay.GetClientRect(&btnrc);
	int cxy;
	if ((btnrc.bottom - btnrc.top) < 30)
		cxy = 16;
	else
		cxy = 32;
	hIcon = (HICON) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_PLAY), IMAGE_ICON, cxy, cxy, LR_DEFAULTCOLOR);
	btnPlay.SetIcon(hIcon);
	hIcon = (HICON) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_LOOP), IMAGE_ICON, cxy, cxy, LR_DEFAULTCOLOR);
	btnLoop.SetIcon(hIcon);
	hIcon = (HICON) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, cxy, cxy, LR_DEFAULTCOLOR);
	btnStop.SetIcon(hIcon);
	btnStop.EnableWindow(FALSE);

	CButton btnStyle;
	HBITMAP bm;

	btnStyle = GetDlgItem(IDC_STACK);
	bm = (HBITMAP) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_STACK), IMAGE_BITMAP, 48, 48, LR_DEFAULTCOLOR);
	btnStyle.SetBitmap(bm);
	btnStyle.SetCheck(BST_CHECKED);
	btnStyle = GetDlgItem(IDC_STACK2);
	bm = (HBITMAP) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_STACK2), IMAGE_BITMAP, 48, 48, LR_DEFAULTCOLOR);
	btnStyle.SetBitmap(bm);
	btnStyle = GetDlgItem(IDC_WYE);
	bm = (HBITMAP) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_WYE), IMAGE_BITMAP, 48, 48, LR_DEFAULTCOLOR);
	btnStyle.SetBitmap(bm);
	btnStyle = GetDlgItem(IDC_DELTA);
	bm = (HBITMAP) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_DELTA), IMAGE_BITMAP, 48, 48, LR_DEFAULTCOLOR);
	btnStyle.SetBitmap(bm);

	btnStyle = GetDlgItem(IDC_COPY_CLIP);
	hIcon = (HICON) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_COPY), IMAGE_ICON, cxy, cxy, LR_DEFAULTCOLOR);
	btnStyle.SetIcon(hIcon);
	btnStyle = GetDlgItem(IDC_SAVE);
	hIcon = (HICON) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_WVFILE), IMAGE_ICON, cxy, cxy, LR_DEFAULTCOLOR);
	btnStyle.SetIcon(hIcon);
	btnStyle = GetDlgItem(IDC_HELP2);
	hIcon = (HICON) ::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_HELP2), IMAGE_ICON, cxy, cxy, LR_DEFAULTCOLOR);
	btnStyle.SetIcon(hIcon);

	SetPreset(&resetParams);

	return TRUE;
}
예제 #12
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;
}