home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / misc / 5491 < prev    next >
Encoding:
Internet Message Format  |  1993-01-29  |  3.4 KB

  1. Path: 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
  2. From: misha@aiva.lt ()
  3. Newsgroups: comp.os.ms-windows.programmer.misc
  4. Subject: Styles of multiline edit
  5. Date: Tue, 26 Jan 93 23:38:53 +0100
  6. Distribution: world
  7. Organization: Aiva System
  8. Message-ID: <199301262257.AA14029@newcom.kiae.su>
  9. Sender: news-service@newcom.kiae.su
  10. Reply-To: misha@aiva.lt
  11. Lines: 93
  12.  
  13.  
  14. Hi, netters!
  15.  
  16. In my program I have 3 multiline edit controls, created as
  17. follows:
  18.  
  19.     for (i = 0; i < 3;  i++)
  20.         hwndCard[i] = CreateWindow(
  21.                       "edit", "",
  22.                       WS_CHILD | WS_VISIBLE | WS_BORDER |
  23.                       ES_MULTILINE | ES_WANTRETURN,
  24.                       CARDX, CARDY,
  25.                       CARDWIDTH, CARDHEIGHT,
  26.                       hwndParent, i,
  27.                       HINSTANCE(hwndParent),
  28.                       NULL);
  29.  
  30. I'd like to let user change alignment in of these edits. Here is a
  31. piece of my code:
  32.  
  33. //==============================================================
  34. //   fnCmdAlign(HWND, WORD, LONG);     wMessage == WM_COMMAND;
  35. //                                     wParam   == MI_LEFT
  36. //                                              or MI_RIGHT
  37. //                                              or MI_CENTER
  38. //==============================================================
  39. long fnCmdAlign(HWND hWnd, WORD wParam, LONG lParam)
  40. {
  41.     register   i;
  42.     DWORD      dwStyle;
  43.     //
  44.     //   Get current dwStyle setting
  45.     //
  46.     dwStyle = GetWindowLong(hwndCard[0], GWL_STYLE);
  47.     //
  48.     //   Set the new dwStyle according to selected menu item.
  49.     //
  50.     switch (wParam)
  51.        {
  52.        case MI_LEFT:   
  53.             dwStyle &= ~ES_RIGHT;    // mask off ES_RIGHT
  54.             dwStyle &= ~ES_CENTER;   // mask off ES_CENTER
  55.             dwStyle |= ES_LEFT;      // set ES_LEFT
  56.             break;
  57.  
  58.        case MI_RIGHT:
  59.             dwStyle &= ~ES_LEFT;     // mask off ES_LEFT
  60.             dwStyle &= ~ES_CENTER;   // mask off ES_CENTER
  61.             dwStyle |= ES_RIGHT;     // set ES_RIGHT
  62.             break;
  63.  
  64.        case MI_CENTER: 
  65.             dwStyle &= ~ES_RIGHT;    // mask off ES_RIGHT
  66.             dwStyle &= ~ES_LEFT;     // mask off ES_LEFT
  67.             dwStyle |= ES_CENTER;    // set ES_CENTER
  68.        } 
  69.     //
  70.     //   Now set up the new window style...
  71.     //
  72.     for (i = 0;  i < 3;  i++)
  73.         {
  74.         //   Here we are...
  75.         //
  76.         SetWindowLong(hwndCard[i], GWL_STYLE, dwStyle);
  77.         InvalidateRect(hwndCard[i], NULL, TRUE);
  78.         UpdateWindow(hwndCard[i]);
  79.         //
  80.         //  AND NOTHING HAPPENS HERE!
  81.         //
  82.         }
  83.  
  84. Yes, the problem is that alignment remains unchanged for my edits,
  85. althought WinSight shows me, that window style bits have been
  86. changed! For further investigation I've tried to play with
  87. ES_UPPERCASE and ES_LOWERCASE styles, and they both work, i.e.
  88. after I set a new style it's in effect immediately.
  89.  
  90. Of course, I can work around the problem by simply destroy and
  91. recreate windows with new style, but it seems, that I'm missing
  92. something simple...
  93.  
  94. I've tried to compile the program with both BC++ 3.1 and MSC 6.0
  95. with libraries from SDK 3.1 - no difference.
  96.  
  97. Any ideas? Please answer to my e-mail address, I don't read this
  98. newsgroup often. Thanks in advance!
  99.  
  100. /\\ichael Dvorkin,
  101. Vilnius, Lithuania                E-mail: misha@aiva.lt
  102. ---
  103.  
  104. ---
  105.  
  106.