各位高手,我用textout编写了一个函数 如下:#include <stdio.h>
#include <windows.h>
void main()
{
int ret,err;
HWND handle; 
HDC hdc;
char *text = "abcdefg"; handle = GetForegroundWindow();
hdc = GetDC(handle);        ret = TextOut(hdc, 50, 50, text, strlen(text));
     printf("ret=%d\n", ret);
}        handle是一个文本文档的窗口句柄。函数返回值为1,说明执行成功了,可是为什么在文本文档中显示不出来text的内容呢?
盼高手指点,急等!!!!

解决方案 »

  1.   

    你的代码很奇怪,不知道你想干什么,TextOut这种函数必须放到OnPaint()这种函数里让它不停的刷新,
    可能你的内容被覆盖了吧
      

  2.   

    文本文档是指 notepad?notepad底下   显示文字的窗口不是主窗口。
    你画的窗口被显示窗口覆盖了,所以看不到。你可以用spy++看一下文本编辑器的句柄 
    以及 你获得的句柄 打印出来 应该是不一样了。
      

  3.   

    这里用void main()可以吗??应该是int WINAPI WinMain(
      HINSTANCE hInstance,      // handle to current instance
      HINSTANCE hPrevInstance,  // handle to previous instance
      LPSTR lpCmdLine,          // command line
      int nCmdShow              // show state
    );