It is not actually off-topic to ask how to do something with C,
just because the answer is »This can't be done with C«,
the question whether it can be done with C still is on topic.
However, a problem is that the question is not posed in a
way I can understand because the phrase »to output some text
at window« does not have a common meaning in the English
language that I know. I even wonder whether it is
grammatical, it seems to lack the artical in front of
»window« (such as in »at a window«), but OTOH there are also
English phrases such as »at gunpoint« where there also is no
article between »at« and the noun.
When a console program outputs text under Microsoft®
Windows, this text /is/ written into a window! (It is
written into the console window.) So, if the question would
be how to write text /into/ some window, the answer might be
that the program already does this under Microsoft® Windows
(unless started in a console in full screen mode).
However, the OP does not want to write »into a window«,
but »at window«, and I just do not know what this means;
but then I am not a native speaker of English.
As a native speaker of English and as someone somewhat familiar with
how Chinese speakers phrase their English after being married to one
for 31 years, I took the OP to mean he wants to print text to a
Windows application the same way the Notepad application does it and
not as a console application.
In this context, the answer is to create a Windows application project
and not a console application project and the details of this are
relevant to the Visual Studio IDE and the Win32 API and these details
are outside the scope of the comp.lang.c group discussion.
If you use the IDE wizard to create a new Win32 project it will create
most of the window program for you. Then you must write the code to
handle the WM_PAINT messages your window will receive. This code is
placed in the WndProc callback function. An example of a minimal
WndProc that prints a "Hello Windows" would look something like this:
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
RECT wr;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd,
About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
GetClientRect(hWnd, &wr);
DrawText(hdc, _T("Hello Windows!"), -1, &wr,
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}