How can I add some text line in my window?How can I profile C++ code running on Linux?API-level Unicode GUI Native apps in C++ for Windows/Linux/Macglobal pointers to objects will break program by access violation when accessing object attributes/methods through themHow to get window proc parameters?updating win32 window to display generated barcodeProblems with a window event callback function C++Child windows does not receive WM_DESTROY?HINSTANCE & HWND Corrupted when passed around functionsWindows freezes after trying to render triangle in directx11Cost of self-executing C++11 lambdas

Do intermediate subdomains need to exist?

How can I effectively map a multi-level dungeon?

What happens if the limit of 4 billion files was exceeded in an ext4 partition?

Machine Learning Golf: Multiplication

Isn't "Dave's protocol" good if only the database, and not the code, is leaked?

Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?

Platform Event Design when Subscribers are Apex Triggers

Why does the Batman "crack his knuckles" in "Batman: Arkham Origins"?

Sleepy tired vs physically tired

How to respond to someone who condemns behavior similar to what they exhibit?

What units are kpts?

Is it bad to suddenly introduce another element to your fantasy world a good ways into the story?

Why would a propeller have blades of different lengths?

how to convert Timestring to seconds

How to improve the size of cells in this table?

How to travel between two stationary worlds in the least amount of time? (time dilation)

Term for a character that only exists to be talked to

Interview Question - Card betting

How frequently do Russian people still refer to others by their patronymic (отчество)?

Milky way is orbiting around?

Why did moving the mouse cursor cause Windows 95 to run more quickly?

What can a novel do that film and TV cannot?

Should I cheat if the majority does it?

What is exact meaning of “ich wäre gern”?



How can I add some text line in my window?


How can I profile C++ code running on Linux?API-level Unicode GUI Native apps in C++ for Windows/Linux/Macglobal pointers to objects will break program by access violation when accessing object attributes/methods through themHow to get window proc parameters?updating win32 window to display generated barcodeProblems with a window event callback function C++Child windows does not receive WM_DESTROY?HINSTANCE & HWND Corrupted when passed around functionsWindows freezes after trying to render triangle in directx11Cost of self-executing C++11 lambdas






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I am able to create a window with a Tile. How can I add now new text line inside the Window ?



All what I succeed to did was only to change the title of the window which is not what I want . I want to add some text line in the window box.



SendMessage function was not working for me.



Please if somebody has some tip for this to tell me !



#include <windows.h>

const char g_szClassName[] = "myWindowClass";
//The Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

switch(msg)

case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);

return 0;


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)

WNDCLASSEX wc;
HWND hwnd;
MSG Msg;

// Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc))

MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION


hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"Title of window",
WS_OVERLAPPEDWINDOW,
1390, 540, 240, 120,
NULL, NULL, hInstance, NULL);

if(hwnd == NULL)
MB_OK);
return 0;


ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);



// The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)

TranslateMessage(&Msg);
DispatchMessage(&Msg);

return Msg.wParam;



enter image description here










share|improve this question

















  • 1





    Maybe docs.microsoft.com/en-us/windows/desktop/api/Winuser/…

    – drescherjm
    Mar 25 at 14:57

















-1















I am able to create a window with a Tile. How can I add now new text line inside the Window ?



All what I succeed to did was only to change the title of the window which is not what I want . I want to add some text line in the window box.



SendMessage function was not working for me.



Please if somebody has some tip for this to tell me !



#include <windows.h>

const char g_szClassName[] = "myWindowClass";
//The Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

switch(msg)

case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);

return 0;


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)

WNDCLASSEX wc;
HWND hwnd;
MSG Msg;

// Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc))

MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION


hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"Title of window",
WS_OVERLAPPEDWINDOW,
1390, 540, 240, 120,
NULL, NULL, hInstance, NULL);

if(hwnd == NULL)
MB_OK);
return 0;


ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);



// The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)

TranslateMessage(&Msg);
DispatchMessage(&Msg);

return Msg.wParam;



enter image description here










share|improve this question

















  • 1





    Maybe docs.microsoft.com/en-us/windows/desktop/api/Winuser/…

    – drescherjm
    Mar 25 at 14:57













-1












-1








-1








I am able to create a window with a Tile. How can I add now new text line inside the Window ?



All what I succeed to did was only to change the title of the window which is not what I want . I want to add some text line in the window box.



SendMessage function was not working for me.



Please if somebody has some tip for this to tell me !



#include <windows.h>

const char g_szClassName[] = "myWindowClass";
//The Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

switch(msg)

case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);

return 0;


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)

WNDCLASSEX wc;
HWND hwnd;
MSG Msg;

// Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc))

MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION


hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"Title of window",
WS_OVERLAPPEDWINDOW,
1390, 540, 240, 120,
NULL, NULL, hInstance, NULL);

if(hwnd == NULL)
MB_OK);
return 0;


ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);



// The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)

TranslateMessage(&Msg);
DispatchMessage(&Msg);

return Msg.wParam;



enter image description here










share|improve this question














I am able to create a window with a Tile. How can I add now new text line inside the Window ?



All what I succeed to did was only to change the title of the window which is not what I want . I want to add some text line in the window box.



SendMessage function was not working for me.



Please if somebody has some tip for this to tell me !



#include <windows.h>

const char g_szClassName[] = "myWindowClass";
//The Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)

switch(msg)

case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);

return 0;


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)

WNDCLASSEX wc;
HWND hwnd;
MSG Msg;

// Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc))

MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION


hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"Title of window",
WS_OVERLAPPEDWINDOW,
1390, 540, 240, 120,
NULL, NULL, hInstance, NULL);

if(hwnd == NULL)
MB_OK);
return 0;


ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);



// The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)

TranslateMessage(&Msg);
DispatchMessage(&Msg);

return Msg.wParam;



enter image description here







c++ winapi window






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 14:53









Alin.BAlin.B

125 bronze badges




125 bronze badges







  • 1





    Maybe docs.microsoft.com/en-us/windows/desktop/api/Winuser/…

    – drescherjm
    Mar 25 at 14:57












  • 1





    Maybe docs.microsoft.com/en-us/windows/desktop/api/Winuser/…

    – drescherjm
    Mar 25 at 14:57







1




1





Maybe docs.microsoft.com/en-us/windows/desktop/api/Winuser/…

– drescherjm
Mar 25 at 14:57





Maybe docs.microsoft.com/en-us/windows/desktop/api/Winuser/…

– drescherjm
Mar 25 at 14:57












2 Answers
2






active

oldest

votes


















1














To draw text in the client area, your wndProc would normally use something like DrawText or TextOut. You typically do that in response to WM_PAINT.



To be able to respond to an external message, you'd typically send a message containing the text. The window would receive that, store (a copy of) the text it received, and (usually) invalidate the window's rectangle. Since the window is now invalidated, the next chance it gets, Windows will send your window a WM_PAINT message (and then you'll draw out the text).






share|improve this answer






























    0














    Handling the WM_PAINT message and drawing the text directly on the window's HDC is one option.



    Another option is to create a child STATIC control in your window, and then you can assign the desired text to that child using SetWindowText() or the WM_SETTEXT message. No manual drawing needed.






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55340590%2fhow-can-i-add-some-text-line-in-my-window%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      To draw text in the client area, your wndProc would normally use something like DrawText or TextOut. You typically do that in response to WM_PAINT.



      To be able to respond to an external message, you'd typically send a message containing the text. The window would receive that, store (a copy of) the text it received, and (usually) invalidate the window's rectangle. Since the window is now invalidated, the next chance it gets, Windows will send your window a WM_PAINT message (and then you'll draw out the text).






      share|improve this answer



























        1














        To draw text in the client area, your wndProc would normally use something like DrawText or TextOut. You typically do that in response to WM_PAINT.



        To be able to respond to an external message, you'd typically send a message containing the text. The window would receive that, store (a copy of) the text it received, and (usually) invalidate the window's rectangle. Since the window is now invalidated, the next chance it gets, Windows will send your window a WM_PAINT message (and then you'll draw out the text).






        share|improve this answer

























          1












          1








          1







          To draw text in the client area, your wndProc would normally use something like DrawText or TextOut. You typically do that in response to WM_PAINT.



          To be able to respond to an external message, you'd typically send a message containing the text. The window would receive that, store (a copy of) the text it received, and (usually) invalidate the window's rectangle. Since the window is now invalidated, the next chance it gets, Windows will send your window a WM_PAINT message (and then you'll draw out the text).






          share|improve this answer













          To draw text in the client area, your wndProc would normally use something like DrawText or TextOut. You typically do that in response to WM_PAINT.



          To be able to respond to an external message, you'd typically send a message containing the text. The window would receive that, store (a copy of) the text it received, and (usually) invalidate the window's rectangle. Since the window is now invalidated, the next chance it gets, Windows will send your window a WM_PAINT message (and then you'll draw out the text).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 16:18









          Jerry CoffinJerry Coffin

          394k57 gold badges490 silver badges933 bronze badges




          394k57 gold badges490 silver badges933 bronze badges























              0














              Handling the WM_PAINT message and drawing the text directly on the window's HDC is one option.



              Another option is to create a child STATIC control in your window, and then you can assign the desired text to that child using SetWindowText() or the WM_SETTEXT message. No manual drawing needed.






              share|improve this answer



























                0














                Handling the WM_PAINT message and drawing the text directly on the window's HDC is one option.



                Another option is to create a child STATIC control in your window, and then you can assign the desired text to that child using SetWindowText() or the WM_SETTEXT message. No manual drawing needed.






                share|improve this answer

























                  0












                  0








                  0







                  Handling the WM_PAINT message and drawing the text directly on the window's HDC is one option.



                  Another option is to create a child STATIC control in your window, and then you can assign the desired text to that child using SetWindowText() or the WM_SETTEXT message. No manual drawing needed.






                  share|improve this answer













                  Handling the WM_PAINT message and drawing the text directly on the window's HDC is one option.



                  Another option is to create a child STATIC control in your window, and then you can assign the desired text to that child using SetWindowText() or the WM_SETTEXT message. No manual drawing needed.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 25 at 18:38









                  Remy LebeauRemy Lebeau

                  354k19 gold badges286 silver badges480 bronze badges




                  354k19 gold badges286 silver badges480 bronze badges



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55340590%2fhow-can-i-add-some-text-line-in-my-window%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript