// config dialog message handler BOOL CALLBACK cfgproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { bool ret = cfg->ReadIni(); if(!ret) { closedialog(cfgwnd->hWindow); closedialog(wnd->hWindow); MessageBox(wnd2->hWindow, "Erose_LS.ini not found!", "Error", MB_ICONERROR | MB_OK); PostQuitMessage(0); } return TRUE; }break; case WM_COMMAND: { switch(wParam) { case IDOK: { cfg->WriteIni(); closedialog(cfgwnd->hWindow); }break; } }break; } return FALSE; }
// about dialog message handler BOOL CALLBACK dlg2proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { return TRUE; }break; case WM_COMMAND: { switch(wParam) { case WM_DESTROY: { closedialog(wnd2->hWindow); } case IDOK: { closedialog(wnd2->hWindow); }break; } }break; } return FALSE; }
void netTestDialog::createItems() { mainFrame = new QFrame(this); mainFrame->setGeometry(QRect(80,60,240,120)); mainFrame->setFrameShape(QFrame::Box); hostNumlabelA = new QLabel(tr("机号"),mainFrame); hoseNumLabelB = new QLabel(tr("机号"),mainFrame); sendLabel = new QLabel(mainFrame); receiveLabel = new QLabel(mainFrame); hostNumSpinBoxA = new QSpinBox(mainFrame); hostNumSpinBoxB = new QSpinBox(mainFrame); hostNumSpinBoxA->setRange(1,20); hostNumSpinBoxB->setRange(1,20); hostNumlabelA->setGeometry(QRect(30, 20, 30, 30)); hoseNumLabelB->setGeometry(QRect(170, 20, 30, 30)); hostNumSpinBoxA->setGeometry(QRect(25, 70, 50, 30)); hostNumSpinBoxB->setGeometry(QRect(165, 70, 50, 30)); sendLabel->setGeometry(QRect(80,20,80,30)); receiveLabel->setGeometry(QRect(80,70,80,30)); sendLabel->setText(tr("< < < < < < ")); receiveLabel->setText(tr("> > > > > > ")); okPushButton = new QPushButton(tr("确定"), this); okPushButton->setGeometry(QRect(110, 230, 80, 24)); cancelPushButton = new QPushButton(tr("取消"), this); cancelPushButton->setGeometry(QRect(210, 230, 80, 24)); cancelPushButton->setFocus();//set default button connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok())); connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(close())); connect(this->parentWidget(), SIGNAL(closedialog()), this, SLOT(close())); }
void serialTestDialog::createItems() { QFont f("unifont",11,QFont::Light); hintContentLabel = new QLabel(this); hintContentLabel->setText(tr("将 RXD(2)与 TXD(3)短接 CRT 口")); hintContentLabel->setFont(f); hintContentLabel->setGeometry(QRect(60,40,300,30)); sendLabel = new QLabel(tr("发 送 : 0 1 2 3 4 5 6"),this); sendLabel->setFont(f); sendLabel->setGeometry(QRect(100,80,300,30)); receiveLabel = new QLabel(tr("接 收 :"),this); receiveLabel->setFont(f); receiveLabel->setGeometry(QRect(100,120,50,30)); receiveContentLabel = new QLabel(this); receiveContentLabel->setGeometry(QRect(140,120,200,30)); okButton = new QPushButton(tr("确定"), this); okButton->setGeometry(QRect(120, 200, 80, 24)); cancelButton = new QPushButton(tr("取消"), this); cancelButton->setGeometry(QRect(220, 200, 80, 24)); cancelButton->setFocus();//set default button connect(okButton, SIGNAL(clicked()), this, SLOT(close())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); connect(this->parentWidget(), SIGNAL(closedialog()), this, SLOT(close())); }
TimeSetDialog::TimeSetDialog(QWidget *parent) : QDialog(parent) { nDateTime = QDateTime::currentDateTime(); createItems(); setWindowTitle(tr("时间设置")); this->setFixedSize (QSize(400, 280)); connect(okButton, SIGNAL(clicked()), this, SLOT(timeResetSlot())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); connect(this, SIGNAL(setSuccessful()), this, SLOT(close())); connect(this->parentWidget(), SIGNAL(closedialog()), this, SLOT(close())); }
void TimeSetDialog::timeResetSlot() { qDebug()<<"in 1 time reset slot"; QDate tmpDate; QTime tmpTime; QProcess *dateProcess = new QProcess(this); QStringList hwClockSetArgs; tmpDate.setDate(yearSpinBox->value(),monthSpinBox->value(),daySpinBox->value()); tmpTime.setHMS(hourSpinBox->value(),minuteSpinBox->value(),secondSpinBox->value()); nDateTime.setDate(tmpDate); nDateTime.setTime(tmpTime); qDebug()<<"in 2 time reset "; hwClockSetArgs <<"-s"; hwClockSetArgs << nDateTime.toString("MMddhhmmyyyy.ss"); dateProcess->start("date",hwClockSetArgs); dateProcess->waitForFinished(3); qDebug()<<"in 3 time reset "; hwClockSetArgs.clear(); hwClockSetArgs<<"-w"; dateProcess->start("hwclock",hwClockSetArgs); dateProcess->waitForFinished(3); qDebug()<<"time reset successfully!"; QMessageBox *box = new QMessageBox(tr("time reset"), tr("Great ,time reset successfully O(∩_∩)O~!"), QMessageBox::Information, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this); box->setAttribute(Qt::WA_DeleteOnClose); connect(this->parentWidget(), SIGNAL(closedialog()), box, SLOT(close())); box->exec(); yearSpinBox->setValue(nDateTime.date().year()); monthSpinBox->setValue(nDateTime.date().month()); daySpinBox->setValue(nDateTime.date().day()); hourSpinBox->setValue(nDateTime.time().hour()); minuteSpinBox->setValue(nDateTime.time().minute()); secondSpinBox->setValue(nDateTime.time().second()); delete(dateProcess); emit setSuccessful(); }
// main dialog message handler BOOL CALLBACK MainDlg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { return FALSE; }break; case WM_COMMAND: { switch(wParam) // TODO add code for the other buttons { case WM_DESTROY: // the red X button closes our dialog and exits // TODO add server stopping code { closedialog(wnd->hWindow); PostQuitMessage(0); }break; case ID_SYSTEM_EXIT: // the menu button Exit also closes our dialog and exits // TODO add server stopping code { closedialog(wnd->hWindow); PostQuitMessage(0); }break; case ID_HELP_ABOUT: { wnd2->hWindow = CreateDialog(wnd2->ghInstance, MAKEINTRESOURCE(IDD_DIALOG2), wnd->hWindow, dlg2proc); //create our about window if(!wnd2->hWindow) { char buf[100]; sprintf_s(buf, "Error 0x%x", GetLastError()); // copy the last error into the buffer MessageBox (0, buf, "Error creating about window", MB_ICONEXCLAMATION | MB_OK); // display it in a message box } SetDlgItemText(wnd2->hWindow, IDC_EDIT1, "\t\t\teRose Login Server\r\n\t\t\tWritten by Dragoon\r\n\t\t [email protected]\r\n"); // lazy way of centering the text ShowWindow(wnd2->hWindow, wnd2->CmdShow); //show it UpdateWindow(wnd2->hWindow); // update it }break; } }break; case WM_NOTIFY: { // we init our stuffs here instead of in the WM_INITDIALOG case, because it is creating the dialog, means it's not there // the result is no text or anything in our control if(!wnd->listset) // init the columns for our listings (f*****g long IMO) { LVCOLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.iSubItem = 0; lvc.pszText = "Account"; lvc.cx = 100; lvc.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST1), 0, &lvc); lvc.iSubItem = 1; lvc.pszText = "IP"; lvc.cx = 100; lvc.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST1), 1, &lvc); lvc.iSubItem = 2; lvc.pszText = "Connected Time"; lvc.cx = 100; lvc.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST1), 2, &lvc); LVCOLUMN lvc2; lvc2.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc2.iSubItem = 0; lvc2.pszText = "Name"; lvc2.cx = 100; lvc2.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST2), 0, &lvc2); lvc2.iSubItem = 1; lvc2.pszText = "IP"; lvc2.cx = 100; lvc2.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST2), 1, &lvc2); lvc2.iSubItem = 2; lvc2.pszText = "Port"; lvc2.cx = 72; lvc2.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST2), 2, &lvc2); lvc2.iSubItem = 3; lvc2.pszText = "Channels"; lvc2.cx = 100; lvc2.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST2), 3, &lvc2); lvc2.iSubItem = 4; lvc2.pszText = "Users"; lvc2.cx = 100; lvc2.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST2), 4, &lvc2); lvc2.iSubItem = 5; lvc2.pszText = "Max users"; lvc2.cx = 100; lvc2.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST2), 5, &lvc2); lvc2.iSubItem = 6; lvc2.pszText = "Connected Time"; lvc2.cx = 100; lvc2.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST2), 6, &lvc2); LVCOLUMN lvc3; lvc3.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc3.iSubItem = 0; lvc3.pszText = "IP"; lvc3.cx = 100; lvc3.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST3), 0, &lvc3); lvc3.iSubItem = 1; lvc3.pszText = "Start"; lvc3.cx = 100; lvc3.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST3), 1, &lvc3); lvc3.iSubItem = 2; lvc3.pszText = "End"; lvc3.cx = 100; lvc3.fmt = LVCFMT_LEFT; ListView_InsertColumn(GetDlgItem(wnd->hWindow, IDC_LIST3), 2, &lvc3); wnd->listset = true; // this is to stop recreating the stuff every time it calls WM_NOTIFY } if(!wnd->tabctr) // init the tabs { if (TabCtrl_InsertItem(GetDlgItem(wnd->hWindow, IDC_TAB1), 0, &wnd->tie) == -1) { return NULL; } if (TabCtrl_InsertItem(GetDlgItem(wnd->hWindow, IDC_TAB1), 1, &wnd->tie2) == -1) { return NULL; } if (TabCtrl_InsertItem(GetDlgItem(wnd->hWindow, IDC_TAB1), 2, &wnd->tie3) == -1) { return NULL; } wnd->tabctr = true; } if(!wnd->configset) { cfgwnd->hWindow = CreateDialog(cfgwnd->ghInstance, MAKEINTRESOURCE(IDD_DIALOG3), wnd->hWindow, cfgproc); if(!cfgwnd->hWindow) { char buf[100]; sprintf_s(buf, "Error 0x%x", GetLastError()); // copy the last error into the buffer MessageBox (0, buf, "Error creating config window", MB_ICONEXCLAMATION | MB_OK); // display it in a message box closedialog(cfgwnd->hWindow); closedialog(wnd->hWindow); PostQuitMessage(0); } ShowWindow(cfgwnd->hWindow, cfgwnd->CmdShow); //show it UpdateWindow(cfgwnd->hWindow); // update it wnd->configset = true; } switch(((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: { return FALSE; // return false to allow the tab to change }break; case TCN_SELCHANGE: { int ipage = TabCtrl_GetCurSel(GetDlgItem(wnd->hWindow, IDC_TAB1)); if(ipage == 0) { ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST1), 1); ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST2), 0); ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST3), 0); } else if(ipage == 1) { ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST1), 0); ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST2), 1); ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST3), 0); } else if(ipage == 2) { ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST1), 0); ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST2), 0); ShowWindow(GetDlgItem(wnd->hWindow, IDC_LIST3), 1); } }break; } }break; } return FALSE; }