Article View: comp.os.ms-windows.programmer.misc
Article #2442Styles of multiline edit
From: misha
Date: Tue, 26 Jan 1993 22:38
Date: Tue, 26 Jan 1993 22:38
92 lines
3589 bytes
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
---
---
Technical Details
Message-ID:
<199301262257.AA14029@newcom.kiae.su>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!concert!gatech!usenet.ins.cwru.edu!agate!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!fuug!kiae!newsservShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!concert!gatech!usenet.ins.cwru.edu!agate!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!fuug!kiae!newsserv From: misha@aiva.lt () Newsgroups: comp.os.ms-windows.programmer.misc Subject: Styles of multiline edit Date: Tue, 26 Jan 93 23:38:53 +0100 Distribution: world Organization: Aiva System Message-ID: <199301262257.AA14029@newcom.kiae.su> Sender: news-service@newcom.kiae.su Reply-To: misha@aiva.lt Lines: 93