|
-
May 17th, 2004, 07:46 AM
#1
Thread Starter
Hyperactive Member
Changing window style (RESOLVED)
Is it possible to change the MultiLine style on a textbox or can it be only set during window creation?
I thought I could something like
long tStyle=0;
tStyle=GetWindowLong(m_hwnd,GWL_STYLE);
if ((tStyle | ES_CENTER)==tStyle)
{
tStyle = tStyle ^ ES_CENTER;
}
tStyle=tStyle | ES_RIGHT;
SetWindowLong(m_hwnd,GWL_STYLE,tStyle);
Last edited by packetVB; May 25th, 2004 at 09:15 AM.
-
May 17th, 2004, 09:38 AM
#2
More efficient to say
tStyle = (tStyle & ~ES_CENTER) | ES_RIGHT;
You can change every style. Just make sure you invalidate and redraw the control after you change the style.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 17th, 2004, 11:48 AM
#3
Thread Starter
Hyperactive Member
Ah thats what im doing wrong.
Thanks again CornedBee.
One other,
Is there any message that I can send to a parent window, that will get sent to all the child windows of the parent?
packetvb
-
May 17th, 2004, 12:10 PM
#4
No, I don't think so. I mean, MFC has a special function to do that, but effectively it just enumerates all childs and sends to message to all of them in turn.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 17th, 2004, 12:16 PM
#5
Thread Starter
Hyperactive Member
CornedBee
Thanks, I guess I will have to do the enum thing.
Sorry to ask another, But
How am I suppose to go about doing the style change
Ive trying to use SetWindowLong with GWL_STYLE
and then calling RedrawWindow once with RDW_INVALIDATE then again with RDW_VALIDATE
Is this correct or am i out to lunch?
Thanks again.
packetvb
-
May 17th, 2004, 12:37 PM
#6
I'd use InvalidateRect and pass NULL as the RECT*. Then UpdateWindow.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 25th, 2004, 08:52 AM
#7
Thread Starter
Hyperactive Member
CornedBee,
I seem to be having a problem with changing the Alignment style of a edit control. Im trying what you suggested but its not working. Is there something else that has to be done for this to work? Can you give me some idea of what im doing wrong?
Here code:
void vTextBox::Alignment(int val)
{
long tStyle=0;
long oStyle=0;
BOOL ll;
//Get style of window
tStyle=GetWindowLong(m_hwnd,GWL_STYLE);
//if its ES_CENTER, which it is because ES_CENTER was
//passed when creating edit window
if ((tStyle | ES_CENTER)==tStyle)
{
//remove ES_CENTER
tStyle = (tStyle ^ ES_CENTER) ;
}
//add ES_RIGHT
tStyle=tStyle | ES_RIGHT;
//set the style
oStyle=SetWindowLong(m_hwnd,GWL_STYLE,tStyle);
//do again to see if ostyle has the new style.
oStyle=SetWindowLong(m_hwnd,GWL_STYLE,tStyle);
InvalidateRect(m_hwnd,NULL,false);
ll=UpdateWindow(m_hwnd);
}
-
May 25th, 2004, 09:15 AM
#8
Thread Starter
Hyperactive Member
Nevermind, finally found info on MSDN that says what im trying cant be done.
-
May 25th, 2004, 10:44 AM
#9
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
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
|