LRESULT CALLBACK ConstantDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char tmp[50]; CONSTANTOBJ * st; st = (CONSTANTOBJ *) actobject; if ((st==NULL)||(st->type!=OB_CONSTANT)) return(FALSE); switch( message ) { case WM_INITDIALOG: sprintf(tmp,"%.2f",st->value); SetDlgItemText(hDlg, IDC_VALUE, tmp); break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_APPLY: GetDlgItemText(hDlg,IDC_VALUE,tmp,30); sscanf(tmp,"%f",&st->value); break; } return TRUE; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK DeviationDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static bool init; DEVIATIONOBJ * st; st = (DEVIATIONOBJ *) actobject; if ((st==NULL)||(st->type!=OB_DEVIATION)) return(FALSE); switch( message ) { case WM_INITDIALOG: SCROLLINFO lpsi; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE|SIF_POS; lpsi.nMin=1; lpsi.nMax=NUMSAMPLES - 1; SetScrollInfo(GetDlgItem(hDlg,IDC_DEVIATIONINTERVALBAR),SB_CTL,&lpsi, TRUE); init = true; SetScrollPos(GetDlgItem(hDlg,IDC_DEVIATIONINTERVALBAR), SB_CTL,st->interval, TRUE); SetDlgItemInt(hDlg, IDC_DEVIATIONINTERVAL, st->interval, FALSE); init = false; break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: return TRUE; break; case WM_HSCROLL: { int nNewPos; if (!init && (nNewPos = get_scrollpos(wParam,lParam)) >= 0) { if (lParam == (long) GetDlgItem(hDlg,IDC_DEVIATIONINTERVALBAR)) { SetDlgItemInt(hDlg, IDC_DEVIATIONINTERVAL, nNewPos, TRUE); st->change_interval(nNewPos); } } break; } case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK AVIDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char szFileName[MAX_PATH]; AVIOBJ * st; st = (AVIOBJ *) actobject; if ((st==NULL)||(st->type!=OB_AVI)) return(FALSE); switch( message ) { case WM_INITDIALOG: SetDlgItemText(hDlg, IDC_AVIFILE, st->avifile); return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_LOADAVI: strcpy(szFileName,GLOBAL.resourcepath); strcat(szFileName,"MOVIES\\*.avi"); if (open_file_dlg(hDlg, szFileName, FT_AVI, OPEN_LOAD)) { if (!st->OpenAVI(szFileName)) report_error("Could not load AVI File"); else { // reduce_filepath(szFileName,szFileName); strcpy(st->avifile,szFileName); SetDlgItemText(hDlg, IDC_AVIFILE, st->avifile); if (st->displayWnd) InvalidateRect(st->displayWnd,NULL,TRUE); } } InvalidateRect(hDlg,NULL,FALSE); break; } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; } return FALSE; }
LRESULT CALLBACK KeyCaptureDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char tmp[50]; KEYCAPTUREOBJ * st; st = (KEYCAPTUREOBJ *) actobject; if ((st==NULL)||(st->type!=OB_KEYCAPTURE)) return(FALSE); switch( message ) { case WM_INITDIALOG: SendDlgItemMessage( hDlg, IDC_MODECOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "output all keycode values" ) ; SendDlgItemMessage( hDlg, IDC_MODECOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "detect one keycode and output custom value" ) ; SendDlgItemMessage( hDlg, IDC_MODECOMBO, CB_SETCURSEL, st->mode, 0L ) ; SetDlgItemInt(hDlg, IDC_ACTKEY, 0, 0); SetDlgItemInt(hDlg, IDC_FINDCODE, st->findcode, 0); SetDlgItemInt(hDlg, IDC_REPLACECODE, st->replacecode, 0); break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_MODECOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) st->mode=(SendMessage(GetDlgItem(hDlg, IDC_MODECOMBO), CB_GETCURSEL , 0, 0)); break; case IDC_FINDCODE: st->findcode=GetDlgItemInt(hDlg,IDC_FINDCODE,0,0); break; case IDC_REPLACECODE: st->replacecode=GetDlgItemInt(hDlg,IDC_REPLACECODE,0,0); break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK IntegrateDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { INTEGRATEOBJ * st; char tmp[30]; st = (INTEGRATEOBJ *) actobject; if ((st==NULL)||(st->type!=OB_INTEGRATE)) return(FALSE); switch( message ) { case WM_INITDIALOG: sprintf(tmp,"%.2f",st->min); SetDlgItemText(hDlg, IDC_MIN, tmp); sprintf(tmp,"%.2f",st->max); SetDlgItemText(hDlg, IDC_MAX, tmp); break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_MIN: GetDlgItemText(hDlg,IDC_MIN,tmp,30); sscanf(tmp,"%f",&st->min); break; case IDC_MAX: GetDlgItemText(hDlg,IDC_MAX,tmp,30); sscanf(tmp,"%f",&st->max); break; case IDC_RESET: st->i_value=0; break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK EvalDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static bool init; EVALOBJ * st; st = (EVALOBJ *) actobject; if ((st==NULL)||(st->type!=OB_EVAL)) return(FALSE); switch( message ) { case WM_INITDIALOG: init = true; if (st->expression != NULL) SetDlgItemText(hDlg, IDC_EVALEXPRESSION, st->expression); init = false; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_EVALAPPLY: char strExpr[MAXEXPRLENGTH+1]; GetDlgItemText(hDlg, IDC_EVALEXPRESSION, strExpr, MAXEXPRLENGTH); st->setExpression(strExpr); strncpy(st->tag, st->expression,12); st->tag[12]='.';st->tag[13]='.';st->tag[14]=0; InvalidateRect(ghWndDesign,NULL,TRUE); break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; } return FALSE; }
LRESULT CALLBACK NotDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { NOTOBJ * st; st = (NOTOBJ *) actobject; if ((st==NULL)||(st->type!=OB_NOT)) return(FALSE); switch( message ) { case WM_INITDIALOG: CheckDlgButton(hDlg, IDC_BINARY, st->binary); SetDlgItemInt(hDlg,IDC_BITS,st->bits,0); break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BINARY: st->binary=IsDlgButtonChecked(hDlg,IDC_BINARY); break; case IDC_BITS: st->bits=GetDlgItemInt(hDlg,IDC_BITS,NULL,0); break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK OPTIMADlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { static int init; NEUROBITOBJ * st; st = (NEUROBITOBJ *) actobject; if ((st==NULL)||(st->type!=OB_NEUROBIT)) return(FALSE); switch( message ) { case WM_INITDIALOG: { for (int t = 0; DevTab[t] != NULL; t++) SendDlgItemMessage( hDlg, IDC_NB_DEVICECOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) DevTab[t] ) ; SetDlgItemText(hDlg,IDC_NB_DEVICECOMBO,st->device); SetDlgItemText(hDlg,IDC_NB_ARCHIVE_NAME,st->archivefile); st->update_channelinfo(); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_NB_DEVICECOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { int sel; sel=SendDlgItemMessage(hDlg, IDC_NB_DEVICECOMBO, CB_GETCURSEL, 0, 0 ) ; strcpy (st->device,DevTab[sel]); if (DevCtx>=0) NdCloseDevContext(DevCtx); DevCtx=NdOpenDevContext(st->device); st->update_channelinfo(); //InvalidateRect(hDlg,NULL,FALSE); } break; case IDC_DISPLAYSETTINGS: if (DevCtx>=0) { HDevWin = NdCreateDevWindow(hInst, ghWndMain, NB_DirName); NB_OBJ=st; } else write_logfile ("could not change Neurobit device settings (no device context)"); break; case IDC_OPEN_NB_ARCHIVE: strcpy(st->archivefile,GLOBAL.resourcepath); strcat(st->archivefile,"ARCHIVES\\*.nba"); if (open_file_dlg(ghWndMain,st->archivefile, FT_NB_ARCHIVE, OPEN_LOAD)) { st->filehandle = CreateFile(st->archivefile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (st->filehandle==INVALID_HANDLE_VALUE) { SetDlgItemText(hDlg,IDC_NB_ARCHIVE_NAME,"none"); report_error("Could not open Archive-File"); } else { SendMessage(ghWndStatusbox,WM_COMMAND,IDC_STOPSESSION,0); SetDlgItemText(hDlg,IDC_NB_ARCHIVE_NAME,st->archivefile); SendMessage(ghWndStatusbox,WM_COMMAND,IDC_RESETBUTTON,0); st->filemode=FILE_READING; } } break; case IDC_CLOSE_NB_ARCHIVE: if (st->filehandle!=INVALID_HANDLE_VALUE) { if (!CloseHandle(st->filehandle)) report_error("could not close Archive file"); st->filehandle=INVALID_HANDLE_VALUE; } break; case IDC_REC_NB_ARCHIVE: strcpy(st->archivefile,GLOBAL.resourcepath); strcat(st->archivefile,"ARCHIVES\\*.nba"); if (open_file_dlg(ghWndMain,st->archivefile, FT_NB_ARCHIVE, OPEN_SAVE)) { st->filehandle = CreateFile(st->archivefile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0,NULL); if (st->filehandle==INVALID_HANDLE_VALUE) { SetDlgItemText(hDlg,IDC_NB_ARCHIVE_NAME,"none"); report_error("Could not open Archive-File"); } else { SetDlgItemText(hDlg,IDC_NB_ARCHIVE_NAME,st->archivefile); st->filemode=FILE_WRITING; } } break; case IDC_END_NB_RECORDING : if (st->filehandle!=INVALID_HANDLE_VALUE) { if (!CloseHandle(st->filehandle)) report_error("could not close Archive file"); st->filehandle=INVALID_HANDLE_VALUE; } break; } return TRUE; case WM_PAINT: color_button(GetDlgItem(hDlg,IDC_QCHN1),COLORS[chncol[1]]); color_button(GetDlgItem(hDlg,IDC_QCHN2),COLORS[chncol[2]]); color_button(GetDlgItem(hDlg,IDC_QCHN3),COLORS[chncol[3]]); color_button(GetDlgItem(hDlg,IDC_QCHN4),COLORS[chncol[4]]); color_button(GetDlgItem(hDlg,IDC_COMVOLT),COLORS[chncol[0]]); break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK TcpReceiveDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { TCP_RECEIVEOBJ * st; char writebuf[100],szdata[100]; char readbuf[readbuflength]; int result; static int actchn; st = (TCP_RECEIVEOBJ *) actobject; if ((st==NULL)||(st->type!=OB_TCP_RECEIVER)) return(FALSE); switch( message ) { case WM_INITDIALOG: SetDlgItemText(hDlg, IDC_HOST, st->host); EnableWindow(GetDlgItem(hDlg, IDC_SELECTCOMBO), FALSE); actchn=0; update_header(hDlg,&st->header); update_channelcombo(hDlg, st->channel, st->header.channels); update_channel(hDlg,st->channel,actchn); if (st->sock) { char actsession[30]; EnableWindow(GetDlgItem(hDlg, IDC_CONNECT), FALSE); if (st->watching) { add_to_listbox(hDlg,IDC_LIST, "Watching Values from Server."); EnableWindow(GetDlgItem(hDlg, IDC_WATCH), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); } else { add_to_listbox(hDlg,IDC_LIST, "Socket connected."); if (st->streamnum>=0) EnableWindow(GetDlgItem(hDlg, IDC_WATCH), TRUE); else { EnableWindow(GetDlgItem(hDlg, IDC_WATCH), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SELECTCOMBO), TRUE); } EnableWindow(GetDlgItem(hDlg, IDC_STOP), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), TRUE); get_connections(hDlg,st); } if (st->streamnum>=0) { sprintf(actsession,"%d:EEG",st->streamnum); SetDlgItemText(hDlg, IDC_SELECTCOMBO, actsession); } } else { add_to_listbox(hDlg,IDC_LIST, "No Socket connected."); EnableWindow(GetDlgItem(hDlg, IDC_CONNECT), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_WATCH), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CONNECT: GetDlgItemText(hDlg, IDC_HOST, st->host, sizeof(st->host)); if ((strlen(st->host)<8)||(!st->connect())) { add_to_listbox(hDlg,IDC_LIST, "Could not connect to Server"); break; } SendDlgItemMessage(hDlg,IDC_LIST, LB_ADDSTRING, 0, (LPARAM) "Socket connection successful."); strcpy(writebuf,"display\n"); result = SDLNet_TCP_Send(st->sock, writebuf, strlen(writebuf)); add_to_listbox(hDlg,IDC_LIST, "sending:DISPLAY"); st->read_tcp(readbuf, readbuflength); strncpy(szdata,readbuf,6);szdata[6]=0; if (strcmp(szdata,"200 OK")) { add_to_listbox(hDlg,IDC_LIST,"Could not select Display-mode"); break;} add_to_listbox(hDlg,IDC_LIST, "OK"); if (!st->sock) { add_to_listbox(hDlg,IDC_LIST,"Socket not connected"); break;} if (!get_connections(hDlg,st)) { add_to_listbox(hDlg,IDC_LIST, "No Sessions available."); st->reset(); InvalidateRect(ghWndMain,NULL,TRUE); break; } EnableWindow(GetDlgItem(hDlg, IDC_CONNECT), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), TRUE); break; case IDC_SELECTCOMBO: if (HIWORD(wParam)!=CBN_SELCHANGE) break; if (!st->sock) { add_to_listbox(hDlg,IDC_LIST, "No Channels available."); st->streamnum=-1; st->out[0].from_port=-1; st->outports=0; break; } st->streamnum=SendDlgItemMessage(hDlg,IDC_SELECTCOMBO,CB_GETITEMDATA, (WPARAM) SendDlgItemMessage(hDlg,IDC_SELECTCOMBO, CB_GETCURSEL , 0, 0), 0); st->clear_buffer(); // SELECT SESSION sprintf(writebuf,"getheader %d\n",st->streamnum); result = SDLNet_TCP_Send(st->sock, writebuf, strlen(writebuf)); add_to_listbox(hDlg,IDC_LIST, "sending:GETHEADER"); st->read_tcp(readbuf, sizeof(readbuf)-1); strncpy(szdata,readbuf,6); szdata[6]=0; if (strcmp(szdata,"200 OK")) { add_to_listbox(hDlg,IDC_LIST,"Could not get EDF-header.");break;} add_to_listbox(hDlg,IDC_LIST, "OK"); strcpy(st->edfheader,readbuf+8); // report(st->edfheader); EnableWindow(GetDlgItem(hDlg, IDC_SELECTCOMBO), FALSE); st->syncloss=0; add_to_listbox(hDlg,IDC_LIST, "Parsing Header"); parse_edf_header(&st->header,st->channel, st->edfheader); add_to_listbox(hDlg,IDC_LIST, "clear OK"); st->outports=st->header.channels; st->height=CON_START+st->outports*CON_HEIGHT+5; st->get_captions(); update_header(hDlg,&st->header); update_channelcombo(hDlg, st->channel, st->header.channels); update_channel(hDlg,st->channel,actchn); add_to_listbox(hDlg,IDC_LIST, "OK"); EnableWindow(GetDlgItem(hDlg, IDC_WATCH), TRUE); InvalidateRect(ghWndDesign,NULL,TRUE); break; case IDC_WATCH: if ((st->outports>0)&&(st->sock)) { add_to_listbox(hDlg,IDC_LIST, "sending:WATCH"); st->clear_buffer(); st->syncloss=0; result=st->start_watching(); if (result!=200) { add_to_listbox(hDlg,IDC_LIST,"Could not enter Watch-Mode"); break;} add_to_listbox(hDlg,IDC_LIST, "OK"); EnableWindow(GetDlgItem(hDlg, IDC_WATCH), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); // EnableWindow(GetDlgItem(hDlg, IDC_SELECTCOMBO), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), TRUE); if (!GLOBAL.running) start_timer(); } else add_to_listbox(hDlg,IDC_LIST, "No Channels available."); break; case IDC_EMPTY: st->bufstart=st->bufend; add_to_listbox(hDlg,IDC_LIST, "buffer cleared."); break; case IDC_STOP: add_to_listbox(hDlg,IDC_LIST, "sending:UNWATCH"); st->unwatch(); EnableWindow(GetDlgItem(hDlg, IDC_WATCH), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), FALSE); // EnableWindow(GetDlgItem(hDlg, IDC_SELECTCOMBO), TRUE); break; case IDC_CLOSE: add_to_listbox(hDlg,IDC_LIST, "sending:CLOSE"); st->reset(); EnableWindow(GetDlgItem(hDlg, IDC_CONNECT), TRUE); // EnableWindow(GetDlgItem(hDlg, IDC_SELECTCOMBO), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_WATCH), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); InvalidateRect(ghWndDesign,NULL,TRUE); break; case IDC_CHANNELCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { get_channel(hDlg, st->channel, actchn); actchn=SendMessage(GetDlgItem(hDlg, IDC_CHANNELCOMBO), CB_GETCURSEL , 0, 0); update_channel(hDlg, st->channel,actchn); } break; } return TRUE; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK CamDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static bool init; CAMOBJ * st; int tmp; st = (CAMOBJ *) actobject; if ((st==NULL)||(st->type!=OB_CAM)) return(FALSE); switch( message ) { case WM_INITDIALOG: SetDlgItemInt(hDlg,IDC_UPDATERATE,update_rate,0); SetDlgItemText(hDlg,IDC_CAMSTATUS,"0"); SetDlgItemInt(hDlg,IDC_ERROR_DIST,(int)dist_threshold,0); SetDlgItemInt(hDlg,IDC_ERROR_ANGLE,(int)angle_threshold,0); SetDlgItemInt(hDlg,IDC_THRESHOLD_TIME,threshold_time,0); SetDlgItemInt(hDlg,IDC_PT1X,(int)(PT1_xpos*100.0f),1); SetDlgItemInt(hDlg,IDC_PT1Y,(int)(PT1_ypos*100.0f),1); SetDlgItemInt(hDlg,IDC_PT2X,(int)(PT2_xpos*100.0f),1); SetDlgItemInt(hDlg,IDC_PT2Y,(int)(PT2_ypos*100.0f),1); CheckDlgButton(hDlg,IDC_AUTORESTORE,autorestore); CheckDlgButton(hDlg,IDC_SHOWLIVE,st->showlive); CheckDlgButton(hDlg,IDC_ENABLE_TRACKING,st->enable_tracking); CheckDlgButton(hDlg,IDC_TRACKFACE,st->trackface); if (st->mode==0) CheckDlgButton(hDlg,IDC_NOARCHIVE,TRUE); else if (st->mode==1) CheckDlgButton(hDlg,IDC_RECORDARCHIVE,TRUE); else if (st->mode==2) CheckDlgButton(hDlg,IDC_PLAYARCHIVE,TRUE); SetDlgItemText(hDlg,IDC_ARCHIVEFILE,st->videofilename); break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_INITCAM: lk_init(st); break; case IDC_EXITCAM: lk_exit(); break; case IDC_RESET: count = 0; break; case IDC_NOARCHIVE: lk_exit(); st->mode=0; lk_init(st); break; case IDC_RECORDARCHIVE: lk_exit(); st->mode=1; if (!strcmp(st->videofilename,"none")) { strcpy(st->videofilename,GLOBAL.resourcepath); strcat(st->videofilename,"MOVIES\\*.avi"); } if (!open_file_dlg(hDlg,st->videofilename, FT_AVI, OPEN_SAVE)) strcpy(st->videofilename,"none"); SetDlgItemText(hDlg, IDC_ARCHIVEFILE,st->videofilename); lk_init(st); break; case IDC_PLAYARCHIVE: lk_exit(); st->mode=2; if (!strcmp(st->videofilename,"none")) { strcpy(st->videofilename,GLOBAL.resourcepath); strcat(st->videofilename,"MOVIES\\*.avi"); } if (!open_file_dlg(hDlg,st->videofilename, FT_AVI, OPEN_LOAD)) strcpy(st->videofilename,"none"); SetDlgItemText(hDlg, IDC_ARCHIVEFILE,st->videofilename); lk_init(st); break; case IDC_SHOWLIVE: st->showlive=IsDlgButtonChecked(hDlg,IDC_SHOWLIVE); if (!st->showlive) cvDestroyWindow("Camera"); else { cvNamedWindow( "Camera", 1 ); cvSetMouseCallback( "Camera", on_mouse, 0 ); } break; case IDC_UPDATERATE: tmp=GetDlgItemInt(hDlg,IDC_UPDATERATE,NULL,0); if ((tmp>10)&&(tmp<1000)) update_rate=tmp; break; case IDC_AUTORESTORE: autorestore=IsDlgButtonChecked(hDlg,IDC_AUTORESTORE); break; case IDC_TRACKFACE: st->trackface=IsDlgButtonChecked(hDlg,IDC_TRACKFACE); if (st->trackface) MAX_COUNT=2; else MAX_COUNT=1; break; case IDC_ERROR_DIST: dist_threshold=(float)GetDlgItemInt(hDlg, IDC_ERROR_DIST,0,0); break; case IDC_ERROR_ANGLE: angle_threshold=(float)GetDlgItemInt(hDlg, IDC_ERROR_ANGLE,0,0); break; case IDC_THRESHOLD_TIME: threshold_time=GetDlgItemInt(hDlg, IDC_THRESHOLD_TIME,0,0); break; case IDC_PT1X: PT1_xpos=(float) GetDlgItemInt(hDlg, IDC_PT1X,0,1) / 100.0f; need_to_init=1; break; case IDC_PT1Y: PT1_ypos=(float)GetDlgItemInt(hDlg, IDC_PT1Y,0,1)/ 100.0f; need_to_init=1; break; case IDC_PT2X: PT2_xpos=(float)GetDlgItemInt(hDlg, IDC_PT2X,0,1)/ 100.0f; need_to_init=1; break; case IDC_PT2Y: PT2_ypos=(float)GetDlgItemInt(hDlg, IDC_PT2Y,0,1)/ 100.0f; need_to_init=1; break; // case IDC_NIGHTMODE: // night_mode ^= 1; // break; case IDC_AUTOINIT: need_to_init=1; break; case IDC_ENABLE_TRACKING: st->enable_tracking=IsDlgButtonChecked(hDlg,IDC_ENABLE_TRACKING); break; case IDC_SETTINGS: { int ncams = cvcamGetCamerasCount( ); // init cvcam if (ncams==0) report("no cam"); cvcamSetProperty(0, CVCAM_PROP_ENABLE, CVCAMTRUE); //Selects the 1-st found camera cvcamInit(); cvcamGetProperty(0, CVCAM_CAMERAPROPS, NULL); // cvcamGetProperty(0, CVCAM_VIDEOFORMAT, NULL); cvcamExit(); } break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK ComWriterDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char szdata[50]; COM_WRITEROBJ * st; st = (COM_WRITEROBJ *) actobject; if ((st==NULL)||(st->type!=OB_COM_WRITER)) return(FALSE); switch( message ) { case WM_INITDIALOG: CheckDlgButton(hDlg, IDC_TRIGGER, st->en_trigger); SetDlgItemInt(hDlg,IDC_COMMAND,st->command,0); SetDlgItemInt(hDlg,IDC_DATA1,st->data1,0); SetDlgItemInt(hDlg,IDC_DATA2,st->data2,0); if (TTY.COMDEV==INVALID_HANDLE_VALUE) SetDlgItemText(hDlg,IDC_STATUS,"COM-Port for EEG not available"); else if (st->cnt==0) SetDlgItemText(hDlg,IDC_STATUS,"ready to send"); else { sprintf(szdata,"%d frames written",st->cnt); SetDlgItemText(hDlg,IDC_STATUS,szdata); } break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SENDCOMMAND: st->command=(unsigned char) GetDlgItemInt(hDlg,IDC_COMMAND,NULL,0); st->data1=(unsigned char) GetDlgItemInt(hDlg,IDC_DATA1,NULL,0); st->data2=(unsigned char) GetDlgItemInt(hDlg,IDC_DATA2,NULL,0); if (TTY.COMDEV!=INVALID_HANDLE_VALUE) { write_to_comport (st->command ); write_to_comport (st->data1 ); write_to_comport (st->data2 ); //if (!SetEvent(TTY.WriterEvent)) // if (WriterProc(NULL)) st->cnt++; sprintf(szdata,"%d frames written",st->cnt); SetDlgItemText(hDlg,IDC_STATUS,szdata); } break; case IDC_TRIGGER: st->en_trigger=IsDlgButtonChecked(hDlg, IDC_TRIGGER); break; case IDC_RESET: st->cnt=0; if (TTY.COMDEV!=INVALID_HANDLE_VALUE) SetDlgItemText(hDlg,IDC_STATUS,"0 frames written"); break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; } return FALSE; }
LRESULT CALLBACK FilterboxDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { int t; // ,z; char newname[25],sztemp[30]; static int acttype; static int dinit=FALSE; static FidFilter * tempf=NULL,* newf=NULL; FILTEROBJ * st; st = (FILTEROBJ *) actobject; if ((st==NULL)||(st->type!=OB_FILTER)) return(FALSE); switch( message ) { case WM_INITDIALOG: dinit=TRUE; SendMessage(GetDlgItem(hDlg, IDC_FILTERTYPECOMBO), CB_RESETCONTENT,0,0); for (t = 0; t < FILTERTYPES; t++) SendMessage( GetDlgItem(hDlg, IDC_FILTERTYPECOMBO), CB_ADDSTRING, 0, (LPARAM) (LPSTR) FILTERTYPE[t].tname) ; SetDlgItemText(hDlg,IDC_FILTERTYPECOMBO, FILTERTYPE[st->filtertype].tname); SetDlgItemText(hDlg,IDC_FILTERNEWNAME, st->name); SetDlgItemInt(hDlg,IDC_FROMFREQ, st->dispfrom,0); SetDlgItemInt(hDlg,IDC_TOFREQ, st->dispto,0); SetDlgItemInt(hDlg,IDC_FILTERPAR0, st->par0,0); sprintf(sztemp,"%.5f",st->par1); SetDlgItemText(hDlg,IDC_FILTERPAR1, sztemp); sprintf(sztemp,"%.5f",st->par2); SetDlgItemText(hDlg,IDC_FILTERPAR2, sztemp); acttype=st->filtertype; dinit=FALSE; newf=do_filt_design(hDlg,acttype); if (newf) tempf=newf; update_filterdialog(hDlg,st->filtertype); return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_FILTERTYPECOMBO: acttype=SendMessage( GetDlgItem(hDlg, IDC_FILTERTYPECOMBO), CB_GETCURSEL, 0, 0 ) ; update_filterdialog(hDlg,acttype); case IDC_FILTERPAR0: case IDC_FILTERPAR1: case IDC_FILTERPAR2: case IDC_FROMFREQ: case IDC_TOFREQ: if (!dinit) { newf=do_filt_design(hDlg,acttype); if (newf) tempf=newf; InvalidateRect(hDlg,NULL,TRUE); } break; case IDC_FILTERSTORE: if (newf) { GetDlgItemText(hDlg, IDC_FILTERNEWNAME,newname,sizeof(newname)); st->filtertype=acttype; st->par0=GetDlgItemInt(hDlg,IDC_FILTERPAR0, NULL, 0); GetDlgItemText(hDlg,IDC_FILTERPAR1,sztemp,sizeof(sztemp)); sscanf(sztemp,"%f",&st->par1); GetDlgItemText(hDlg,IDC_FILTERPAR2,sztemp,sizeof(sztemp)); st->dispfrom=GetDlgItemInt(hDlg, IDC_FROMFREQ, NULL, 0); st->dispto=GetDlgItemInt(hDlg, IDC_TOFREQ, NULL, 0); sscanf(sztemp,"%f",&st->par2); strcpy(st->name,newname); st->filt=do_filt_design(hDlg, acttype); st->run= fid_run_new(st->filt, &(st->funcp)); if (st->fbuf!=NULL) { fid_run_freebuf(st->fbuf); st->fbuf=fid_run_newbuf(st->run); } } break; } return(TRUE); case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; RECT rect; HPEN tpen; HBRUSH tbrush; int height; int f1,f2; float fstep,val,x; hdc = BeginPaint (hDlg, &ps); GetClientRect(hDlg, &rect); tpen = CreatePen (PS_SOLID,1,0); SelectObject (hdc, tpen); tbrush = CreateSolidBrush(RGB(240,240,240)); SelectObject(hdc,tbrush); rect.top+=80; rect.bottom -= 18; height= rect.bottom-rect.top; Rectangle(hdc,rect.left,rect.top-1,rect.right,rect.bottom+20); Rectangle(hdc,rect.left,rect.top-1,rect.right,rect.bottom); Rectangle(hdc,rect.left,rect.bottom-(int)(height/1.3),rect.right,rect.bottom); DeleteObject(tbrush); DeleteObject(tpen); tpen = CreatePen (PS_SOLID,1,RGB(0,100,0)); SelectObject (hdc, tpen); f1=GetDlgItemInt(hDlg, IDC_FROMFREQ, NULL, 0); f2=GetDlgItemInt(hDlg, IDC_TOFREQ, NULL, 0); fstep=(float)(f2-f1)/(rect.right-rect.left); MoveToEx(hdc,rect.left+1,rect.bottom-(int)(height*fid_response(tempf, (float)f1/256.0)/1.3),NULL); for (t=rect.left; t<rect.right; t++) { MoveToEx(hdc,1+t,rect.bottom,NULL); LineTo(hdc,1+t,rect.bottom-(int)(height*fid_response(tempf, (((float)f1+fstep*(t-rect.left))/PACKETSPERSECOND))/1.3)); } SelectObject(hdc, DRAW.scaleFont); wsprintf(sztemp,"1.0"); ExtTextOut( hdc, rect.left+2,rect.top+(int)(height*0.2308), 0, &rect,sztemp, strlen(sztemp), NULL ) ; val=(f2-f1)/10.0f; fstep=((rect.right-25)-rect.left)/10.0f; for (t=0; t<=10; t++) { x=f1+val*t; wsprintf(sztemp,"%d.%d",(int)x,(int)(x*10)%10); ExtTextOut( hdc, rect.left+2+(int)(fstep*t),rect.bottom+2, 0, &rect,sztemp, strlen(sztemp), NULL ) ; } DeleteObject(tpen); EndPaint(hDlg, &ps ); } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK MagnitudeDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { int t; // ,z; static int tempfilt=0,acttype=0; static int dinit=FALSE; char sztemp[30]; MAGNITUDEOBJ * st; st = (MAGNITUDEOBJ *) actobject; if ((st==NULL)||(st->type!=OB_MAGNITUDE)) return(FALSE); switch( message ) { case WM_INITDIALOG: { SCROLLINFO lpsi; SendMessage(GetDlgItem(hDlg, IDC_PASSTYPECOMBO), CB_RESETCONTENT,0,0); for (t = 0; t < PASSTYPES; t++) SendMessage( GetDlgItem(hDlg, IDC_PASSTYPECOMBO), CB_ADDSTRING, 0, (LPARAM) (LPSTR) PASSTYPE[t].tname) ; SetDlgItemText(hDlg,IDC_PASSTYPECOMBO, PASSTYPE[st->filtertype].tname); acttype=st->filtertype; SetDlgItemInt(hDlg,IDC_ORDER, st->order,0); SetDlgItemInt(hDlg,IDC_GAIN, st->gain,0); lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE|SIF_POS; lpsi.nMin=1; lpsi.nMax=1280; SetScrollInfo(GetDlgItem(hDlg,IDC_CENTERBAR),SB_CTL,&lpsi,TRUE); lpsi.nMin=1; lpsi.nMax=200; SetScrollInfo(GetDlgItem(hDlg,IDC_WIDTHBAR),SB_CTL,&lpsi,TRUE); SetScrollPos(GetDlgItem(hDlg,IDC_CENTERBAR), SB_CTL,(int)(st->center*10.0f),TRUE); sprintf(sztemp,"%.4f",st->center); SetDlgItemText(hDlg,IDC_CENTER, sztemp); SetScrollPos(GetDlgItem(hDlg,IDC_WIDTHBAR), SB_CTL,(int)(st->wid*10.0f),TRUE); sprintf(sztemp,"%.4f",st->wid); SetDlgItemText(hDlg,IDC_WIDTH, sztemp); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PASSTYPECOMBO: acttype=SendMessage( GetDlgItem(hDlg, IDC_PASSTYPECOMBO), CB_GETCURSEL, 0, 0 ) ; break; case IDC_CENTER: if (HIWORD(wParam) == EN_KILLFOCUS) { GetDlgItemText(hDlg, IDC_CENTER, sztemp, 20); st->center = (float)atof(sztemp); if (st->center<0) { st->center=0; SetDlgItemText(hDlg,IDC_CENTER,"0");} if (st->center>PACKETSPERSECOND/2) { st->center=(float)(PACKETSPERSECOND/2); SetDlgItemInt(hDlg,IDC_CENTER,PACKETSPERSECOND/2,0);} // SendMessage (hDlg,WM_COMMAND,IDC_STORE,0); } break; case IDC_WIDTH: if (HIWORD(wParam) == EN_KILLFOCUS) { GetDlgItemText(hDlg, IDC_WIDTH, sztemp, 20); st->wid = (float)atof(sztemp); if (st->wid<0.0001) { st->wid=1; SetDlgItemText(hDlg,IDC_CENTER,"0.0001");} if (st->wid>PACKETSPERSECOND/2) { st->wid=(float)(PACKETSPERSECOND/2); SetDlgItemInt(hDlg,IDC_WIDTH,PACKETSPERSECOND/2,0);} // SendMessage (hDlg,WM_COMMAND,IDC_STORE,0); } break; case IDC_STORE: { char sztemp[30]; char szorder[5]; int test; test=GetDlgItemInt(hDlg,IDC_ORDER, NULL, 0); if ((test<1)||((test>10)&&(acttype==0))||((test>60)&&(acttype==1))) { SetDlgItemInt(hDlg,IDC_ORDER,st->order,0); return(TRUE); } st->filtertype=acttype; st->order=test; st->gain=GetDlgItemInt(hDlg,IDC_GAIN, NULL, 0); strcpy(sztemp,PASSTYPE[st->filtertype].init); GetDlgItemText(hDlg, IDC_ORDER, szorder, sizeof(szorder)); strcat(sztemp,szorder); st->lp1filt= fid_design(sztemp, PACKETSPERSECOND, (double)st->wid, 0, 0, 0); st->lp1run= fid_run_new(st->lp1filt, &(st->lp1funcp)); if (st->lp1fbuf!=NULL) { fid_run_freebuf(st->lp1fbuf); st->lp1fbuf=fid_run_newbuf(st->lp1run); } st->lp2filt= fid_design(sztemp, PACKETSPERSECOND,(double)st->wid, 0, 0, 0); st->lp2run= fid_run_new(st->lp2filt, &(st->lp2funcp)); if (st->lp2fbuf!=NULL) { fid_run_freebuf(st->lp2fbuf); st->lp2fbuf=fid_run_newbuf(st->lp2run); } return TRUE; } break; } return (TRUE); case WM_HSCROLL: { int nNewPos; if((nNewPos=get_scrollpos(wParam,lParam))>=0) { if (lParam == (long) GetDlgItem(hDlg,IDC_CENTERBAR)) { st->center=(float)nNewPos/10.0f; sprintf(sztemp,"%.2f",st->center); SetDlgItemText(hDlg, IDC_CENTER,sztemp); } if (lParam == (long) GetDlgItem(hDlg,IDC_WIDTHBAR)) { st->wid=(float)nNewPos/10.0f; sprintf(sztemp,"%.2f",st->wid); SetDlgItemText(hDlg, IDC_WIDTH,sztemp); } } } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK MCIDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char szFileName[MAX_PATH]; MCIOBJ * st; st = (MCIOBJ *) actobject; if ((st==NULL)||(st->type!=OB_MCIPLAYER)) return(FALSE); switch( message ) { case WM_INITDIALOG: SetDlgItemText(hDlg, IDC_MCIFILE, st->mcifile); SCROLLINFO lpsi; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE|SIF_POS; lpsi.nMin=4; lpsi.nMax=5000; SetScrollInfo(GetDlgItem(hDlg,IDC_SPEEDUPDATEBAR),SB_CTL,&lpsi, TRUE); SetScrollPos(GetDlgItem(hDlg,IDC_SPEEDUPDATEBAR), SB_CTL,st->upd_speed, TRUE); SetDlgItemInt(hDlg, IDC_UPDATESPEED, st->upd_speed, FALSE); SetDlgItemInt(hDlg, IDC_POS_CENTER, st->pos_center, FALSE); CheckDlgButton(hDlg, IDC_PLAY_ONCE, st->play_once); return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_OPEN: if (!(strcmp(st->mcifile,"none"))) { strcpy(szFileName,GLOBAL.resourcepath); strcat(szFileName,"MOVIES\\*.avi"); } else strcpy (szFileName,st->mcifile); if (open_file_dlg(hDlg, szFileName, FT_AVI, OPEN_LOAD)) { st->playing=FALSE; strcpy(st->mcifile,szFileName); SetDlgItemText(hDlg, IDC_MCIFILE, st->mcifile); } InvalidateRect(hDlg,NULL,FALSE); break; case IDC_PLAY_ONCE: st->play_once=IsDlgButtonChecked(hDlg,IDC_PLAY_ONCE); break; case IDC_LOAD: if (st->m_video) { MCIWndStop(st->m_video); MCIWndDestroy(st->m_video); } st->m_video = MCIWndCreate(ghWndMain, hInst,WS_VISIBLE|WS_THICKFRAME|MCIWNDF_NOERRORDLG,st->mcifile); if (!st->m_video) report_error ("Cannot open MCI File"); else { RECT prc; MCIWndSetZoom(st->m_video,100); MCIWndGetSource(st->m_video,&prc); MCIWndSetTimeFormat(st->m_video ,"ms"); MCIWndSetActiveTimer(st->m_video,500); if ((!strstr(st->mcifile,".mp3")) && (!strstr(st->mcifile,".wav"))) SetWindowPos(st->m_video,HWND_TOPMOST,st->left,st->top,st->left+prc.right-prc.left,st->top+prc.bottom-prc.top,SWP_SHOWWINDOW); else ShowWindow(st->m_video,FALSE); } break; case IDC_MCIPLAY: if (st->m_video) { MCIWndSetSpeed(st->m_video,st->speed); MCIWndPlay(st->m_video); st->playing=TRUE; } break; case IDC_MCISTOP: if (st->m_video) { MCIWndStop(st->m_video);} // MCIWndDestroy(st->m_video); } st->playing=FALSE; break; case IDC_MCIPLUS: st->speed+=50; if (st->m_video) { MCIWndSetSpeed(st->m_video,st->speed); //MCIWndStep(st->m_video,2); MCIWndPlay(st->m_video); } break; case IDC_MCIMINUS: st->speed-=50; if (st->m_video) { MCIWndSetSpeed(st->m_video,st->speed); //MCIWndStep(st->m_video,2); MCIWndPlay(st->m_video); } break; case IDC_POS_CENTER: st->pos_center=GetDlgItemInt(hDlg,IDC_POS_CENTER,0,FALSE); break; } break; case WM_HSCROLL: { int nNewPos; nNewPos = get_scrollpos(wParam,lParam); if (lParam == (long) GetDlgItem(hDlg,IDC_SPEEDUPDATEBAR)) { SetDlgItemInt(hDlg, IDC_UPDATESPEED, nNewPos, TRUE); st->upd_speed=nNewPos; } break; } case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; } return FALSE; }
LRESULT CALLBACK EdfReaderDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { EDF_READEROBJ * st; int x; static int actchn; char strfloat[21]; st = (EDF_READEROBJ *) actobject; if ((st==NULL)||(st->type!=OB_EDF_READER)) return(FALSE); switch( message ) { case WM_INITDIALOG: actchn=0; update_header(hDlg,&st->header); update_channelcombo(hDlg, st->channel, st->header.channels); update_channel(hDlg,st->channel,actchn); update_state(hDlg,st->state); sprintf(strfloat,"%.2f",(float)st->offset/(float)PACKETSPERSECOND); SetDlgItemText(hDlg,IDC_OFFSET,strfloat); if (st->edffile!=INVALID_HANDLE_VALUE) SetDlgItemText(hDlg, IDC_EDFFILE, st->filename); else SetDlgItemText(hDlg, IDC_EDFFILE, "none"); return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SELECT: st->filename[0]=0; if ((st->edffile=open_edf_file(&st->header,st->channel,st->filename))==INVALID_HANDLE_VALUE) st->state=0; else if (st->header.channels==0) { SendMessage(hDlg,WM_COMMAND,IDC_CLOSE,0); report("EDF-File contained no channel inforamtion, file closed."); st->state=0; } else st->state=1; update_state(hDlg,st->state); if (!st->state) break; st->calc_session_length(); get_session_length(); //set_session_pos(0); st->session_pos(0); st->packetcount=0; st->sampos=0; if (st->outports!=st->header.channels) { for (x=0;x<MAX_CONNECTS;x++) { st->out[x].from_port=-1; st->out[x].to_port=-1; st->out[x].to_object=-1; } for (x=0;x<MAX_PORTS;x++) st->out_ports[x].out_name[0]=0; } st->outports=st->header.channels; st->height=CON_START+st->outports*CON_HEIGHT+5; update_header(hDlg,&st->header); update_channelcombo(hDlg, st->channel, st->header.channels); update_channel(hDlg,st->channel,actchn); st->get_captions(); update_dimensions(); SetDlgItemText(hDlg, IDC_EDFFILE, st->filename); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_SELECT), FALSE); InvalidateRect(ghWndDesign,NULL,TRUE); break; case IDC_CLOSE: st->state=0; update_state(hDlg,st->state); SetDlgItemText(hDlg, IDC_EDFFILE, "none"); add_to_listbox(hDlg,IDC_LIST, "file closed."); strcpy(st->filename,"none"); if (st->edffile==INVALID_HANDLE_VALUE) break; CloseHandle(st->edffile); st->edffile=INVALID_HANDLE_VALUE; get_session_length(); InvalidateRect(ghWndDesign,NULL,TRUE); break; case IDC_APPLYOFFSET: GetDlgItemText(hDlg, IDC_OFFSET, strfloat, 20); st->offset = (int)((float)atof(strfloat) * (float) PACKETSPERSECOND); st->calc_session_length(); get_session_length(); break; case IDC_CHANNELCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { get_channel(hDlg, st->channel, actchn); actchn=SendMessage(GetDlgItem(hDlg, IDC_CHANNELCOMBO), CB_GETCURSEL , 0, 0); update_channel(hDlg, st->channel,actchn); } break; } return TRUE; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK ParticleDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { PARTICLEOBJ * st; st = (PARTICLEOBJ *) actobject; if ((st==NULL)||(st->type!=OB_PARTICLE)) return(FALSE); switch( message ) { case WM_INITDIALOG: { SCROLLINFO lpsi; char sztemp[3]; int t; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE|SIF_POS; lpsi.nMin=1; lpsi.nMax=1024; SetScrollInfo(GetDlgItem(hDlg,IDC_VALUEBAR),SB_CTL,&lpsi,TRUE); for (t=0;t<PARTICLE_PARAMS;t++) SendDlgItemMessage(hDlg, IDC_PARAMETERCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) PARTICLEPARAMETER[t].paramname ) ; SendDlgItemMessage(hDlg, IDC_REMOTECOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "none" ) ; for (t=1;t<7;t++) { sprintf(sztemp,"%d",t); SendDlgItemMessage(hDlg, IDC_REMOTECOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) sztemp ) ; } update_particledialog(hDlg,st); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PARAMETERCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { st->act_parameter=SendDlgItemMessage(hDlg, IDC_PARAMETERCOMBO, CB_GETCURSEL, 0, 0 ) ; update_particledialog(hDlg,st); EnableWindow(GetDlgItem(hDlg, IDC_VALUEBAR),TRUE); } break; case IDC_PARTICLEMUTE: st->mute=IsDlgButtonChecked(hDlg, IDC_PARTICLEMUTE); break; case IDC_REMOTECOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { st->remote[st->act_parameter]=SendDlgItemMessage(hDlg, IDC_REMOTECOMBO, CB_GETCURSEL, 0, 0 ) ; //update_particledialog(hDlg,st); } break; case IDC_SETMIN: st->min[st->act_parameter]=st->get_paramvalue(st->act_parameter); st->value[st->act_parameter]=1.0f; //SetScrollPos(GetDlgItem(hDlg,IDC_VALUEBAR), SB_CTL,1,TRUE); update_particledialog(hDlg,st); break; case IDC_SETMAX: st->max[st->act_parameter]=st->get_paramvalue(st->act_parameter); st->value[st->act_parameter]=1024.0f; //SetScrollPos(GetDlgItem(hDlg,IDC_VALUEBAR), SB_CTL,1024,TRUE); update_particledialog(hDlg,st); break; case IDC_RESETMINMAX: st->min[st->act_parameter]=PARTICLEPARAMETER[st->act_parameter].min; st->max[st->act_parameter]=PARTICLEPARAMETER[st->act_parameter].max; update_particledialog(hDlg,st); break; case IDC_LOADPAL: { char szFileName[100]; int t; strcpy(szFileName,GLOBAL.resourcepath); strcat(szFileName,"PALETTES\\*.pal"); if (open_file_dlg(hDlg, szFileName, FT_PALETTE, OPEN_LOAD)) { if (!load_from_file(szFileName, &(st->cols), sizeof(st->cols))) report_error("Could not load Color Palette"); else { reduce_filepath(szFileName,szFileName); strcpy(st->palettefile,szFileName); SetDlgItemText(hDlg, IDC_PALETTEFILE, st->palettefile); for (t=0;t<128;t++) { st->colors[t][0]=(float)((st->cols[t]&0xff)/256.0); st->colors[t][1]=(float)(((st->cols[t]>>8)&0xff)/256.0); st->colors[t][2]=(float)((st->cols[t]>>16)/256.0); } } } } break; } return TRUE; break; case WM_HSCROLL: { int nNewPos; if ((nNewPos=get_scrollpos(wParam, lParam))>=0) { if (lParam == (long) GetDlgItem(hDlg,IDC_VALUEBAR)) { char sztemp[10]; st->value[st->act_parameter]=(float)nNewPos; sprintf(sztemp,"%.2f",st->get_paramvalue(st->act_parameter)); SetDlgItemText(hDlg, IDC_VALUE,sztemp); } } } case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK FileReaderDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { FILE_READEROBJ * st; static int actchn; st = (FILE_READEROBJ *) actobject; if ((st==NULL)||(st->type!=OB_FILE_READER)) return(FALSE); switch( message ) { case WM_INITDIALOG: SetDlgItemText(hDlg, IDC_FILENAME, st->filename); SendDlgItemMessage(hDlg,IDC_FORMATCOMBO,CB_ADDSTRING,0,(LPARAM) (LPSTR) "ASCII-Integer Values, TAB / CR+LF delimited"); SendDlgItemMessage(hDlg,IDC_FORMATCOMBO,CB_ADDSTRING,0,(LPARAM) (LPSTR) "ASCII-Integer Values, Comma / CR+LF delimited"); SendDlgItemMessage(hDlg,IDC_FORMATCOMBO,CB_ADDSTRING,0,(LPARAM) (LPSTR) "ASCII-Float Values, TAB / CR+LF delimited"); SendDlgItemMessage(hDlg,IDC_FORMATCOMBO,CB_ADDSTRING,0,(LPARAM) (LPSTR) "ASCII-Float Values, Comma / CR+LF delimited"); SendDlgItemMessage(hDlg,IDC_FORMATCOMBO,CB_ADDSTRING,0,(LPARAM) (LPSTR) "ASCII-BioExplorer with header"); SendDlgItemMessage(hDlg,IDC_FORMATCOMBO,CB_ADDSTRING,0,(LPARAM) (LPSTR) "1-Channel raw integer 16bit signed"); SendDlgItemMessage(hDlg,IDC_FORMATCOMBO,CB_ADDSTRING,0,(LPARAM) (LPSTR) "1-Channel raw integer 16bit unsigned"); SendDlgItemMessage(hDlg, IDC_FORMATCOMBO, CB_SETCURSEL, st->format, 0L ) ; if (st->state) { SetDlgItemText(hDlg,IDC_FILESTATUS,"reading File"); EnableWindow(GetDlgItem(hDlg, IDC_OPENFILE), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_START), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); } else { if (st->file!=INVALID_HANDLE_VALUE) { SetDlgItemText(hDlg,IDC_FILESTATUS,"File opened"); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), TRUE); } else { SetDlgItemText(hDlg,IDC_FILESTATUS,"File not opened."); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); } EnableWindow(GetDlgItem(hDlg, IDC_OPENFILE), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_START), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), FALSE); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_OPENFILE: if (!strcmp(st->filename,"none")) { strcpy(st->filename,GLOBAL.resourcepath); strcat(st->filename,"ARCHIVES\\*.*"); } if (open_file_dlg(ghWndMain,st->filename, FT_TXT, OPEN_LOAD)) { if (!open_textarchive(st)) SetDlgItemText(hDlg,IDC_FILESTATUS,"Could not open File"); else { EnableWindow(GetDlgItem(hDlg, IDC_OPENFILE), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_START), TRUE); SetDlgItemText(hDlg,IDC_FILESTATUS,"File opened"); } } get_session_length(); SetDlgItemText(hDlg,IDC_FILENAME,st->filename); InvalidateRect(ghWndDesign,NULL,TRUE); break; case IDC_START: if ((st->outports>0) &&(st->file!=INVALID_HANDLE_VALUE)) { SetDlgItemText(hDlg,IDC_FILESTATUS, "reading File"); // START FILE READING st->state=1; EnableWindow(GetDlgItem(hDlg, IDC_START), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); } else SetDlgItemText(hDlg,IDC_FILESTATUS, "No Channels available."); break; case IDC_STOP: SetDlgItemText(hDlg,IDC_FILESTATUS, "stopped"); st->state=0; EnableWindow(GetDlgItem(hDlg, IDC_START), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_OPENFILE), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_STOP), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), TRUE); break; case IDC_CLOSE: SetDlgItemText(hDlg,IDC_FILESTATUS, "file closed."); st->state=0; if (st->file!=INVALID_HANDLE_VALUE) CloseHandle(st->file); st->file=INVALID_HANDLE_VALUE; EnableWindow(GetDlgItem(hDlg, IDC_OPENFILE), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_START), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); get_session_length(); st->samplecount=0; InvalidateRect(ghWndDesign,NULL,TRUE); break; case IDC_FORMATCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { st->format=SendMessage(GetDlgItem(hDlg, IDC_FORMATCOMBO), CB_GETCURSEL , 0, 0); } break; } return TRUE; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK CounterDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { static int init; COUNTEROBJ * st; st = (COUNTEROBJ *) actobject; if ((st==NULL)||(st->type!=OB_COUNTER)) return(FALSE); switch( message ) { case WM_INITDIALOG: SCROLLINFO lpsi; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE|SIF_POS; lpsi.nMin=4; lpsi.nMax=300; SetScrollInfo(GetDlgItem(hDlg,IDC_FONTSIZEBAR),SB_CTL,&lpsi, TRUE); SetScrollPos(GetDlgItem(hDlg,IDC_FONTSIZEBAR), SB_CTL,st->fontsize, TRUE); SetDlgItemInt(hDlg, IDC_FONTSIZE, st->fontsize, FALSE); SetDlgItemText(hDlg, IDC_CAPTION, st->wndcaption); SetDlgItemInt(hDlg, IDC_RESETVALUE, (int)st->resetvalue,TRUE); switch (st->mode) { case 0: CheckDlgButton(hDlg, IDC_COUNTFT,TRUE); break; case 1: CheckDlgButton(hDlg, IDC_COUNTTF,TRUE); break; case 2: CheckDlgButton(hDlg, IDC_COUNTIV,TRUE); break; case 3: CheckDlgButton(hDlg, IDC_COUNTFREQ,TRUE); break; } CheckDlgButton(hDlg, IDC_SHOWCOUNTER,st->showcounter); CheckDlgButton(hDlg, IDC_INTEGER,st->integer); return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_COUNTFT: st->mode=0; break; case IDC_COUNTTF: st->mode=1; break; case IDC_COUNTIV: st->mode=2; break; case IDC_COUNTFREQ: st->mode=3; break; case IDC_RESETCOUNTER: st->countervalue=st->resetvalue; break; case IDC_RESETVALUE: st->resetvalue=(float)GetDlgItemInt(hDlg, IDC_RESETVALUE,NULL, 1); break; case IDC_FONTCOLOR: st->fontcolor=select_color(hDlg); InvalidateRect(hDlg,NULL,FALSE); InvalidateRect(st->displayWnd,NULL,TRUE); break; case IDC_BKCOLOR: st->bkcolor=select_color(hDlg); InvalidateRect(hDlg,NULL,FALSE); InvalidateRect(st->displayWnd,NULL,TRUE); break; case IDC_CAPTION: GetDlgItemText(hDlg,IDC_CAPTION,st->wndcaption,50); SetWindowText(st->displayWnd,st->wndcaption); break; case IDC_INTEGER: st->integer=IsDlgButtonChecked(hDlg,IDC_INTEGER); InvalidateRect(st->displayWnd,NULL,TRUE); break; case IDC_SHOWCOUNTER: { int i; i=IsDlgButtonChecked(hDlg,IDC_SHOWCOUNTER); if ((st->showcounter)&&(!i)&&(st->displayWnd)) { DestroyWindow(st->displayWnd); st->displayWnd=NULL; } if ((!st->showcounter)&&(i)) { if(!(st->displayWnd=CreateWindow("Counter_Class", "Counter", WS_THICKFRAME| WS_CLIPCHILDREN,st->left, st->top, st->right-st->left, st->bottom-st->top, NULL, NULL, hInst, NULL))) report_error("can't create Counter Window"); else { ShowWindow( st->displayWnd, TRUE ); UpdateWindow( st->displayWnd ); } } st->showcounter=i; } break; } return TRUE; case WM_HSCROLL: if (lParam == (long) GetDlgItem(hDlg,IDC_FONTSIZEBAR)) { int nNewPos=get_scrollpos(wParam,lParam); SetDlgItemInt(hDlg, IDC_FONTSIZE, nNewPos, TRUE); st->fontsize=nNewPos; if (st->font) DeleteObject(st->font); if (!(st->font = CreateFont(-MulDiv(st->fontsize, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"))) report_error("Font creation failed!"); InvalidateRect(st->displayWnd, NULL, TRUE); } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); case WM_PAINT: color_button(GetDlgItem(hDlg,IDC_FONTCOLOR),st->fontcolor); color_button(GetDlgItem(hDlg,IDC_BKCOLOR),st->bkcolor); break; } return FALSE; }
LRESULT CALLBACK SignalDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { static int init; char sztemp[20]; SIGNALOBJ * st; st = (SIGNALOBJ *) actobject; if ((st==NULL)||(st->type!=OB_SIGNAL)) return(FALSE); switch( message ) { case WM_INITDIALOG: { SCROLLINFO lpsi; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE|SIF_POS; lpsi.nMin=0; lpsi.nMax=6000; SetScrollInfo(GetDlgItem(hDlg,IDC_FREQUENCYBAR),SB_CTL,&lpsi,TRUE); lpsi.nMin=0; lpsi.nMax=1000; SetScrollInfo(GetDlgItem(hDlg,IDC_GAINBAR),SB_CTL,&lpsi,TRUE); lpsi.nMin=0; lpsi.nMax=360; SetScrollInfo(GetDlgItem(hDlg,IDC_PHASEBAR),SB_CTL,&lpsi,TRUE); lpsi.nMin=-5000; lpsi.nMax=5000; SetScrollInfo(GetDlgItem(hDlg,IDC_CENTERBAR),SB_CTL,&lpsi,TRUE); lpsi.nMin=0; lpsi.nMax=1000; SetScrollInfo(GetDlgItem(hDlg,IDC_NOISEBAR),SB_CTL,&lpsi,TRUE); SetScrollPos(GetDlgItem(hDlg,IDC_FREQUENCYBAR), SB_CTL,(int)(st->frequency*100.0f),TRUE); sprintf(sztemp,"%.2f",st->frequency); SetDlgItemText(hDlg, IDC_FREQUENCY,sztemp); SetScrollPos(GetDlgItem(hDlg,IDC_CENTERBAR), SB_CTL,(int)st->center,TRUE); SetDlgItemInt(hDlg, IDC_CENTER, (int)st->center,1); SetScrollPos(GetDlgItem(hDlg,IDC_GAINBAR), SB_CTL,(int)st->gain,TRUE); SetDlgItemInt(hDlg, IDC_GAIN, (int)(st->gain/1000.0f*st->out_ports[0].out_max),0); SetScrollPos(GetDlgItem(hDlg,IDC_PHASEBAR), SB_CTL,(int)st->phase,TRUE); SetDlgItemInt(hDlg, IDC_PHASE, (int)st->phase,0); SetScrollPos(GetDlgItem(hDlg,IDC_NOISEBAR), SB_CTL,(int)st->noise,TRUE); SetDlgItemInt(hDlg, IDC_NOISE, (int)st->noise,0); SendDlgItemMessage( hDlg, IDC_SIGNALCOMBO, CB_ADDSTRING, 0,(LPARAM) "Sinus") ; SendDlgItemMessage( hDlg, IDC_SIGNALCOMBO, CB_ADDSTRING, 0,(LPARAM) "Sawtooth") ; SendDlgItemMessage( hDlg, IDC_SIGNALCOMBO, CB_ADDSTRING, 0,(LPARAM) "Rectangle") ; SendDlgItemMessage( hDlg, IDC_SIGNALCOMBO, CB_ADDSTRING, 0,(LPARAM) "Ramp") ; SendDlgItemMessage( hDlg, IDC_SIGNALCOMBO, CB_SETCURSEL, st->sigtype, 0L ) ; CheckDlgButton(hDlg, IDC_ENABLE_IN, st->enable_in); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SIGNALCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) st->sigtype=SendMessage(GetDlgItem(hDlg, IDC_SIGNALCOMBO), CB_GETCURSEL , 0, 0); break; case IDC_ENABLE_IN: st->enable_in= IsDlgButtonChecked(hDlg, IDC_ENABLE_IN); if (st->enable_in) { st->width=80; st->inports=2; st->height=CON_START+2*CON_HEIGHT+5;} else {st->width=50; st->inports=0; st->height=CON_START+CON_HEIGHT+5; } InvalidateRect(ghWndDesign,NULL,TRUE); break; } return TRUE; case WM_HSCROLL: { int nNewPos; //if (( nNewPos=get_scrollpos(wParam, lParam); //)>=0) { if (lParam == (long) GetDlgItem(hDlg,IDC_FREQUENCYBAR)) { sprintf(sztemp,"%.2f",nNewPos/100.0f); SetDlgItemText(hDlg, IDC_FREQUENCY,sztemp); st->frequency=(float)nNewPos/100.0f; } if (lParam == (long) GetDlgItem(hDlg,IDC_CENTERBAR)) { st->center=(float)nNewPos; SetDlgItemInt(hDlg, IDC_CENTER,(int)(st->center),1); } if (lParam == (long) GetDlgItem(hDlg,IDC_GAINBAR)) { st->gain=(float)nNewPos; SetDlgItemInt(hDlg, IDC_GAIN,(int)(st->gain/1000.0f*st->out_ports[0].out_max),0); } if (lParam == (long) GetDlgItem(hDlg,IDC_PHASEBAR)) { SetDlgItemInt(hDlg, IDC_PHASE,nNewPos,0); st->phase=(float)nNewPos; } if (lParam == (long) GetDlgItem(hDlg,IDC_NOISEBAR)) { SetDlgItemInt(hDlg, IDC_NOISE,nNewPos,0); st->noise=nNewPos; } } } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK Sample_HoldDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char tmp[50]; SAMPLE_HOLDOBJ * st; st = (SAMPLE_HOLDOBJ *) actobject; if ((st==NULL)||(st->type!=OB_SAMPLE_HOLD)) return(FALSE); switch( message ) { case WM_INITDIALOG: sprintf(tmp,"%.4f",st->hold); SetDlgItemText(hDlg, IDC_HOLD, tmp); sprintf(tmp,"%.4f",st->resetvalue); SetDlgItemText(hDlg, IDC_RESETVALUE, tmp); switch (st->mode) { case 0: CheckDlgButton(hDlg, IDC_TRG_MANUAL,TRUE); break; case 1: CheckDlgButton(hDlg, IDC_TRG_RISING,TRUE); break; case 2: CheckDlgButton(hDlg, IDC_TRG_FALLING,TRUE); break; } break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SAMPLE: st->hold=st->act; sprintf(tmp,"%.2f",st->hold); SetDlgItemText(hDlg,IDC_HOLD,tmp); break; case IDC_RESETVALUE: if (HIWORD(wParam) == EN_KILLFOCUS) { GetDlgItemText(hDlg,IDC_RESETVALUE,tmp,sizeof(tmp)); st->resetvalue=(float)atof(tmp); } break; case IDC_TRG_MANUAL: st->mode=0; break; case IDC_TRG_RISING: st->mode=1; break; case IDC_TRG_FALLING: st->mode=2; break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK SpellerDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { SPELLEROBJ * st; char szFileName [256]; st = (SPELLEROBJ *) actobject; if ((st==NULL)||(st->type!=OB_SPELLER)) return(FALSE); switch( message ) { case WM_INITDIALOG: SetDlgItemInt(hDlg, IDC_SWITCHTIME,st->speed,0); SetDlgItemInt(hDlg, IDC_IDLETIME,st->idle,0); SetDlgItemInt(hDlg, IDC_PRESSTIME,st->press,0); SetDlgItemInt(hDlg, IDC_WORDCOUNT,st->wordcount,0); SetDlgItemText(hDlg, IDC_WORDFILE,st->wordfile); SetDlgItemText(hDlg,IDC_DICTFILE,st->dictfile); CheckDlgButton(hDlg, IDC_AUTOLEARN, st->autolearn); CheckDlgButton(hDlg, IDC_DIRECTSEND, st->directsend); SendDlgItemMessage( hDlg, IDC_MODECOMBO, CB_ADDSTRING, 0,(LPARAM) "Automatic Switching") ; SendDlgItemMessage( hDlg, IDC_MODECOMBO, CB_ADDSTRING, 0,(LPARAM) "Paddle + Joystick-Button") ; SendDlgItemMessage( hDlg, IDC_MODECOMBO, CB_ADDSTRING, 0,(LPARAM) "Joystick (2-Directions)") ; SendDlgItemMessage( hDlg, IDC_MODECOMBO, CB_SETCURSEL, st->mode, 0L ) ; return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_AUTOLEARN: st->autolearn=IsDlgButtonChecked(hDlg,IDC_AUTOLEARN); break; case IDC_DIRECTSEND: st->directsend=IsDlgButtonChecked(hDlg,IDC_DIRECTSEND); break; case IDC_SWITCHTIME: st->speed=GetDlgItemInt(hDlg,IDC_SWITCHTIME,NULL,0); break; case IDC_IDLETIME: st->idle=GetDlgItemInt(hDlg,IDC_IDLETIME,NULL,0); break; case IDC_PRESSTIME: st->press=GetDlgItemInt(hDlg,IDC_PRESSTIME,NULL,0); break; case IDC_DICTFILE: GetDlgItemText(hDlg,IDC_DICTFILE,st->dictfile,256); break; case IDC_LEARN: GetDlgItemText(hDlg, IDC_NEWWORDS,st->word,sizeof(st->word)); st->learn_words(); SetDlgItemText(hDlg, IDC_NEWWORDS,""); strcpy(st->word,""); SetDlgItemInt(hDlg, IDC_WORDCOUNT,st->wordcount,0); break; case IDC_IMPORTLIST: strcpy(szFileName,GLOBAL.resourcepath); strcat(szFileName,"dictionary\\*.txt"); if (open_file_dlg(hDlg, szFileName, FT_TXT, OPEN_LOAD)) { if (!import_words(st, szFileName)) report_error("Could not import Word list"); else { strcpy(st->wordfile,szFileName); SetDlgItemText(hDlg, IDC_WORDFILE,st->wordfile); SetDlgItemInt(hDlg, IDC_WORDCOUNT,st->wordcount,0); } } else report_error("Could not open File"); break; case IDC_LOADDICT: strcpy(szFileName,GLOBAL.resourcepath); strcat(szFileName,"dictionary\\*.dic"); if (open_file_dlg(hDlg, szFileName, FT_DIC, OPEN_LOAD)) st->load_dictionary(szFileName); break; case IDC_SAVEDICT: if (strlen(st->dictfile)>=7) strcpy(szFileName,st->dictfile); else { strcpy(szFileName,GLOBAL.resourcepath); strcat(szFileName,"dictionary\\*.dic"); } if (open_file_dlg(hDlg, szFileName, FT_DIC, OPEN_SAVE)) st->save_dictionary(szFileName); break; case IDC_CLEARDICT: init_dict(st); SetDlgItemInt(hDlg, IDC_WORDCOUNT,st->wordcount,0); break; case IDC_EXPORTLIST: break; case IDC_MODECOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) st->mode=SendMessage(GetDlgItem(hDlg, IDC_MODECOMBO), CB_GETCURSEL , 0, 0); switch (st->mode) { case 0: st->selections=st->entries; break; case 1: st->selections=st->entries; break; case 2: st->selections=st->entries; break; } break; } return TRUE; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); case WM_PAINT: // color_button(GetDlgItem(hDlg,IDC_SELECTCOLOR),st->color); break; } return FALSE; }
LRESULT CALLBACK Array3600DlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char szBuffer[50]; int wPosition,t; ARRAY3600OBJ * st; st = (ARRAY3600OBJ *) actobject; if ((st==NULL)||(st->type!=OB_ARRAY3600)) return(FALSE); switch( message ) { case WM_INITDIALOG: for (t = 0; t < MAX_COMPORT; t++) { wsprintf( szBuffer, "COM%d", t + 1 ) ; SendDlgItemMessage( hDlg, IDC_PORTCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) szBuffer ) ; } if (st->comport) SendDlgItemMessage( hDlg, IDC_PORTCOMBO, CB_SETCURSEL, (WPARAM) (st->comport - 1), 0L ) ; else SetDlgItemText( hDlg, IDC_PORTCOMBO, "none") ; for (t = 0; BaudTable[t]!=0 ; t++) { wPosition = LOWORD( SendDlgItemMessage( hDlg, IDC_BAUDCOMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) szBaud[t] ) ) ; SendDlgItemMessage( hDlg, IDC_BAUDCOMBO, CB_SETITEMDATA, (WPARAM) wPosition, (LPARAM) BaudTable[t]) ; if (BaudTable[t] == st->baudrate) SendDlgItemMessage( hDlg, IDC_BAUDCOMBO, CB_SETCURSEL, (WPARAM) wPosition, 0L ) ; } if (st->comdev==INVALID_HANDLE_VALUE) CheckDlgButton(hDlg, IDC_CONNECTED, FALSE); else CheckDlgButton(hDlg, IDC_CONNECTED, TRUE); SetDlgItemInt(hDlg,IDC_MAXVOLTAGE,st->maxvoltage,0); SetDlgItemInt(hDlg,IDC_MAXCURRENT,st->maxcurrent,0); SetDlgItemInt(hDlg,IDC_MAXPOWER,st->maxpower,0); SetDlgItemInt(hDlg,IDC_VOLTAGE,st->voltage,0); SetDlgItemInt(hDlg,IDC_ADDRESS,st->address,0); SetDlgItemInt(hDlg,IDC_PERIOD,st->period,0); CheckDlgButton(hDlg, IDC_PERIODIC, st->periodic); break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PORTCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { st->comport=SendDlgItemMessage(hDlg, IDC_PORTCOMBO, CB_GETCURSEL, 0, 0 )+1 ; st->BreakDownComPort(); CheckDlgButton(hDlg,IDC_CONNECTED,FALSE); } break; case IDC_BAUDCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { int sel; sel=SendDlgItemMessage(hDlg, IDC_BAUDCOMBO, CB_GETCURSEL, 0, 0 ) ; st->baudrate=BaudTable[sel]; if (st->comdev!=INVALID_HANDLE_VALUE) { st->BreakDownComPort(); st->connected=st->SetupComPort(st->comport); CheckDlgButton(hDlg, IDC_CONNECTED, st->connected); } } break; case IDC_CONNECT: if (st->connected) { st->BreakDownComPort(); CheckDlgButton(hDlg, IDC_CONNECTED, FALSE); } else { st->connected=st->SetupComPort(st->comport); CheckDlgButton(hDlg, IDC_CONNECTED, st->connected); } break; case IDC_CONNECTED: CheckDlgButton(hDlg,IDC_CONNECTED, st->connected); break; case IDC_SETNOW: st->setParameters(st->address, st->maxcurrent, st->maxvoltage, st->maxpower, st->voltage); break; case IDC_CONTROL_ON: st->setToPcControlOn(); break; case IDC_CONTROL_OFF: st->setToPcControlOff(); break; case IDC_PERIODIC: st->periodic=IsDlgButtonChecked(hDlg, IDC_PERIODIC); break; case IDC_PERIOD: st->period=GetDlgItemInt(hDlg, IDC_PERIOD, 0,0); break; case IDC_MAXVOLTAGE: st->maxvoltage=GetDlgItemInt(hDlg, IDC_MAXVOLTAGE, 0,0); break; case IDC_MAXCURRENT: st->maxcurrent=GetDlgItemInt(hDlg, IDC_MAXCURRENT, 0,0); break; case IDC_MAXPOWER: st->maxpower=GetDlgItemInt(hDlg, IDC_MAXPOWER, 0,0); break; case IDC_VOLTAGE: st->voltage=GetDlgItemInt(hDlg, IDC_VOLTAGE, 0,0); break; case IDC_ADDRESS: st->address=GetDlgItemInt(hDlg, IDC_ADDRESS, 0,0); break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; } return FALSE; }
LRESULT CALLBACK Mixer4DlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { char sztemp[20]; MIXER4OBJ * st; st = (MIXER4OBJ *) actobject; if ((st==NULL)||(st->type!=OB_MIXER4)) return(FALSE); switch( message ) { case WM_INITDIALOG: { SCROLLINFO lpsi; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE|SIF_POS; lpsi.nMin=0; lpsi.nMax=5000; SetScrollInfo(GetDlgItem(hDlg,IDC_CHN1BAR),SB_CTL,&lpsi,TRUE); SetScrollInfo(GetDlgItem(hDlg,IDC_CHN2BAR),SB_CTL,&lpsi,TRUE); SetScrollInfo(GetDlgItem(hDlg,IDC_CHN3BAR),SB_CTL,&lpsi,TRUE); SetScrollInfo(GetDlgItem(hDlg,IDC_CHN4BAR),SB_CTL,&lpsi,TRUE); switch (st->invmode) { case 0: CheckDlgButton(hDlg,IDC_INVIGNORE,TRUE); break; case 1: CheckDlgButton(hDlg,IDC_INVAND,TRUE); break; case 2: CheckDlgButton(hDlg,IDC_INVOR,TRUE); break; } update_scrollpos(hDlg,st); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SOLO1: st->chn1vol=100.0f; st->chn2vol=0.0f;st->chn3vol=0.0f;st->chn4vol=0.0f; update_scrollpos(hDlg,st); break; case IDC_SOLO2: st->chn2vol=100.0f; st->chn1vol=0.0f;st->chn3vol=0.0f;st->chn4vol=0.0f; update_scrollpos(hDlg,st); break; case IDC_SOLO3: st->chn3vol=100.0f; st->chn1vol=0.0f;st->chn2vol=0.0f;st->chn4vol=0.0f; update_scrollpos(hDlg,st); break; case IDC_SOLO4: st->chn4vol=100.0f; st->chn1vol=0.0f;st->chn2vol=0.0f;st->chn3vol=0.0f; update_scrollpos(hDlg,st); break; case IDC_INVIGNORE: st->invmode=0; break; case IDC_INVAND: st->invmode=1; break; case IDC_INVOR: st->invmode=2; break; } return TRUE; case WM_HSCROLL: { int nNewPos; nNewPos=get_scrollpos(wParam, lParam); { if (lParam == (long) GetDlgItem(hDlg,IDC_CHN1BAR)) { sprintf(sztemp,"%.2f",nNewPos/10.0f); SetDlgItemText(hDlg, IDC_CHN1,sztemp); st->chn1vol=(float)nNewPos/10.0f; } if (lParam == (long) GetDlgItem(hDlg,IDC_CHN2BAR)) { sprintf(sztemp,"%.2f",nNewPos/10.0f); SetDlgItemText(hDlg, IDC_CHN2,sztemp); st->chn2vol=(float)nNewPos/10.0f; } if (lParam == (long) GetDlgItem(hDlg,IDC_CHN3BAR)) { sprintf(sztemp,"%.2f",nNewPos/10.0f); SetDlgItemText(hDlg, IDC_CHN3,sztemp); st->chn3vol=(float)nNewPos/10.0f; } if (lParam == (long) GetDlgItem(hDlg,IDC_CHN4BAR)) { sprintf(sztemp,"%.2f",nNewPos/10.0f); SetDlgItemText(hDlg, IDC_CHN4,sztemp); st->chn4vol=(float)nNewPos/10.0f; } } } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK EMOTIVDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { EMOTIVOBJ * st; char userBuffer[18]; int t; st = (EMOTIVOBJ *) actobject; if ((st==NULL)||(st->type!=OB_EMOTIV)) return(FALSE); switch (message) { case WM_INITDIALOG: { for (t = 0; t < 18; t++) { wsprintf( userBuffer , "User %d" , t + 1 ); SendDlgItemMessage(hDlg, IDC_USERID_COMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) userBuffer); } } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_USERID_COMBO: { if (HIWORD(wParam)==CBN_SELCHANGE) { userID_selected = SendDlgItemMessage(hDlg, IDC_USERID_COMBO, CB_GETCURSEL, 0, 0 ); } } } break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_PAINT: color_button(GetDlgItem(hDlg,IDC_CQ_AF3),COLORS_Q[chncolor[0]]); color_button(GetDlgItem(hDlg,IDC_CQ_F7),COLORS_Q[chncolor[1]]); color_button(GetDlgItem(hDlg,IDC_CQ_F3),COLORS_Q[chncolor[2]]); color_button(GetDlgItem(hDlg,IDC_CQ_FC5),COLORS_Q[chncolor[3]]); color_button(GetDlgItem(hDlg,IDC_CQ_T7),COLORS_Q[chncolor[4]]); color_button(GetDlgItem(hDlg,IDC_CQ_P7),COLORS_Q[chncolor[5]]); color_button(GetDlgItem(hDlg,IDC_CQ_O1),COLORS_Q[chncolor[6]]); color_button(GetDlgItem(hDlg,IDC_CQ_O2),COLORS_Q[chncolor[7]]); color_button(GetDlgItem(hDlg,IDC_CQ_P8),COLORS_Q[chncolor[8]]); color_button(GetDlgItem(hDlg,IDC_CQ_T8),COLORS_Q[chncolor[9]]); color_button(GetDlgItem(hDlg,IDC_CQ_FC6),COLORS_Q[chncolor[10]]); color_button(GetDlgItem(hDlg,IDC_CQ_F4),COLORS_Q[chncolor[11]]); color_button(GetDlgItem(hDlg,IDC_CQ_F8),COLORS_Q[chncolor[12]]); color_button(GetDlgItem(hDlg,IDC_CQ_AF4),COLORS_Q[chncolor[13]]); color_button(GetDlgItem(hDlg,IDC_WIRELESS_QUALITY),COLORS_Q[wirelesscol]); //SetDlgItemInt(hDlg, IDC_BATTERY_CHARGE_LEVEL, BatteryLevel, FALSE); break; case WM_SIZE: break; case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK BALLGAMEDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { BALLGAMEOBJ * st; st = (BALLGAMEOBJ *) actobject; if ((st==NULL)||(st->type!=OB_BALLGAME)) return(FALSE); switch( message ) { case WM_INITDIALOG: { SCROLLINFO lpsi; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE; // |SIF_POS; lpsi.nMin=1; lpsi.nMax=100; SetScrollInfo(GetDlgItem(hDlg,IDC_SPEEDBAR),SB_CTL,&lpsi,TRUE); SetScrollInfo(GetDlgItem(hDlg,IDC_RACKETBAR),SB_CTL,&lpsi,TRUE); SetDlgItemInt(hDlg, IDC_SPEED,st->speed,0); SetDlgItemInt(hDlg, IDC_RACKET,st->racket,0); SetScrollPos(GetDlgItem(hDlg,IDC_SPEEDBAR), SB_CTL,st->speed,TRUE); SetScrollPos(GetDlgItem(hDlg,IDC_RACKETBAR), SB_CTL,st->racket,TRUE); CheckDlgButton(hDlg, IDC_MIDDLE, st->reset_middle); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_RESETBEST: st->best=0; break; case IDC_MIDDLE: st->reset_middle=IsDlgButtonChecked(hDlg,IDC_MIDDLE); break; } return TRUE; case WM_HSCROLL: { int nNewPos; nNewPos=get_scrollpos(wParam,lParam); if (lParam == (long) GetDlgItem(hDlg,IDC_SPEEDBAR)) { SetDlgItemInt(hDlg, IDC_SPEED,nNewPos,0); st->speed=nNewPos;} if (lParam == (long) GetDlgItem(hDlg,IDC_RACKETBAR)) { SetDlgItemInt(hDlg, IDC_RACKET,nNewPos,0);st->racket=nNewPos;} InvalidateRect(st->displayWnd,NULL,TRUE); } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); case WM_PAINT: // color_button(GetDlgItem(hDlg,IDC_SELECTCOLOR),st->color); break; } return FALSE; }
LRESULT CALLBACK PortDlgHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { PORTOBJ * st; char tmp[20]; st = (PORTOBJ *) actobject; if ((st==NULL)||(st->type!=OB_PORT_IO)) return(FALSE); switch( message ) { case WM_INITDIALOG: SendDlgItemMessage(hDlg, IDC_PORTADDRESSCOMBO, CB_RESETCONTENT,0,0); SendDlgItemMessage(hDlg, IDC_PORTADDRESSCOMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) " LPT1 (378h)") ; SendDlgItemMessage(hDlg, IDC_PORTADDRESSCOMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) " LPT2 (278h)") ; SendDlgItemMessage(hDlg, IDC_PORTADDRESSCOMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) " LPT3 (3BCh)") ; if (st->portaddress==0x378) SendDlgItemMessage(hDlg, IDC_PORTADDRESSCOMBO, CB_SETCURSEL, 0, 0L ) ; if (st->portaddress==0x278) SendDlgItemMessage(hDlg, IDC_PORTADDRESSCOMBO, CB_SETCURSEL, 1, 0L ) ; if (st->portaddress==0x3bc) SendDlgItemMessage(hDlg, IDC_PORTADDRESSCOMBO, CB_SETCURSEL, 2, 0L ) ; SendDlgItemMessage(hDlg, IDC_PORTMODECOMBO, CB_RESETCONTENT,0,0); SendDlgItemMessage(hDlg, IDC_PORTMODECOMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) "no periodic updates") ; SendDlgItemMessage(hDlg, IDC_PORTMODECOMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) "trigger updates") ; SendDlgItemMessage(hDlg, IDC_PORTMODECOMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) "bitwise updates") ; SendDlgItemMessage(hDlg, IDC_PORTMODECOMBO, CB_ADDSTRING, 0, (LPARAM) (LPSTR) "meter updates") ; SendDlgItemMessage(hDlg, IDC_PORTMODECOMBO, CB_SETCURSEL, st->triggermode, 0L ) ; SetDlgItemInt(hDlg,IDC_VAL0, st->val0,0); SetDlgItemInt(hDlg,IDC_VAL1, st->val1,0); sprintf(tmp,"%04X",st->portaddress); SetDlgItemText(hDlg,IDC_PORTADDRESS, tmp); update_bitpositions(hDlg, st->portval); break; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PORTADDRESSCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { switch (SendDlgItemMessage(hDlg, IDC_PORTADDRESSCOMBO, CB_GETCURSEL, 0, 0 )) { case 0: st->portaddress=0x378; break; case 1: st->portaddress=0x278; break; case 2: st->portaddress=0x3bc; break; } sprintf(tmp,"%04X",st->portaddress); SetDlgItemText(hDlg,IDC_PORTADDRESS, tmp); } break; case IDC_PORTMODECOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) st->triggermode= SendDlgItemMessage(hDlg, IDC_PORTMODECOMBO, CB_GETCURSEL, 0, 0 ); break; case IDC_VAL0: st->val0=GetDlgItemInt(hDlg,IDC_VAL0,NULL,0); break; case IDC_VAL1: st->val1=GetDlgItemInt(hDlg,IDC_VAL1,NULL,0); break; case IDC_PD7: st->portval^=128; outportb (st->portaddress,st->portval); break; case IDC_PD6: st->portval^=64; outportb (st->portaddress,st->portval); break; case IDC_PD5: st->portval^=32; outportb (st->portaddress,st->portval); break; case IDC_PD4: st->portval^=16; outportb (st->portaddress,st->portval); break; case IDC_PD3: st->portval^=8; outportb (st->portaddress,st->portval); break; case IDC_PD2: st->portval^=4; outportb (st->portaddress,st->portval); break; case IDC_PD1: st->portval^=2; outportb (st->portaddress,st->portval); break; case IDC_PD0: st->portval^=1; outportb (st->portaddress,st->portval); break; case IDC_WRITEVAL0: outportb (st->portaddress,st->val0); st->portval=st->val0; update_bitpositions(hDlg, st->portval); break; case IDC_WRITEVAL1: outportb (st->portaddress,st->val1); st->portval=st->val1; update_bitpositions(hDlg, st->portval); break; } return TRUE; break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
LRESULT CALLBACK KeystrikeDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { KEYSTRIKEOBJ * st; char sztemp[50]; st = (KEYSTRIKEOBJ *) actobject; if ((st==NULL)||(st->type!=OB_KEYSTRIKE)) return(FALSE); switch( message ) { case WM_INITDIALOG: { int i=0; SetDlgItemText(hDlg, IDC_KEY,"test"); while (virtkeys[i][0]) SendDlgItemMessage(hDlg, IDC_KEYCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) virtkeys[i++]) ; SendDlgItemMessage( hDlg, IDC_MIDIINSTCOMBO, CB_SETCURSEL, 0, 0L ) ; for (i=0;i<st->numkeys;i++) SendDlgItemMessage(hDlg, IDC_KEYLIST, LB_ADDSTRING, 0,(LPARAM) (LPSTR) st->keylist[i]) ; } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_KEYCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { st->actkey=SendMessage(GetDlgItem(hDlg, IDC_KEYCOMBO), CB_GETCURSEL , 0, 0); SetDlgItemText(hDlg, IDC_KEY,virtkeys[st->actkey]); } break; case IDC_KEYLIST: if (HIWORD(wParam)==LBN_SELCHANGE) { int i,sel; sel=SendDlgItemMessage( hDlg, IDC_KEYLIST, LB_GETCURSEL , 0, 0L ) ; SendDlgItemMessage( hDlg, IDC_KEYLIST, LB_DELETESTRING , (WPARAM) sel, 0L ) ; //SendDlgItemMessage(hDlg, IDC_KEYLIST, LB_GETTEXT, st->actkey, (LPARAM) (LPSTR) sztemp) ; //SetDlgItemText(hDlg, IDC_KEY,sztemp); for (i=sel;i<st->numkeys;i++) strcpy (st->keylist[i],st->keylist[i+1]); st->numkeys--; } break; case IDC_ADDKEYUP: if (st->actkey) { strcpy (sztemp,"Release "); strcat(sztemp,virtkeys[st->actkey]); SendDlgItemMessage(hDlg, IDC_KEYLIST, LB_ADDSTRING, 0,(LPARAM) (LPSTR) sztemp) ; strcpy(st->keylist[st->numkeys],sztemp); st->numkeys++; } break; case IDC_ADDKEYDOWN: if (st->actkey) { strcpy (sztemp,"Press "); strcat(sztemp,virtkeys[st->actkey]); SendDlgItemMessage(hDlg, IDC_KEYLIST, LB_ADDSTRING, 0,(LPARAM) (LPSTR) sztemp) ; strcpy(st->keylist[st->numkeys],sztemp); st->numkeys++; } break; } return TRUE; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return TRUE; } return FALSE; }
LRESULT CALLBACK TranslateDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { char sztemp[20]; TRANSLATEOBJ * st; st = (TRANSLATEOBJ *) actobject; if ((st==NULL)||(st->type!=OB_TRANSLATE)) return(FALSE); switch( message ) { case WM_INITDIALOG: sprintf(sztemp,"%.2f",st->in_ports[0].in_min); SetDlgItemText(hDlg, IDC_IN_MIN, sztemp); sprintf(sztemp,"%.2f",st->in_ports[0].in_max); SetDlgItemText(hDlg, IDC_IN_MAX, sztemp); sprintf(sztemp,"%.2f",st->out_ports[0].out_min); SetDlgItemText(hDlg, IDC_OUT_MIN, sztemp); sprintf(sztemp,"%.2f",st->out_ports[0].out_max); SetDlgItemText(hDlg, IDC_OUT_MAX, sztemp); return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_APPLY: st->in_ports[0].get_range=-1; st->out_ports[0].get_range=-1; GetDlgItemText(hDlg,IDC_IN_MIN,sztemp,sizeof(sztemp)); sscanf(sztemp,"%f",&st->in_ports[0].in_min); GetDlgItemText(hDlg,IDC_IN_MAX,sztemp,sizeof(sztemp)); sscanf(sztemp,"%f",&st->in_ports[0].in_max); GetDlgItemText(hDlg,IDC_OUT_MIN,sztemp,sizeof(sztemp)); sscanf(sztemp,"%f",&st->out_ports[0].out_min); GetDlgItemText(hDlg,IDC_OUT_MAX,sztemp,sizeof(sztemp)); sscanf(sztemp,"%f",&st->out_ports[0].out_max); break; } return TRUE; case WM_LBUTTONUP: st->setpoint=-1; break; case WM_LBUTTONDOWN: { int minpoint,i,z; float actdist,mindist,actx,acty; st->actmousex=(int)LOWORD(lParam); st->actmousey=(int)HIWORD(lParam); if ((st->actmousex<left)||(st->actmousex>right)|| (st->actmousey>bottom)||(st->actmousey<top)) break; mindist=10000;minpoint=-1; actx=(float)(st->actmousex-left)/(right-left)*1023.0f; acty=(float)(bottom-st->actmousey)/(bottom-top); for (i=0;i<st->points;i++) { actdist = (st->pointx[i]-actx)*(st->pointx[i]-actx) + (st->pointy[i]-acty)*(st->pointy[i]-acty); if (actdist<mindist) { mindist=actdist; minpoint=i; } } if (mindist<300) st->setpoint=minpoint; else { if (st->points>=MAX_TRANSLATIONPOINTS-1) break; i=0;while ((st->pointx[i]<actx)&&(i<st->points)) i++; for (z=st->points;z>i;z--) { st->pointx[z]=st->pointx[z-1]; st->pointy[z]=st->pointy[z-1]; } st->pointx[z]=(int)actx; st->pointy[z]=acty; st->points++; InvalidateRect(hDlg,NULL,TRUE); st->setpoint=z; } } case WM_MOUSEMOVE: { int i; st->actmousex=(int)LOWORD(lParam); st->actmousey=(int)HIWORD(lParam); if (st->setpoint!=-1) { if ((st->actmousex<left)||(st->actmousex>right)|| (st->actmousey>bottom)||(st->actmousey<top)) { if (st->points<=2) break; for (i=st->setpoint;i<st->points;i++) { st->pointx[i]=st->pointx[i+1]; st->pointy[i]=st->pointy[i+1]; } st->points--; st->pointx[0]=0;st->pointx[st->points-1]=1023; st->setpoint=-1; } else { st->pointx[st->setpoint]=(int)((st->actmousex-left)/(float)(right-left)*1023.0f); st->pointy[st->setpoint]=(float)(bottom-st->actmousey)/(bottom-top); if (st->setpoint==0) st->pointx[0]=0; if (st->setpoint==st->points-1) st->pointx[st->points-1]=1023; } st->calculate_map(); InvalidateRect(hDlg,NULL,TRUE); } } break; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; HPEN tpen; HBRUSH tbrush; int i; float dx,dy; hdc = BeginPaint (hDlg, &ps); tpen = CreatePen (PS_SOLID,3,50); SelectObject (hdc, tpen); SelectObject (hdc, DRAW.brush_ltorange); tbrush = CreateSolidBrush(PALETTERGB(240,240,240)); SelectObject (hdc, tbrush); Rectangle(hdc,left,top,right,bottom); dx=(float)(right-left)/1023.0f; dy=(float)(bottom-top); DeleteObject(tpen); tpen = CreatePen (PS_SOLID,2,PALETTERGB(180,0,0)); SelectObject (hdc, tpen); for (i=0;i<st->points-1;i++) { MoveToEx(hdc,left+ (int)((float)st->pointx[i]*dx),bottom - (int)(st->pointy[i]*dy),NULL); LineTo(hdc,left + (int)((float)st->pointx[i+1]*dx),bottom - (int)(st->pointy[i+1]*dy)); } DeleteObject(tbrush); DeleteObject(tpen); EndPaint(hDlg, &ps ); } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; } return FALSE; }
LRESULT CALLBACK ThresholdDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { static int init; char temp[100]; THRESHOLDOBJ * st; int x; st = (THRESHOLDOBJ *) actobject; if ((st==NULL)||(st->type!=OB_THRESHOLD)) return(FALSE); for (x=0;x<GLOBAL.objects;x++) if (objects[x]==actobject) { char tmp[10]; wsprintf(tmp,"%d",x); //SendDlgItemMessage(ghWndStatusbox,IDC_LISTE,LB_ADDSTRING, 0, (LPARAM)(tmp)); } switch( message ) { case WM_INITDIALOG: { SCROLLINFO lpsi; lpsi.cbSize=sizeof(SCROLLINFO); lpsi.fMask=SIF_RANGE; // |SIF_POS; lpsi.nMin=1; lpsi.nMax=1000; SetScrollInfo(GetDlgItem(hDlg,IDC_AVGINTERVALBAR),SB_CTL,&lpsi,TRUE); SetScrollInfo(GetDlgItem(hDlg,IDC_ADAPTINTERVALBAR),SB_CTL,&lpsi,TRUE); lpsi.nMin=-1000; lpsi.nMax=1000; SetScrollInfo(GetDlgItem(hDlg,IDC_AVGGAINBAR),SB_CTL,&lpsi,TRUE); lpsi.nMin=0; lpsi.nMax=1000; SetScrollInfo(GetDlgItem(hDlg,IDC_AVGFROMBAR),SB_CTL,&lpsi,TRUE); SetScrollInfo(GetDlgItem(hDlg,IDC_AVGTOBAR),SB_CTL,&lpsi,TRUE); lpsi.nMin=0; lpsi.nMax=100; SetScrollInfo(GetDlgItem(hDlg,IDC_BARSIZEBAR),SB_CTL,&lpsi,TRUE); SetScrollInfo(GetDlgItem(hDlg,IDC_FONTSIZEBAR),SB_CTL,&lpsi,TRUE); init=TRUE; SetDlgItemInt(hDlg, IDC_AVGINTERVAL, st->interval_len,TRUE); SetDlgItemInt(hDlg, IDC_ADAPTINTERVAL, st->adapt_interval,TRUE); SetScrollPos(GetDlgItem(hDlg,IDC_AVGINTERVALBAR), SB_CTL,st->interval_len,TRUE); SetScrollPos(GetDlgItem(hDlg,IDC_ADAPTINTERVALBAR), SB_CTL,st->adapt_interval,TRUE); SetDlgItemInt(hDlg, IDC_AVGGAIN, st->signal_gain,1); SetScrollPos(GetDlgItem(hDlg,IDC_AVGGAINBAR), SB_CTL,st->signal_gain,TRUE); SetDlgItemInt(hDlg, IDC_BARSIZE, st->barsize,0); SetScrollPos(GetDlgItem(hDlg,IDC_BARSIZEBAR), SB_CTL,st->barsize,TRUE); SetDlgItemInt(hDlg, IDC_FONTSIZE, st->fontsize,0); SetScrollPos(GetDlgItem(hDlg,IDC_FONTSIZEBAR), SB_CTL,st->fontsize,TRUE); sprintf(temp,"%.2f",st->from_input); SetDlgItemText(hDlg, IDC_AVGFROM, temp); SetScrollPos(GetDlgItem(hDlg,IDC_AVGFROMBAR), SB_CTL,(int) size_value(st->in_ports[0].in_min,st->in_ports[0].in_max, st->from_input ,0.0f,1000.0f,0),TRUE); sprintf(temp,"%.2f",st->to_input); SetDlgItemText(hDlg, IDC_AVGTO, temp); SetScrollPos(GetDlgItem(hDlg,IDC_AVGTOBAR), SB_CTL,(int) size_value(st->in_ports[0].in_min,st->in_ports[0].in_max, st->to_input ,0.0f,1000.0f,0),TRUE); SetDlgItemInt(hDlg, IDC_BIGADAPT, st->bigadapt,TRUE); SetDlgItemInt(hDlg, IDC_SMALLADAPT, st->smalladapt,TRUE); SetDlgItemText(hDlg, IDC_METERCAPTION, st->wndcaption); CheckDlgButton(hDlg, IDC_AND,st->op); CheckDlgButton(hDlg, IDC_OR,!st->op); CheckDlgButton(hDlg, IDC_SHOWMETER,st->showmeter); CheckDlgButton(hDlg, IDC_RISING,st->rising); CheckDlgButton(hDlg, IDC_FALLING,st->falling); CheckDlgButton(hDlg, IDC_USE_MEDIAN,st->usemedian); CheckDlgButton(hDlg, IDC_BASELINE,st->baseline); if (st->baseline) SetDlgItemText(hDlg,IDC_INTERVALUNIT,"Seconds"); else SetDlgItemText(hDlg,IDC_INTERVALUNIT,"Samples"); init=FALSE; } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_AND: st->op=TRUE; break; case IDC_OR: st->op=FALSE; break; case IDC_RISING: st->rising=IsDlgButtonChecked(hDlg,IDC_RISING); break; case IDC_FALLING: st->falling=IsDlgButtonChecked(hDlg,IDC_FALLING); break; case IDC_USE_MEDIAN: st->usemedian=IsDlgButtonChecked(hDlg,IDC_USE_MEDIAN); break; case IDC_BASELINE: st->baseline=IsDlgButtonChecked(hDlg,IDC_BASELINE); if (st->baseline) SetDlgItemText(hDlg,IDC_INTERVALUNIT,"Seconds"); else SetDlgItemText(hDlg,IDC_INTERVALUNIT,"Samples"); break; case IDC_SELECTCOLOR: st->color=select_color(hDlg,st->color); st->redraw=1; InvalidateRect(hDlg,NULL,FALSE); break; case IDC_BKCOLOR: st->bkcolor=select_color(hDlg,st->bkcolor); st->redraw=1; InvalidateRect(hDlg,NULL,FALSE); break; case IDC_FONTCOL: st->fontcolor=select_color(hDlg,st->fontcolor); st->redraw=1; InvalidateRect(hDlg,NULL,FALSE); break; case IDC_FONTBKCOL: st->fontbkcolor=select_color(hDlg,st->fontbkcolor); st->redraw=1; InvalidateRect(hDlg,NULL,FALSE); break; case IDC_AVGFROM: GetDlgItemText(hDlg, IDC_AVGFROM,temp,sizeof(temp)); if (!init) st->from_input=(float)atof(temp); break; case IDC_AVGTO: GetDlgItemText(hDlg, IDC_AVGTO,temp,sizeof(temp)); if (!init) st->to_input=(float)atof(temp); break; case IDC_AVGINTERVAL: case IDC_ADAPTINTERVAL: case IDC_AVGGAIN: case IDC_BIGADAPT: case IDC_SMALLADAPT: case IDC_METERCAPTION: if (!init) apply_threshold(hDlg, st); break; case IDC_SHOWMETER: { int i; i=IsDlgButtonChecked(hDlg,IDC_SHOWMETER); if ((st->showmeter)&&(!i)&&(st->displayWnd)) { DestroyWindow(st->displayWnd); st->displayWnd=NULL; } if ((!st->showmeter)&&(i)) { if(!(st->displayWnd=CreateWindow("Meter_Class", st->wndcaption, WS_CLIPSIBLINGS| WS_CHILD | WS_CAPTION | WS_THICKFRAME ,st->left, st->top, st->right-st->left, st->bottom-st->top, ghWndMain, NULL, hInst, NULL))) report_error("can't create Meter Window"); else { st->last_value=0; ShowWindow( st->displayWnd, TRUE ); UpdateWindow( st->displayWnd ); } } st->showmeter=i; } break; } return TRUE; case WM_HSCROLL: { int nNewPos; float x; nNewPos=get_scrollpos(wParam,lParam); if (lParam == (long) GetDlgItem(hDlg,IDC_AVGINTERVALBAR)) SetDlgItemInt(hDlg, IDC_AVGINTERVAL,nNewPos,0); if (lParam == (long) GetDlgItem(hDlg,IDC_ADAPTINTERVALBAR)) SetDlgItemInt(hDlg, IDC_ADAPTINTERVAL,nNewPos,0); if (lParam == (long) GetDlgItem(hDlg,IDC_AVGGAINBAR)) SetDlgItemInt(hDlg, IDC_AVGGAIN,nNewPos,TRUE); if (lParam == (long) GetDlgItem(hDlg,IDC_BARSIZEBAR)) SetDlgItemInt(hDlg, IDC_BARSIZE,nNewPos,TRUE); if (lParam == (long) GetDlgItem(hDlg,IDC_FONTSIZEBAR)) SetDlgItemInt(hDlg, IDC_FONTSIZE,nNewPos,TRUE); if (lParam == (long) GetDlgItem(hDlg,IDC_AVGFROMBAR)) { x=size_value(0.0f,1000.0f,(float)nNewPos,st->in_ports[0].in_min,st->in_ports[0].in_max,0); sprintf(temp,"%.2f",x); SetDlgItemText(hDlg, IDC_AVGFROM, temp); } if (lParam == (long) GetDlgItem(hDlg,IDC_AVGTOBAR)) { x=size_value(0.0f,1000.0f,(float)nNewPos,st->in_ports[0].in_min,st->in_ports[0].in_max,0); sprintf(temp,"%.2f",x); SetDlgItemText(hDlg, IDC_AVGTO, temp); } apply_threshold(hDlg,st); if (st->displayWnd) {st->last_value=INVALID_VALUE; st->redraw=1; InvalidateRect(st->displayWnd,NULL,TRUE);} } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); case WM_PAINT: color_button(GetDlgItem(hDlg,IDC_SELECTCOLOR),st->color); color_button(GetDlgItem(hDlg,IDC_BKCOLOR),st->bkcolor); color_button(GetDlgItem(hDlg,IDC_FONTCOL),st->fontcolor); color_button(GetDlgItem(hDlg,IDC_FONTBKCOL),st->fontbkcolor); break; } return FALSE; }
LRESULT CALLBACK ButtonDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { static int init; char temp[100]; BUTTONOBJ * st; int x; st = (BUTTONOBJ *) actobject; if ((st==NULL)||(st->type!=OB_BUTTON)) return(FALSE); switch( message ) { case WM_INITDIALOG: { SetDlgItemInt(hDlg, IDC_VALUE1, st->value1,TRUE); SetDlgItemInt(hDlg, IDC_VALUE2, st->value2,TRUE); SetDlgItemText(hDlg, IDC_BUTTONPATH, st->buttonpath); SetDlgItemText(hDlg, IDC_BUTTONCAPTION, st->buttoncaption); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "Play Session"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "Stop Session"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "End Session"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "Output Value1 if pressed, else Value2"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "Output Value1 if pressed, else INVALID_VALUE"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "Toggle Value1 and Value2"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "Send Value2 for 1 second"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "Display Device Settings"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_ADDSTRING, 0,(LPARAM) (LPSTR) "Display Application Settings"); SendDlgItemMessage( hDlg, IDC_FUNCTIONCOMBO, CB_SETCURSEL, (WPARAM) (st->buttonfunction), 0L ) ; CheckDlgButton(hDlg, IDC_DISPLAYBORDER, st->displayborder); } return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_TRANSCOL: st->transcolor=select_color(hDlg,st->transcolor); st->redraw=1; InvalidateRect(hDlg,NULL,FALSE); InvalidateRect(st->displayWnd,NULL,FALSE); break; case IDC_BKCOL: st->bkcolor=select_color(hDlg,st->bkcolor); st->redraw=1; InvalidateRect(hDlg,NULL,FALSE); InvalidateRect(st->displayWnd,NULL,FALSE); break; case IDC_BUTTONPATH: GetDlgItemText(hDlg,IDC_BUTTONPATH,st->buttonpath,256); InvalidateRect(st->displayWnd,NULL,FALSE); break; case IDC_BUTTONCAPTION: GetDlgItemText(hDlg, IDC_BUTTONCAPTION, st->buttoncaption, 80); SetWindowText(st->displayWnd,st->buttoncaption); InvalidateRect(st->displayWnd,NULL,FALSE); break; case IDC_VALUE1: st->value1=GetDlgItemInt(hDlg,IDC_VALUE1,NULL,TRUE); break; case IDC_VALUE2: st->value2=GetDlgItemInt(hDlg,IDC_VALUE2,NULL,TRUE); break; case IDC_FUNCTIONCOMBO: if (HIWORD(wParam)==CBN_SELCHANGE) { st->buttonfunction=SendDlgItemMessage(hDlg, IDC_FUNCTIONCOMBO, CB_GETCURSEL, 0, 0 ); } break; case IDC_DISPLAYBORDER: st->displayborder=IsDlgButtonChecked(hDlg,IDC_DISPLAYBORDER); update_border(st->displayWnd,st->displayborder); st->redraw=1; InvalidateRect(st->displayWnd,NULL,FALSE); break; } return TRUE; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); case WM_PAINT: color_button(GetDlgItem(hDlg,IDC_TRANSCOL),st->transcolor); color_button(GetDlgItem(hDlg,IDC_BKCOL),st->bkcolor); break; } return FALSE; }