Something similiar to VB Code Editor ???

tcywlw
tcywlw used Ask the Experts™
on
I would like to create a editor that is similiar to
VB code editor. I also have this config file :

[StartA]
Apple
Angle

[StartB]
Boy
Bay
Baby

[StartC]
Car
Care
Cole
Caution


So, when I type StartA with a period, like StartA., then
I will see a square box will a list of Apple, Angle to
let me select. When I select Angle, and hit ENTER or use
mouse click somewhere on the editor, then Angle will
be appended to StartA., just like StartA.Angle.

If I type StartD., I should not see square box, because
StartD does not appear in the config file.


A very simple exmaple is welcome. If this is a complicated
program, please give me detial for how to do it. Thanks !

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
You could process the keypress event - when they press a "." scan backwards to get the word they just entered "StartA".

Then have a class which holds the list of available "dropdowns" (or "properties" for want of a better word).

Given a collection which holds all the top level (StartA/B/C), you can easily get the class from that collection.  

If the class itself holds a collection of the class objects, then it can be used to drill down the various properties (only 1 in your case, but could easily be extended).

eg:

' ClassProp

public Name as string
private col as collection

...various functions for adding/remove/lookup in col...

public sub AddProp(strName as string)
   dim obj as ClassProp
   set obj = new classprop
   obj.name = strname
   col.additem obj, strname
end sub



Once you have a list of available properties for any given property, you could populate a floating listbox filled with the properties, positioned to the correct place (you'll probably need some API calls to find the screen location to display the listbox).  Set the listbox focus when it appears then close it on lose focus event (to handle clicking elsewhere) or close it on certain keypresses to the listbox (eg enter, space, dot)

Then when hiding the listbox, add the listbox.text to the edit window.

The hardest bit will be positioning the listbox.


Author

Commented:
Nazdor,

Sound like what I have in my mind. But can you give me
more infor on collection ?
Commented:
Other than the code I already posted and:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconthevisualbasiccollectionobject.asp

I'm not sure what sort of information you need, or that I can give you... if this isn't enough, try something more specific
Author of the Year 2009

Commented:
Hi tcywlw,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Nazdor's comment(s) as an answer.

tcywlw, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial