本文整理汇总了C++中GetWindowTextLength函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWindowTextLength函数的具体用法?C++ GetWindowTextLength怎么用?C++ GetWindowTextLength使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetWindowTextLength函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CEditWnd
void CEditUI::DoEvent(TEventUI& event)
{
if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) {
if( m_pParent != NULL ) m_pParent->DoEvent(event);
else CLabelUI::DoEvent(event);
return;
}
if( event.Type == UIEVENT_SETCURSOR && IsEnabled() )
{
::SetCursor(::LoadCursor(NULL, IDC_IBEAM));
return;
}
if( event.Type == UIEVENT_WINDOWSIZE )
{
if( m_pWindow != NULL ) m_pManager->SetFocusNeeded(this);
}
if( event.Type == UIEVENT_SCROLLWHEEL )
{
if( m_pWindow != NULL ) return;
}
if( event.Type == UIEVENT_SETFOCUS && IsEnabled() )
{
if( m_pWindow ) return;
m_pWindow = new CEditWnd();
ASSERT(m_pWindow);
m_pWindow->Init(this);
Invalidate();
}
if( event.Type == UIEVENT_KILLFOCUS && IsEnabled() )
{
Invalidate();
}
if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK || event.Type == UIEVENT_RBUTTONDOWN)
{
if( IsEnabled() ) {
GetManager()->ReleaseCapture();
if( IsFocused() && m_pWindow == NULL )
{
m_pWindow = new CEditWnd();
ASSERT(m_pWindow);
m_pWindow->Init(this);
if( PtInRect(&m_rcItem, event.ptMouse) )
{
int nSize = GetWindowTextLength(*m_pWindow);
if( nSize == 0 )
nSize = 1;
Edit_SetSel(*m_pWindow, 0, nSize);
}
}
else if( m_pWindow != NULL )
{
#if 1
int nSize = GetWindowTextLength(*m_pWindow);
if( nSize == 0 )
nSize = 1;
Edit_SetSel(*m_pWindow, 0, nSize);
#else
POINT pt = event.ptMouse;
pt.x -= m_rcItem.left + m_rcTextPadding.left;
pt.y -= m_rcItem.top + m_rcTextPadding.top;
::SendMessage(*m_pWindow, WM_LBUTTONDOWN, event.wParam, MAKELPARAM(pt.x, pt.y));
#endif
}
}
return;
}
if( event.Type == UIEVENT_MOUSEMOVE )
{
return;
}
if( event.Type == UIEVENT_BUTTONUP )
{
return;
}
if( event.Type == UIEVENT_CONTEXTMENU )
{
return;
}
if( event.Type == UIEVENT_MOUSEENTER )
{
if( IsEnabled() ) {
m_uButtonState |= UISTATE_HOT;
Invalidate();
}
return;
}
if( event.Type == UIEVENT_MOUSELEAVE )
{
if( IsEnabled() ) {
m_uButtonState &= ~UISTATE_HOT;
Invalidate();
}
return;
}
CLabelUI::DoEvent(event);
}
示例2: LinkList_Main
static INT_PTR LinkList_Main(WPARAM wParam, LPARAM)
{
HANDLE hContact = (HANDLE)wParam;
HWND hWnd = WindowList_Find(hWindowList, hContact);
if ( hWnd != NULL ) {
int len;
SetForegroundWindow(hWnd);
SetFocus(hWnd);
len = GetWindowTextLength(GetDlgItem(hWnd, IDC_MAIN));
PostMessage(GetDlgItem(hWnd, IDC_MAIN), EM_SETSEL, (WPARAM)len, (LPARAM)len);
return 0;
}
HANDLE hEvent = db_event_first(hContact);
if (hEvent == NULL) {
MessageBox(NULL, TXT_EMPTYHISTORY, TXT_PLUGINNAME, MB_OK | MB_ICONINFORMATION );
return 0;
}
int histCount = db_event_count(hContact), actCount = 0;
DBEVENTINFO dbe = { sizeof(dbe) };
dbe.cbBlob = db_event_getBlobSize(hEvent);
dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
db_event_get(hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
RECT DesktopRect;
GetWindowRect(GetDesktopWindow(), &DesktopRect);
HWND hWndProgress = CreateWindow(_T("Progressbar"), TranslateT("Processing history..."), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 45, NULL, NULL, hInst, NULL);
if ( hWndProgress == 0 ) {
free(dbe.pBlob);
MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION );
return -1;
}
SetWindowPos(hWndProgress, HWND_TOP, (int)(DesktopRect.right*0.5)-175, (int)(DesktopRect.bottom*0.5)-22, 0, 0, SWP_NOSIZE);
ShowWindow(hWndProgress, SW_SHOW);
SetForegroundWindow(hWndProgress);
LISTELEMENT *listStart = (LISTELEMENT*)malloc(sizeof(LISTELEMENT));
ZeroMemory(listStart, sizeof(LISTELEMENT));
while( 1 ) {
if ( dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE ) {
// Call function to find URIs
if ( ExtractURI(&dbe, hEvent, listStart) < 0 ) {
free(dbe.pBlob);
RemoveList(listStart);
MessageBox(NULL, TranslateT("Could not allocate memory!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION);
return -1;
}
}
actCount++;
if ( ((int)(((float)actCount/histCount)*100.00)) % 10 == 0 )
SendMessage(hWndProgress, WM_COMMAND, 100, ((int)(((float)actCount/histCount)*100.00)));
hEvent = db_event_next(hEvent);
if ( hEvent == NULL )
break;
free(dbe.pBlob);
dbe.cbBlob = db_event_getBlobSize(hEvent);
dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
db_event_get(hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
}
free(dbe.pBlob);
SendMessage(hWndProgress, WM_CLOSE, 0, 0);
if ( ListCount(listStart) <= 0 ) {
RemoveList(listStart);
MessageBox(NULL, TXT_NOLINKINHISTORY, TXT_PLUGINNAME, MB_OK | MB_ICONINFORMATION);
return 0;
}
DIALOGPARAM *DlgParam = (DIALOGPARAM*)malloc(sizeof(DIALOGPARAM));
DlgParam->hContact = hContact;
DlgParam->listStart = listStart;
DlgParam->findMessage = 0;
DlgParam->chrg.cpMax = -1;
DlgParam->chrg.cpMin = -1;
HWND hWndMain = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN_DLG), NULL, MainDlgProc, (LPARAM)DlgParam);
if (hWndMain == 0) {
RemoveList(listStart);
MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION );
return -1;
}
ShowWindow(hWndMain, SW_SHOW);
return 0;
}
示例3: GetWindowTextLength
int CxEdit::GotoEnd(BOOL bScroll /*= TRUE*/)
{
const int length = GetWindowTextLength();
SetSel(length, length, !bScroll); // end of edit text
return LineFromChar(length);
}
示例4: SelectContainerDlgProc
INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndMsgDlg = 0;
hwndMsgDlg = (HWND) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG: {
TCHAR szNewTitle[128];
RECT rc, rcParent;
struct TContainerData *pContainer = 0;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) lParam);
hwndMsgDlg = (HWND) lParam;
TranslateDialogDefault(hwndDlg);
if (lParam) {
struct TWindowData *dat = (struct TWindowData *)GetWindowLongPtr((HWND)lParam, GWLP_USERDATA);
if (dat) {
mir_sntprintf(szNewTitle, safe_sizeof(szNewTitle), CTranslator::get(CTranslator::CNT_SELECT_FOR), dat->cache->getNick());
SetWindowText(hwndDlg, szNewTitle);
}
}
SendMessage(hwndDlg, DM_SC_BUILDLIST, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_NEWCONTAINERNAME, EM_LIMITTEXT, (WPARAM)CONTAINER_NAMELEN, 0);
SendDlgItemMessage(hwndDlg, IDC_NEWCONTAINER, EM_LIMITTEXT, (WPARAM)CONTAINER_NAMELEN, 0);
GetWindowRect(hwndDlg, &rc);
GetWindowRect(GetParent(hwndDlg), &rcParent);
SetWindowPos(hwndDlg, 0, (rcParent.left + rcParent.right - (rc.right - rc.left)) / 2, (rcParent.top + rcParent.bottom - (rc.bottom - rc.top)) / 2, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK: {
TCHAR szName[CONTAINER_NAMELEN];
LRESULT iItem;
if ((iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETCURSEL, 0, 0)) != LB_ERR) {
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM) iItem, (LPARAM) szName);
if (IsWindow(hwndMsgDlg))
SendMessage(hwndMsgDlg, DM_CONTAINERSELECTED, 0, (LPARAM) szName);
}
if (IsWindow(hwndDlg))
DestroyWindow(hwndDlg);
break;
}
case IDCANCEL:
DestroyWindow(hwndDlg);
break;
case IDC_DELETECONTAINER: {
TCHAR szName[CONTAINER_NAMELEN + 1];
LRESULT iItem;
if ((iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETCURSEL, 0, 0)) != LB_ERR) {
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM) iItem, (LPARAM) szName);
if (!_tcsncmp(szName, _T("default"), CONTAINER_NAMELEN) || !_tcsncmp(szName, CTranslator::get(CTranslator::GEN_DEFAULT_CONTAINER_NAME), CONTAINER_NAMELEN))
MessageBox(hwndDlg, CTranslator::get(CTranslator::CNT_SELECT_DELETEERROR), _T("Error"), MB_OK | MB_ICONERROR);
else {
int iIndex = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETITEMDATA, (WPARAM)iItem, 0);
DeleteContainer(iIndex);
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_RESETCONTENT, 0, 0);
SendMessage(hwndDlg, DM_SC_BUILDLIST, 0, 0);
BuildContainerMenu();
}
}
break;
}
case IDC_RENAMECONTAINER: {
TCHAR szNewName[CONTAINER_NAMELEN], szName[CONTAINER_NAMELEN + 1];
int iLen, iItem;
struct TContainerData *pCurrent = pFirstContainer;
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_NEWCONTAINERNAME));
if (iLen) {
GetWindowText(GetDlgItem(hwndDlg, IDC_NEWCONTAINERNAME), szNewName, CONTAINER_NAMELEN);
if(!_tcsncmp(szNewName, CGlobals::m_default_container_name, CONTAINER_NAMELEN) || !_tcsncmp(szNewName, CTranslator::get(CTranslator::GEN_DEFAULT_CONTAINER_NAME), CONTAINER_NAMELEN)) {
MessageBox(hwndDlg, CTranslator::get(CTranslator::CNT_SELECT_RENAMEERROR), _T("Error"), MB_OK | MB_ICONERROR);
break;
}
iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_FINDSTRING, (WPARAM) - 1, (LPARAM) szNewName);
if (iItem != LB_ERR) {
TCHAR szOldName[CONTAINER_NAMELEN + 1];
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM) iItem, (LPARAM) szOldName);
if (lstrlen(szOldName) == lstrlen(szNewName)) {
MessageBox(0, CTranslator::get(CTranslator::CNT_SELECT_INUSE), _T("Error"), MB_OK | MB_ICONERROR);
SetFocus(GetDlgItem(hwndDlg, IDC_NEWCONTAINERNAME));
break;
}
}
if ((iItem = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETCURSEL, 0, 0)) != LB_ERR) {
SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETTEXT, (WPARAM) iItem, (LPARAM) szName);
if (!_tcsncmp(szName, _T("default"), CONTAINER_NAMELEN) || !_tcsncmp(szName, CTranslator::get(CTranslator::GEN_DEFAULT_CONTAINER_NAME), CONTAINER_NAMELEN))
MessageBox(hwndDlg, CTranslator::get(CTranslator::CNT_SELECT_RENAMEERROR), _T("Error"), MB_OK | MB_ICONERROR);
else {
int iIndex = SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_GETITEMDATA, (WPARAM)iItem, 0);
//.........这里部分代码省略.........
示例5: _tcslen
//////////////////////////////////////////////////////////////////////////////
// This function is based on Daniel Lohmann's article "CEditLog - fast logging
// into an edit control with cout" at http://www.codeproject.com
void CLogEditCtrl::AddLine(LPCTSTR pszMsg, int iLen)
{
int iMsgLen = (iLen == -1) ? _tcslen(pszMsg) : iLen;
if (iMsgLen == 0)
return;
#ifdef _DEBUG
if (pszMsg[iMsgLen - 1] == _T('\n'))
ASSERT( iMsgLen >= 2 && pszMsg[iMsgLen - 2] == _T('\r') );
#endif
// Get Edit contents dimensions and cursor position
int iStartChar, iEndChar;
GetSel(iStartChar, iEndChar);
int iWndTxtLen = GetWindowTextLength();
if (iStartChar == iWndTxtLen && iWndTxtLen == iEndChar)
{
// The cursor resides at the end of text
SCROLLINFO si;
si.cbSize = sizeof si;
si.fMask = SIF_ALL;
if (m_bAutoScroll && GetScrollInfo(SB_VERT, &si) && si.nPos >= (int)(si.nMax - si.nPage + 1))
{
// Not scrolled away
SafeAddLine(iWndTxtLen, iMsgLen, pszMsg, iStartChar, iEndChar);
if (m_bAutoScroll && !IsWindowVisible())
ScrollToLastLine();
}
else
{
// Reduce flicker by ignoring WM_PAINT
m_bNoPaint = true;
BOOL bIsVisible = IsWindowVisible();
if (bIsVisible)
SetRedraw(FALSE);
// Remember where we are
int nFirstLine = !m_bAutoScroll ? GetFirstVisibleLine() : 0;
// Select at the end of text and replace the selection
// This is a very fast way to add text to an edit control
SafeAddLine(iWndTxtLen, iMsgLen, pszMsg, iStartChar, iEndChar);
SetSel(iStartChar, iEndChar, TRUE); // Restore our previous selection
if (!m_bAutoScroll)
LineScroll(nFirstLine - GetFirstVisibleLine());
else
ScrollToLastLine();
m_bNoPaint = false;
if (bIsVisible){
SetRedraw();
if (m_bRichEdit)
Invalidate();
}
}
}
else
{
// We should add the text anyway...
// Reduce flicker by ignoring WM_PAINT
m_bNoPaint = true;
BOOL bIsVisible = IsWindowVisible();
if (bIsVisible)
SetRedraw(FALSE);
// Remember where we are
int nFirstLine = !m_bAutoScroll ? GetFirstVisibleLine() : 0;
if (iStartChar != iEndChar)
{
// If we are currently selecting some text, we have to find out
// if the caret is near the beginning of this block or near the end.
// Note that this does not always work. Because of the EM_CHARFROMPOS
// message returning only 16 bits this will fail if the user has selected
// a block with a length dividable by 64k.
// NOTE: This may cause a lot of terrible CRASHES within the RichEdit control when used for a RichEdit control!?
// To reproduce the crash: click in the RE control while it's drawing a line an start a selection!
if (!m_bRichEdit){
CPoint pt;
::GetCaretPos(&pt);
int nCaretPos = CharFromPos(pt);
if (abs((iStartChar % 0xffff - nCaretPos)) < abs((iEndChar % 0xffff - nCaretPos)))
{
nCaretPos = iStartChar;
iStartChar = iEndChar;
iEndChar = nCaretPos;
}
}
}
// Note: This will flicker, if someone has a good idea how to prevent this - let me know
// Select at the end of text and replace the selection
// This is a very fast way to add text to an edit control
//.........这里部分代码省略.........
示例6: WindowProc
//.........这里部分代码省略.........
case WM_COMMAND: // Item do menu, tecla de atalho ou controle ativado
{
// Verifica bit menos significativo de wParam (ID’s)
switch(LOWORD(wParam))
{
case IDM_ABRIR:
{
// Se arquivo ainda não foi aberto
if(hFile == NULL)
{
// Abre/cria arquivo
hFile = CreateFile("dados.txt", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
// Verifica se identificador do arquivo é válido
if(hFile == INVALID_HANDLE_VALUE)
MessageBox(hWnd, "Erro ao abrir/criar arquivo.", "Erro!", MB_ICONERROR | MB_OK);
else // Arquivo é válido
{
MessageBox(hWnd, "Arquivo aberto/criado.", "Aviso!", MB_ICONINFORMATION | MB_OK);
SendMessage(hWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)"Arquivo aberto/criado.");
// Cria botões para usuário selecionar opção
hWndBotao = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "Clique aqui!", WS_CHILD | WS_VISIBLE, 10, 10, 100, 30, hWnd, (HMENU)IDC_BOTAO, NULL, NULL);
}
}
} break;
case IDM_SALVAR:
{
if(hFile != INVALID_HANDLE_VALUE) // Arquivo está aberto
{
// Obtém quantidade de caracteres da caixa de texto
int tam = GetWindowTextLength(hWndTexto);
// Obtém conteúdo da caixa de texto, alocando memória para os dados
// (alocação no modo Windows)
LPSTR lpstrBuffer = (LPSTR)GlobalAlloc(GPTR, tam + 1);
GetWindowText(hWndTexto, lpstrBuffer, tam + 1);
// Armazena quantos bytes foram escritos no arquivo
DWORD dwBytesEscritos;
// Modifica posição do arquivo para o início
SetFilePointer(hFile, NULL, NULL, FILE_BEGIN);
// Grava conteúdo da caixa de texto no arquivo
WriteFile(hFile, lpstrBuffer, tam, &dwBytesEscritos, NULL);
// Define fim do arquivo
SetEndOfFile(hFile);
// Libera memória dos dados
GlobalFree(lpstrBuffer);
MessageBox(hWnd, "Conteúdo escrito no arquivo.", "Aviso!", MB_ICONINFORMATION | MB_OK);
}
else // Arquivo não foi aberto
MessageBox(hWnd, "Erro ao escrever no arquivo.", "Erro!", MB_ICONERROR | MB_OK);
} break;
case IDM_FECHAR:
{
// Se o arquivo está aberto, fecha
if(hFile)
{
示例7: GetSel
void CHexEdit::OnContextMenu(CWnd* pWnd, CPoint point)
{
int start,end;
GetSel(start,end);
CString text;
this->GetWindowText(text);
char head=0,second=0;
bool bCut=true;
SetFocus();
CMenu menu;
menu.CreatePopupMenu();
//No problems with default undo
BOOL bReadOnly = GetStyle() & ES_READONLY;
DWORD flags = CanUndo() && !bReadOnly ? 0 : MF_GRAYED;
menu.InsertMenu(0, MF_BYPOSITION | flags, EM_UNDO,
MES_UNDO);
menu.InsertMenu(1, MF_BYPOSITION | MF_SEPARATOR);
//No problem with default Copy
DWORD sel = GetSel();
flags = LOWORD(sel) == HIWORD(sel) ? MF_GRAYED : 0;
menu.InsertMenu(2, MF_BYPOSITION | flags, WM_COPY,
MES_COPY);
//Cut and delete should be modified
if(text.GetLength()>0) head=text.GetAt(0);
if(text.GetLength()>1) second=text.GetAt(1);
if(second=='X'||second=='x'){
//does not allow cut first char
if(start==0&&end==1)
bCut=false;
}
flags = (flags == MF_GRAYED || bReadOnly||!bCut) ? MF_GRAYED : 0;
menu.InsertMenu(2, MF_BYPOSITION | flags, WM_CUT,
MES_CUT);
menu.InsertMenu(4, MF_BYPOSITION | flags, WM_CLEAR,
MES_DELETE);
//Paste should be modified
flags = IsClipboardFormatAvailable(CF_TEXT) &&
!bReadOnly ? 0 : MF_GRAYED;
if(!this->OpenClipboard())
::AfxMessageBox("Cannot open clipboard!");
HGLOBAL hglb;
LPTSTR lptstr;
hglb=GetClipboardData(CF_TEXT);
if (hglb != NULL)
{
lptstr =(LPTSTR) GlobalLock(hglb);
//Check invalid hex string
if(!this->IsHexConvertableText(lptstr))
{
flags=MF_GRAYED;
}
}
CloseClipboard();
menu.InsertMenu(4, MF_BYPOSITION | flags, WM_PASTE,
MES_PASTE);
menu.InsertMenu(6, MF_BYPOSITION | MF_SEPARATOR);
//No problem with default Sel All
int len = GetWindowTextLength();
flags = (!len || (LOWORD(sel) == 0 && HIWORD(sel) ==
len)) ? MF_GRAYED : 0;
menu.InsertMenu(7, MF_BYPOSITION | flags, ME_SELECTALL,
MES_SELECTALL);
flags=0;
if(text.GetLength()==0||(text.GetLength()==2&&text.Find("0x")==0))
flags=MF_GRAYED;
menu.InsertMenu(8, MF_BYPOSITION | MF_SEPARATOR);
menu.InsertMenu(9, MF_BYPOSITION | flags, ME_CONVERT,
MES_CONVERT);
menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON |
TPM_RIGHTBUTTON, point.x, point.y, this);
}
示例8: DlgProc
//.........这里部分代码省略.........
{
MessageBox(hwnd, "Admin access required. Some features may not work properly. \n\n"
"**If on Vista (or Server 2008), choose the \"Run as administrator\" option.",
"Admin access required.", MB_OK);
break;
}
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
/* In case of SAVE */
case IDC_ADD:
{
int chd = 0;
int len;
if(config_inst.admin_access == 0)
{
MessageBox(hwnd, "Unable to edit configuration. "
"Admin access required.",
"Error Saving.", MB_OK);
break;
}
/** Getting values from the user (if chosen save)
* We should probably create another function for it...
**/
/* Getting server ip */
len = GetWindowTextLength(GetDlgItem(hwnd, UI_SERVER_TEXT));
if(len > 0)
{
char *buf;
/* Allocating buffer */
buf = (char*)GlobalAlloc(GPTR, len + 1);
if(!buf)
{
exit(-1);
}
GetDlgItemText(hwnd, UI_SERVER_TEXT, buf, len + 1);
/* If auth key changed, set it */
if(strcmp(buf, config_inst.server) != 0)
{
if(set_ossec_server(buf, hwnd))
{
chd = 1;
}
}
else
{
GlobalFree(buf);
}
}
/* Getting auth key */
len = GetWindowTextLength(GetDlgItem(hwnd, UI_SERVER_AUTH));
if(len > 0)
示例9: MainWindowProc
//.........这里部分代码省略.........
break;
// We accept this message so we can set a minimum window size. This only sets the users
// tracking size. The window itself can always be resized smaller programmatically unless
// you restrict it in WM_WINDOWPOSCHANGING/WM_WINDOWPOSCHANGED.
case WM_GETMINMAXINFO:
{
LPMINMAXINFO lpInfo = (LPMINMAXINFO)lParam;
if(lpInfo)
lpInfo->ptMinTrackSize.x = 250, lpInfo->ptMinTrackSize.y = 300;
}
return 0;
// These next two messages are better to use rather than WM_MOVE/WM_SIZE.
// Remember WM_MOVE/WM_SIZE are from 16bit windows. In 32bit windows the window
// manager only sends these two messages and the DefWindowProc() handler actually
// accepts them and converts them to WM_MOVE/WM_SIZE.
//
// We accept this so we can scale our controls to the client size.
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
{
HDWP hDWP;
RECT rc;
// Create a deferred window handle.
if(hDWP = BeginDeferWindowPos(4))
{
// Deferring 4 child controls
GetClientRect(hWnd, &rc);
// Calculate the size needed for the static text at the top
RECT rcText = { 10, 10, rc.right - 20, 0 } ;
CalcWindowTextSize(GetDlgItem(hWnd, IDC_LBLINFO), &rcText);
// Defer each window move/size until end and do them all at once.
hDWP = DeferWindowPos(hDWP, GetDlgItem(hWnd, IDC_LBLINFO), NULL,
10, 10, rc.right - 20, rcText.bottom,
SWP_NOZORDER | SWP_NOREDRAW);
// Move/Size the listbox
hDWP = DeferWindowPos(hDWP, GetDlgItem(hWnd, IDC_LSTCUSTOM), NULL,
10, rcText.bottom + 20, rc.right - 20, rc.bottom - rcText.bottom - 75,
SWP_NOZORDER | SWP_NOREDRAW);
// Move/Size the input box
hDWP = DeferWindowPos(hDWP, GetDlgItem(hWnd, IDC_INPUTBOX), NULL,
10, rc.bottom - 40, rc.right - 90, 30,
SWP_NOZORDER | SWP_NOREDRAW);
// Move/Size the send button
hDWP = DeferWindowPos(hDWP, GetDlgItem(hWnd, IDCANCEL), NULL,
(rc.right) - 70, rc.bottom - 40, 60, 30,
SWP_NOZORDER | SWP_NOREDRAW);
// Resize all windows under the deferred window handled at the same time.
EndDeferWindowPos(hDWP);
// We told DeferWindowPos not to redraw the controls so we can redraw
// them here all at once.
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN |
RDW_ERASE | RDW_NOFRAME | RDW_UPDATENOW);
}
}
return 0;
// Handle the notifications of button presses.
case WM_COMMAND:
// If it was a button press and it came from our button.
if(wParam == MAKELONG(IDCANCEL, BN_CLICKED) ||
(GetFocus() == inputhwnd) && (0x8000 & GetKeyState(VK_RETURN)))
{
// process typed command
if(GetWindowTextLength(inputhwnd) == 0)
break;
char str[512];
SendMessage(inputhwnd, WM_GETTEXT, (WPARAM)512, (LPARAM)str);
SendMessage(inputhwnd, WM_SETTEXT, 0, (LPARAM)"");
RunCommand(str, 0);
SetFocus(inputhwnd);
}
else if(HIWORD(wParam) == LBN_DBLCLK)
{
}
break;
case WM_DESTROY:
// We post a WM_QUIT when our window is destroyed so we break the main message loop.
sampDisconnect(0);
PostQuitMessage(0);
break;
}
// Not a message we wanted? No problem hand it over to the Default Window Procedure.
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
示例10: PrintWindowSettings
void PrintWindowSettings( FILE * fp ) {
int ret ;
RECT r ;
char buffer[MAX_VALUE_NAME] ;
GetOSInfo( buffer ) ;
fprintf( fp, "OSVersion=%s\n", buffer ) ;
ret = GetWindowText( MainHwnd, buffer, MAX_VALUE_NAME ) ;
buffer[ret]='\0';
ret = GetWindowTextLength( MainHwnd ) ;
fprintf( fp, "Title (length)=%s (%d)\n", buffer, ret ) ;
if( GetWindowRect( MainHwnd, &r ) ) {
fprintf( fp, "WindowRect.left=%ld\n", r.left ) ;
fprintf( fp, "WindowRect.right=%ld\n", r.right ) ;
fprintf( fp, "WindowRect.top=%ld\n", r.top ) ;
fprintf( fp, "WindowRect.bottom=%ld\n", r.bottom ) ;
}
if( GetClientRect( MainHwnd, &r ) ) {
fprintf( fp, "ClientRect.left=%ld\n", r.left ) ;
fprintf( fp, "ClientRect.right=%ld\n", r.right ) ;
fprintf( fp, "ClientRect.top=%ld\n", r.top ) ;
fprintf( fp, "ClientRect.bottom=%ld\n", r.bottom ) ;
}
ret = GetWindowModuleFileName( MainHwnd, buffer, MAX_VALUE_NAME ) ;
buffer[ret]='\0';
fprintf( fp, "WindowModuleFileName=%s\n", buffer ) ;
WINDOWINFO wi ;
wi.cbSize = sizeof( WINDOWINFO ) ;
if( GetWindowInfo( MainHwnd, &wi ) ) {
fprintf( fp, "WindowInfo.cbSize=%lu\n", wi.cbSize ) ;
fprintf( fp, "WindowInfo.rcWindow.left=%ld\n", wi.rcWindow.left ) ;
fprintf( fp, "WindowInfo.rcWindow.right=%ld\n", wi.rcWindow.right ) ;
fprintf( fp, "WindowInfo.rcWindow.top=%ld\n", wi.rcWindow.top ) ;
fprintf( fp, "WindowInfo.rcWindow.bottom=%ld\n", wi.rcWindow.bottom ) ;
fprintf( fp, "WindowInfo.rcClient.left=%ld\n", wi.rcWindow.left ) ;
fprintf( fp, "WindowInfo.rcClient.right=%ld\n", wi.rcWindow.right ) ;
fprintf( fp, "WindowInfo.rcClient.top=%ld\n", wi.rcWindow.top ) ;
fprintf( fp, "WindowInfo.rcClient.bottom=%ld\n", wi.rcWindow.bottom ) ;
fprintf( fp, "WindowInfo.dwStyle=%lu\n", wi.dwStyle ) ;
fprintf( fp, "WindowInfo.dwExStyle=%lu\n", wi.dwExStyle ) ;
fprintf( fp, "WindowInfo.dwWindowStatus=%lu\n", wi.dwWindowStatus ) ;
fprintf( fp, "WindowInfo.cxWindowBorders=%u\n", wi.cxWindowBorders ) ;
fprintf( fp, "WindowInfo.cyWindowBorders=%u\n", wi.cyWindowBorders ) ;
fprintf( fp, "WindowInfo.wCreatorVersion=%d\n", wi.wCreatorVersion ) ;
}
WINDOWPLACEMENT wp;
wp.length=sizeof(WINDOWPLACEMENT) ;
if( GetWindowPlacement( MainHwnd, &wp ) ) {
fprintf( fp, "WindowPlacement.length=%u\n", wp.length ) ;
fprintf( fp, "WindowPlacement.flags=%u\n", wp.flags ) ;
fprintf( fp, "WindowPlacement.showCmd=%u\n", wp.showCmd ) ;
fprintf( fp, "WindowPlacement.ptMinPosition.x=%ld\n", wp.ptMinPosition.x ) ;
fprintf( fp, "WindowPlacement.ptMinPosition.y=%ld\n", wp.ptMinPosition.y ) ;
fprintf( fp, "WindowPlacement.ptMaxPosition.x=%ld\n", wp.ptMaxPosition.x ) ;
fprintf( fp, "WindowPlacement.ptMaxPosition.y=%ld\n", wp.ptMaxPosition.y ) ;
fprintf( fp, "WindowPlacement.rcNormalPosition.left=%ld\n", wp.rcNormalPosition.left ) ;
fprintf( fp, "WindowPlacement.rcNormalPosition.right=%ld\n", wp.rcNormalPosition.right ) ;
fprintf( fp, "WindowPlacement.rcNormalPosition.top=%ld\n", wp.rcNormalPosition.top ) ;
fprintf( fp, "WindowPlacement.rcNormalPosition.bottom=%ld\n", wp.rcNormalPosition.bottom ) ;
}
fprintf( fp, "IsIconic=%d\n", IsIconic( MainHwnd ) ) ;
fprintf( fp, "IsWindow=%d\n", IsWindow( MainHwnd ) ) ;
fprintf( fp, "IsWindowUnicode=%d\n", IsWindowUnicode( MainHwnd ) ) ;
fprintf( fp, "IsWindowVisible=%d\n", IsWindowVisible( MainHwnd ) ) ;
fprintf( fp, "IsZoomed=%d\n", IsZoomed( MainHwnd ) ) ;
fprintf( fp, "ScaleX=%d\n", GetDeviceCaps(GetDC(MainHwnd),LOGPIXELSX) ) ;
fprintf( fp, "ScaleY=%d\n", GetDeviceCaps(GetDC(MainHwnd),LOGPIXELSY) ) ;
}
示例11: GetWindowTextLength
int WinGui::EditBox::length(){
return GetWindowTextLength(hWnd);
}
示例12: GetWindowText
int WinGui::EditBox::getText(char* to){
GetWindowText(hWnd, to, GetWindowTextLength(hWnd) + 1);
return 0;
}
示例13: MainDlgProc
//.........这里部分代码省略.........
* Initially, hide the progress bar and the key display,
* and show the no-key display. Also disable the Save
* buttons, because with no key we obviously can't save
* anything.
*/
ui_set_state(hwnd, state, 0);
/*
* Load a key file if one was provided on the command line.
*/
if (cmdline_keyfile) {
Filename *fn = filename_from_str(cmdline_keyfile);
load_key_file(hwnd, state, fn, 0);
filename_free(fn);
}
return 1;
case WM_MOUSEMOVE:
state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (state->collecting_entropy &&
state->entropy && state->entropy_got < state->entropy_required) {
state->entropy[state->entropy_got++] = lParam;
state->entropy[state->entropy_got++] = GetMessageTime();
SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS,
state->entropy_got, 0);
if (state->entropy_got >= state->entropy_required) {
struct rsa_key_thread_params *params;
DWORD threadid;
/*
* Seed the entropy pool
*/
random_add_heavynoise(state->entropy, state->entropy_size);
smemclr(state->entropy, state->entropy_size);
sfree(state->entropy);
state->collecting_entropy = FALSE;
SetDlgItemText(hwnd, IDC_GENERATING, generating_msg);
SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0,
MAKELPARAM(0, PROGRESSRANGE));
SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, 0, 0);
params = snew(struct rsa_key_thread_params);
params->progressbar = GetDlgItem(hwnd, IDC_PROGRESS);
params->dialog = hwnd;
params->keysize = state->keysize;
params->is_dsa = state->is_dsa;
params->key = &state->key;
params->dsskey = &state->dsskey;
if (!CreateThread(NULL, 0, generate_rsa_key_thread,
params, 0, &threadid)) {
MessageBox(hwnd, "Out of thread resources",
"Key generation error",
MB_OK | MB_ICONERROR);
sfree(params);
} else {
state->generation_thread_exists = TRUE;
}
}
}
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_KEYSSH1:
case IDC_KEYSSH2RSA:
case IDC_KEYSSH2DSA:
{
state = (struct MainDlgState *)
GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (!IsDlgButtonChecked(hwnd, LOWORD(wParam)))
CheckRadioButton(hwnd, IDC_KEYSSH1, IDC_KEYSSH2DSA,
LOWORD(wParam));
CheckMenuRadioItem(state->keymenu, IDC_KEYSSH1, IDC_KEYSSH2DSA,
LOWORD(wParam), MF_BYCOMMAND);
}
break;
case IDC_QUIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
case IDC_COMMENTEDIT:
if (HIWORD(wParam) == EN_CHANGE) {
state = (struct MainDlgState *)
GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (state->key_exists) {
HWND editctl = GetDlgItem(hwnd, IDC_COMMENTEDIT);
int len = GetWindowTextLength(editctl);
if (*state->commentptr)
sfree(*state->commentptr);
*state->commentptr = snewn(len + 1, char);
GetWindowText(editctl, *state->commentptr, len + 1);
if (state->ssh2) {
setupbigedit2(hwnd, IDC_KEYDISPLAY, IDC_PKSTATIC,
&state->ssh2key);
} else {
setupbigedit1(hwnd, IDC_KEYDISPLAY, IDC_PKSTATIC,
&state->key);
}
}
}
示例14: NotesDlgProc
static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{ DBVARIANT dbv;
HFONT hFont;
LOGFONT lf;
HDC hDC = GetDC(hwndDlg);
lf.lfHeight = -MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72);
ReleaseDC(hwndDlg, hDC);
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = FW_NORMAL;
lf.lfItalic = 0;
lf.lfUnderline = 0;
lf.lfStrikeOut = 0;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
lstrcpy(lf.lfFaceName, _T("Courier New"));
lf.lfCharSet = DEFAULT_CHARSET;
hFont = CreateFontIndirect(&lf);
SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0));
if ( !db_get_s((HANDLE)lParam, "UserInfo", "MyNotes", &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_MYNOTES, dbv.pszVal);
db_free(&dbv);
}
}
SendDlgItemMessage(hwndDlg, IDC_MYNOTES, EM_LIMITTEXT, 2048, 0);
break;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_INFOCHANGED:
{ char *szProto;
HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam;
if (hContact != NULL) {
szProto = GetContactProto(hContact);
if (szProto == NULL) break;
SetValue(hwndDlg, IDC_ABOUT, hContact, szProto, "About", 0);
}
break;
}
case PSN_APPLY:
{ HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam;
if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MYNOTES))) {
char text[2048];
GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, SIZEOF(text));
db_set_s(hContact, "UserInfo", "MyNotes", text);
}
else db_unset(hContact, "UserInfo", "MyNotes");
break;
}
}
break;
}
break;
case WM_COMMAND:
if (wParam == MAKEWPARAM(IDC_MYNOTES, EN_CHANGE))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
else if (LOWORD(wParam) == IDCANCEL)
SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
break;
case WM_DESTROY:
{
HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_GETFONT, 0, 0);
DeleteObject(hFont);
}
break;
}
return FALSE;
}
示例15: DialogProc
//.........这里部分代码省略.........
}
selectedCheckBox = IsDlgButtonChecked(hDlg, IDC_CHECK1);
// 設定ファイルに状態を書き出す
switch (selectedRadioButton) {
case IDC_RADIO1:
iniFile->write("Config", "radio", "1");
break;
case IDC_RADIO2:
iniFile->write("Config", "radio", "2");
break;
case IDC_RADIO3:
iniFile->write("Config", "radio", "3");
break;
case IDC_RADIO4:
iniFile->write("Config", "radio", "4");
break;
default:
iniFile->write("Config", "radio", "1");
break;
}
if (selectedCheckBox) {
iniFile->write("Config", "check", "TRUE");
} else {
iniFile->write("Config", "check", "FALSE");
}
// 履歴を保存
length = GetWindowTextLength(hwndEdit);
if (length != 0) {
char *buf = new char[length + 1];
buf[length] = '\0';
GetWindowText(hwndEdit, buf, length + 1);
std::string temp = buf;
delete[] buf;
history.insert(history.begin(), temp);
for (unsigned int i = 0; i < history.size() - 1; i++) {
for (unsigned int j = i + 1; j < history.size(); j++) {
std::string str1 = history[i];
std::string str2 = history[j];
if (str1 == str2) {
history[j] = "";
}
}
}
int index = 0;
for (unsigned int i = 0; i < MAX_HISTORY && i < history.size(); i++) {
if (history[i] != "") {
std::string key = "history";
char num[3] = {0};
sprintf_s(num, "%d", index);
key += num;
iniFile->write("History", key.c_str(), history[i].c_str());
index++;
}
}