|
-
April 2nd, 2005, 10:40 PM
#1
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."
-
April 2nd, 2005, 11:36 PM
#2
Re: Text wont wrap in static control
What's the dimension of the static control?
Kuphryn
-
April 3rd, 2005, 12:04 AM
#3
Re: Text wont wrap in static control
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."
-
April 3rd, 2005, 01:33 AM
#4
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
-
April 3rd, 2005, 02:45 AM
#5
Re: Text wont wrap in static control
 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.
-
April 3rd, 2005, 12:51 PM
#6
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
-
April 3rd, 2005, 03:23 PM
#7
Re: Text wont wrap in static control
 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.
-
April 3rd, 2005, 05:14 PM
#8
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."
-
April 3rd, 2005, 05:50 PM
#9
Re: Text wont wrap in static control
 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.
 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?
 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.
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|