以 LPCTSTR 开头编写另一行文本的最佳方法是什么?

What is the best way to write another text line starting with LPCTSTR?

本文关键字:文本 一行 最佳 方法 是什么 开头 LPCTSTR      更新时间:2023-10-16

我正在尝试再写第二行,但我不知道该使用哪个代码。

我尝试过使用 \r、\

n、\r 等,但他们都没有奏效。

感谢所有提供帮助的人!:)

这是我代码的一部分。(我也包括了标题。

HINSTANCE g_hInst;
LPCTSTR lpszClass = L"HelloAPI";
LPCTSTR ChildClassName  = L"ChildWin";

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszCmdParam,
                     int nCmdShow)
    hWnd=CreateWindow(lpszClass,            
                    L"Visual C++",              
                    WS_OVERLAPPEDWINDOW | WS_VISIBLE,   
                    200, 200,                           
                    600, 600,                                           
                    (HWND)NULL,                         
                    (HMENU)NULL,                        
                    NULL);                              
       ShowWindow(hWnd,nCmdShow);
    while(GetMessage(&Message,0,0,0)) {
        TranslateMessage(&Message);
        DispatchMessage(&Message);
    }
    return Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage,
                         WPARAM wParam, LPARAM lParam)
{
    LPCTSTR text = L"Visual C++201934-243369";
    switch(iMessage) {
        case WM_PAINT:
            {
                PAINTSTRUCT ps;
                HDC hdc = BeginPaint(hWnd, &ps);
                TextOut(hdc,100, 100, text, lstrlen(text));
                EndPaint(hWnd,&ps);
                return 0;
            }
TextOut

处理输入字符串中的换行符。 请改用DrawText,指定DT_WORDBREAK标志。

元评论:现在你明白为什么我们需要你发布你的代码了。