Results 1 to 9 of 9

Thread: Changing window style (RESOLVED)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271

    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.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271
    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

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271
    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

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271
    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);


    }

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271
    Nevermind, finally found info on MSDN that says what im trying cant be done.

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Sorry for that.
    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
  •  



Click Here to Expand Forum to Full Width