CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2005
    Location
    Canada Alberta
    Posts
    80

    Text wont wrap in static control

    I have created a static control the is initialy not visible and is a child of the main window, it has no text.

    I latter show the window and set the text (SetWinowText()), how ever the text will not wrap and just trims itself.

    window style tags used: WS_CHILD | SS_SIMPLE (using white seems to disable text display)

    why wont it wrap? even adding SS_LEFT dosn't work.
    In C, you merely shoot yourself in the foot.

    In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."

  2. #2
    Join Date
    Feb 2002
    Posts
    5,758

    Re: Text wont wrap in static control

    What's the dimension of the static control?

    Kuphryn

  3. #3
    Join Date
    Mar 2005
    Location
    Canada Alberta
    Posts
    80

    Re: Text wont wrap in static control

    100 by 100
    In C, you merely shoot yourself in the foot.

    In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."

  4. #4
    Join Date
    Feb 2002
    Posts
    5,758

    Re: Text wont wrap in static control

    In general, static control does not auto-wrap, at least not by default. Determine the maximum text length that will fit with the selected font and inside "\n" before the next character.

    Kuphryn

  5. #5
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Text wont wrap in static control

    Quote Originally Posted by kuphryn
    In general, static control does not auto-wrap, at least not by default.
    Yes, it does.

    @barrensoul: Your problem is the SS_SIMPLE style: It limits the static control to a single line. Remove that style, and the text in the control will wrap around.

  6. #6
    Join Date
    Feb 2002
    Posts
    5,758

    Re: Text wont wrap in static control

    Incorrect, or maybe I've not enabled it with my previous projects. I've always had to resize the static control at run-time.

    Kuphryn

  7. #7
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Text wont wrap in static control

    Quote Originally Posted by kuphryn
    Incorrect, or maybe I've not enabled it with my previous projects. I've always had to resize the static control at run-time.
    I don't know what you have done, but it's easy to try out: Just create a simple dialog box, place a static control on it (make sure it is tall enough to display multiple lines), and create a DDX member variable of type CString for it. Then assign a string to it that won't fit into one single line, and you will see that the text will break into multiple lines at word boundaries. But since you said you had to resize the control at run-time: Looks like you've confounded word wrapping with automatic resizing.

  8. #8
    Join Date
    Mar 2005
    Location
    Canada Alberta
    Posts
    80

    Re: Text wont wrap in static control

    lol I'm not using MFC or any class stuff

    Z = CreateWindow("STATIC","",SS_SIMPLE |SS_LEFT | WS_CHILD ,0,0,100,100, mainwindow,(HMENU)DisplayS, ghinst,0);

    on a black direct draw window (you people and your stupid predefined classes >: ) and your stupid wizard creation to easy)

    neways so how do I change that line? just remove simple? but the background window is black :\

    and why when I move my winow does it consider one of my buttons to be pressed?

    switch(LOWORD(wParam)) with the hmenu value as the cases is how I'm currently dettecting a button press

    (who moved this to VC++?? it should have been placed in winapi since my program can compile under GCC just fine -_-')

    Code:
    long FAR PASCAL WndProc (HWND myhwnd, UINT message, WPARAM wParam, LPARAM lParam)//Message Handling
    {
     switch (message)
     {
      case WM_CHAR:
       if (wParam == 27)
    	  PostQuitMessage(0);
       break;
      case WM_DESTROY: 
       PostQuitMessage(0);
       break;
     }
    
    if((LOWORD(wParam) == StopB)&&(message == BN_SETFOCUS))
     windowswitch = 0;
    
     switch (LOWORD(wParam))
      {
      case CancelB://if wParam is == button then the button associated was clicked
       PostQuitMessage(0);
       break;
      case AdverB:
       if(windowswitch!=1)
        windowswitch = 1;
       break;
      case BankB:
       if(windowswitch!=2)
        windowswitch = 2;
       break;
      case BlockB:
       if(windowswitch!=3)
        windowswitch = 3;
       break;
      case SutekB:
       if(windowswitch!=4)
        windowswitch = 4;
       break;
      case StopB:
       DestroyWindow(H);
       windowswitch = 0;
       break;
      }
     return(DefWindowProc(myhwnd,message,wParam,lParam));
    Last edited by barrensoul; April 3rd, 2005 at 05:16 PM.
    In C, you merely shoot yourself in the foot.

    In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."

  9. #9
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Text wont wrap in static control

    Quote Originally Posted by barrensoul
    neways so how do I change that line? just remove simple?
    Yes, as I said: Just remove SS_SIMPLE. It has nothing to do with MFC or "stupid classes", it's plain Win32 SDK - and it's documented in MSDN.

    Quote Originally Posted by barrensoul
    but the background window is black :\
    So what? What would you expect to see, what do you see with the SS_SIMPLE style, and what without?

    Quote Originally Posted by barrensoul
    and why when I move my winow does it consider one of my buttons to be pressed?
    I don't know - however, I doubt that it has anything to do with the styles of the static control. You must be doing something else wrong.

    Quote Originally Posted by barrensoul
    switch(LOWORD(wParam)) with the hmenu value as the cases is hw I'm currently dettecting a button press
    That too is a new topic altogether - you should probably start two new threads for those separate questions. Note however that MFC's "stupid predefined classes" take away some of the complexity of plain Win32 SDK programming which often make beginners stumble.
    Last edited by gstercken; April 3rd, 2005 at 05:52 PM.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts



HTML5 Development Center

Click Here to Expand Forum to Full Width