当前位置: 首页>>代码示例>>C++>>正文


C++ GetWindowTextLengthW函数代码示例

本文整理汇总了C++中GetWindowTextLengthW函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWindowTextLengthW函数的具体用法?C++ GetWindowTextLengthW怎么用?C++ GetWindowTextLengthW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetWindowTextLengthW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sqlQueryCallback

	int sqlQueryCallback(void *arg, int argc, char **argv, char **azColName)
	{
		HWND hRes = static_cast<HWND>(arg);
		
		std::ostringstream ss;
		int len = GetWindowTextLengthW(hRes);
		if(len < 4096)
		{
			if(len > 0)
			{
				wchar_t* prev = new wchar_t[len+2];
				GetWindowTextW(hRes, prev, len+1);
				utfstring wPrev(prev);
				delete [] prev;
				ss << wPrev.toUTF8() << "\r\n";
			}
		}
		else
			return SQLITE_TOOBIG;

		for(int i=0; i<argc; i++)
		{
			if(azColName[i])
				ss << azColName[i] << ": " << argv[i] << "\r\n";
		}

		utfstring ws(ss.str().c_str());
		SetWindowText(hRes, ws.toUTF16());

		return SQLITE_OK;
	}
开发者ID:mmuszkow,项目名称:archStatusLog,代码行数:31,代码来源:SqlCmdWnd.cpp

示例2: CreateInstOnProc

static INT_PTR CALLBACK CreateInstOnProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    HWND hEdit;

    switch(uMsg)
    {
        case WM_COMMAND:
            switch(LOWORD(wParam)) {
            case IDOK:
                memset(globals.wszMachineName, 0, sizeof(WCHAR[MAX_LOAD_STRING]));
                hEdit = GetDlgItem(hDlgWnd, IDC_MACHINE);

                if (GetWindowTextLengthW(hEdit)>0)
                    GetWindowTextW(hEdit, globals.wszMachineName, MAX_LOAD_STRING);

                EndDialog(hDlgWnd, IDOK);
                return TRUE;
            case IDCANCEL:
                EndDialog(hDlgWnd, IDCANCEL);
                return TRUE;
            }
    }

    return FALSE;
}
开发者ID:Sunmonds,项目名称:wine,代码行数:25,代码来源:oleview.c

示例3: starlog_log

static void
starlog_log(Starlog *s)
{
	const size_t MAX_BYTES = 1024;
	unsigned short *log = NULL;
	DWORD textlen, loglen;
	SYSTEMTIME t;

	GetLocalTime(&t);
	textlen = GetWindowTextLengthW(s->edit_log);
	if(!textlen) {
		return;
	}
	log = HeapAlloc(GetProcessHeap(), 0, sizeof(char)*MAX_BYTES);
	loglen = wsprintfW(log, L"~~~ %02d.%02d.%04d %02d:%02d:%02d ~~~\r\n",
		t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond);
	loglen += GetWindowTextW(s->edit_log, &log[loglen],
		sizeof(short)*(MAX_BYTES-loglen));
	log[loglen] = '\r';
	log[loglen+1] = '\n';
	log[loglen+2] = 0;
	if(loglen) {
		HANDLE fd = CreateFile(".\\star.log",
			FILE_APPEND_DATA, FILE_SHARE_READ,
			NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
		if(fd==INVALID_HANDLE_VALUE) {
			return;
		}
		DWORD n = lstrlenW(log);
		WriteFile(fd, log, n*sizeof(short), &n, 0);
		CloseHandle(fd);
	}
	HeapFree(GetProcessHeap(), 0, log);
}
开发者ID:henkman,项目名称:starlog,代码行数:34,代码来源:starlog.c

示例4: DIALOG_EditWrap

VOID DIALOG_EditWrap(VOID)
{
    BOOL modify = FALSE;
    static const WCHAR editW[] = { 'e','d','i','t',0 };
    DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL |
                    ES_AUTOVSCROLL | ES_MULTILINE;
    RECT rc;
    DWORD size;
    LPWSTR pTemp;

    size = GetWindowTextLengthW(Globals.hEdit) + 1;
    pTemp = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
    if (!pTemp)
    {
        ShowLastError();
        return;
    }
    GetWindowTextW(Globals.hEdit, pTemp, size);
    modify = SendMessageW(Globals.hEdit, EM_GETMODIFY, 0, 0);
    DestroyWindow(Globals.hEdit);
    GetClientRect(Globals.hMainWnd, &rc);
    if( Globals.bWrapLongLines ) dwStyle |= WS_HSCROLL | ES_AUTOHSCROLL;
    Globals.hEdit = CreateWindowExW(WS_EX_CLIENTEDGE, editW, NULL, dwStyle,
                         0, 0, rc.right, rc.bottom, Globals.hMainWnd,
                         NULL, Globals.hInstance, NULL);
    SendMessageW(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
    SetWindowTextW(Globals.hEdit, pTemp);
    SendMessageW(Globals.hEdit, EM_SETMODIFY, modify, 0);
    SetFocus(Globals.hEdit);
    HeapFree(GetProcessHeap(), 0, pTemp);
    
    Globals.bWrapLongLines = !Globals.bWrapLongLines;
    CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_WRAP,
        MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED));
}
开发者ID:AlexSteel,项目名称:wine,代码行数:35,代码来源:dialog.c

示例5: DoCloseFile

/**
 * Returns:
 *   TRUE  - User agreed to close (both save/don't save)
 *   FALSE - User cancelled close by selecting "Cancel"
 */
BOOL DoCloseFile(void)
{
    int nResult;
    static const WCHAR empty_strW[] = { 0 };

    nResult=GetWindowTextLengthW(Globals.hEdit);
    if (SendMessageW(Globals.hEdit, EM_GETMODIFY, 0, 0) &&
        (nResult || Globals.szFileName[0]))
    {
        /* prompt user to save changes */
        nResult = AlertFileNotSaved(Globals.szFileName);
        switch (nResult) {
            case IDYES:     return DIALOG_FileSave();

            case IDNO:      break;

            case IDCANCEL:  return(FALSE);

            default:        return(FALSE);
        } /* switch */
    } /* if */

    SetFileNameAndEncoding(empty_strW, ENCODING_ANSI);

    UpdateWindowCaption();
    return(TRUE);
}
开发者ID:AlexSteel,项目名称:wine,代码行数:32,代码来源:dialog.c

示例6: SendMessage

void NFOView::CopySelectedText(void)
{
    DWORD selStart;
    DWORD selEnd;
    SendMessage(_handle, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);

    if (selEnd > selStart)
    {
        int textLength = GetWindowTextLengthW(_handle);
        if (textLength > 0)
        {
            HGLOBAL selTextHandle;
            selTextHandle = GlobalAlloc(GHND, sizeof(wchar_t)*(selEnd - selStart + 1));

            // copy selected text to memory
            wchar_t* selText = (wchar_t*)GlobalLock(selTextHandle);
            memcpy(selText, _nfoText.c_str()+selStart, (selEnd-selStart)*sizeof(wchar_t));
            GlobalUnlock(selTextHandle);

            // copy to clipboard
            if (!OpenClipboard(_handle))
            { 
                return;
            }
            EmptyClipboard();
            SetClipboardData(CF_UNICODETEXT, selTextHandle);
            CloseClipboard();
        }
    }
    
    // deselect text after copy
    SendMessage(_handle, EM_SETSEL, (WPARAM)-1, (LPARAM)0);
}
开发者ID:wowh,项目名称:SimpleNfoViewer,代码行数:33,代码来源:NFOView.cpp

示例7: GetStringFromDialog

static LPWSTR
GetStringFromDialog(PCREATE_DATA Data,
                    UINT id)
{
    HWND hwnd;
    LPWSTR lpString = NULL;
    INT iLen = 0;

    hwnd = GetDlgItem(Data->hSelf,
                      id);
    if (hwnd)
    {
        iLen = GetWindowTextLengthW(hwnd);
        if (iLen)
        {
            lpString = (LPWSTR)HeapAlloc(ProcessHeap,
                                         0,
                                         (iLen + 1) * sizeof(WCHAR));
            if (lpString)
            {
                GetWindowTextW(hwnd,
                               lpString,
                               iLen + 1);
            }
        }
    }

    return lpString;
}
开发者ID:AmineKhaldi,项目名称:reactos,代码行数:29,代码来源:create.c

示例8: GetWindowTextUTF8

int GetWindowTextUTF8(HWND hWnd, LPTSTR lpString, int nMaxCount)
{
  if (!lpString) return 0;
  if (nMaxCount>0 AND_IS_NOT_WIN9X)
  {
    int alloc_size=nMaxCount;

    // prevent large values of nMaxCount from allocating memory unless the underlying text is big too
    if (alloc_size > 512)  
    {
      int l=GetWindowTextLengthW(hWnd);
      if (l>=0 && l < 512) alloc_size=1000;
    }

    {
      WIDETOMB_ALLOC(wbuf, alloc_size);
      if (wbuf)
      {
        GetWindowTextW(hWnd,wbuf,(int) (wbuf_size/sizeof(WCHAR)));

        if (!WideCharToMultiByte(CP_UTF8,0,wbuf,-1,lpString,nMaxCount,NULL,NULL) && GetLastError()==ERROR_INSUFFICIENT_BUFFER)
          lpString[nMaxCount-1]=0;

        WIDETOMB_FREE(wbuf);

        return (int)strlen(lpString);
      }
    }
  }
  return GetWindowTextA(hWnd,lpString,nMaxCount);
}
开发者ID:Artogn,项目名称:licecap,代码行数:31,代码来源:win32_utf8.c

示例9: win_copy_title

void
win_copy_title(void)
{
  int len = GetWindowTextLengthW(wnd);
  wchar title[len + 1];
  len = GetWindowTextW(wnd, title, len + 1);
  win_copy(title, 0, len + 1);
}
开发者ID:jdmansour,项目名称:mintty,代码行数:8,代码来源:winmain.c

示例10: GetWindowTextLengthW

        String Win32Window::GetTitle()
        {
            int l = GetWindowTextLengthW(hWnd);
            if (l == 0) return String();

            Utf16String titleW = Utf16String::Create(l);
            l = GetWindowText(hWnd, titleW.Ptr(), l);

            return Unicode::Utf16To8(titleW);
        }
开发者ID:drakh,项目名称:Xli,代码行数:10,代码来源:Win32Window.cpp

示例11: win_prefix_title

void
win_prefix_title(const char * prefix)
{
  int len = GetWindowTextLengthW(wnd);
  wchar ptitle[strlen(prefix) + len + 1];
  int plen = cs_mbstowcs(ptitle, prefix, lengthof(ptitle));
  wchar * title = & ptitle[plen];
  len = GetWindowTextW(wnd, title, len + 1);
  SetWindowTextW(wnd, ptitle);
}
开发者ID:jdmansour,项目名称:mintty,代码行数:10,代码来源:winmain.c

示例12: MyGetWindowText

void MyGetWindowText(ScriptValue &s, ScriptValue *args) {
	int len = GetWindowTextLengthW((HWND)args[0].intVal);
	if (len > 0) {
		len += 200;
		wchar_t *temp = (wchar_t*) malloc(sizeof(wchar_t) * len);
		int len2 = GetWindowTextW((HWND)args[0].intVal, temp, len);
		CreateStringValue(s, temp, len2);
		free(temp);
	}
}
开发者ID:ZmeyNet,项目名称:lcdmiscellany,代码行数:10,代码来源:ScriptWindowManagement.cpp

示例13: win_save_title

void
win_save_title(void)
{
  int len = GetWindowTextLengthW(wnd);
  wchar *title = newn(wchar, len + 1);
  GetWindowTextW(wnd, title, len + 1);
  delete(titles[titles_i]);
  titles[titles_i++] = title;
  if (titles_i == lengthof(titles))
    titles_i = 0;
}
开发者ID:jdmansour,项目名称:mintty,代码行数:11,代码来源:winmain.c

示例14: IPADDRESS_IsBlank

static BOOL IPADDRESS_IsBlank (IPADDRESS_INFO *infoPtr)
{
    int i;

    TRACE("\n");

    for (i = 0; i < 4; i++)
        if (GetWindowTextLengthW (infoPtr->Part[i].EditHwnd)) return FALSE;

    return TRUE;
}
开发者ID:howard5888,项目名称:wineT,代码行数:11,代码来源:ipaddress.c

示例15: SetLrgFont

static
HFONT
SetLrgFont(PMAP infoPtr)
{
    LOGFONTW lf;
    HFONT hFont = NULL;
    HDC hdc;
    HWND hCombo;
    LPWSTR lpFontName;
    INT Len;

    hCombo = GetDlgItem(infoPtr->hParent,
                        IDC_FONTCOMBO);

    Len = GetWindowTextLengthW(hCombo);

    if (Len != 0)
    {
        lpFontName = HeapAlloc(GetProcessHeap(),
                               0,
                               (Len + 1) * sizeof(WCHAR));

        if (lpFontName)
        {
            SendMessageW(hCombo,
                         WM_GETTEXT,
                         Len + 1,
                         (LPARAM)lpFontName);

            ZeroMemory(&lf,
                       sizeof(lf));

            hdc = GetDC(infoPtr->hLrgWnd);
            lf.lfHeight = GetDeviceCaps(hdc,
                                        LOGPIXELSY) / 2;
            ReleaseDC(infoPtr->hLrgWnd,
                      hdc);

            lf.lfCharSet =  DEFAULT_CHARSET;
            wcsncpy(lf.lfFaceName,
                    lpFontName,
                    sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]));

            hFont = CreateFontIndirectW(&lf);

            HeapFree(GetProcessHeap(),
                     0,
                     lpFontName);
        }
    }

    return hFont;
}
开发者ID:AmineKhaldi,项目名称:reactos,代码行数:53,代码来源:lrgcell.c


注:本文中的GetWindowTextLengthW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。