コード例 #1
0
ファイル: DP_RepMain.cpp プロジェクト: P3tr0viCh/DP_Rep
// ---------------------------------------------------------------------------
void __fastcall TMain::FormShow(TObject *Sender) {
	bool NeedUpdate, OKUpdate;

	if (!IsShift()) {
		NeedUpdate = true;
		OKUpdate   = true;

		if (FindCmdLineSwitch("UPDATE")) {
			OKUpdate   = ReportUpdate();
			NeedUpdate = false;
		}

		if (FindCmdLineSwitch("MAIL")) {
			if (NeedUpdate) {
				OKUpdate   = ReportUpdate();
				NeedUpdate = false;
			}
			if (OKUpdate)
				ReportMail();
		}

		if (FindCmdLineSwitch("SAVE")) {
			if (NeedUpdate)
				OKUpdate = ReportUpdate();
			if (OKUpdate)
				ReportSave();
		}
		if (FindCmdLineSwitch("CLOSE") & OKUpdate)
			Close();
	}
}
コード例 #2
0
int GetExtKey(int *isshift)
{
    int key =  ext_getch();

    *isshift = IsShift();
    return key;
}
コード例 #3
0
ファイル: AboutFrm.cpp プロジェクト: P3tr0viCh/UtilsAndComps
void ShowAbout(int iFontSize, Byte bLineBreak, Byte bVersionPos, String sDate,
	TPicture *pPicture, String sAddComp, String sVersion, String sAppName,
	String sCopyright, String sText, HICON hIcon) {
	TForm *Form;

	int I;
	String sCaption;

	TVSFixedFileInfo FileVersionInfo;

	String CompanyName, FileDescription, FileVersion, InternalName,
		LegalCopyright, OriginalFilename, ProductName, ProductVersion;

	TAboutObject *AboutObject;

	ShowWaitCursor();
//	Randomize;

	if (IsShift() & IsCtrl()) {
		sAppName = "Дураев";
		sAppName += sLineBreak;
		sAppName += "Константин Петрович";
		sCopyright = "";
		sCaption   = "Автор";
		sDate      = "29.03.1981";
		sVersion   = "";
		iFontSize  = 16;
		sAddComp   = NULL;
		pPicture   = NULL;
		sText      = "";
		for (int i = 1; i < 280; i++)
			if (i % 40 == 0)
				sText = sText + sLineBreak;
			else
				// TODO: 				sText = sText + String(AnsiChar(Chr(Ord('А') +
				// Random(Ord('Я') - Ord('А')))));
					sText = sText + L"Я";
	}
	else {
		GetFileVerInfo(Application->ExeName, FileVersionInfo, CompanyName,
			FileDescription, FileVersion, InternalName, LegalCopyright,
			OriginalFilename, ProductName, ProductVersion);

		sCaption = LoadStr(IDS_ABOUT_CAPTION);

		if (sDate == NULL)
			sDate = FormatDateTime("yyyy.mm.dd",
			UnixToDateTime(((PIMAGE_NT_HEADERS)((DWORD)((PIMAGE_DOS_HEADER)
			HInstance) + (((PIMAGE_DOS_HEADER) HInstance)->e_lfanew)))
			->FileHeader.TimeDateStamp));

		if (sVersion == NULL) {
			sVersion = FileVersion;
			if (IsValueInWord(FileVersionInfo.dwFileFlags, VS_FF_DEBUG))
				sVersion = sVersion + LoadStr(IDS_ABOUT_DEBUG);
			else if (IsValueInWord(FileVersionInfo.dwFileFlags,
				VS_FF_PRERELEASE))
				sVersion = sVersion + LoadStr(IDS_ABOUT_RC);
		}

		if (sAppName == NULL)
			sAppName = ProductName;

		if (sCopyright == NULL)
			sCopyright = LegalCopyright + "|@[email protected]";

		if (sText == NULL) {
			sText = LoadStr(IDS_ABOUT_EULA1) + sLineBreak +
				LoadStr(IDS_ABOUT_EULA2) + sLineBreak + LoadStr(IDS_ABOUT_EULA3)
				+ sLineBreak + LoadStr(IDS_ABOUT_EULA4);
		}

		if (bLineBreak != MAXBYTE) {
			I        = PosPlace(SPACE, sAppName, bLineBreak);
			sAppName = sAppName.SubString(1, I - 1) + sLineBreak +
				sAppName.SubString(I + 1, MAXINT);
		}
	} // IsShift and IsCtrl

	if (hIcon == NULL)
		hIcon = LoadIcon(HInstance, L"MAINICON");

	AboutObject = new TAboutObject();

	Form               = new TForm(Application); // Owner;
	Form->ShowHint     = true;
	Form->Font->Name   = "Arial";
	Form->Font->Size   = 10;
	Form->BorderStyle  = bsDialog;
	Form->Caption      = sCaption;
	Form->ClientHeight = 165;
	Form->ClientWidth  = 420;

	TBevel *bvlIconFrame = new TBevel(Form);
	bvlIconFrame->Parent = Form;
	bvlIconFrame->SetBounds(8, 14, 52, 52);
	bvlIconFrame->Shape = bsFrame;

	TPanel *pnlIcon = new TPanel(Form);
	pnlIcon->Parent = Form;
	pnlIcon->SetBounds(16, 22, 36, 36);
	pnlIcon->Caption          = "";
	pnlIcon->BevelOuter       = bvNone;
	pnlIcon->BorderStyle      = bsSingle;
	pnlIcon->ParentBackground = false;
	pnlIcon->Color            = (TColor) Random(0xFFFFFF);

	TImage *imgIcon                = new TImage(Form); // Icon
	imgIcon->Parent                = pnlIcon;
	imgIcon->Align                 = alClient;
	imgIcon->Transparent           = true;
	imgIcon->Picture->Icon->Handle = hIcon;

	TLabel *lblCopyright      = new TLabel(Form); // Copyright
	lblCopyright->Tag         = 1;
	lblCopyright->Parent      = Form;
	lblCopyright->Font->Style = TFontStyles() << fsBold;
	lblCopyright->SetBounds(8, 80, 0, 0);

	int PosHint = Pos('|', sCopyright);
	if (PosHint == 0)
		lblCopyright->Caption = sCopyright;
	else {
		lblCopyright->Caption      = sCopyright.SubString(1, PosHint - 1);
		lblCopyright->Hint         = sCopyright.SubString(PosHint + 1, MAXINT);
		lblCopyright->Cursor       = crHandPoint;
		lblCopyright->OnMouseEnter = AboutObject->MouseEnter;
		lblCopyright->OnMouseLeave = AboutObject->MouseLeave;
		if (lblCopyright->Hint[1] == '@') {
			lblCopyright->Hint = lblCopyright->Hint.SubString(2, MAXINT);

			AboutObject->MailAddress = lblCopyright->Hint;
			AboutObject->MailSubject = OriginalFilename + " " + FileVersion;
		}
		lblCopyright->OnClick = AboutObject->Click;
	}

	TLabel *lblText = new TLabel(Form); // Text
	lblText->Parent   = Form;
	lblText->WordWrap = true;
	lblText->SetBounds(8, 100, Form->ClientWidth - 16, 0);
	lblText->Caption = sText;
	// I                  =
	lblText->Top + lblText->Height;
	Form->ClientHeight = Form->ClientHeight + lblText->Height;

	if (sAddComp != NULL) {
		/* with TBevel.Create(Form) do
		 {
		 Parent = Form;
		 SetBounds(7, I + 5, Form.ClientWidth - 15, 5);
		 Shape = bsTopLine;
		 I = Top + Height;
		 };

		 with TLabel.Create(Form) do // Add Components
		 {
		 Parent = Form;
		 SetBounds(8, I, 0, 0);
		 Caption = 'Программное обеспечение использует следующие компоненты:';
		 I = Top + Height;
		 };

		 with TLabel.Create(Form) do // Components
		 {
		 Tag = 2;
		 Parent = Form;
		 Font.Style = [fsBold];
		 SetBounds(8, I, 0, 0);
		 Caption = sAddComp;
		 Form.ClientHeight = Form.ClientHeight + Height + 12;
		 if FileExists(FileInAppDir(rsLicenses)) then
		 {
		 Cursor = crHandPoint;
		 OnClick = ClickObject.Click;
		 OnMouseEnter = ClickObject.MouseEnter;
		 OnMouseLeave = ClickObject.MouseLeave;
		 };
		 } */
	}
	else // sAddComp != NULL
			Form->ClientHeight = Form->ClientHeight - 12;

	TBevel *bvlBottom = new TBevel(Form);
	bvlBottom->Parent = Form;
	bvlBottom->SetBounds(7, Form->ClientHeight - 43, Form->ClientWidth - 15, 5);
	bvlBottom->Shape = bsTopLine;

	lblMemory         = new TLabel(Form); // Физическая ...
	lblMemory->Parent = Form;
	lblMemory->SetBounds(8, Form->ClientHeight - 38, 0, 0);
	lblMemory->Caption = LoadStr(IDS_ABOUT_MEMORY);

	lblMemoryValue              = new TLabel(Form); // TotalPhys
	lblMemoryValue->Parent      = Form;
	lblMemoryValue->Font->Style = TFontStyles() << fsBold;
	lblMemoryValue->SetBounds(lblMemory->Width + 13,
		Form->ClientHeight - 38, 0, 0);

	lblProc         = new TLabel(Form); // Процессор:
	lblProc->Parent = Form;
	lblProc->SetBounds(8, Form->ClientHeight - 22, 0, 0);
	lblProc->Caption = LoadStr(IDS_ABOUT_PROCESSOR);

	lblProcValue              = new TLabel(Form); // CPUSpeed
	lblProcValue->Parent      = Form;
	lblProcValue->Font->Style = TFontStyles() << fsBold;
	lblProcValue->SetBounds(lblMemory->Width + 13,
		Form->ClientHeight - 22, 0, 0);

	TGradientPanel *pnlName = new TGradientPanel(Form);
	pnlName->Parent = Form;
	pnlName->StartUpdate();
	pnlName->SetBounds(68, 8, Form->ClientWidth - 76, 64);
	pnlName->BorderStyle = bsSingle;

	pnlName->BevelOuter       = bvNone;
	pnlName->ParentBackground = false;
	if (pPicture == NULL) pnlName->ColorStart = pnlIcon->Color;
	else pnlName->ColorStart = clBlack;
	pnlName->ColorEnd = clBlack;
	pnlName->EndUpdate();

	if (pPicture == NULL) {
		TLabel *lblAppName = new TLabel(Form); // Application Name (1)
		lblAppName->Parent = pnlName;
		lblAppName->SetBounds(2, 2, Form->ClientWidth - 83, 58);
		lblAppName->Alignment     = taCenter;
		lblAppName->AutoSize      = false;
		lblAppName->Caption       = sAppName;
		lblAppName->ParentColor   = false;
		lblAppName->Color         = clBlack;
		lblAppName->ParentFont    = false;
		lblAppName->Font->Charset = DEFAULT_CHARSET;
		lblAppName->Font->Color   = clBlack;
		lblAppName->Font->Height  = -51;
		lblAppName->Font->Name    = "Courier New";
		lblAppName->Font->Style   = TFontStyles() << fsBold << fsItalic;
		lblAppName->Font->Size    = iFontSize;
		lblAppName->Transparent   = true;
		lblAppName->Layout        = tlCenter;
		lblAppName->WordWrap      = true;

		TLabel *lblAppName2 = new TLabel(Form); // Application Name (2)
		lblAppName2->Parent = pnlName;
		lblAppName2->SetBounds(0, 0, Form->ClientWidth - 83, 58);
		lblAppName2->Alignment     = taCenter;
		lblAppName2->AutoSize      = false;
		lblAppName2->Caption       = sAppName;
		lblAppName2->ParentColor   = false;
		lblAppName2->Color         = clBlack;
		lblAppName2->ParentFont    = false;
		lblAppName2->Font->Charset = DEFAULT_CHARSET;
		lblAppName2->Font->Color   = clWhite;
		lblAppName2->Font->Height  = -51;
		lblAppName2->Font->Name    = "Courier New";
		lblAppName2->Font->Style   = TFontStyles() << fsBold << fsItalic;
		lblAppName2->Font->Size    = iFontSize;
		lblAppName2->Transparent   = true;
		lblAppName2->Layout        = tlCenter;
		lblAppName2->WordWrap      = true;
	} // pPicture == NULL
	else {
		TImage *imgPicture = new TImage(Form);
		imgPicture->Parent = pnlName;
		imgPicture->Align  = alClient;
		imgPicture->Picture->Assign(pPicture);
	}

	TLabel *lblDate = new TLabel(Form); // Date
	lblDate->Parent  = pnlName;
	lblDate->Caption = sDate;
	lblDate->Font->Assign(Form->Font);
	lblDate->Font->Style = TFontStyles() << fsBold;
	lblDate->Font->Color = clWhite;
	lblDate->Font->Size  = 8;
	lblDate->Alignment   = taRightJustify;

	switch (3) {
	case 0:
		lblDate->SetBounds(2, 2, lblDate->Width, lblDate->Height);
		break;
	case 1:
		lblDate->SetBounds(2, pnlName->ClientHeight - lblDate->Height - 2,
			lblDate->Width, lblDate->Height);
		break;
	case 2:
		lblDate->SetBounds(pnlName->ClientWidth - lblDate->Width - 2, 2,
			lblDate->Width, lblDate->Height);
		break;
	default:
		lblDate->SetBounds(pnlName->ClientWidth - lblDate->Width - 2,
			pnlName->ClientHeight - lblDate->Height - 2, lblDate->Width,
			lblDate->Height);
	}
	lblDate->Transparent = true;

	TLabel *lblVerion  = new TLabel(Form); // Version
	lblVerion->Parent  = pnlName;
	lblVerion->Caption = sVersion;
	lblVerion->Font->Assign(Form->Font);
	lblVerion->Font->Style = TFontStyles() << fsBold;
	lblVerion->Font->Color = clWhite;
	lblVerion->Font->Size  = 8;

	switch (2) {
	case 0:
		lblVerion->SetBounds(2, 2, lblVerion->Width, lblVerion->Height);
		break;
	case 1:
		lblVerion->SetBounds(2, pnlName->ClientHeight - lblVerion->Height - 2,
			lblVerion->Width, lblVerion->Height);
		break;
	case 2:
		lblVerion->SetBounds(pnlName->ClientWidth - lblVerion->Width - 2, 2,
			lblVerion->Width, lblVerion->Height);
		break;
	default:
		lblVerion->SetBounds(pnlName->ClientWidth - lblVerion->Width - 2,
			pnlName->ClientHeight - lblVerion->Height - 2, lblVerion->Width,
			lblVerion->Height);
	}
	lblVerion->Transparent = true;

	TButton *btnClose     = new TButton(Form);
	btnClose->Parent      = Form;
	btnClose->Caption     = "OK";
	btnClose->ModalResult = mrCancel;
	btnClose->Cancel      = true;
	btnClose->SetBounds(Form->ClientWidth - 83, Form->ClientHeight - 34,
		75, 26);
	btnClose->TabOrder = 0;

	TTimer *timer   = new TTimer(Form);
	timer->OnTimer  = AboutObject->TimerTimer;
	timer->Interval = 1;
	timer->Enabled  = true;

	RestoreCursor();

	Form->Left = (Screen->Width - Form->Width) / 2;
	Form->Top  = (Screen->Height - Form->Height) / 2;

	SetCurPosToCenter(btnClose);

	Form->ShowModal();

	Form->Free();
	AboutObject->Free();

	lblMemory      = NULL;
	lblProc        = NULL;
	lblMemoryValue = NULL;
	lblProcValue   = NULL;
}
コード例 #4
0
static intptr_t WINAPI OFDProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2)
{
  OFDData *DlgParams=(OFDData *)Info.SendDlgMessage(hDlg,DM_GETDLGDATA,0,0);
  TCHAR newdir[MAX_PATH];

  TCHAR newcurdir[MAX_PATH];
  FarListGetItem item={sizeof(FarListGetItem)};
  BOOL ItemPresent=FALSE;
  if (Msg==DN_CONTROLINPUT||Msg==DN_CLOSE)
  {
    item.ItemIndex=Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,0,0);
    ItemPresent=Info.SendDlgMessage(hDlg,DM_LISTGETITEM,0,&item);
    if(ItemPresent)
    {
      lstrcpy(newcurdir,DlgParams->curr_dir);
      lstrcat(newcurdir,DlgParams->names[item.ItemIndex].Text);
    }
  }

  switch(Msg)
  {
    case DN_CONTROLINPUT:
      {
        const INPUT_RECORD* record=(const INPUT_RECORD*)Param2;
        if(record->EventType==KEY_EVENT&&record->Event.KeyEvent.bKeyDown)
        {
          WORD Key=record->Event.KeyEvent.wVirtualKeyCode;
          wchar_t Char=FSF.LUpper(record->Event.KeyEvent.uChar.UnicodeChar);
          if((IsNone(record)&&Key==VK_RETURN)||(IsCtrl(record)&&Key==VK_RETURN)||(IsCtrl(record)&&Char=='\\'))
          {
            bool bRoot=(Char=='\\');
            if(ItemPresent||bRoot)
            {
              if(bRoot||(item.Item.Flags&LIF_CHECKED&&IsNone(record)))
              {
                TCHAR *ptr,old_dir[MAX_PATH];//,buffer[MAX_PATH];
                lstrcpy(old_dir,DlgParams->curr_dir);
                int Len=lstrlen(old_dir);
                if (bRoot)
                {
                  *newdir=0;
                  lstrcpy(newcurdir,_T(".."));
                }
                else
                {
                  GetFullPathName(newcurdir,ArraySize(newdir),newdir,&ptr);
                  FSF.AddEndSlash(newdir);
                }
                //MessageBox(NULL,old_dir,newcurdir,MB_OK);
                if (TryLoadDir(hDlg,DlgParams,newdir))
                {
                  if(!lstrcmp(newcurdir+(bRoot?0:Len),_T("..")))
                  {
                    if(Len)
                    {
                      if (bRoot)
                      {
                        ptr=old_dir;
                        for (; *ptr && *ptr!='\\'; ptr++)
                          ;
                        if (*ptr=='\\')
                          ptr[1]=0;
                        ptr=old_dir;
                      }
                      else
                      {
                        if(old_dir[Len-1]=='\\')
                          old_dir[Len-1]=0;
                        ptr=(TCHAR*)FSF.PointToName(old_dir);
                      }
                      FarListPos Pos={sizeof(FarListPos)};
                      FarListFind find={sizeof(FarListFind),0,ptr,LIFIND_EXACTMATCH};
                      Pos.SelectPos=Info.SendDlgMessage(hDlg,DM_LISTFINDSTRING,0,&find);
                      Pos.TopPos=-1;
                      if(Pos.SelectPos>=0)
                        Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,0,&Pos);
                    }
                  }
                }
                return TRUE;
              }
              if(!(IsNone(record)&&Key==VK_RETURN))
              {
                Info.SendDlgMessage(hDlg,DM_CLOSE,0,0);
                return TRUE;
              }
              return FALSE;
            } else return TRUE;
          }
          else if(IsShift(record)&&Key==VK_RETURN)
          {
            if(ItemPresent)
            {
              SHELLEXECUTEINFO info;
              ZeroMemory(&info,sizeof(info));
              info.cbSize=sizeof(info);
              info.fMask=SEE_MASK_NOCLOSEPROCESS|SEE_MASK_FLAG_DDEWAIT;
              info.lpFile=newcurdir;
              info.nShow=SW_SHOWNORMAL;
              ShellExecuteEx(&info);
            }
            return TRUE;
          }
          else if(IsAlt(record)&&Char>='A'&&Char<='Z')
          {
            int Drive=Char-'A';
            DWORD Disks=GetLogicalDrives();
            if(Disks&(1<<Drive))
            {
              TCHAR temp_dir[3]=_T("A:"),*fileptr;
              temp_dir[0]=(TCHAR)(temp_dir[0]+Drive);
              if(!GetFullPathName(temp_dir,ArraySize(newdir),newdir,&fileptr))
                lstrcpy(newdir,temp_dir);
              FSF.AddEndSlash(newdir);
              TryLoadDir(hDlg,DlgParams,newdir);
            }
            return TRUE;
          }
          else if(IsRCtrl(record)&&Char>='0'&&Char<='9')
          {
            FarSettingsCreate settings={sizeof(FarSettingsCreate),FarGuid,INVALID_HANDLE_VALUE};
            HANDLE Settings=Info.SettingsControl(INVALID_HANDLE_VALUE,SCTL_CREATE,0,&settings)?settings.Handle:0;
            if(Settings)
            {
              FarSettingsEnum enums={sizeof(FarSettingsEnum),0,0,{0}};
              enums.Root=FSSF_FOLDERSHORTCUT_0+Char-'0';
              if(Info.SettingsControl(Settings,SCTL_ENUM,0,&enums)&&enums.Count>0)
              {
                intptr_t menu_id=-1;
                if (enums.Count==1)
                {
                  menu_id=0;
                } 
                else
                {
                  FarMenuItem *menuElements=(FarMenuItem *)malloc(enums.Count*sizeof(FarMenuItem));
                  for(size_t ii=0;ii<enums.Count;ii++)
                  {
                    menuElements[ii].Text=enums.Histories[ii].Name;
                    menuElements[ii].Flags=0;
                  }
                  menu_id=Info.Menu(&MainGuid,&ShortcutMenuDiag,-1,-1,0,FMENU_WRAPMODE,GetMsg(mFolderShortcut),0,NULL,NULL,NULL,menuElements,enums.Count);
                  free(menuElements);
                }
                if (menu_id!=-1)
                {
                  lstrcpy(newdir,enums.Histories[menu_id].Name);
                  FSF.AddEndSlash(newdir);
                  TryLoadDir(hDlg,DlgParams,newdir);
                }
              }
              Info.SettingsControl(Settings,SCTL_FREE,0,0);
            }
            return TRUE;
          }
          else if(IsNone(record)&&Key==VK_LEFT)
          {
            INPUT_RECORD keyOut={0};
            keyOut.EventType=KEY_EVENT;
            keyOut.Event.KeyEvent.bKeyDown=1;
            keyOut.Event.KeyEvent.wRepeatCount=1;
            keyOut.Event.KeyEvent.wVirtualKeyCode=VK_HOME;
            Info.SendDlgMessage(hDlg,DM_KEY,1,&keyOut);
            return TRUE;
          }
          else if(IsNone(record)&&Key==VK_RIGHT)
          {
            INPUT_RECORD keyOut={0};
            keyOut.EventType=KEY_EVENT;
            keyOut.Event.KeyEvent.bKeyDown=1;
            keyOut.Event.KeyEvent.wRepeatCount=1;
            keyOut.Event.KeyEvent.wVirtualKeyCode=VK_END;
            Info.SendDlgMessage(hDlg,DM_KEY,1,&keyOut);
            return TRUE;
          }
        }
      }
      break;
    case DN_CTLCOLORDIALOG:
      Info.AdvControl(&MainGuid,ACTL_GETCOLOR,COL_MENUTEXT, Param2);
      return true;
    case DN_CTLCOLORDLGLIST:
      if(Param1==0)
      {
        FarDialogItemColors *fdic=(FarDialogItemColors *)Param2;
        FarColor *Colors = fdic->Colors;
        
        int ColorIndex[]={COL_MENUTEXT,COL_MENUTEXT,COL_MENUTITLE,COL_MENUTEXT,COL_MENUHIGHLIGHT,COL_MENUTEXT,COL_MENUSELECTEDTEXT,COL_MENUSELECTEDHIGHLIGHT,COL_MENUSCROLLBAR,COL_MENUDISABLEDTEXT};
        size_t Count=sizeof(ColorIndex)/sizeof(ColorIndex[0]);
        if(Count>fdic->ColorsCount) Count=fdic->ColorsCount;
        for(size_t i=0;i<Count;i++)
        {
          FarColor fc;
          if (Info.AdvControl(&MainGuid, ACTL_GETCOLOR, ColorIndex[i],&fc))
          {
            Colors[i] = fc;
          }
        }
        return TRUE;
      }
      break;
    case DN_INITDIALOG:
      Info.SendDlgMessage(hDlg,DM_UPDATESIZE,0,0);
      TryLoadDir(hDlg,(OFDData *)Param2,((OFDData *)Param2)->curr_dir);
      break;
    case DN_HELP:
      Info.ShowHelp(Info.ModuleName,_T("FileDialog"),FHELP_SELFHELP);
      return (long)NULL;
    case DN_CLOSE:
      {
        if((Param1==0)&&ItemPresent)
        {
          lstrcpy(DlgParams->filename,DlgParams->curr_dir);
          if(lstrcmp(DlgParams->names[item.ItemIndex].Text,_T("..")))
            lstrcat(DlgParams->filename,DlgParams->names[item.ItemIndex].Text);
          DlgParams->result=true;
        }
        if (DlgParams->names)
        {
          free(DlgParams->names);
          DlgParams->names=NULL;
        }
      }
      break;
    case DN_RESIZECONSOLE:
      Info.SendDlgMessage(hDlg,DM_UPDATESIZE,0,0);
      break;
    case DM_UPDATESIZE:
      {
        const int minimal_width=65,minimal_height=12;
        int width=minimal_width,height=minimal_height;
        HANDLE console=CreateFile(_T("CONOUT$"),GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
        if(console!=INVALID_HANDLE_VALUE)
        {
          COORD console_size={80,25};
          SMALL_RECT console_rect;
          if(Info.AdvControl(&MainGuid,ACTL_GETFARRECT,0,&console_rect))
          {
            console_size.X=console_rect.Right-console_rect.Left+1;
            console_size.Y=console_rect.Bottom-console_rect.Top+1;
          }
          width=console_size.X*3/5;
          if(width<minimal_width) width=minimal_width;
          height=console_size.Y*2/3;
          if(height<minimal_height) height=minimal_height;
          if(width>(console_size.X-11)) width=console_size.X-11;
          if(height>(console_size.Y-4)) height=console_size.Y-4;
          CloseHandle(console);
        }
        Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
        { //minimize listbox
          SMALL_RECT listbox_size={3,1,4,2};
          Info.SendDlgMessage(hDlg,DM_SETITEMPOSITION,0,&listbox_size);
        }
        { //resize and move dialog
          COORD dialog_size={(short)(width+6),(short)(height+2)};
          Info.SendDlgMessage(hDlg,DM_RESIZEDIALOG,0,&dialog_size);
          COORD position={-1,-1};
          Info.SendDlgMessage(hDlg,DM_MOVEDIALOG,TRUE,&position);
        }
        { //resize listbox
          SMALL_RECT listbox_size={3,1,(short)(width+2),(short)(height)};
          Info.SendDlgMessage(hDlg,DM_SETITEMPOSITION,0,&listbox_size);
        }
        Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
      }
      break;
  }
  return Info.DefDlgProc(hDlg,Msg,Param1,Param2);
}
コード例 #5
0
ファイル: test.cpp プロジェクト: Maximus5/evil-programmers
static intptr_t WINAPI MainDialogProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2)
{
  switch(Msg)
  {
    case DN_INITDIALOG:
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_INIT,1,0);
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("aaa"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("1 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("2 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("3 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("4 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("5 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("6 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("7 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("8 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("9 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("0 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("1 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("2 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("3 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("4 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("5 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("6 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("7 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("8 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("9 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("0 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("1 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("2 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("3 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("4 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("5 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("6 bbb"));
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ADDSTR,1,(void*)_T("7 bbb"));
      {
        ListBoxExSetColor color={2,LISTBOXEX_COLORS_ITEM,0,{{FCF_FG_4BIT|FCF_BG_4BIT,0xC,0x7,NULL},0,false}};
        for(int i=2;i<5;i++)
        {
          color.ColorIndex=i;
          Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_SETCOLOR,1,&color);
        }
        color.Color.Color.ForegroundColor=0xA;
        color.Color.Color.BackgroundColor=0x7;
        for(int i=7;i<10;i++)
        {
          color.ColorIndex=i;
          Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_SETCOLOR,1,&color);
        }
        color.Color.Color.ForegroundColor=0x9;
        color.Color.Color.BackgroundColor=0x7;
        for(int i=12;i<15;i++)
        {
          color.ColorIndex=i;
          Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_SETCOLOR,1,&color);
        }
        color.Color.Color.ForegroundColor=0x9;
        color.Color.Color.BackgroundColor=0x0;
        color.TypeIndex=LISTBOXEX_COLORS_SELECTED;
        for(int i=12;i<15;i++)
        {
          color.ColorIndex=i;
          Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_SETCOLOR,1,&color);
        }
        ListBoxExSetHotkey hotkey={16,'a'};
        Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_SETHOTKEY,1,&hotkey);
      }
      break;
    case DN_CONTROLINPUT:
      {
        const INPUT_RECORD* record=(const INPUT_RECORD *)Param2;
        if(record->EventType==KEY_EVENT&&record->Event.KeyEvent.bKeyDown)
        {
          WORD vk=record->Event.KeyEvent.wVirtualKeyCode;
          if(IsNone(record))
          {
            switch(vk)
            {
              case VK_DELETE:
                {
                  FarListDelete list={sizeof(FarListDelete),3,4};
                  Info.SendDlgMessage(hDlg,DM_LISTBOXEX_DELETE,1,&list);
                }
                break;
              case VK_F2:
                {
                  ListBoxExSetFlags flags={Info.SendDlgMessage(hDlg,DM_LISTBOXEX_GETCURPOS,1,0L),LIFEX_DISABLE};
                  Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_SETFLAGS,1,&flags);
                }
                break;
              case VK_F3:
                {
                  ListBoxExSetFlags flags={Info.SendDlgMessage(hDlg,DM_LISTBOXEX_GETCURPOS,1,0L)-1,0};
                  Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_SETFLAGS,1,&flags);
                }
                break;
              case VK_INSERT:
                Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_TOGGLE,1,(void*)Info.SendDlgMessage(hDlg,DM_LISTBOXEX_GETCURPOS,1,0L));
                break;
            }
          }
          else if(IsShift(record))
          {
            switch(vk)
            {
              case VK_DELETE:
                {
                  ListBoxExSetFlags flags={Info.SendDlgMessage(hDlg,DM_LISTBOXEX_GETCURPOS,1,0L),LIFEX_HIDDEN};
                  Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_SETFLAGS,1,&flags);
                }
                break;
            }
          }
          else if(IsCtrl(record))
          {
            switch(vk)
            {
              case VK_UP:
                {
                  FarListPos pos={sizeof(FarListPos),Info.SendDlgMessage(hDlg,DM_LISTBOXEX_GETCURPOS,1,0L),-1};
                  Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_MOVE_UP,1,(void*)(INT_PTR)pos.SelectPos);
                  pos.SelectPos--;
                  Info.SendDlgMessage(hDlg,DM_LISTBOXEX_SETCURPOS,1,&pos);
                }
                break;
              case VK_DOWN:
                {
                  FarListPos pos={sizeof(FarListPos),Info.SendDlgMessage(hDlg,DM_LISTBOXEX_GETCURPOS,1,0L),-1};
                  Info.SendDlgMessage(hDlg,DM_LISTBOXEX_ITEM_MOVE_DOWN,1,(void*)(INT_PTR)pos.SelectPos);
                  pos.SelectPos++;
                  Info.SendDlgMessage(hDlg,DM_LISTBOXEX_SETCURPOS,1,&pos);
                }
                break;
            }
          }
        }
      }
      break;
    case DN_CLOSE:
      Info.SendDlgMessage(hDlg,DM_LISTBOXEX_FREE,1,0);
      break;
    case DM_LISTBOXEX_ISLBE:
      if(Param1==1) return TRUE;
      return FALSE;
  }
  return ListBoxExDialogProc(hDlg,Msg,Param1,Param2);
}
コード例 #6
0
void
WidgetKeyboardEvent::GetShortcutKeyCandidates(
                       ShortcutKeyCandidateArray& aCandidates)
{
  MOZ_ASSERT(aCandidates.IsEmpty(), "aCandidates must be empty");

  // ShortcutKeyCandidate::mCharCode is a candidate charCode.
  // ShortcutKeyCandidate::mIgnoreShift means the mCharCode should be tried to
  // execute a command with/without shift key state. If this is TRUE, the
  // shifted key state should be ignored. Otherwise, don't ignore the state.
  // the priority of the charCodes are (shift key is not pressed):
  //   0: PseudoCharCode()/false,
  //   1: unshiftedCharCodes[0]/false, 2: unshiftedCharCodes[1]/false...
  // the priority of the charCodes are (shift key is pressed):
  //   0: PseudoCharCode()/false,
  //   1: shiftedCharCodes[0]/false, 2: shiftedCharCodes[0]/true,
  //   3: shiftedCharCodes[1]/false, 4: shiftedCharCodes[1]/true...
  uint32_t pseudoCharCode = PseudoCharCode();
  if (pseudoCharCode) {
    ShortcutKeyCandidate key(pseudoCharCode, false);
    aCandidates.AppendElement(key);
  }

  uint32_t len = mAlternativeCharCodes.Length();
  if (!IsShift()) {
    for (uint32_t i = 0; i < len; ++i) {
      uint32_t ch = mAlternativeCharCodes[i].mUnshiftedCharCode;
      if (!ch || ch == pseudoCharCode) {
        continue;
      }
      ShortcutKeyCandidate key(ch, false);
      aCandidates.AppendElement(key);
    }
    // If unshiftedCharCodes doesn't have numeric but shiftedCharCode has it,
    // this keyboard layout is AZERTY or similar layout, probably.
    // In this case, Accel+[0-9] should be accessible without shift key.
    // However, the priority should be lowest.
    if (!HasASCIIDigit(aCandidates)) {
      for (uint32_t i = 0; i < len; ++i) {
        uint32_t ch = mAlternativeCharCodes[i].mShiftedCharCode;
        if (ch >= '0' && ch <= '9') {
          ShortcutKeyCandidate key(ch, false);
          aCandidates.AppendElement(key);
          break;
        }
      }
    }
  } else {
    for (uint32_t i = 0; i < len; ++i) {
      uint32_t ch = mAlternativeCharCodes[i].mShiftedCharCode;
      if (!ch) {
        continue;
      }

      if (ch != pseudoCharCode) {
        ShortcutKeyCandidate key(ch, false);
        aCandidates.AppendElement(key);
      }

      // If the char is an alphabet, the shift key state should not be
      // ignored. E.g., Ctrl+Shift+C should not execute Ctrl+C.

      // And checking the charCode is same as unshiftedCharCode too.
      // E.g., for Ctrl+Shift+(Plus of Numpad) should not run Ctrl+Plus.
      uint32_t unshiftCh = mAlternativeCharCodes[i].mUnshiftedCharCode;
      if (CharsCaseInsensitiveEqual(ch, unshiftCh)) {
        continue;
      }

      // On the Hebrew keyboard layout on Windows, the unshifted char is a
      // localized character but the shifted char is a Latin alphabet,
      // then, we should not execute without the shift state. See bug 433192.
      if (IsCaseChangeableChar(ch)) {
        continue;
      }

      // Setting the alternative charCode candidates for retry without shift
      // key state only when the shift key is pressed.
      ShortcutKeyCandidate key(ch, true);
      aCandidates.AppendElement(key);
    }
  }

  // Special case for "Space" key.  With some keyboard layouts, "Space" with
  // or without Shift key causes non-ASCII space.  For such keyboard layouts,
  // we should guarantee that the key press works as an ASCII white space key
  // press.  However, if the space key is assigned to a function key, it
  // shouldn't work as a space key.
  if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING &&
      mCodeNameIndex == CODE_NAME_INDEX_Space && pseudoCharCode != ' ') {
    ShortcutKeyCandidate spaceKey(' ', false);
    aCandidates.AppendElement(spaceKey);
  }
}