WndProperty * RowFormWidget::Add(const TCHAR *label, const TCHAR *help, bool read_only) { WndProperty *edit = CreateEdit(label, help, read_only); Add(Row::Type::EDIT, edit); return edit; }
//列表左鍵兩下 void CLaserAdjust::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); NM_LISTVIEW *pEditCtrl = (NM_LISTVIEW *)pNMHDR; if (pEditCtrl->iItem == -1) //條件一 : 不在表單上 { if (m_Edit.GetSafeHwnd()) { DistroyEdit(&m_ListLaserAdjust, &m_Edit, m_OldListRow, m_OldListColumn); } } else //條件一 : 在表單上 { if (pEditCtrl->iSubItem != 1) { //如果Edit已創建,創建 if (m_Edit.GetSafeHwnd()) { DistroyEdit(&m_ListLaserAdjust, &m_Edit, m_OldListRow, m_OldListColumn); } m_OldListRow = pEditCtrl->iItem; m_OldListColumn = pEditCtrl->iSubItem; } else //代表選到"工作方式" { if (m_Edit.GetSafeHwnd()) //條件二:是否創建CEdit { if (!(m_OldListRow == pEditCtrl->iItem && m_OldListColumn == pEditCtrl->iSubItem)) //條件三:是否按的為同一格 { DistroyEdit(&m_ListLaserAdjust, &m_Edit, m_OldListRow, m_OldListColumn); CreateEdit(pEditCtrl, &m_Edit); } else//点中的单元格是之前创建好的 { m_Edit.SetFocus();//设置为焦点 } } else //還沒創建combobox { CreateEdit(pEditCtrl, &m_Edit); } } } *pResult = 0; }
//------------------------------------------------------------------------ //! Overrides OnEditBegin() to provide a CEdit cell value editor //! //! @param owner The list control starting edit //! @param nRow The index of the row for the cell to edit //! @param nCol The index of the column for the cell to edit //! @return Pointer to the cell editor to use (NULL if cell edit is not possible) //------------------------------------------------------------------------ CWnd* CGridColumnTraitEdit::OnEditBegin(CGridListCtrlEx& owner, int nRow, int nCol) { // Get position of the cell to edit CRect rectCell = GetCellEditRect(owner, nRow, nCol); // Get the text-style of the cell to edit DWORD dwStyle = m_EditStyle; HDITEM hditem = {0}; hditem.mask = HDI_FORMAT; VERIFY( owner.GetHeaderCtrl()->GetItem(nCol, &hditem) ); if (hditem.fmt & HDF_CENTER) dwStyle |= ES_CENTER; else if (hditem.fmt & HDF_RIGHT) dwStyle |= ES_RIGHT; else dwStyle |= ES_LEFT; // Create edit control to edit the cell CEdit* pEdit = CreateEdit(owner, nRow, nCol, dwStyle, rectCell); VERIFY(pEdit!=NULL); if (pEdit==NULL) return NULL; // Configure font pEdit->SetFont(owner.GetCellFont()); // First column (Label) doesn't have a margin when imagelist is assigned if (nCol==0 && owner.GetImageList(LVSIL_SMALL)!=NULL) pEdit->SetMargins(0, 0); else // First column (Label) doesn't have a margin when checkboxes are enabled if (nCol==0 && owner.GetExtendedStyle() & LVS_EX_CHECKBOXES) pEdit->SetMargins(1, 0); else // Label column doesn't have margin when not first in column order if (nCol==0 && owner.GetFirstVisibleColumn()!=nCol) pEdit->SetMargins(1, 0); else if (dwStyle & ES_CENTER) pEdit->SetMargins(0, 0); else if (dwStyle & ES_RIGHT) pEdit->SetMargins(0, 7); else pEdit->SetMargins(4, 0); if (m_EditLimitText!=UINT_MAX) pEdit->SetLimitText(m_EditLimitText); CString cellText = owner.GetItemText(nRow, nCol); pEdit->SetWindowText(cellText); pEdit->SetSel(0, -1, 0); return pEdit; }
OpLabel::OpLabel() : m_wrap(FALSE) , m_edit(NULL) { // This MUST be first otherwise GetBorderSkin()->SetImage(UNI_L("Label Skin")); will crash below CreateEdit(FALSE); SetSkinned(TRUE); GetBorderSkin()->SetImage("Label Skin"); m_delayed_trigger.SetDelayedTriggerListener(this); m_delayed_trigger.SetTriggerDelay(0, 50); }
OP_STATUS OpLabel::SetWrap(BOOL wrap) { // Recreate the control if the type just changed if (m_wrap != wrap) { RETURN_IF_ERROR(CreateEdit(wrap)); } // Store if we are using wrapping m_wrap = wrap; return OpStatus::OK; }
//------------------------------------------------------------------------ //! Overrides OnEditBegin() to provide a CEdit cell value editor //! //! @param owner The list control starting edit //! @param nRow The index of the row for the cell to edit //! @param nCol The index of the column for the cell to edit //! @return Pointer to the cell editor to use (NULL if cell edit is not possible) //------------------------------------------------------------------------ CWnd* CGridColumnTraitEdit::OnEditBegin(CGridListCtrlEx& owner, int nRow, int nCol) { // Get position of the cell to edit CRect rcItem = GetCellEditRect(owner, nRow, nCol); // Create edit control to edit the cell CEdit* pEdit = CreateEdit(owner, nRow, nCol, rcItem); VERIFY(pEdit!=NULL); pEdit->SetWindowText(owner.GetItemText(nRow, nCol)); pEdit->SetSel(0, -1, 0); return pEdit; }
//------------------------------------------------------------------------ //! Overrides OnEditBegin() to provide a CEdit cell value editor //! //! @param owner The list control starting edit //! @param nRow The index of the row for the cell to edit //! @param nCol The index of the column for the cell to edit //! @return Pointer to the cell editor to use (NULL if cell edit is not possible) //------------------------------------------------------------------------ CWnd* CGridColumnTraitEdit::OnEditBegin(CGridListCtrlEx& owner, int nRow, int nCol) { // Get position of the cell to edit CRect rectCell = GetCellEditRect(owner, nRow, nCol); // Get the text-style of the cell to edit DWORD dwStyle = m_EditStyle; HDITEM hditem = {0}; hditem.mask = HDI_FORMAT; VERIFY( owner.GetHeaderCtrl()->GetItem(nCol, &hditem) ); if (hditem.fmt & HDF_CENTER) dwStyle |= ES_CENTER; else if (hditem.fmt & HDF_RIGHT) dwStyle |= ES_RIGHT; else dwStyle |= ES_LEFT; // Create edit control to edit the cell CEdit* pEdit = CreateEdit(owner, nRow, nCol, dwStyle, rectCell); VERIFY(pEdit!=NULL); if (pEdit==NULL) return NULL; // Configure font pEdit->SetFont(owner.GetCellFont()); // First item (Label) doesn't have a margin (Subitems does) if (nCol==0 || (dwStyle & ES_CENTER)) pEdit->SetMargins(0, 0); else if (dwStyle & ES_RIGHT) pEdit->SetMargins(0, 7); else pEdit->SetMargins(4, 0); if (m_EditLimitText!=UINT_MAX) pEdit->SetLimitText(m_EditLimitText); CString cellText = owner.GetItemText(nRow, nCol); pEdit->SetWindowText(cellText); pEdit->SetSel(0, -1, 0); return pEdit; }
int CSynBCGPEditView::OnCreate(LPCREATESTRUCT lpCreateStruct) { // if (CBCGPEditView::OnCreate(lpCreateStruct) == -1) // return -1; if (CView::OnCreate(lpCreateStruct) == -1) return -1; m_pWndEditCtrl = CreateEdit (); if (m_pWndEditCtrl == NULL) { TRACE0("CBCGPEditView::OnCreate: edit control is not created\n"); return -1; } ASSERT_VALID (m_pWndEditCtrl); ASSERT (m_pWndEditCtrl->IsKindOf (RUNTIME_CLASS (CBCGPEditCtrl))); if (!m_pWndEditCtrl->Create (WS_CHILD, CRect (0, 0, 0, 0), this, 1)) { TRACE0("CBCGPEditView::OnCreate: cannot create edit control\n"); return -1; } ResetDefaultFont(); m_pEdit->EnableOutlining(TRUE); m_pEdit->EnableAutoOutlining(TRUE); m_pEdit->EnableOutlineParser(TRUE); m_pEdit->EnableHyperlinkSupport(TRUE); m_pEdit->EnableToolTips(TRUE); m_pEdit->m_bEnableCurrentLineCopy = TRUE; //³¬Á´½ÓÑÕÉ«¹Ø±Õ m_pEdit->SetHyperlinkColor(FALSE); DisableMainframeForFindDlg(FALSE); return 0; }
// Create a edit control for channel number // Place control in columns of 32 to the right of the button number void SppBtnsDlg::CreateChannelEdit(UINT iButton) { // Constants UINT RowSpace = ROWSPACE; // Space between rows UINT ColSpace = COLSPACE; // Space between columns RECT rc = {85,10,120,30}; // Text rectangle // Location UINT iCol = (iButton-1)/32; // Zero-based column index UINT iRow = (iButton-1)%32; // Zero-based row index rc.top+=iRow*RowSpace; rc.bottom+=iRow*RowSpace; rc.left+=iCol*ColSpace; rc.right+=iCol*ColSpace; wstring ch; if (iButton<=24) ch = to_wstring(iButton+8); else ch = to_wstring(9); HWND hCh = CreateEdit(m_hDlg, m_hInstance ,0, rc,ID_BASE_CH+iButton,ch.c_str()); m_ahEdtBtn[iButton-1] = hCh; }
//************************************************************************** void CBCGPRibbonComboBox::OnAfterChangeRect (CDC* pDC) { ASSERT_VALID (this); ASSERT_VALID (pDC); CBCGPRibbonButton::OnAfterChangeRect (pDC); if (m_rect.IsRectEmpty ()) { if (m_pWndEdit->GetSafeHwnd () != NULL) { m_pWndEdit->ShowWindow (SW_HIDE); } if (m_pBtnClear->GetSafeHwnd () != NULL) { m_pBtnClear->ShowWindow (SW_HIDE); } return; } CRect rectCommandOld = m_rectCommand; m_Location = RibbonElementSingleInGroup; m_rectMenu = m_rect; m_rectMenu.left = m_rectMenu.right - GetDropDownImageWidth () - 2 * m_nMenuArrowMargin; m_rectCommand = m_rect; m_rectCommand.right = m_rectMenu.left; m_rectCommand.left += m_nLabelImageWidth; int cx = m_bFloatyMode ? m_nWidthFloaty : m_nWidth; if (globalData.GetRibbonImageScale () > 1.) { cx = (int)(.5 + globalData.GetRibbonImageScale () * cx); } if (m_rectCommand.Width () > cx) { m_rectCommand.left = m_rectCommand.right - cx; } m_rectMenu.DeflateRect (1, 1); m_bMenuOnBottom = FALSE; if (!m_bHasEditBox) { return; } if (m_pWndEdit == NULL) { DWORD dwEditStyle = WS_CHILD | ES_WANTRETURN | ES_AUTOHSCROLL | WS_TABSTOP; dwEditStyle |= m_nAlign; CWnd* pWndParent = GetParentWnd (); ASSERT_VALID (pWndParent); if ((m_pWndEdit = CreateEdit (pWndParent, dwEditStyle)) == NULL) { return; } m_pWndEdit->SendMessage (EM_SETTEXTMODE, TM_PLAINTEXT); m_pWndEdit->SetEventMask (m_pWndEdit->GetEventMask () | ENM_CHANGE); m_pWndEdit->SetFont (GetTopLevelRibbonBar ()->GetFont ()); m_pWndEdit->SetWindowText (m_strEdit); } if (rectCommandOld != m_rectCommand || !m_pWndEdit->IsWindowVisible ()) { CRect rectEdit = m_rectCommand; rectEdit.DeflateRect (m_szMargin.cx, m_szMargin.cy, 0, m_szMargin.cy); rectEdit.DeflateRect(0, m_sizePadding.cy / 2); if (m_bSearchMode) { rectEdit.right -= m_rect.Height(); } m_pWndEdit->SetWindowPos (NULL, rectEdit.left, rectEdit.top, rectEdit.Width (), rectEdit.Height (), SWP_NOZORDER | SWP_NOACTIVATE); m_pWndEdit->ShowWindow (SW_SHOWNOACTIVATE); if (m_bSearchMode && m_pBtnClear->GetSafeHwnd () != NULL) { m_pBtnClear->SetWindowPos (NULL, m_rectMenu.left - m_rect.Height() + 2, m_rect.top + 1, m_rect.Height () - 2, m_rect.Height () - 2, SWP_NOZORDER | SWP_NOACTIVATE); m_pBtnClear->ShowWindow (m_strEdit.IsEmpty() ? SW_HIDE : SW_SHOWNOACTIVATE); } } }
LRESULT CALLBACK WndProc(HWND hW, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; char buf[4096]; switch (message) { case WM_CREATE:{ SetTimer(hW, TIMER, 50, NULL); CreateButton(L"Send", 10, 22, 50, 20, BUTTON1, hW, hInst); CreateButton(L"Start", 10, 2, 50, 20, BUTTON2, hW, hInst); FILE *fp = fopen("server.ini", "r"); if (fp == NULL) { MessageBox(hW, L"Unable to open server.ini. Please specify server IPsddress in server.ini", L"Warning", MB_OK); PostQuitMessage(NULL); } while ((fgets(buf, 4096, fp)) != NULL) { if (buf[0] == '#') continue; sServerAddress = buf; } fclose(fp); if (sServerAddress.size() == 0) { MessageBox(hW, L"Unable to find server IPaddress in server.ini", L"Warning", MB_OK); PostQuitMessage(NULL); } TCHAR szProxyAddr[16]; _tcscpy_s(szProxyAddr, CA2T(sServerAddress.c_str())); // CreateEdit(szProxyAddr, 70, 2, 180, 20, EDIT2, hW, hInst); // ip CreateEdit(L"8084", 260, 2, 90, 20, EDIT3, hW, hInst); // port // CreateEdit(L"", 70, 22, 180, 20, EDIT1, hW, hInst); CreateEdit(L"ID", 260, 22, 90, 20, EDIT4, hW, hInst); CreateMemo(L"Info.\n", 2, 45, 350, 120, MEMO1, hW, hInst); SetFocus(GetDlgItem(hW, BUTTON1)); EnableWindow(GetDlgItem(hW, BUTTON1), FALSE); EnableWindow(GetDlgItem(hW, BUTTON2), TRUE); break; } case WM_SETFOCUS: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case EDIT1: //SendMessage(GetDlgItem(hW, EDIT1), EM_SETSEL, -1, -1); SetWindowText(GetDlgItem(hW, EDIT1), L""); break; case EDIT4: SetWindowText(GetDlgItem(hW, EDIT4), L""); break; default: break; } break; case WM_TIMER:{ AfxBeginThread(MessageRecThread, 0); break; } case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case BUTTON1:{ GetDlgItemTextA(hW, EDIT4, buffer2, sizeof(buffer2)); string a = buffer2; GetDlgItemTextA(hW, EDIT1, buffer2, sizeof(buffer2)); a = a + ": " + buffer2; //basic_string<TCHAR> str = buffer2; MyMessObj.SendMessagePort(a); //SendMessage(GetDlgItem(hW, EDIT1), EM_SETSEL, -1, -1); SetWindowText(GetDlgItem(hW, EDIT1), L""); break; } case BUTTON2: EnableWindow(GetDlgItem(hW, BUTTON2), FALSE); EnableWindow(GetDlgItem(hW, BUTTON1), TRUE); EnableWindow(GetDlgItem(hW, EDIT2), FALSE); EnableWindow(GetDlgItem(hW, EDIT3), FALSE); MyMessObj.Init(sServerAddress, 8084); if (!MyMessObj.IsConnected()) { MessageBox(hW, L"Unable to connect to the IPaddress specified in server.ini", L"Warning", MB_OK); PostQuitMessage(NULL); } AfxBeginThread(MessageRecThread, 0); SetFocus(GetDlgItem(hW, EDIT1)); break; case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hW, About); break; case IDM_EXIT: DestroyWindow(hW); break; default: return DefWindowProc(hW, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hW, &ps); // TODO: Add any drawing code here... EndPaint(hW, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hW, message, wParam, lParam); } return 0; }
void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM& cp) { CreateEdit(cp); CreateButton(cp); CreateListBox(cp); }
// // 함수: WndProc(HWND, UINT, WPARAM, LPARAM) // // 목적: 주 창의 메시지를 처리합니다. // // WM_COMMAND - 응용 프로그램 메뉴를 처리합니다. // WM_PAINT - 주 창을 그립니다. // WM_DESTROY - 종료 메시지를 게시하고 반환합니다. // // LRESULT CALLBACK cGameApplication::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { g_pGameMgr->MsgProc(hWnd, message, wParam, lParam, _hInst); char buf[4096]; int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; //HWND hWndChild; switch (message) { case WM_CREATE:{ //SetTimer(hWnd, TIMER, 50, NULL); //CreateButton(L"Send", 10, 62, 50, 20, BUTTON1, hWnd, _hInst); //CreateButton(L"Start", 10, 42, 50, 20, BUTTON2, hWnd, _hInst); FILE *fp = fopen("server.ini", "r"); if (fp == NULL) { //MessageBox(hWnd, L"Unable to open server.ini. Please specify server IPsddress in server.ini", L"Warning", MB_OK); //PostQuitMessage(NULL); cChatManager::GetInstance().addToChatLog("서버 파일 로드 불가"); break; } while ((fgets(buf, 4096, fp)) != NULL) { if (buf[0] == '#') continue; sServerAddress = buf; } fclose(fp); if (sServerAddress.size() == 0) { cChatManager::GetInstance().addToChatLog("서버파일내에서 주소 로드 불가"); break; //MessageBox(hWnd, L"Unable to find server IPaddress in server.ini", L"Warning", MB_OK); //PostQuitMessage(NULL); } TCHAR szProxyAddr[16]; _tcscpy_s(szProxyAddr, CA2T(sServerAddress.c_str())); // //CreateEdit(szProxyAddr, 70, 42, 180, 20, EDIT2, hWnd, _hInst); // ip //CreateEdit(L"8084", 260, 42, 90, 20, EDIT3, hWnd, _hInst); // port // _hwMemo = CreateEdit(L"", 738, 686+1000, 254, 20+1000, EDIT1, hWnd, _hInst); CreateEdit(L"ID", 260, 62, 90, 20, EDIT4, hWnd, _hInst); CreateMemo(L"Info.\n", 2-800, 85, 350, 120, MEMO1, hWnd, _hInst); //SetFocus(GetDlgItem(hWnd, BUTTON1)); //EnableWindow(GetDlgItem(hWnd, BUTTON1), FALSE); EnableWindow(GetDlgItem(hWnd, EDIT1), FALSE); EnableWindow(GetDlgItem(hWnd, BUTTON2), TRUE); EnableWindow(GetDlgItem(hWnd, BUTTON2), FALSE); //EnableWindow(GetDlgItem(hWnd, BUTTON1), TRUE); EnableWindow(GetDlgItem(hWnd, EDIT2), FALSE); EnableWindow(GetDlgItem(hWnd, EDIT3), FALSE); MyMessObj.Init(sServerAddress, 8084); MyCharMessObj.Init(sServerAddress, 8085); if (!MyMessObj.IsConnected()) { //MessageBox(hWnd, L"Unable to connect to the IPaddress specified in server.ini", L"Warning", MB_OK); cChatManager::GetInstance().addToChatLog("채팅 서버접속불가"); EnableWindow(GetDlgItem(hWnd, EDIT1), FALSE); if (!MyCharMessObj.IsConnected()){ cChatManager::GetInstance().addToChatLog("캐릭터서버접속불가"); } break; //PostQuitMessage(NULL); } else if (!MyCharMessObj.IsConnected()){ cChatManager::GetInstance().addToChatLog("캐릭터서버접속불가"); } else { cChatManager::GetInstance().addToChatLog("채팅 및 캐릭터 서버접속완료"); } EnableWindow(GetDlgItem(hWnd, EDIT1), TRUE); AfxBeginThread(MessageRecThread, 0); AfxBeginThread(MessageRecThread2, 0); SetFocus(hWnd); break; } case WM_SETFOCUS: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case EDIT1: SetWindowText(GetDlgItem(hWnd, EDIT1), L""); break; case EDIT4: SetWindowText(GetDlgItem(hWnd, EDIT4), L""); break; default: break; } break; /*case WM_TIMER:{ break; }*/ case WM_KEYUP: switch (wParam){ case VK_RETURN : if (IsWindowEnabled(GetDlgItem(hWnd, EDIT1))){ g_pChatMgr->setInputString(">"); SetFocus(_hwMemo); } break; } break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { //case BUTTON2: //EnableWindow(GetDlgItem(hWnd, BUTTON2), FALSE); ////EnableWindow(GetDlgItem(hWnd, BUTTON1), TRUE); //EnableWindow(GetDlgItem(hWnd, EDIT2), FALSE); //EnableWindow(GetDlgItem(hWnd, EDIT3), FALSE); //MyMessObj.Init(sServerAddress, 8084); //if (!MyMessObj.IsConnected()) //{ // //MessageBox(hWnd, L"Unable to connect to the IPaddress specified in server.ini", L"Warning", MB_OK); // cChatManager::GetInstance().addToChatLog("서버접속불가"); // //PostQuitMessage(NULL); //} //EnableWindow(GetDlgItem(hWnd, EDIT1), TRUE); //AfxBeginThread(MessageRecThread, 0); //SetFocus(GetDlgItem(hWnd, EDIT1)); //break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: 여기에 그리기 코드를 추가합니다. EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }