🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7342

Re: Multi line edit control foe ListView

#7342
From: Sam S. Firouz
Date: Tue, 08 Feb 2005 20:18
115 lines
4783 bytes
Here is what I am doing:
LRESULT CALLBACK MyEditWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM 
lParam)
{
 LRESULT RetVal(0);

 if(uMsg == WM_WINDOWPOSCHANGING)
 {
  // this inline editor has a bad habit of re-positioning itself
  // back on top of the Caption after every key typed in,
  // so let's stop it from moving

  WINDOWPOS *WindowPos = (LPWINDOWPOS)lParam;
  WindowPos->flags |= (SWP_NOMOVE | SWP_NOSIZE);
 }
 else // everything else
  RetVal = CallWindowProc(OldEditProc, hwnd, uMsg, wParam, lParam);
   return RetVal;
}
bool __fastcall TListViewEx::CanEdit(TListItem* Item)
{
 bool RetVal(true);

   if (0 < ColumnToEdit)  // ignore the Caption, let it do its default 
handling
   {
    if (NULL != FOnSubItemEditing)
       FOnSubItemEditing(this, Item, ColumnToEdit, RetVal);
      if (RetVal)
      {
         HWND hEdit = ListView_GetEditControl(Handle);   // get the inline 
editor's handle
         SetWindowLong(hEdit, GWL_STYLE, ES_MULTILINE);

         if (NULL != hEdit)
         {
            TRect R;

            if(GetEditRect(Item, ColumnToEdit, R)) // determine the 
dimensions of the subitem being edited
            {
               MYWNDPROC TempEditProc;
               LONG TempStyle;

               // move the inline editor over the subitem
               MoveWindow(hEdit, R.Left, R.Top - 2, R.Width(), R.Height() + 
4, TRUE);

               // update the inline editor's text with the subitem's text 
rather than the Caption
               SetWindowText(hEdit, 
Item->SubItems->Strings[ColumnToEdit -1 ].c_str());

               // subclass the inline editor so we can catch its movements
               TempEditProc = (MYWNDPROC)GetWindowLong(hEdit, GWL_WNDPROC);
               if (TempEditProc != (MYWNDPROC)MyEditWndProc)
               {
                  OldEditProc = TempEditProc;
                  SetWindowLong(hEdit, GWL_WNDPROC, (LONG)MyEditWndProc);

                  // Get The Current Style;
                  TempStyle = GetWindowLong(hEdit, GWL_STYLE) | ES_MULTILINE 
| ES_AUTOVSCROLL;
                  SetWindowLong(hEdit, GWL_STYLE, TempStyle);
               }
            }
         }
      }
   }
   else if (NULL != OnEditing)
    OnEditing(this, Item, RetVal);
   return RetVal;
}
since I have added the Get/SetWindowLong(GWL_WNDPROC), as soon as the Edit 
control is displayed, an exception thrown with the error message that cannot 
access address 00000100.

Thank you
Sam

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:420900fb$1@newsgroups.borland.com...
>
> "Sam S. Firouz" <sfirouz@Hotmail.com> wrote in message
> news:4208d83b$1@newsgroups.borland.com...
>
>> 1 - Does any one know how to make that window a Multi line edit window?
>
> Once you have the handle, to can use Get/SetWindowLong(GWL_STYLE) to give 
> it
> the ES_MULTILINE style.
>
>> 2 - What message should I be listening for to be notified when
>> the text of the edit control has changed so I can resize the
>> edit control accordingly?
>
> The ListView should receive EN_UPDATE notifications via the WM_COMMAND
> message when the child edit control changes.
>
> Also, you can subclass the edit window' handle via
> Get/SetWindowLong(GWL_WNDPROC) and have your own window procedure check 
> for
> the WM_WIDOWPOSCHANGING message.  Every time a character is typed, the 
> edit
> window tries to resize and reposition itself automatically.  You can
> override the message's default values to specify your own size and 
> position
> values before then passing the message to the edit window's original 
> window
> procedure.
>
>
> Gambit
>
> 
Technical Details
Message-ID: <42091d9a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4208d83b$1@newsgroups.borland.com> <420900fb$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,1917315e7e13daf3
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Sam S. Firouz" <sfirouz@Hotmail.com>
From: "Sam S. Firouz" <sfirouz@Hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4208d83b$1@newsgroups.borland.com> <420900fb$1@newsgroups.borland.com>
Subject: Re: Multi line edit control foe ListView
Date: Tue, 8 Feb 2005 15:18:34 -0500
Lines: 117
Organization: F. C. C.
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 132.250.186.165
Message-ID: <42091d9a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1107893658 132.250.186.165 (8 Feb 2005 12:14:18 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail