Results 1 to 3 of 3

Thread: Callbacks for user defined controls & menuitems

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170

    Callbacks for user defined controls & menuitems

    Many - not all- controls provide a syntax as
    Control Add xxx,[...],Style,ExStyle, Call EventHandler
    
    Where Eventhandler is the callback functions name that will handle events of that control.

    Some- as ListView or Viewport offer already to assign a NAME to the controls so its simple and not necessary to append
    "Call Eventhandler" explicitely because f.e."myListview_OnCallback" allows to handle the events in dedicated functions that only have to dimension local variables for the current CBCTL.

    Sadly its not possible to filter the callback on a menuitem that it would allow to connect a function instantly on creation to handle
    all events for that item and menu events are handled within the parenting dialog which leads to long "ladders" of
    CallBack Function MainWndProc() 
    
    Local <a bunch of variables but only a few are needed to handle the current event>
    Local <many of the variables are unused and only to be ready for another controls event>
    
    Static <requires additional conditional clauses mostly because this>
    Static <callback handles multiple events of different controls>
    
    select case message
        case messageX
             select case object
                  case objectY
                         select case ...
    
    Situation so far...

    now questions:

    ...
    Menu Add String hDlg, hMenu, "text", %IDM_myMenuItem, %MF_Enabled
    
    -no controls name that will enable "_OnCallback" nor call-syntax to assign a function to it-

    How can a apply a functions name to handle events for this menuitem only?
    How to tell thinBasic to call a dedicated callback function for this menuitem?
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    > How can a apply a functions name to handle events for this menuitem only?
    > How to tell thinBasic to call a dedicated callback function for this menuitem?

    You can't. A menu item is not a control. The only control is the menu, that manages an array of menu items, each of which is an structure holding relevant information, which does not include a pointer for a callback function.


    Last edited by José Roca; 05-09-2020 at 21:18.

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    Quote Originally Posted by José Roca View Post
    >
    You can't.

    okay that sounds better than that i was hoping for.
    So actually it only a static aligned to top of window that has to be clicked (%WM_Command) and from then it manages it by itself to measure to which "imaginary item" the next click will go? So wow- i can completely design the menubar-control by myself as soon i trapped the message that tells me the very first click onto the menubar occured open/draw and focussing and even different controls from that what the menus usually would offer is completely up to me?

    So i can draw it completely from scratch which allows even controls that are not designed yet?

    Would it equire some flag for Style as %SS_OWNERDRAW or %SS_USERITEM to set and the callback of the static (myMenubar-control, a label na lang) will receive a message that says:
    "Hey, you, wanna be a programmer? Then now direct me to how shall your user-defined control be drawn? I need instructions!"

    What would the callback message be, that i have to wait for? %WM_Paint | %WM_USER? any other that is known to be used in cases like this?

    What i see from thinbasic-help is no automated message that says OnPaint - the "Callback Function myMenubar.OnPaint()" would probably not get fired automatic -

    Can gdi draw simply on top of the windows surface and cover (full or partially) existing controls or - as in some cases menu-dropdowns exceed the size of a window: were it a good idea to draw directly on the desktop ?
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. User-defined typed lists
    By ReneMiner in forum General purpose scripts
    Replies: 0
    Last Post: 30-05-2013, 10:55
  2. Article: User defined entities
    By Petr Schreiber in forum vBCms Comments
    Replies: 0
    Last Post: 03-01-2011, 20:52
  3. User Defined Types
    By Charles Pegge in forum O2h Compiler
    Replies: 3
    Last Post: 18-03-2009, 01:28
  4. New in UI module: Controls CALLBACKs
    By ErosOlmi in forum thinBasic vaporware
    Replies: 13
    Last Post: 12-07-2008, 16:45

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •