VOID TfrmFamilyManager::NewFamily( KFont_family* pFamily ) { _pFamily = pFamily; TreeView1->Items->Clear(); TTreeNode* pFamilyNode = TreeView1->Items->Add( NULL, _pFamily->name.c_str() ); UINT nFaceCnt = pFamily->size(); for( UINT i = 0; i < nFaceCnt; i++ ) { KFont_face* pFace = pFamily->at( i ); TTreeNode* pFaceNode = TreeView1->Items->AddChild( pFamilyNode, pFace->name.c_str() ); UINT nGlyphCnt = pFace->size(); for(UINT j = 0; j < nGlyphCnt; j++) { KFont_glyph* pGlyph = pFace->at( j ); TreeView1->Items->AddChild( pFaceNode, pGlyph->name.c_str() ); } } pFamilyNode->Expand( TRUE ); }
//--------------------------------------------------------------------------- void __fastcall TLocationProfilesDialog::FindProfile(TTreeView * ProfilesView) { if ((ProfilesView->Selected == NULL) || !ProfileMatch(ProfilesView->Selected)) { TTreeNode * Match = NULL; for (int Index = 0; Index < ProfilesView->Items->Count; Index++) { TTreeNode * Node = ProfilesView->Items->Item[Index]; if (ProfileMatch(Node)) { Match = Node; break; } } if (Match) { ProfilesView->Selected = Match; Match->MakeVisible(); } else { ProfilesView->Selected = NULL; } } }
VOID TfrmFamilyManager::OpenFamily( KFont_family* pFamily ) { //파일 열기 전에 모두 닫는다. //frmMain->CloseAll(); //openStream 에서 받은 Family를 가져온다. _pFamily = pFamily; TTreeNode* pFamilyNode = TreeView1->Items->Add( NULL, _pFamily->name.c_str() ); UINT nFaceCnt = pFamily->size(); for( UINT i = 0; i < nFaceCnt; i++ ) { KFont_face* pFace = pFamily->at( i ); TTreeNode* pFaceNode = TreeView1->Items->AddChild( pFamilyNode, pFace->name.c_str() ); UINT nGlyphCnt = pFace->size(); for(UINT j = 0; j < nGlyphCnt; j++) { KFont_glyph* pGlyph = pFace->at( j ); TreeView1->Items->AddChild( pFaceNode, pGlyph->name.c_str() ); } } pFamilyNode->Expand( TRUE ); }
void TGuiToProfile::_sourceRootDirList() { PProfile->sourceRootDirList.clear(); TTreeNode* node = f_Main->fr_Source->tv_Dirs->Items->GetFirstNode(); while (node) { PProfile->sourceRootDirList.push_back(IncludeTrailingPathDelimiter(node->Text)); node = node->getNextSibling(); } }
void TfrmMove::LoadTree( TTreeView* tree, TTreeNode* parent, IPart* data ) { if( data != NULL && data->getType() < IPart::BoxType ) { //don't go below box Util::ShowTreeNode(tree, parent, false, false); TTreeNode* node = parent->getFirstChild(); while( node != NULL ) { LoadTree( tree, node, (IPart*)node->Data ); node = node->GetNextChild(node); } } }
//--------------------------------------------------------------------------- void __fastcall TLocationProfilesDialog::BookmarkMove(TObject * Sender, TTreeNode * Source, TTreeNode * Dest) { TBookmarkList * BookmarkList = GetBookmarkList(Sender); TTreeView * ProfilesView = GetProfilesView(Sender); TStringList * Folders = GetFolders(Sender); assert(Source && Source->Data); TBookmark * Bookmark = (TBookmark *)Source->Data; TTreeNode * PrevFolderNode = Source->Parent; if (!Dest || !Dest->Data) { Bookmark->Node = Dest ? Dest->Text : UnicodeString(); BookmarkList->MoveTo(BookmarkList->Bookmarks[BookmarkList->Count - 1], Bookmark, false); ProfilesView->Selected->MoveTo(Dest, naAddChild); } else { TBookmark * DestBookmark = (TBookmark *)Dest->Data; Bookmark->Node = DestBookmark->Node; BookmarkList->MoveTo(DestBookmark, Bookmark, Source->AbsoluteIndex > Dest->AbsoluteIndex); if (Source->AbsoluteIndex > Dest->AbsoluteIndex) { Source->MoveTo(Dest, naInsert); } else if (Dest->getNextSibling() != NULL) { Source->MoveTo(Dest->getNextSibling(), naInsert); } else { Source->MoveTo(Dest, naAdd); } } if (PrevFolderNode && !PrevFolderNode->Count) { assert(Folders->IndexOfObject(PrevFolderNode) >= 0); Folders->Delete(Folders->IndexOfObject(PrevFolderNode)); PrevFolderNode->Delete(); } Source->MakeVisible(); UpdateControls(); }
void TGuiToProfile::sourceDirLists() { _sourceRootDirList(); PProfile->excludeDirList.clear(); PProfile->includeDirList.clear(); PProfile->excludeTreeList.clear(); PProfile->includeTreeList.clear(); String rootdir; TTreeNode* node = f_Main->fr_Source->tv_Dirs->Items->GetFirstNode(); while (node) { _addSourceDirToList(node, rootdir, false); _sourceDirLists2(node->getFirstChild(), IncludeTrailingPathDelimiter(rootdir + node->Text)); node = node->getNextSibling(); } }
AnsiString __fastcall TfrmTreeFrame::GetOption() { AnsiString opt,temp; TTreeNode *node =Tree->Items->GetFirstNode(); while (node !=NULL) { if ((node->ImageIndex==2) || (node->ImageIndex==1)) { temp = GetSub(node); if ((temp !="") & (opt!="")) opt =opt+ CRLF +temp; else opt =opt+temp; } node = node->getNextSibling(); } return opt; }
//--------------------------------------------------------------------------- void __fastcall TLocationProfilesDialog::BookmarkButtonClick(TObject * Sender) { TControl * Control = dynamic_cast<TControl *>(Sender); TTreeNode * Node = GetProfilesView(Sender)->Selected; assert(Node); assert(Node->Data); TTreeNode * TargetNode; if (Control->Tag < 0) { TargetNode = Node->getPrevSibling(); assert(TargetNode); } else { TargetNode = Node->getNextSibling(); } BookmarkMove(Sender, Node, TargetNode ? TargetNode : Node->Parent); }
//--------------------------------------------------------------------------- void __fastcall TDialogProjectNew::ListViewClick(TObject *Sender) { if (ListView->Selected) { TBusy Busy; { String Path = Usul()->Path + "\\Templates\\Projects\\." + ListView->Selected->Caption + ".rtf"; RichEdit->Visible = FileExists(Path); if (RichEdit->Visible) RichEdit->Lines->LoadFromFile(Path); } TreeView->Items->BeginUpdate(); TreeView->Items->Clear(); String Path = TemplatePath + "\\" + ListView->Selected->Caption; TTreeNode *TreeNode = TreeView->Items->Add(0, Path); TreeNode->ImageIndex = 1; TreeNode->SelectedIndex = 1; BuildTreeView(TreeView, TreeNode, Path); TreeNode->Expand(true); TreeView->Items->EndUpdate(); } }
//--------------------------------------------------------------------------- void __fastcall TFrm1010::CarregaMenu(TTreeNode *pParentItem) { String TextNode; SfgMenuInfo *MenuInfo; TTreeNode *pChildItem = NULL; TTreeNode *pFirstItem = NULL; CadMenu->Filtered = false; if (pParentItem == NULL) { CadMenu->Filter = "cod_rotina_pai IS NULL"; } else { MenuInfo = (SfgMenuInfo*)pParentItem->Data; CadMenu->Filter = "cod_rotina_pai = " + QuotedStr(MenuInfo->cod_rotina); } CadMenu->Filtered = true; CadMenu->First(); while (!CadMenu->Eof) { MenuInfo = new SfgMenuInfo(); MenuInfo->cod_rotina = CadMenu->FieldByName("cod_rotina")->AsString; if (CadMenu->FieldByName("programa")->AsString.Length() > 0) { TextNode = CadMenu->FieldByName("programa")->AsString.UpperCase() + " - " + CadMenu->FieldByName("den_rotina")->AsString; } else { TextNode = CadMenu->FieldByName("den_rotina")->AsString; } if (pParentItem == NULL) { pChildItem = TreeMenu->Items->AddObject(pParentItem, TextNode, (void*)MenuInfo); } else { pChildItem = TreeMenu->Items->AddChildObject(pParentItem, TextNode, (void*)MenuInfo); } pChildItem->ImageIndex = CadMenu->FieldByName("ico_index")->AsInteger; pChildItem->SelectedIndex = pChildItem->ImageIndex; if (pFirstItem == NULL) { pFirstItem = pChildItem; } CadMenu->Next(); } while(pFirstItem != NULL) { CarregaMenu(pFirstItem); pFirstItem = pFirstItem->getNextSibling(); } }
//--------------------------------------------------------------------------- void __fastcall TFrm1010::execBtCancelExecute(TObject *Sender) { TTreeNode *Node; TTreeNode *Prew = NULL; if (CadMenu->State == dsInsert) { Node = TreeMenu->Selected; Prew = Node->getPrevSibling(); if(Prew == NULL) { Prew = Node->GetPrev(); } if (Node) { TreeMenu->Items->Delete(Node); } } CadMenu->Cancel(); pWorkEdition->SetWorkEdition(false,true,AppConfig->Colors->Disabled); HabilitarItens(false); ico_index->Color = AppConfig->Colors->Disabled; if (Prew != NULL) { TreeMenu->Selected = Prew; } }
//--------------------------------------------------------------------------- void __fastcall TLocationProfilesDialog::RemoveBookmark(TObject * Sender) { TBookmarkList * BookmarkList = GetBookmarkList(Sender); TTreeView * ProfilesView = GetProfilesView(Sender); TStringList * Folders = GetFolders(Sender); assert(ProfilesView->Selected); TTreeNode * Node = ProfilesView->Selected; if (Node->Data) { BookmarkList->Delete((TBookmark *)Node->Data); TTreeNode * ParentNode = Node->Parent; Node->Delete(); if (ParentNode && !ParentNode->Count) { assert(Folders->IndexOfObject(ParentNode) >= 0); Folders->Delete(Folders->IndexOfObject(ParentNode)); ParentNode->Delete(); } } else { UnicodeString Message = MainInstructions(LoadStr(DELETE_BOOKMARK_FOLDER)); if (MessageDialog(Message, qtConfirmation, qaYes | qaNo, HELP_LOCATION_PROFILE_DELETE) == qaYes) { assert(Node->Count); for (int i = 0; i < Node->Count; i++) { BookmarkList->Delete((TBookmark *)Node->Item[i]->Data); } assert(Folders->IndexOfObject(Node) >= 0); Folders->Delete(Folders->IndexOfObject(Node)); Node->Delete(); } } UpdateControls(); }
Fun TreeBreadthFirstTraverse(TTreeNode& tree_node, Fun func) { ETreeTraverseCode stop_scan; stop_scan = func(tree_node); switch(stop_scan) { case eTreeTraverseStop: case eTreeTraverseStepOver: return func; case eTreeTraverse: break; } if ( stop_scan ) return func; TTreeNode* tr = &tree_node; typedef typename TTreeNode::TNodeList_I TTreeNodeIterator; TTreeNodeIterator it = tr->SubNodeBegin(); TTreeNodeIterator it_end = tr->SubNodeEnd(); if (it == it_end) return func; queue<TTreeNodeIterator> tree_queue; while (it != it_end) tree_queue.push(it++); while (!tree_queue.empty()) { it = tree_queue.front(); // get oldest node on queue tr = *it; tree_queue.pop(); // take oldest node off stop_scan = eTreeTraverse; if (tr) { stop_scan = func(*tr); switch(stop_scan) { case eTreeTraverseStop: return func; case eTreeTraverse: case eTreeTraverseStepOver: break; } } // Add children (if any) of node to queue if (stop_scan != eTreeTraverseStepOver && !tr->IsLeaf()) { it = tr->SubNodeBegin(); it_end = tr->SubNodeEnd(); while (it != it_end) tree_queue.push(it++); } } return func; }
//--------------------------------------------------------------------------- extern "C" int _export PASCAL UIShowFolderSelectorForm(void *reserved, char *buf) { TFolderSelectorForm *form = new TFolderSelectorForm(Application); form->ShellTreeView->Path = buf; // initial directory if(form->ShellTreeView->Selected) { form->ShellTreeView->Selected->Expanded = true; TTreeNode * topnode = form->ShellTreeView->Selected; if(topnode->Count >= 1) { TTreeNode * longestitem = NULL; int longesttextsize = -1; for(int i = 0; i < topnode->Count; i++) { TTreeNode *subnode = topnode->Item[i]; TRect rect = subnode->DisplayRect(true); if(rect.right > longesttextsize) { longesttextsize = rect.right; longestitem = topnode->Item[i]; } } if(longestitem) longestitem->MakeVisible(); // form->ShellTreeView->Selected->MakeVisible(); // INT min, max; // ::GetScrollRange(form->ShellTreeView->Handle, SB_HORZ, &min, &max); // ::SetScrollPos(form->ShellTreeView->Handle, SB_HORZ, max, true); // form->ShellTreeView->Selected->MakeVisible(); // TreeView_EnsureVisible(form->ShellTreeView->Selected->Handle, // form->ShellTreeView->Selected->ItemId); } form->ShellTreeView->TopItem = topnode; topnode->MakeVisible(); } int res = form->ShowModal(); if(res == mrOk) { if(DirectoryExists(form->Selected)) { form->Selected = IncludeTrailingBackslash(form->Selected); } strcpy(buf, form->Selected.c_str()); } delete form; return res; }
__fastcall TRelFolderSelectorForm::TRelFolderSelectorForm(TComponent* Owner) : TForm(Owner) { ShellTreeView->Path = ExtractFileDir(ParamStr(0)); // adjust components Label1->Left = SPACER; Label1->Top = SPACER; ShellComboBox->Left = SPACER; ShellComboBox->Top = SPACER + Label1->Height + 2; ShellComboBox->Width = ClientWidth - SPACER * 2; ShellTreeView->Left = SPACER; ShellTreeView->Top = ShellComboBox->Height + ShellComboBox->Top; ShellTreeView->Width = ClientWidth - SPACER * 2; OKButton->Top = ClientHeight - OKButton->Height - SPACER; CancelButton->Top = ClientHeight - CancelButton->Height - SPACER; OKButton->Left = ClientWidth - (StatusBar->Width + SPACER + CancelButton->Width + SPACER + OKButton->Width); CancelButton->Left = ClientWidth - ( StatusBar->Width + SPACER + CancelButton->Width); ShellTreeView->Height = CancelButton->Top - SPACER - ShellTreeView->Top; if(ShellTreeView->Selected) { ShellTreeView->Selected->Expanded = true; TTreeNode * topnode = ShellTreeView->Selected; if(topnode->Count >= 1) { TTreeNode * longestitem = NULL; int longesttextsize = -1; for(int i = 0; i < topnode->Count; i++) { TTreeNode *subnode = topnode->Item[i]; TRect rect = subnode->DisplayRect(true); if(rect.right > longesttextsize) { longesttextsize = rect.right; longestitem = topnode->Item[i]; } } if(longestitem) longestitem->MakeVisible(); } ShellTreeView->TopItem = topnode; topnode->MakeVisible(); } }
void __fastcall TBatchCollectDataThread::Execute() { //---- Place thread code here ---- ValidSBTN->Enabled = false; if(SerReceiveFunc&&SendAckFunc) { /* String filepathstr = GlobalPath+"\\StroeBatchDataFile.dat"; hStoreToFile = CreateFile(filepathstr.t_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(hStoreToFile) { */ errortag = false; *validcollecttag = true; ValidEBTN->Enabled = true; ModeOFCollect = 2; String CollectTime = "*CollectTime* "; CollectTime += Date(); CollectTime += " "; CollectTime += Time(); BatchDataSaveToFileStream<<endl<<CollectTime.t_str()<<endl; nodecount = ValidPosTreeList->Items->Count; currentcount = 0; ValidCProgressBar->Position = 0; TTreeNode* tmpnode = ValidPosTreeList->Items->GetFirstNode(); while(tmpnode) { errortag = false; poscollectedrecordcount = 0; if(!Terminated) { tmpnode->Data; POSPARA* tmppospara = (POSPARA*)(tmpnode->Data); if(4 == tmppospara->tag) { WORD ReceiveStatus = -1; WORD SynchroStatus = -1; char temp[10] = ""; unsigned char como = (unsigned char)(tmppospara->comnum); PosNumber = tmppospara->posnum; WORD PosNO = (WORD)(tmppospara->posnum); unsigned char ReceiveCMD = 0x23; unsigned char SynchroCMD = 0x54; ZeroMemory(receivebuf, 2048); int receivelen = 2048; unsigned char* dir = "E:\\RAD\\2010-9-26\\Recieve"; int dirlen = strlen(dir); UpdateDataBaseQuery->Close(); UpdateDataBaseQuery->SQL->Clear(); String tmpsql = "select * from SFJPARAM where JH="; tmpsql += tmppospara->posnum; // tmpsql += "'"; UpdateDataBaseQuery->SQL->Add(tmpsql); UpdateDataBaseQuery->Open(); Place = UpdateDataBaseQuery->FieldByName("STNAME")->AsAnsiString.Trim(); UpdateDataBaseQuery->Close(); int recordinpos = 0; WORD posstatus = -1; WORD poscomo = como; unsigned char statusCMD = 0x43; unsigned char statusbuf[16]; ZeroMemory(statusbuf,16); int statuslen = 16; posstatus = SerReceiveFunc(poscomo, PosNO, statusCMD, statusbuf, statuslen, 1, dir, dirlen); if(0 == posstatus) { int lowptr = 256*(int)statusbuf[0] + (int)statusbuf[1]; int highptr = 256*(int)statusbuf[2] + (int)statusbuf[3]; if(highptr >= lowptr) { recordinpos = highptr - lowptr; } else { recordinpos = highptr + 6576 - lowptr; } posallrecordcount = recordinpos; } else { tmpnode->Text = "POS机异常"; tmpnode = tmpnode->GetNext(); currentcount++; continue; } tmpcaptionstr = "正在采集"; tmpcaptionstr += tmppospara->posnum; tmpcaptionstr += "号机,位于:"; tmpcaptionstr += Place; tmpcaptionstr += ",该POS机含有消费记录"; tmpcaptionstr += recordinpos; tmpcaptionstr += "条。"; ValidInfoPanel->Caption = tmpcaptionstr; bool continued = true; DisplayCollectingFunc(); while(continued) { if(!Terminated) { ReceiveStatus = SerReceiveFunc(como, PosNO, ReceiveCMD, receivebuf, receivelen, 1, dir, dirlen); if(0 == ReceiveStatus) { SynchroStatus = SendAckFunc(como, SynchroCMD); if(0 == SynchroStatus) { // for(int i = 0; i < 2048; i++) // BatchDataSaveToFileStream<<receivebuf[i]; if((0x00 == receivebuf[10])&&(0x00 == receivebuf[11])) continued = false; if(0x00 != receivebuf[8]) { Synchronize(AnalyzeDataFunc); } CollectOverStautsStr = "已完成批量数据采集!"; } // else // { // MessageBox(SDIAppForm->Handle, "Sysc error", "error", MB_OK|MB_ICONERROR); // } } else { continued = false; CollectOverStautsStr = "POS机通信异常,采集数据不完整!"; errortag = true; } Sleep(100); } else { continued = false; *validcollecttag = false; ModeOFCollect = 0; CloseHandle(hStoreToFile); // ValidStoreBtn->Enabled = true; ValidEBTN->Enabled = true; // if(BatchDataSaveToFileStream) // BatchDataSaveToFileStream.close(); BatchCollectFRM->Close(); ValidSBTN->Enabled = true; return; } } DisplayEndCollectFunc(); } } else { *validcollecttag = false; ModeOFCollect = 0; // CloseHandle(hStoreToFile); // ValidStoreBtn->Enabled = true; ValidEBTN->Enabled = true; // if(BatchDataSaveToFileStream) // BatchDataSaveToFileStream.close(); BatchCollectFRM->Close(); ValidSBTN->Enabled = true; return; } tmpnode = tmpnode->GetNext(); currentcount++; ValidCProgressBar->Position = currentcount*100/nodecount; } *validcollecttag = false; // CloseHandle(hStoreToFile); // ValidStoreBtn->Enabled = true; ValidEBTN->Enabled = true; // if(BatchDataSaveToFileStream) // BatchDataSaveToFileStream.close(); ValidCProgressBar->Position = 100; if(!errortag) { ValidInfoPanel->Caption = "数据采集完毕!"; MessageBox(SDIAppForm->Handle, "数据采集完毕!", "采集完毕", MB_OK); } else { ValidInfoPanel->Caption = "数据采集过程中出现通信异常,部分数据采集不成功,可以通过重新采集修补!"; MessageBox(SDIAppForm->Handle, "数据采集过程中出现通信异常,部分数据采集不成功,可以通过重新采集修补!", "采集不完整", MB_OK|MB_ICONERROR); } /* if(mrOk == MessageBox(SDIAppForm->Handle, "数据采集完毕,是否进行数据入库?", "采集完毕", MB_OKCANCEL|MB_ICONQUESTION)) ValidStoreBtn->Click(); else { ValidCProgressBar->Properties->Marquee = false; } */ /* } else { MessageBox(SDIAppForm->Handle, "无法创建数据存储文件,请联系技术人员!", "Error", MB_OK|MB_ICONERROR); // if(BatchDataSaveToFileStream) // BatchDataSaveToFileStream.close(); *validcollecttag = false; ModeOFCollect = 0; return; } */ } else { *validcollecttag = false; ModeOFCollect = 0; if(BatchDataSaveToFileStream) BatchDataSaveToFileStream.close(); MessageBox(SDIAppForm->Handle, "Error in Load SerReceiveFunc Or SendAckFunc!", "Error", MB_OK|MB_ICONERROR); } ValidSBTN->Enabled = true; }
void TestTreeFunction() { TestData data[] = { { 0, "/" }, { 1, "home" }, { 2, "usr" }, { 3, "var" }, { 4, "user" }, { 5, "muggle" }, { 6, "bin" }, { 7, "include" }, { 8, "local" }, { 9, "lib" }, { 10, "sbin" }, { 11, "src" }, }; // init TTreeNode<TestData>* root = TTreeNode<TestData>::Create(data[0]); TTreeNode<TestData>* home = root->AddChild(TTreeNode<TestData>::Create(data[1])); TTreeNode<TestData>* usr = root->AddChild(TTreeNode<TestData>::Create(data[2])); root->AddChild(TTreeNode<TestData>::Create(data[3])); home->AddChild(TTreeNode<TestData>::Create(data[4])); home->AddChild(TTreeNode<TestData>::Create(data[5])); usr->AddChild(TTreeNode<TestData>::Create(data[6])); usr->AddChild(TTreeNode<TestData>::Create(data[7])); TTreeNode<TestData>* local = usr->AddChild(TTreeNode<TestData>::Create(data[8])); local->AddChild(TTreeNode<TestData>::Create(data[9])); local->AddChild(TTreeNode<TestData>::Create(data[10])); local->AddChild(TTreeNode<TestData>::Create(data[11])); TTreeNode<TestData>* copy_root = TTreeNode<TestData>::Create(*root); TestTNodeFunction(root); TestTTreeFunction(copy_root); }
//--------------------------------------------------------------------------- void __fastcall TCollectDataWOThread::Execute() { //---- Place thread code here ---- if(SerReceiveFunc&&SendAckFunc) { String filepathstr = GlobalPath+"\\StoreRealCWOIBData.dat"; hStoreToFile = CreateFile(filepathstr.t_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(!hStoreToFile) { MessageBox(SDIAppForm->Handle, "无法创建数据存储文件,请联系技术人员!", "Error", MB_OK|MB_ICONERROR); *validcollecttag = false; ModeOFCollect = 0; return; } ValidLostInfoT->Active = false; ValidLostInfoT->Active = true; ValidLostInfoT->First(); *validcollecttag = true; ModeOFCollect = 5; String CollectTime = "*CollectTime* "; CollectTime += Date(); CollectTime += " "; CollectTime += Time(); // DataSaveToFileStream<<endl<<CollectTime.t_str()<<endl; TTreeNode* tmpnode = ValidPosTreeList->Items->GetFirstNode(); while(tmpnode) { if(!Terminated) { tmpnode->Data; POSPARA* tmppospara = (POSPARA*)(tmpnode->Data); if(4 == tmppospara->tag) { WORD ReceiveStatus = -1; WORD SynchroStatus = -1; char temp[10] = ""; unsigned char como = (unsigned char)(tmppospara->comnum); WORD PosNO = (WORD)(tmppospara->posnum); unsigned char ReceiveCMD = 0x25; unsigned char SynchroCMD = 0x54; ZeroMemory(receivebuf, 16); int receivelen = 16; unsigned char* dir = "E:\\RAD\\2010-9-26\\Recieve"; int dirlen = strlen(dir); // unsigned char* SynchroTagbuf = new unsigned char[300]; // ZeroMemory(SynchroTagbuf, *ONLinePosNum); String comparestr = "FFFFFF"; /* UpdateDataBaseQuery->Close(); UpdateDataBaseQuery->SQL->Clear(); String tmpsql = "select * from SFJPARAM where JH='"; tmpsql += tmppospara->posnum; tmpsql += "'"; UpdateDataBaseQuery->SQL->Add(tmpsql); UpdateDataBaseQuery->Open(); Place = UpdateDataBaseQuery->FieldByName("STNAME")->AsAnsiString.Trim(); UpdateDataBaseQuery->Close(); */ if(!Terminated) { ReceiveStatus = SerReceiveFunc(como, PosNO, ReceiveCMD, receivebuf, receivelen, 1, dir, dirlen); if(0 == ReceiveStatus) { SynchroStatus = SendAckFunc(como, SynchroCMD); if(0 == SynchroStatus) { OrignalDataStr = ""; for (int i = 0; i < receivelen; i++) { OrignalDataStr = OrignalDataStr + (IntToHex((byte)receivebuf[i], 2)); } if(comparestr != OrignalDataStr.SubString(0, 6)) { PosNumber = PosNO; DataStatusStr = "正常"; Synchronize(SaveDataToFileFunc); // Synchronize(UpdateDataBaseFunc); Synchronize(DisplayDataFunc); } } Sleep(50); } //挂失一条 if(ValidGSTag) { int GSkh; unsigned char SendStr[3]; int Strlen = 3; unsigned char status; unsigned char port; WORD pos; unsigned char CMD; if(!ValidLostInfoT->Eof) { GSkh = ValidLostInfoT->FieldByName("PARA")->AsInteger; SendStr[0] = (unsigned char)(GSkh/65536); SendStr[1] = (unsigned char)((GSkh%65536)/256); SendStr[2] = (unsigned char)GSkh; port = (unsigned char)(ValidLostInfoT->FieldByName("SFJPORT")->AsInteger); pos = WORD(ValidLostInfoT->FieldByName("SFJID")->AsInteger); if(1 == ValidLostInfoT->FieldByName("CMD")->AsInteger) { CMD = 0x33; status = SerSendFunc(port, pos, CMD, SendStr, Strlen, 1); if(0 == status) { ValidLostInfoT->Delete(); // ValidLostInfoT->Next(); } else ValidLostInfoT->Next(); } else if(2 == ValidLostInfoT->FieldByName("CMD")->AsInteger) { CMD = 0x38; status = SerSendFunc(port, pos, CMD, SendStr, Strlen, 1); if(0 == status) { ValidLostInfoT->Delete(); // ValidLostInfoT->Next(); } else ValidLostInfoT->Next(); } Sleep(50); } } } else { *validcollecttag = false; ModeOFCollect = 0; ValidCProgressBar->Properties->Marquee = false; // if(DataSaveToFileStream) // DataSaveToFileStream.close(); /// RealTimeCollectFRM->Close(); return; } } } else { *validcollecttag = false; ModeOFCollect = 0; // if(DataSaveToFileStream) // DataSaveToFileStream.close(); RealTimeCollectFRM->Close(); return; } tmpnode = tmpnode->GetNext(); if(!tmpnode) tmpnode = ValidPosTreeList->Items->GetFirstNode(); } } else { *validcollecttag = false; ModeOFCollect = 0; // if(DataSaveToFileStream) // DataSaveToFileStream.close(); MessageBox(SDIAppForm->Handle, "Error in Load SerReceiveFunc Or SendAckFunc!", "Error", MB_OK); } }
Fun TreeDepthFirstTraverse(TTreeNode& tree_node, Fun func) { int delta_level = 0; ETreeTraverseCode stop_scan; stop_scan = func(tree_node, delta_level); switch (stop_scan) { case eTreeTraverseStop: case eTreeTraverseStepOver: return func; case eTreeTraverse: break; } if (stop_scan) return func; delta_level = 1; TTreeNode* tr = &tree_node; typedef typename TTreeNode::TNodeList_I TTreeNodeIterator; TTreeNodeIterator it = tr->SubNodeBegin(); TTreeNodeIterator it_end = tr->SubNodeEnd(); if (it == it_end) return func; stack<TTreeNodeIterator> tree_stack; while (true) { tr = (TTreeNode*)*it; stop_scan = eTreeTraverse; if (tr) { stop_scan = func(*tr, delta_level); switch (stop_scan) { case eTreeTraverseStop: return func; case eTreeTraverse: case eTreeTraverseStepOver: break; } } if ( (stop_scan != eTreeTraverseStepOver) && (delta_level >= 0) && (!tr->IsLeaf())) { // sub-node, going down tree_stack.push(it); it = tr->SubNodeBegin(); it_end = tr->SubNodeEnd(); delta_level = 1; continue; } ++it; if (it == it_end) { // end of level, going up if (tree_stack.empty()) { break; } it = tree_stack.top(); tree_stack.pop(); tr = (TTreeNode*)*it; it_end = tr->GetParent()->SubNodeEnd(); delta_level = -1; continue; } // same level delta_level = 0; } // while func(tree_node, -1); return func; }