void grpc_iomgr_shutdown(void) { grpc_iomgr_object *obj; grpc_iomgr_closure *closure; gpr_timespec shutdown_deadline = gpr_time_add(gpr_now(), gpr_time_from_seconds(10)); gpr_mu_lock(&g_mu); g_shutdown = 1; while (g_cbs_head || g_root_object.next != &g_root_object) { size_t nobjs = count_objects(); gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed%s", nobjs, g_cbs_head ? " and executing final callbacks" : ""); if (g_cbs_head) { do { closure = g_cbs_head; g_cbs_head = closure->next; if (!g_cbs_head) g_cbs_tail = NULL; gpr_mu_unlock(&g_mu); closure->cb(closure->cb_arg, 0); gpr_mu_lock(&g_mu); } while (g_cbs_head); continue; } if (nobjs > 0) { int timeout = 0; gpr_timespec short_deadline = gpr_time_add(gpr_now(), gpr_time_from_millis(100)); while (gpr_cv_wait(&g_rcv, &g_mu, short_deadline) && g_cbs_head == NULL) { if (gpr_time_cmp(gpr_now(), shutdown_deadline) > 0) { timeout = 1; break; } } if (timeout) { gpr_log(GPR_DEBUG, "Failed to free %d iomgr objects before shutdown deadline: " "memory leaks are likely", count_objects()); for (obj = g_root_object.next; obj != &g_root_object; obj = obj->next) { gpr_log(GPR_DEBUG, "LEAKED OBJECT: %s", obj->name); } break; } } } gpr_mu_unlock(&g_mu); grpc_kick_poller(); gpr_event_wait(&g_background_callback_executor_done, gpr_inf_future); grpc_iomgr_platform_shutdown(); grpc_alarm_list_shutdown(); gpr_mu_destroy(&g_mu); gpr_cv_destroy(&g_rcv); }
int cmd_count_objects(int argc, const char **argv, const char *prefix) { int i, verbose = 0; const char *objdir = get_object_directory(); int len = strlen(objdir); char *path = xmalloc(len + 50); unsigned long loose = 0, packed = 0, packed_loose = 0, garbage = 0; unsigned long loose_size = 0; struct option opts[] = { OPT__VERBOSE(&verbose), OPT_END(), }; argc = parse_options(argc, argv, opts, count_objects_usage, 0); /* we do not take arguments other than flags for now */ if (argc) usage_with_options(count_objects_usage, opts); memcpy(path, objdir, len); if (len && objdir[len-1] != '/') path[len++] = '/'; for (i = 0; i < 256; i++) { DIR *d; sprintf(path + len, "%02x", i); d = opendir(path); if (!d) continue; count_objects(d, path, len, verbose, &loose, &loose_size, &packed_loose, &garbage); closedir(d); } if (verbose) { struct packed_git *p; unsigned long num_pack = 0; unsigned long size_pack = 0; if (!packed_git) prepare_packed_git(); for (p = packed_git; p; p = p->next) { if (!p->pack_local) continue; if (open_pack_index(p)) continue; packed += p->num_objects; size_pack += p->pack_size + p->index_size; num_pack++; } printf("count: %lu\n", loose); printf("size: %lu\n", loose_size / 1024); printf("in-pack: %lu\n", packed); printf("packs: %lu\n", num_pack); printf("size-pack: %lu\n", size_pack / 1024); printf("prune-packable: %lu\n", packed_loose); printf("garbage: %lu\n", garbage); } else printf("%lu objects, %lu kilobytes\n", loose, loose_size / 1024); return 0; }
//WARN! This operation invalidates the instance and reset the pointer in its parent void Entry::balance() { size_t obj_num = count_objects(); vector<Object> objects; objects.reserve(obj_num); all_objects(objects); nth_element(objects.begin(), objects.begin() + obj_num / 2, objects.end(), [](const Object &o1, const Object &o2) { return o1.x > o2.x; }); float middle_x = objects[obj_num / 2].x - 0.1f; nth_element(objects.begin(), objects.begin() + obj_num / 2, objects.end(), [](const Object &o1, const Object &o2) { return o1.y > o2.y; }); float middle_y = objects[obj_num / 2].y - 0.1f; auto p1 = partition(objects.begin(), objects.begin() + obj_num / 2, [middle_x](const Object &o) { return o.x >= middle_x; }); auto p2 = partition(objects.begin() + obj_num / 2, objects.end(), [middle_x](const Object &o) { return o.x < middle_x; }); unique_ptr<Node> n(new Node(parent, direction, middle_x, middle_y)); n->quad[0]->insert_object_range(objects.begin(), p1); n->quad[1]->insert_object_range(p1, objects.begin() + obj_num / 2); n->quad[2]->insert_object_range(objects.begin() + obj_num / 2, p2); n->quad[3]->insert_object_range(p2, objects.end()); for (auto &q :n->quad) { q->balance_if_necessary(); }; parent->assign_child(direction, move(n)); }
void grpc_iomgr_shutdown(void) { grpc_iomgr_closure *closure; gpr_timespec shutdown_deadline = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(10, GPR_TIMESPAN)); gpr_timespec last_warning_time = gpr_now(GPR_CLOCK_REALTIME); gpr_mu_lock(&g_mu); g_shutdown = 1; while (g_cbs_head != NULL || g_root_object.next != &g_root_object) { if (gpr_time_cmp( gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time), gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) { if (g_cbs_head != NULL && g_root_object.next != &g_root_object) { gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed and executing " "final callbacks", count_objects()); } else if (g_cbs_head != NULL) { gpr_log(GPR_DEBUG, "Executing final iomgr callbacks"); } else { gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed", count_objects()); } last_warning_time = gpr_now(GPR_CLOCK_REALTIME); } if (g_cbs_head) { do { closure = g_cbs_head; g_cbs_head = closure->next; if (!g_cbs_head) g_cbs_tail = NULL; gpr_mu_unlock(&g_mu); closure->cb(closure->cb_arg, 0); gpr_mu_lock(&g_mu); } while (g_cbs_head); continue; } if (grpc_alarm_check(&g_mu, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL)) { continue; } if (g_root_object.next != &g_root_object) { int timeout = 0; while (g_cbs_head == NULL) { gpr_timespec short_deadline = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(100, GPR_TIMESPAN)); if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline) && g_cbs_head == NULL) { if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) > 0) { timeout = 1; break; } } } if (timeout) { gpr_log(GPR_DEBUG, "Failed to free %d iomgr objects before shutdown deadline: " "memory leaks are likely", count_objects()); dump_objects("LEAKED"); break; } } } gpr_mu_unlock(&g_mu); grpc_kick_poller(); gpr_event_wait(&g_background_callback_executor_done, gpr_inf_future(GPR_CLOCK_REALTIME)); grpc_alarm_list_shutdown(); grpc_iomgr_platform_shutdown(); gpr_mu_destroy(&g_mu); gpr_cv_destroy(&g_rcv); }
void grpc_iomgr_shutdown(void) { gpr_timespec shutdown_deadline = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(10, GPR_TIMESPAN)); gpr_timespec last_warning_time = gpr_now(GPR_CLOCK_REALTIME); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_iomgr_platform_flush(); gpr_mu_lock(&g_mu); g_shutdown = 1; while (g_root_object.next != &g_root_object) { if (gpr_time_cmp( gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time), gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) { if (g_root_object.next != &g_root_object) { gpr_log(GPR_DEBUG, "Waiting for %d iomgr objects to be destroyed", count_objects()); } last_warning_time = gpr_now(GPR_CLOCK_REALTIME); } if (grpc_timer_check(&exec_ctx, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL)) { gpr_mu_unlock(&g_mu); grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(&g_mu); continue; } if (g_root_object.next != &g_root_object) { gpr_timespec short_deadline = gpr_time_add( gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(100, GPR_TIMESPAN)); if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline)) { if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) > 0) { if (g_root_object.next != &g_root_object) { gpr_log(GPR_DEBUG, "Failed to free %d iomgr objects before shutdown deadline: " "memory leaks are likely", count_objects()); dump_objects("LEAKED"); if (grpc_iomgr_abort_on_leaks()) { abort(); } } break; } } } } gpr_mu_unlock(&g_mu); grpc_timer_list_shutdown(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx); /* ensure all threads have left g_mu */ gpr_mu_lock(&g_mu); gpr_mu_unlock(&g_mu); grpc_pollset_global_shutdown(); grpc_iomgr_platform_shutdown(); grpc_exec_ctx_global_shutdown(); gpr_mu_destroy(&g_mu); gpr_cv_destroy(&g_rcv); }
// // function: MainWndHandler(HWND, unsigned, WORD, LONG) // // purpose: make initialisations (globals, Def-TTY settings) // create Toolbox Dialog // // process Menu Selections // load/save Config // play/capture Archive // open midi-device // change com settings // connect/disconnect to EEG-amp // load/save Config // // scale and paint the channel-oscilloscope // // // LRESULT CALLBACK MainWndHandler(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; char sztemp[256]; switch( message ) { case WM_CREATE: break; case WM_ENABLE: if ((wParam==TRUE) && (NB_OBJ != NULL)) { NB_OBJ->update_channelinfo(); NB_OBJ=NULL; } break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Menüauswahlen analysieren: switch( wmId ) { case IDM_NEWCONFIG: stop_timer(); TTY.read_pause=1; //BreakDownCommPort(); CAPTFILE.do_read=0; close_captfile(); if (ghWndAnimation!=NULL) SendMessage(ghWndAnimation,WM_CLOSE,0,0); ghWndAnimation=NULL; close_toolbox(); write_logfile("new config: deleting all objects."); while (GLOBAL.objects>0) free_object(0); deviceobject=NULL; GLOBAL.showdesign=TRUE; ShowWindow(ghWndDesign,TRUE); SetWindowPos(ghWndDesign,HWND_TOP,0,0,0,0,SWP_DRAWFRAME|SWP_NOMOVE|SWP_NOSIZE); SetDlgItemText(ghWndStatusbox,IDC_DESIGN,"Hide Design"); GLOBAL.hidestatus=FALSE; ShowWindow(ghWndStatusbox,TRUE); SetWindowText(ghWndMain,"BrainBay"); GLOBAL.configfile[0]=0; init_system_time(); PACKET.readstate=0; GLOBAL.session_length=0; SetDlgItemText(ghWndStatusbox,IDC_STATUS,"ready."); SetDlgItemInt(ghWndStatusbox,IDC_SAMPLINGRATE,PACKETSPERSECOND,0); SetDlgItemText(ghWndStatusbox,IDC_STATUS,"Configuration loaded"); SetDlgItemText(ghWndStatusbox,IDC_TIME,"0.0"); SetDlgItemText(ghWndStatusbox,IDC_JUMPPOS,"0.0"); SetDlgItemText(ghWndStatusbox,IDC_SESSLEN,"0.0"); SendMessage(GetDlgItem(ghWndStatusbox,IDC_SESSIONPOS),TBM_SETPOS,TRUE,(LONG)0); SendMessage(GetDlgItem(ghWndStatusbox,IDC_SESSIONPOS),TBM_SETSELEND,TRUE,(LONG)0); SendMessage(GetDlgItem(ghWndStatusbox,IDC_SESSIONPOS),TBM_SETSELSTART,TRUE,(LONG)0); InvalidateRect(ghWndDesign,NULL,TRUE); InvalidateRect(ghWndMain,NULL,TRUE); break; case IDM_SAVECONFIG: { char configfilename[MAX_PATH]; int save_toolbox=GLOBAL.showtoolbox; close_toolbox(); GLOBAL.showtoolbox=save_toolbox; strcpy(configfilename,GLOBAL.resourcepath); if (GLOBAL.configfile[0]==0) strcat(configfilename,"CONFIGURATIONS\\*.con"); else strcpy(configfilename,GLOBAL.configfile); if (open_file_dlg(hWnd,configfilename, FT_CONFIGURATION, OPEN_SAVE)) { if (!save_configfile(configfilename)) report_error("Could not save Config File"); else { char * d_name,new_name[80]; write_logfile("configruation saved."); d_name=configfilename; while (strstr(d_name,"\\")) d_name=strstr(d_name,"\\")+1; strcpy(new_name,"BrainBay - ");strcat(new_name,d_name); SetWindowText(ghWndMain,new_name); } } if (GLOBAL.showtoolbox!=-1) { actobject=objects[GLOBAL.showtoolbox]; actobject->make_dialog(); } } break; case IDM_LOADCONFIG: { char configfilename[MAX_PATH]; close_toolbox(); strcpy(configfilename,GLOBAL.resourcepath); strcat(configfilename,"CONFIGURATIONS\\*.con"); if (open_file_dlg(hWnd,configfilename, FT_CONFIGURATION, OPEN_LOAD)) { write_logfile("load config: free existing objects."); if (!load_configfile(configfilename)) report_error("Could not load Config File"); else sort_objects(); } } break; case IDM_ABOUT: close_toolbox(); DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)AboutDlgHandler); break; case IDM_HELP: { char tmpfile [250]; close_toolbox(); strcpy(tmpfile,GLOBAL.resourcepath); strcat(tmpfile,"brainbay_user_manual.pdf"); ShellExecute(0, "open", tmpfile, NULL, NULL, SW_SHOWNORMAL); } break; case IDM_VIEWLASTLOGFILE: { char tmpfile [250]; close_toolbox(); strcpy(tmpfile,GLOBAL.resourcepath); strcat(tmpfile,"bbay.log"); ShellExecute(0, "open", tmpfile, NULL, NULL, SW_SHOWNORMAL); } break; case IDM_EXIT: DestroyWindow( hWnd ); break; case IDM_PLAY: SendMessage(ghWndStatusbox,WM_COMMAND, IDC_RUNSESSION,0); break; case IDM_STOP: SendMessage(ghWndStatusbox,WM_COMMAND, IDC_STOPSESSION,0); break; case IDM_NEUROSERVER: strcpy(sztemp,GLOBAL.resourcepath); strcat(sztemp,"NETWORK\\nsd.exe"); ShellExecute(hWnd, "open", sztemp, NULL, NULL, SW_SHOWNORMAL); break; case IDM_READEDF: { char edffilename[MAX_PATH]; close_toolbox(); strcpy(edffilename,GLOBAL.resourcepath); strcat(edffilename,"ARCHIVES\\*.edf"); if (open_file_dlg(hWnd,edffilename, FT_EDF, OPEN_LOAD)) { strcpy(sztemp,GLOBAL.resourcepath); strcat(sztemp,"NETWORK\\readedf.exe"); ShellExecute(hWnd, NULL, sztemp, edffilename, NULL, SW_SHOWNORMAL); } } break; case IDM_EDITCOLORS: close_toolbox(); display_toolbox(CreateDialog(hInst, (LPCTSTR)IDD_EDITCOLORBOX, ghWndStatusbox, (DLGPROC)COLORDlgHandler)); break; case IDM_EDITSCALES: close_toolbox(); display_toolbox(CreateDialog(hInst, (LPCTSTR)IDD_EDITSCALEBOX, ghWndStatusbox, (DLGPROC)SCALEDlgHandler)); break; case IDM_SETTINGS: if (ghWndSettings==NULL) ghWndSettings=CreateDialog(hInst, (LPCTSTR)IDD_SETTINGSBOX, ghWndStatusbox, (DLGPROC)SETTINGSDlgHandler); else SetForegroundWindow(ghWndSettings); break; case IDM_DEVICESETTINGS: if (deviceobject) { close_toolbox(); actobject=deviceobject; // GLOBAL.showtoolbox=find_object(devicebox); actobject->make_dialog(); if (actobject->displayWnd) SetWindowPos(actobject->displayWnd,HWND_TOP,0,0,0,0,SWP_DRAWFRAME|SWP_NOMOVE|SWP_NOSIZE); } else report ("No Amplifier Device present in the design"); break; case IDM_INSERTMIDI: create_object(OB_MIDI); break; case IDM_INSERTSPECTRUM: create_object(OB_FFT); break; case IDM_INSERTTHRESHOLD: create_object(OB_THRESHOLD); break; case IDM_INSERTFILTER: create_object(OB_FILTER); break; case IDM_INSERTMAGNITUDE:create_object(OB_MAGNITUDE); break; case IDM_INSERTPARTICLE:create_object(OB_PARTICLE); break; case IDM_INSERTOSCI:create_object(OB_OSCI); break; case IDM_INSERTTRANSLATE:create_object(OB_TRANSLATE); break; case IDM_INSERTSIGNAL:create_object(OB_SIGNAL); break; case IDM_INSERTAND:create_object(OB_AND); break; case IDM_INSERTOR:create_object(OB_OR); break; case IDM_INSERTNOT:create_object(OB_NOT); break; case IDM_INSERTWAV: if (!count_objects(OB_WAV)) create_object(OB_WAV); else report_error("Currently only one Sound player is supported."); break; case IDM_INSERTTCPRECEIVER:create_object(OB_TCP_RECEIVER); break; case IDM_INSERTDOKU:create_object(OB_DOKU); break; case IDM_INSERTEVAL:create_object(OB_EVAL); break; case IDM_INSERTAVI:create_object(OB_AVI); break; case IDM_INSERTAVERAGE:create_object(OB_AVERAGE); break; case IDM_INSERTCORR:create_object(OB_CORR); break; case IDM_INSERTEDFWRITER:create_object(OB_EDF_WRITER); break; case IDM_INSERTTCPSENDER:create_object(OB_TCP_SENDER); break; case IDM_INSERTEDFREADER:create_object(OB_EDF_READER); break; case IDM_INSERTCOMPARE:create_object(OB_COMPARE); break; case IDM_INSERTBALLGAME:create_object(OB_BALLGAME); break; case IDM_INSERTMIXER4:create_object(OB_MIXER4); break; case IDM_INSERTMOUSE:create_object(OB_MOUSE); break; case IDM_INSERTERPDETECT:create_object(OB_ERPDETECT); break; case IDM_INSERTCOM_WRITER:create_object(OB_COM_WRITER); break; case IDM_INSERTCAM: if (!count_objects(OB_CAM)) create_object(OB_CAM); break; case IDM_INSERTINTEGRATE:create_object(OB_INTEGRATE); break; case IDM_INSERTDEBOUNCE:create_object(OB_DEBOUNCE); break; case IDM_INSERTSAMPLE_HOLD:create_object(OB_SAMPLE_HOLD); break; case IDM_INSERTCONSTANT:create_object(OB_CONSTANT); break; case IDM_INSERTMATLAB:create_object(OB_MATLAB); break; case IDM_INSERTCOUNTER:create_object(OB_COUNTER); break; case IDM_INSERTSKINDIALOG: if (!count_objects(OB_SKINDIALOG)) create_object(OB_SKINDIALOG); break; case IDM_INSERTFILE_WRITER:create_object(OB_FILE_WRITER); break; case IDM_INSERTDEVIATION:create_object(OB_DEVIATION); break; case IDM_INSERTMCIPLAYER:create_object(OB_MCIPLAYER); break; case IDM_INSERTKEYSTRIKE:create_object(OB_KEYSTRIKE); break; case IDM_INSERTPEAKDETECT:create_object(OB_PEAKDETECT); break; case IDM_INSERTSPELLER:create_object(OB_SPELLER); break; case IDM_INSERTMARTINI:create_object(OB_MARTINI); break; case IDM_INSERTFILE_READER:create_object(OB_FILE_READER); break; case IDM_INSERTPORT_IO:create_object(OB_PORT_IO); break; case IDM_INSERTARRAY3600:create_object(OB_ARRAY3600); break; case IDM_INSERTCOMREADER:create_object(OB_COMREADER); break; case IDM_INSERTMIN:create_object(OB_MIN); break; case IDM_INSERTMAX:create_object(OB_MAX); break; case IDM_INSERTROUND:create_object(OB_ROUND); break; case IDM_INSERTDIFFERENTIATE:create_object(OB_DIFFERENTIATE); break; case IDM_INSERTDELAY:create_object(OB_DELAY); break; case IDM_INSERTLIMITER:create_object(OB_LIMITER); break; case IDM_INSERTFLOATVECTOR: create_object(OB_FLOATVECTOR); break; case IDM_INSERTVECTORFLOAT: create_object(OB_VECTORFLOAT); break; case IDM_INSERTDISPLAYVECTOR: create_object(OB_DISPLAYVECTOR); break; case IDM_INSERTVECTORBUFFER: create_object(OB_BUFFER); break; // here are th supported EED devices case IDM_INSERT_EEG_GENERIC8: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_RAW8BIT; create_object(OB_EEG);} break; case IDM_INSERT_EEG_GENERIC16: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_RAW; create_object(OB_EEG);} break; case IDM_INSERT_EEG_IBVA: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_IBVA; create_object(OB_EEG);} break; case IDM_INSERT_EEG_NIA: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_NIA; create_object(OB_EEG);} break; case IDM_INSERT_EEG_P21: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_MONOLITHEEG_P21; create_object(OB_EEG);} break; case IDM_INSERT_EEG_OPENBCI8: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_OPENBCI8; create_object(OB_EEG);} break; case IDM_INSERT_EEG_P2: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_MODEEG_P2; create_object(OB_EEG);} break; case IDM_INSERT_EEG_P3: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_MODEEG_P3; create_object(OB_EEG);} break; case IDM_INSERT_EEG_PENDANT: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_PENDANT3; create_object(OB_EEG);} break; case IDM_INSERT_EEG_QDS: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_QDS; create_object(OB_EEG);} break; case IDM_INSERT_EEG_SBT4: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_SBT4; create_object(OB_EEG);} break; case IDM_INSERT_EEG_SBT2: if (!count_objects(OB_EEG)) { TTY.devicetype=DEV_SBT2; create_object(OB_EEG);} break; // these devices need special care (seperate element) case IDM_INSERTOPTIMA: if ((!count_objects(OB_NEUROBIT)) && (!count_objects(OB_EEG))) create_object(OB_NEUROBIT); break; case IDM_INSERTEMOTIV: if ((!count_objects(OB_EMOTIV)) && (!count_objects(OB_EEG))) create_object(OB_EMOTIV); break; case IDM_COPY: if (actobject) { copy_object=actobject; if ((copy_object->type!=OB_EEG)&&(copy_object->type!=OB_WAV)&&(copy_object->type!=OB_CAM) &&(copy_object->type!=OB_SKINDIALOG)&&(copy_object->type!=OB_NEUROBIT)) { HANDLE hFile; char tmpfile[256]; create_object(copy_object->type); strcpy(tmpfile,GLOBAL.resourcepath); strcat(tmpfile,"tmp_copy.con"); hFile = CreateFile(tmpfile, GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile != INVALID_HANDLE_VALUE) { copy_object->save(hFile); save_property(hFile,"end Object",P_END,NULL); CloseHandle(hFile); } hFile = CreateFile(tmpfile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if(hFile != INVALID_HANDLE_VALUE) { load_next_config_buffer(hFile); actobject->load(hFile); CloseHandle(hFile); DeleteFile(tmpfile); } actobject->xPos+=10; actobject->yPos+=10; } close_toolbox(); } break; default: return DefWindowProc( hWnd, message, wParam, lParam ); } break; case WM_ACTIVATE: { /* char t[50]; static int cn=0; cn++; sprintf(t,"%d:%d,%d",cn,HIWORD(lParam),LOWORD(lParam)); //==WA_CLICKACTIVE)) SendDlgItemMessage(ghWndStatusbox,IDC_LIST2, LB_ADDSTRING, 0, (LPARAM) t); SendDlgItemMessage(ghWndStatusbox,IDC_LIST2, LB_SETCURSEL, SendDlgItemMessage(ghWndStatusbox,IDC_LIST2, LB_GETCOUNT, 0, 0)-1, 0); UpdateWindow(ghWndStatusbox); */ if ((LOWORD(lParam)==WA_CLICKACTIVE) || (HIWORD(lParam)==WA_CLICKACTIVE)) SetWindowPos(ghWndMain,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); SetFocus(ghWndMain); } break; case WM_ACTIVATEAPP: { /* char t[50]; static int cn=0; cn++; sprintf(t,"%d:%d,%d",cn,HIWORD(lParam),LOWORD(lParam)); //==WA_CLICKACTIVE)) SendDlgItemMessage(ghWndStatusbox,IDC_LIST2, LB_ADDSTRING, 0, (LPARAM) t); SendDlgItemMessage(ghWndStatusbox,IDC_LIST2, LB_SETCURSEL, SendDlgItemMessage(ghWndStatusbox,IDC_LIST2, LB_GETCOUNT, 0, 0)-1, 0); UpdateWindow(ghWndStatusbox); */ // if ((LOWORD(lParam)==1828) || (LOWORD(lParam)==964)) //SetWindowPos(ghWndMain,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); SetWindowPos(ghWndMain,0,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); // return DefWindowProc( hWnd, message, wParam, lParam ); } break; case WM_KEYDOWN: if (lParam==KEY_DELETE ) SendMessage(ghWndDesign, message,wParam,lParam); break; case WM_SIZE: if (wParam== SIZE_MAXIMIZED) { GLOBAL.main_maximized=lParam; ShowWindow(ghWndStatusbox,TRUE); GLOBAL.hidestatus=FALSE; if (GLOBAL.session_length==0) SetWindowPos(ghWndStatusbox, ghWndMain, 4, HIWORD(lParam)+15, LOWORD(lParam)-8,HIWORD(lParam), 0); else SetWindowPos(ghWndStatusbox, ghWndMain, 4, HIWORD(lParam)-20, LOWORD(lParam)-8,HIWORD(lParam), 0); } else if (wParam== SIZE_RESTORED) { WINDOWPLACEMENT wndpl; GetWindowPlacement(ghWndMain, &wndpl); GLOBAL.top=wndpl.rcNormalPosition.top; GLOBAL.left=wndpl.rcNormalPosition.left; GLOBAL.right=wndpl.rcNormalPosition.right; GLOBAL.bottom=wndpl.rcNormalPosition.bottom; GLOBAL.main_maximized=0; update_status_window(); } else if (wParam== SIZE_MINIMIZED) { ShowWindow(ghWndStatusbox,FALSE); GLOBAL.hidestatus=TRUE; } break; case WM_MOVE: { WINDOWPLACEMENT wndpl; GetWindowPlacement(ghWndMain, &wndpl); GLOBAL.top=wndpl.rcNormalPosition.top; GLOBAL.left=wndpl.rcNormalPosition.left; GLOBAL.right=wndpl.rcNormalPosition.right; GLOBAL.bottom=wndpl.rcNormalPosition.bottom; update_status_window(); } break; //case WM_PAINT: // break; case WM_DESTROY: actobject=0; GlobalCleanup(); PostQuitMessage( 0 ); break; case WM_INPUT: if ((TTY.CONNECTED) && (!GLOBAL.loading)) ReadNIA( wParam, lParam); // NIA Daten vorhanden: auslesen return(TRUE); default: return DefWindowProc( hWnd, message, wParam, lParam ); } return 0; }