Announcement

Collapse
No announcement yet.

Edit boxes and how they work....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Borje Hagsten
    replied
    Weekend? I started with one two months ago and still haven't got all
    done. Okay, so I haven't had a lot of time to work with it either,
    but still, code is now up to 160KB, and growing..

    When you start from scratch, you also discover how much there really
    is behind a "simple", standard edit control. It's very educational..


    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    Instance subclassing is much easier than superclassing, but, hey... there is nothing like a challenge for the weekend, right?

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Jules Marchildon
    replied
    Mark;

    The edit control gives you alot of stuff for free already. If you want
    to minimize the extra code, then subclass the control. The messages
    you want i.e. Tab & Enter Notifications can be generated by you simply
    by Message forwarding to your parent window. I just can't see this path
    to be a messy one.

    Regards,
    Jules

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Now the wind has changed, got to do a little tacking to sail
    into the wind. Sounds like the hard way to do it, but hey
    that's what makes the challenge SO MUCH fun.

    1. Set up a wndclass for the class name to use.
    2. Assign the wndproc for the class, OBTW a custom one
    for your particular situation. Don't forget to call the default
    proc for unprocessed messages.
    3. Register your class.
    4. Call CreateWindow() API function.

    That's it, minus a whole lot of coding for the class def and
    wndproc. Don't forget those nasty WM_NOTIFY messages you'll
    need to send to the parent of the edit control.

    Good Luck,
    Cecil

    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Thanks Cecil,

    But what I want to do is build my own custom edit box control. That way I can make it do what I want without having to twist and contort the windows controls.

    ------------------
    Cheers

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Haven't tested but this might work:

    fStyle = GetWindowLong(hEdit, %GWL_STYLE)
    fStyle = fStyle OR %ES_MULTILINE
    SetWindowLong hEdit, %GWL_STYLE, fStyle

    You might need to add a few more styles for
    scrollbars or whatever if I understand!

    Cheers,
    Cecil

    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Hey guys,

    Thanks for the pointers. I thought long and hard over subclassing but it seems very messy and If i'm going through the trouble of doing that much work than I might as well just write one myself. I don't need anything fancy just a multiline edit that can scroll over the text. I really dont mind forcing a maximum string length. These edit boxes will be used to enter text that resides inside a structure so fixed length strings works out great. Thanks again guys!

    ------------------
    Cheers

    Leave a comment:


  • Lance Edmonds
    replied
    It does sound like you may want to investigate Instance Subclassing (or possibly even superclassing).

    Essentially, Instance Subclassing lets you modify the behavior of a given control to suit your own needs.

    With Instance Subclassing, you "intercept" messages for a particular control, thereby giving you a chance to process messages before the control's own handler gets them. You can even swallow messages too.

    For the case you mentioned above, you would look for relevent %WM_CHAR messages, and either forward the message to the parent's callback, or send you own customized message to the parent.

    Most of the good Win32 programming books cover subclassing.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Borje Hagsten
    replied
    Basically speaking, an editor is nothing but an ownerdrawn window
    that uses a parser and TextOut to print the text to the screen.
    Simple, until you start doing one from scratch yourself. Then you
    discover how much code there really is behind the editor scene. The
    textbox probably is one of the most complicated controls of them all.
    Scroolbars, code to handle keyboard input, mouse and caret movements,
    text buffers, fast parsers, undo/redo memory buffers. Different kinds
    of painting procedures, depending on if text is selected ot not, etc.

    Good place to start is by looking at the translated Petzold samples
    available in PB's file area. There's one called "Typer there, in
    Chapter 5, which can serve as a base for your own edit control.
    There are also some samples of custom control editors in the source
    code forum that can be helpful to look at.


    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Edit boxes and how they work....

    Edit boxes and how they work....

    Hello Everybody,


    Does anyone know how or what API functions are called to get an edit box to display multiline text. What is happening when you scroll over the text? The reason I'm asking is because I want to make my own edit box that passes TABS,ENTER,etc.. back to the controls owner. Any ideas on how to start this little adventure?

    ------------------
    Cheers
Working...
X