🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.ms-windows.programmer.misc
1 messages
1 total messages Started by misha Tue, 26 Jan 1993 22:38
Styles of multiline edit
#2442
Author: misha
Date: Tue, 26 Jan 1993 22:38
92 lines
3589 bytes
Hi, netters!

In my program I have 3 multiline edit controls, created as
follows:

    for (i = 0; i < 3;  i++)
        hwndCard[i] = CreateWindow(
                      "edit", "",
                      WS_CHILD | WS_VISIBLE | WS_BORDER |
                      ES_MULTILINE | ES_WANTRETURN,
                      CARDX, CARDY,
                      CARDWIDTH, CARDHEIGHT,
                      hwndParent, i,
                      HINSTANCE(hwndParent),
                      NULL);

I'd like to let user change alignment in of these edits. Here is a
piece of my code:

//==============================================================
//   fnCmdAlign(HWND, WORD, LONG);     wMessage == WM_COMMAND;
//                                     wParam   == MI_LEFT
//                                              or MI_RIGHT
//                                              or MI_CENTER
//==============================================================
long fnCmdAlign(HWND hWnd, WORD wParam, LONG lParam)
{
    register   i;
    DWORD      dwStyle;
    //
    //   Get current dwStyle setting
    //
    dwStyle = GetWindowLong(hwndCard[0], GWL_STYLE);
    //
    //   Set the new dwStyle according to selected menu item.
    //
    switch (wParam)
       {
       case MI_LEFT:   
            dwStyle &= ~ES_RIGHT;    // mask off ES_RIGHT
            dwStyle &= ~ES_CENTER;   // mask off ES_CENTER
            dwStyle |= ES_LEFT;      // set ES_LEFT
            break;

       case MI_RIGHT:
            dwStyle &= ~ES_LEFT;     // mask off ES_LEFT
            dwStyle &= ~ES_CENTER;   // mask off ES_CENTER
            dwStyle |= ES_RIGHT;     // set ES_RIGHT
            break;

       case MI_CENTER: 
            dwStyle &= ~ES_RIGHT;    // mask off ES_RIGHT
            dwStyle &= ~ES_LEFT;     // mask off ES_LEFT
            dwStyle |= ES_CENTER;    // set ES_CENTER
       } 
    //
    //   Now set up the new window style...
    //
    for (i = 0;  i < 3;  i++)
        {
        //   Here we are...
        //
        SetWindowLong(hwndCard[i], GWL_STYLE, dwStyle);
        InvalidateRect(hwndCard[i], NULL, TRUE);
        UpdateWindow(hwndCard[i]);
        //
        //  AND NOTHING HAPPENS HERE!
        //
        }

Yes, the problem is that alignment remains unchanged for my edits,
althought WinSight shows me, that window style bits have been
changed! For further investigation I've tried to play with
ES_UPPERCASE and ES_LOWERCASE styles, and they both work, i.e.
after I set a new style it's in effect immediately.

Of course, I can work around the problem by simply destroy and
recreate windows with new style, but it seems, that I'm missing
something simple...

I've tried to compile the program with both BC++ 3.1 and MSC 6.0
with libraries from SDK 3.1 - no difference.

Any ideas? Please answer to my e-mail address, I don't read this
newsgroup often. Thanks in advance!

/\\ichael Dvorkin,
Vilnius, Lithuania                E-mail: misha@aiva.lt
---

---
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads