예제 #1
0
bool CFanmotorDlg::GetActiveDevice(BYTE& DeviceAddress)
{
	DeviceAddress = 255;
	CListBox* listBoxDevices = (CListBox*)GetDlgItem(IDC_DEVICE_LISTBOX);
	listBoxDevices->SetCurSel(0);
	if (listBoxDevices->GetCurSel() < 0) {
		DisplayInforMessageBox((LPCWSTR)L"Error", L"Select Active DEVICE!\r\nPress \"Device List\" button and Select Device");
		return false;
	}
	CString s;
	int n = listBoxDevices->GetTextLen(listBoxDevices->GetCurSel());
	WCHAR *ch, *buf = s.GetBuffer(n);
	listBoxDevices->GetText(listBoxDevices->GetCurSel(), buf);
	DeviceAddress = (BYTE)wcstol(buf,&ch,16);
	s.ReleaseBuffer();
	return true;
}
예제 #2
0
void CSystemTestDlg::OnLbnDblclkImageList()
{
	CString str;
	TCHAR buff[MAX_PATH] = {0};
	CListBox* listBox = (CListBox *)GetDlgItem(IDC_IMAGE_LIST);
	int idx = listBox->GetCurSel();
	if(idx > -1)
	{
		int len = listBox->GetTextLen(idx);
		listBox->GetText(idx, str);
		swprintf(buff, sizeof(TCHAR)*MAX_PATH, TEXT("img\\screenshot\\%s"), str.GetBuffer(0));

		_out(TEXT("Loading file:"));
		_out(buff);
		_initScreen(buff);
		
	}
	
}
예제 #3
0
void CSystemTestDlg::OnLbnDblclkMatchList()
{
	CString str;
	TCHAR buff[MAX_PATH] = {0};
	CListBox* listBox = (CListBox *)GetDlgItem(IDC_MATCH_LIST);
	int idx = listBox->GetCurSel();
	CImage image;
	RECT rect;
	if(idx > -1)
	{
		int len = listBox->GetTextLen(idx);
		listBox->GetText(idx, str);
		swprintf(buff, sizeof(TCHAR)*MAX_PATH, TEXT("img\\match\\%s"), str.GetBuffer(0));
		CHWNDScreen::loadInToCImage(buff, &image);
		_out(TEXT("Load match image done."));
		if(pScreen->locate(&image, &rect))
		{
			swprintf(buff, sizeof(TCHAR)*MAX_PATH, TEXT("Locate left: %d, right: %d, top: %d, bottom: %d")
				, rect.left, rect.right, rect.top, rect.bottom);
			_out(buff);
			CHWNDScreen::flashRECT(&rect);
		}
	}
}
예제 #4
0
void campaign_tree_view::drop_mission(int m, CPoint point)
{
	char name[MAX_FILENAME_LEN + 1];
	int i, item, level, pos;
	cmission *cm;
	mission a_mission;
	CListBox *listbox;

	level = query_level(point);
	pos = query_pos(point);
	Assert((level >= 0) && (pos >= 0));  // this should be impossible

	listbox = (CListBox *) &Campaign_tree_formp->m_filelist;
	item = listbox->GetCurSel();
	if (item == LB_ERR) {
		MessageBox("Select a mission from listbox to add.", "Error");
		return;
	}

	if (listbox->GetTextLen(item) > MAX_FILENAME_LEN) {
		char buf[256];

		sprintf(buf, "Filename is too long.  Must be %d or less characters.", MAX_FILENAME_LEN);
		MessageBox(buf, "Error");
		return;  // filename is too long.  Would overflow our buffer
	}

	// grab the filename selected from the listbox
	listbox->GetText(item, name);

	if (Campaign.num_missions >= MAX_CAMPAIGN_MISSIONS) {  // Can't add any more
		MessageBox("Too many missions.  Can't add more to Campaign.", "Error");
		return;
	}

	if (!level && (get_root_mission() >= 0)) {
		MessageBox("Only 1 mission may be in the top level");
		return;
	}

	// check the number of players in a multiplayer campaign against the number of players
	// in the mission that was just dropped
	if ( Campaign.type != CAMPAIGN_TYPE_SINGLE ) {
		get_mission_info(name, &a_mission);
		if ( !(a_mission.game_type & MISSION_TYPE_MULTI) ) {
			char buf[256];

			sprintf(buf, "Mission \"%s\" is not a multiplayer mission", name);
			MessageBox(buf, "Error");
			return;
		}

		if (Campaign.num_players != 0) {
			if (Campaign.num_players != a_mission.num_players) {
				char buf[512];

				sprintf(buf, "Mission \"%s\" has %d players.  Campaign has %d players.  Campaign will not play properly in FreeSpace", name, a_mission.num_players, Campaign.num_players );
				MessageBox(buf, "Warning");
			}

		} else {
			Campaign.num_players = a_mission.num_players;
		}
	}

	Elements[Campaign.num_missions].from_links = Elements[Campaign.num_missions].to_links = 0;
	cm = &(Campaign.missions[Campaign.num_missions++]);
	cm->name = strdup(name);
	cm->formula = Locked_sexp_true;
	cm->num_goals = -1;
	cm->notes = NULL;
	cm->briefing_cutscene[0] = 0;
	for (i=0; i<Campaign.num_missions - 1; i++)
		if ((Campaign.missions[i].level == level) && (Campaign.missions[i].pos + 1 == pos)) {
			pos = query_alternate_pos(point);
			break;
		}

	cm->level = level;
	cm->pos = pos - 1;
	correct_position(Campaign.num_missions - 1);
	sort_links();
	SetScrollSizes(MM_TEXT, CSize(total_width * CELL_WIDTH, total_levels * LEVEL_HEIGHT));
	Invalidate();

	// update and reinitialize dialog items
	if ( Campaign.type != CAMPAIGN_TYPE_SINGLE ) {
		Campaign_tree_formp->update();
		Campaign_tree_formp->initialize(0);
	}

	listbox->DeleteString(item);
	Campaign_modified = 1;
	return;
}
예제 #5
0
std::wstring GetListBoxText(const CListBox& box, int item)
{
	std::vector<wchar_t> text(box.GetTextLen(item) + 1);
	box.GetText(item, text.data());
	return text.data();
}