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


C++ GetWindowTextA函数代码示例

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


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

示例1: GetWindowTextA

void CNodeInfoWindow::OnClickUpdateTransformButton()
{
	EditorScene* scene = EditorScene::getInstance();
	SNodeInfo* info = scene->GetSelectedNodeInfo();
	if (!info)
		return;

	f32 position[3];
	f32 rotation[3];
	f32 scaling[3];

	char text[256];
	for (u32 i = 0; i < 3; i++)
	{
		GetWindowTextA(mPosTextFields[i], text, 256);
		int err = sscanf_s(text, "%f", &position[i]);
		if (err < 1 || err == EOF)
		{
			MessageBoxA(mParentHwnd, "cannot convert position value", "Error", NULL);
			return;
		}
	}

	for (u32 i = 0; i < 3; i++)
	{
		GetWindowTextA(mRotTextFields[i], text, 256);
		int err = sscanf_s(text, "%f", &rotation[i]);
		if (err < 1 || err == EOF)
		{
			MessageBoxA(mParentHwnd, "cannot convert rotation value", "Error", NULL);
			return;
		}
	}

	for (u32 i = 0; i < 3; i++)
	{
		GetWindowTextA(mScaleTextFields[i], text, 256);
		int err = sscanf_s(text, "%f", &scaling[i]);
		if (err < 1 || err == EOF)
		{
			MessageBoxA(mParentHwnd, "cannot convert scale value", "Error", NULL);
			return;
		}
	}

	info->Position.x = position[0];
	info->Position.y = position[1];
	info->Position.z = position[2];

	info->Rotation.x = rotation[0] * XM_PI / 180.0f;
	info->Rotation.y = rotation[1] * XM_PI / 180.0f;
	info->Rotation.z = rotation[2] * XM_PI / 180.0f;

	info->Scaling.x = scaling[0];
	info->Scaling.y = scaling[1];
	info->Scaling.z = scaling[2];

	scene->UpdateNodeInfo(info);
	UpdateShowing(info);
}
开发者ID:Wu1994,项目名称:GameFinal,代码行数:60,代码来源:CNodeInfoWindow.cpp

示例2: GetWindowTextA

bool CCylinderBoundingWindow::Update(SBoundingShape* shape)
{
	f32 height, radius;
	int err;
	char text[256];
	GetWindowTextA(mHeightTextField, text, 256);
	err = sscanf_s(text, "%f", &height);
	if (err < 1 || err == EOF)
	{
		MessageBoxA(mParentHwnd, "cannot convert height value", "Error", NULL);
		return false;
	}

	GetWindowTextA(mRadiusTextField, text, 256);
	err = sscanf_s(text, "%f", &radius);
	if (err < 1 || err == EOF)
	{
		MessageBoxA(mParentHwnd, "cannot convert radius value", "Error", NULL);
		return false;
	}

	SCylinderBounding* cylinder = (SCylinderBounding*)shape;
	cylinder->Height = height;
	cylinder->Radius = radius;

	return true;
}
开发者ID:Wu1994,项目名称:GameFinal,代码行数:27,代码来源:CCylinderBoundingWindow.cpp

示例3: test_get_set_text

static void test_get_set_text(void)
{
    HWND hwnd;
    CHAR ip[16];
    INT r;

    hwnd = create_ipaddress_control();
    if (!hwnd)
    {
        win_skip("IPAddress control not implemented\n");
        return;
    }

    /* check text just after creation */
    r = GetWindowTextA(hwnd, ip, ARRAY_SIZE(ip));
    expect(7, r);
    ok(strcmp(ip, "0.0.0.0") == 0, "Expected null IP address, got %s\n", ip);

    SendMessageA(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(127, 0, 0, 1));
    r = GetWindowTextA(hwnd, ip, ARRAY_SIZE(ip));
    expect(9, r);
    ok(strcmp(ip, "127.0.0.1") == 0, "Expected 127.0.0.1, got %s\n", ip);

    DestroyWindow(hwnd);
}
开发者ID:Jactry,项目名称:wine,代码行数:25,代码来源:ipaddress.c

示例4: AddLine

void CListSide::AddLineAt(int nLine)
{
	AddLine();
	int nrLines = m_Lines.size();
	for (int i = nrLines - 2; i>= nLine; i--)
	{
		HWND hWnd = m_Lines.at(i).edSecond.m_hWnd;
		int len = GetWindowTextLengthA(hWnd);
		char* str = NULL;
		if (len)
		{
			len++;
			str = new char[len];
			GetWindowTextA(hWnd, str, len);
			SetWindowTextA(hWnd, "0:00");
			hWnd = m_Lines.at(i+1).edSecond.m_hWnd;
			SetWindowTextA(hWnd, str);
			delete[] str;
		}

		
		hWnd = m_Lines.at(i).edText.m_hWnd;
		len = GetWindowTextLengthA(hWnd);
		if (len)
		{
			len++;
			str = new char[len];
			GetWindowTextA(hWnd, str, len);
			SetWindowTextA(hWnd, "");
			hWnd = m_Lines.at(i+1).edText.m_hWnd;
			SetWindowTextA(hWnd, str);
			delete[] str;
		}
	}
}
开发者ID:Feoggou,项目名称:gen_ym10,代码行数:35,代码来源:ListSide.cpp

示例5: test_UDS_SETBUDDYINT

static void test_UDS_SETBUDDYINT(void)
{
    HWND updown;
    DWORD style, ret;
    CHAR text[10];

    /* cleanup buddy */
    text[0] = '\0';
    SetWindowTextA(g_edit, text);

    /* creating without UDS_SETBUDDYINT */
    updown = create_updown_control(UDS_ALIGNRIGHT, g_edit);
    /* try to set UDS_SETBUDDYINT after creation */
    style = GetWindowLongA(updown, GWL_STYLE);
    SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
    style = GetWindowLongA(updown, GWL_STYLE);
    ok(style & UDS_SETBUDDYINT, "Expected UDS_SETBUDDY to be set\n");
    SendMessageA(updown, UDM_SETPOS, 0, 20);
    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
    ok(lstrlenA(text) == 0, "Expected empty string\n");
    DestroyWindow(updown);

    /* creating with UDS_SETBUDDYINT */
    updown = create_updown_control(UDS_SETBUDDYINT | UDS_ALIGNRIGHT, g_edit);
    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
    /* 50 is initial value here */
    ok(lstrcmpA(text, "50") == 0, "Expected '50', got '%s'\n", text);
    /* now remove style flag */
    style = GetWindowLongA(updown, GWL_STYLE);
    SetWindowLongA(updown, GWL_STYLE, style & ~UDS_SETBUDDYINT);
    SendMessageA(updown, UDM_SETPOS, 0, 20);
    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
    ok(lstrcmpA(text, "20") == 0, "Expected '20', got '%s'\n", text);
    /* set edit text directly, check position */
    strcpy(text, "10");
    SetWindowTextA(g_edit, text);
    ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
    expect(10, ret);
    strcpy(text, "11");
    SetWindowTextA(g_edit, text);
    ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
    expect(11, LOWORD(ret));
    expect(0,  HIWORD(ret));
    /* set to invalid value */
    strcpy(text, "21st");
    SetWindowTextA(g_edit, text);
    ret = SendMessageA(updown, UDM_GETPOS, 0, 0);
    expect(11, LOWORD(ret));
    expect(TRUE, HIWORD(ret));
    /* set style back */
    style = GetWindowLongA(updown, GWL_STYLE);
    SetWindowLongA(updown, GWL_STYLE, style | UDS_SETBUDDYINT);
    SendMessageA(updown, UDM_SETPOS, 0, 30);
    GetWindowTextA(g_edit, text, ARRAY_SIZE(text));
    ok(lstrcmpA(text, "30") == 0, "Expected '30', got '%s'\n", text);
    DestroyWindow(updown);
}
开发者ID:Jactry,项目名称:wine,代码行数:57,代码来源:updown.c

示例6: page_dlg_proc

static INT_PTR CALLBACK page_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam,
                                      LPARAM lparam)
{
    switch(msg)
    {
    case WM_INITDIALOG:
      {
        HWND sheet = GetParent(hwnd);
        char caption[256];
        GetWindowTextA(sheet, caption, sizeof(caption));
        ok(!strcmp(caption,"test caption"), "caption: %s\n", caption);
        return TRUE;
      }

    case WM_NOTIFY:
      {
        NMHDR *nmhdr = (NMHDR *)lparam;
        switch(nmhdr->code)
        {
        case PSN_APPLY:
            return TRUE;
        default:
            return FALSE;
        }
      }
    case WM_NCDESTROY:
        ok(!SendMessageA(sheethwnd, PSM_INDEXTOHWND, 400, 0),"Should always be 0\n");
        return TRUE;

    default:
        return FALSE;
    }
}
开发者ID:Strongc,项目名称:reactos,代码行数:33,代码来源:propsheet.c

示例7: test_dtm_set_format

static void test_dtm_set_format(void)
{
    HWND hWnd;
    CHAR txt[256];
    SYSTEMTIME systime;
    LRESULT r;

    hWnd = create_datetime_control(DTS_SHOWNONE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    r = SendMessageA(hWnd, DTM_SETFORMATA, 0, 0);
    expect(1, r);

    r = SendMessageA(hWnd, DTM_SETFORMATA, 0,
		    (LPARAM)"'Today is: 'hh':'m':'s dddd MMM dd', 'yyyy");
    expect(1, r);

    ok_sequence(sequences, DATETIME_SEQ_INDEX, test_dtm_set_format_seq, "test_dtm_set_format", FALSE);

    r = SendMessageA(hWnd, DTM_SETFORMATA, 0, (LPARAM)"'hh' hh");
    expect(1, r);
    ZeroMemory(&systime, sizeof(systime));
    systime.wYear = 2000;
    systime.wMonth = systime.wDay = 1;
    r = SendMessageA(hWnd, DTM_SETSYSTEMTIME, 0, (LPARAM)&systime);
    expect(1, r);
    GetWindowTextA(hWnd, txt, 256);
    ok(strcmp(txt, "hh 12") == 0, "String mismatch (\"%s\" vs \"hh 12\")\n", txt);

    DestroyWindow(hWnd);
}
开发者ID:GYGit,项目名称:reactos,代码行数:32,代码来源:datetime.c

示例8: SERIALUI_GetConfItems

/*
 * Get the current sellection of the given combo box and set a DCB field to
 * the value matching that selection.
 */
static BOOL SERIALUI_GetConfItems(HWND hDlg, DWORD id, LPCPARAM2STR table, LPDWORD lpdwVal)
{
    DWORD i;
    CHAR lpEntry[20];
    HWND hControl = GetDlgItem(hDlg,id);

    if( (!hControl) || (!lpdwVal))
    {
        TRACE("Couldn't get window handle for item %lx\n",id);
        return FALSE;
    }

    if(!GetWindowTextA(hControl, &lpEntry[0], sizeof(lpEntry)))
    {
        TRACE("Couldn't get window text for item %lx\n",id);
        return FALSE;
    }
    /* TRACE("%ld contains %s\n",id, lpEntry); */

    for(i=0; i<table->dwSize; i++)
    {
        if(!lstrcmpA(table->data[i].name,lpEntry))
	{
            *lpdwVal = table->data[i].val;
            return TRUE;
	}
    }

    return FALSE;
}
开发者ID:howard5888,项目名称:wineT,代码行数:34,代码来源:confdlg.c

示例9: GetWindowTextLengthA

BOOL CALLBACK CWindowsFunctions::CB_EnumChildProc(HWND hwnd, LPARAM lParam)
{
	int length = GetWindowTextLengthA(hwnd);

	if (length > 0)
	{
		length++; // NULL character

		char* jpn = new char[length];
	
		length = GetWindowTextA(hwnd, jpn, length);

		if (length > 0)
		{
			char className[6];
			GetClassNameA(hwnd, className, sizeof(className));

			if (strcmp(className, "Edit") != 0)
			{
				bool result = m_resources->TranslateUserInterface(jpn, m_uiBuffer, UI_BUFFER);

				if (result)
				{
					SetWindowTextA(hwnd, m_uiBuffer);
				}
			}
		}

		delete[] jpn;
	}

	return TRUE;
}
开发者ID:eplightning,项目名称:afhook,代码行数:33,代码来源:CWindowsFunctions.cpp

示例10: GetEdit1TextAsMPZ

BOOL GetEdit1TextAsMPZ(HWND hDlg, mpz_t _P)
{
 char b[2048];
 LPSTR buf=(LPSTR)b;
 GetWindowTextA(GetDlgItem(hDlg, IDC_EDIT1), &buf[0], 2047);
 INT ii=(INT)SendMessage(GetDlgItem(hDlg, IDC_BASE_LIST), LB_GETCURSEL, 0, 0);
 UINT i, Base, Bits, Trues;
 BOOL Success=TRUE;
  switch(ii)
  {
   case 0: Base=10; break;
   case 1: case 2: Base=16; break;
   case 3: Base=32; break;
   case 4: Base=62; break;
   default: Success=FALSE; break;
  }
  //uint32_t ulMaxBits=2*sizeof(uint32_t)*8 + mp_bits_per_limb;mpz_init2(FFmpzTMP, ulMaxBits);
  Success &= (mpz_init_set_str(_P, (char*)buf, Base)!=-1);
   if(Success)
   {
    Bits=mpz_sizeinbase(_P, 2);
    Trues=0;
      for(i=0; i<Bits; i++)
       if(mpz_tstbit(_P, i))Trues++;
    SetLabelUI(hDlg, IDC_BITS_STT,  Bits);
    SetLabelUI(hDlg, IDC_TRUES_STT, Trues);
   }
   else
   {
    SetLabelUI(hDlg, IDC_BITS_STT, 0xFFFFFFFF);
    SetLabelUI(hDlg, IDC_TRUES_STT, 0xFFFFFFFF);
   }
  return Success;
}//--//
开发者ID:rob72,项目名称:Prime-numbers-generator,代码行数:34,代码来源:PrimeGen_WinAPI.cpp

示例11: 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

示例12: DoSaveFile

static VOID DoSaveFile(VOID)
{
    HANDLE hFile;
    DWORD dwNumWrite;
    LPSTR pTemp;
    DWORD size;

    hFile = CreateFile(Globals.szFileName, GENERIC_WRITE, FILE_SHARE_WRITE,
                       NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if(hFile == INVALID_HANDLE_VALUE)
    {
        ShowLastError();
        return;
    }

    size = GetWindowTextLengthA(Globals.hEdit) + 1;
    pTemp = HeapAlloc(GetProcessHeap(), 0, size);
    if (!pTemp)
    {
	CloseHandle(hFile);
        ShowLastError();
        return;
    }
    size = GetWindowTextA(Globals.hEdit, pTemp, size);

    if (!WriteFile(hFile, pTemp, size, &dwNumWrite, NULL))
        ShowLastError();
    else
        SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0);

    SetEndOfFile(hFile);
    CloseHandle(hFile);
    HeapFree(GetProcessHeap(), 0, pTemp);
}
开发者ID:howard5888,项目名称:wineT,代码行数:34,代码来源:dialog.c

示例13: test_create_updown_control

static void test_create_updown_control(void)
{
    CHAR text[MAX_PATH];

    parent_wnd = create_parent_window();
    ok(parent_wnd != NULL, "Failed to create parent window!\n");
    ok_sequence(sequences, PARENT_SEQ_INDEX, create_parent_wnd_seq, "create parent window", TRUE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    edit = create_edit_control();
    ok(edit != NULL, "Failed to create edit control\n");
    ok_sequence(sequences, PARENT_SEQ_INDEX, add_edit_to_parent_seq, "add edit control to parent", FALSE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    updown = create_updown_control();
    ok(updown != NULL, "Failed to create updown control\n");
    ok_sequence(sequences, PARENT_SEQ_INDEX, add_updown_to_parent_seq, "add updown control to parent", TRUE);
    ok_sequence(sequences, EDIT_SEQ_INDEX, add_updown_with_edit_seq, "add updown control with edit", FALSE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    GetWindowTextA(edit, text, MAX_PATH);
    ok(lstrlenA(text) == 0, "Expected empty string\n");
    ok_sequence(sequences, EDIT_SEQ_INDEX, get_edit_text_seq, "get edit text", FALSE);

    flush_sequences(sequences, NUM_MSG_SEQUENCES);

    test_updown_pos();
    test_updown_pos32();
    test_updown_buddy();
    test_updown_base();
    test_updown_unicode();
}
开发者ID:devyn,项目名称:wine,代码行数:35,代码来源:updown.c

示例14: set_foreground

static DWORD set_foreground(HWND hwnd)
{
    HWND hwnd_fore;
    DWORD set_id, fore_id, ret;
    char win_text[1024];

    hwnd_fore = GetForegroundWindow();
    GetWindowTextA(hwnd_fore, win_text, 1024);
    set_id = GetWindowThreadProcessId(hwnd, NULL);
    fore_id = GetWindowThreadProcessId(hwnd_fore, NULL);
    trace("\"%s\" %p %08x hwnd %p %08x\n", win_text, hwnd_fore, fore_id, hwnd, set_id);
    ret = AttachThreadInput(set_id, fore_id, TRUE);
    trace("AttachThreadInput returned %08x\n", ret);
    ret = ShowWindow(hwnd, SW_SHOWNORMAL);
    trace("ShowWindow returned %08x\n", ret);
    ret = SetWindowPos(hwnd, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
    trace("set topmost returned %08x\n", ret);
    ret = SetWindowPos(hwnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
    trace("set notopmost returned %08x\n", ret);
    ret = SetForegroundWindow(hwnd);
    trace("SetForegroundWindow returned %08x\n", ret);
    Sleep(250);
    AttachThreadInput(set_id, fore_id, FALSE);
    return ret;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:25,代码来源:winstation.c

示例15: DoMyControlProcessing

int DoMyControlProcessing(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam,INT_PTR *bReturn)
{
	switch(message) {
		case WM_INITDIALOG:
			EnumChildWindows(hdlg,MyControlsEnumChildren,0);
			if(hEmfHeaderLogo==NULL) {
				HRSRC hRsrc=FindResourceA(hInst,MAKEINTRESOURCEA(IDE_HDRLOGO),"EMF");
				HGLOBAL hGlob=LoadResource(hInst,hRsrc);
				hEmfHeaderLogo=SetEnhMetaFileBits(SizeofResource(hInst,hRsrc),(PBYTE)LockResource(hGlob));
			}
			SendDlgItemMessage(hdlg,IDC_HDRLOGO,STM_SETIMAGE,IMAGE_ENHMETAFILE,(LPARAM)hEmfHeaderLogo);
			break;
		case WM_CTLCOLORSTATIC:
			if((GetWindowLong((HWND)lParam,GWL_STYLE)&0xFFFF)==0) {
				char szText[256];
				GetWindowTextA((HWND)lParam,szText,sizeof(szText));
				if(!strcmp(szText,"whiterect")) {
					SetTextColor((HDC)wParam,RGB(255,255,255));
					SetBkColor((HDC)wParam,RGB(255,255,255));
					SetBkMode((HDC)wParam,OPAQUE);
					*bReturn=(INT_PTR)GetStockObject(WHITE_BRUSH);
					return TRUE;
				}
				else {
					SetBkMode((HDC)wParam,TRANSPARENT);
					*bReturn=(INT_PTR)GetStockObject(NULL_BRUSH);
					return TRUE;
				}
			}
			break;
	}
	return FALSE;
}
开发者ID:dineshkummarc,项目名称:miranda-im-v0.9.47-src,代码行数:33,代码来源:wizard.cpp


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