100求助:窗体不能隐藏
BOOL CPlcCommDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
//ShowWindow(SW_HIDE);
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = this->m_hWnd;
nid.uID = IDR_MAINFRAME;
nid.uFlags = NIF_TIP | NIF_ICON | NIF_MESSAGE;
nid.uCallbackMessage = MYWM_NOTIFYICON;
nid.hIcon = this->m_hIcon;
sprintf(nid.szTip,"PLC通讯中。");
Shell_NotifyIcon(NIM_ADD, &nid);
m_tab.InsertItem(0, "读出PLC");
m_tab.InsertItem(1, "写入PLC");
CRect rct;
m_tab.GetWindowRect(&rct);
m_list1.MoveWindow(rct.left,rct.top, rct.right-5, rct.bottom-62);
m_list2.MoveWindow(rct.left,rct.top, rct.right-5, rct.bottom-62);
m_list2.ShowWindow(SW_HIDE);
g_blShutDown = false;
//读取系统设定
if(!ReadSysSetting(SysSettings)){
CString str = "读取系统设定信息失败,无法与PLC通讯。";
m_list1.InsertString(0, str);
return false;
}
if(g_bytCommMode == TCPIP){//TCP/IP
strTaitle.Format("PLC IP: %s; PORT: %d", g_szPlcAddress, g_intPort);
SetWindowText(strTaitle);
UpdateData(false);
LoadWinSock();
//启动读线程
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&GetPlcDataThread, &m_list1, 0, 0);
if(g_bytToPlc==1){//启动写线程
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&SetPlcDataThread, &m_list2, 0, 0);
}
}
ShowWindow(SW_HIDE);
return TRUE; // return TRUE unless you set the focus to a control
}