在使用C窗口中显示的字符串输出(在WIN32 API) [英] Displaying String Output in a Window using C (in WIN32 API)

查看:522
本文介绍了在使用C窗口中显示的字符串输出(在WIN32 API)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有一个适当的方式,我可以输出字符串和创建的窗口显示。
我已经采用的TextOut()函数,但因为它仅描绘了窗口,一旦窗口最小化并恢复回来,在窗口上显示的数据消失。
另外,当要显示的数据是超过窗口的大小,则仅显示等于窗口尺寸数据和其它数据被截断。
是否有任何其他的方式来输出数据在一个窗口?

I want a proper way in which I can output a character string and display it on a Window created. I had been using textout() function, but since it only paints the window, once the window is minimized and restored back, the data displayed on the window disappears. Also when the data to be displayed is exceeds the size of Window, only the data equal to window size is displayed and other data is truncated. Is there any other way to output data on a Window?

推荐答案

您可以把的 静态 或一个的 修改 控制(标签和一个文本框)你的窗口上显示的数据。

You can put a Static or an Edit control (Label and a text box) on your window to show the data.

调用其中的一个时 WM_CREATE

HWND hWndExample = CreateWindow("STATIC", "Text Goes Here", WS_VISIBLE | WS_CHILD | SS_LEFT, 10,10,100,100, hWnd, NULL, hInstance, NULL);

或者

HWND hWndExample = CreateWindow("EDIT", "Text Goes Here", WS_VISIBLE | WS_CHILD | ES_LEFT, 10,10,100,100, hWnd, NULL, hInstance, NULL);

如果您使用的是修改那么用户也将能够滚动,复制和粘贴文本。

If you use an Edit then the user will also be able to scroll, and copy and paste the text.

在这两种情况下,文本可以使用 SetWindowText函数()

In both cases, the text can be updated using SetWindowText():

SetWindowText(hWndExample, TEXT("Control string"));

(<一个href=\"http://stackoverflow.com/questions/15429541/displaying-string-output-in-a-window-using-c-in-win32-api/15434274?noredirect=1#comment21831177_15434274\">Curtosy Daboyzuk 的)

这篇关于在使用C窗口中显示的字符串输出(在WIN32 API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆