Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Lorenz 3D - & question

  1. #1

    Lorenz 3D - & question

    Hi all,

    Another system of 3 non-lin dif equations ...
    You can use the arrow Pg U/D keys to navigate. - u can change the a , b & c parameter as well ...
    S saves an ASC file -- result via MeshLab (could be nice for a 3D print).

    Question : how do one stop the interaction between the arrow keys and the left textbox.


    t.i.a.

    Rob
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by RobbeK; 11-04-2014 at 00:53.

  2. #2
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    Quote Originally Posted by RobbeK View Post
    ...
    Question : how do one stop the interaction between the arrow keys and the left textbox.

    t.i.a.

    Rob
    Edit:
    The behaviour is sadly built-in to windows, seems the ms-developers standpoint is: Windows is the OS and the OS makes the rules how keys work so they occupied these keys (Tab, Arrows, Alt, F10 etc.) and all windows-users have to live with that decision now. However you may visit their compliant departement

    Don't know if helps - I append some complete list of UI-equates here, sorted by alphabet - can not be wrong to have it in stock and is much easier to read than ms-documentation, especially when searching for a certain message where you only have a small clue as "Focus" etc. (CTRL+F & F3 are your friends)

    The %WM_...Focus-messages seem only to apply to the window itself but in general any control is a window too - but I'd try the simple %BN_-messages as first - even if it's a canvas

    I guess there's some callback-event-msg for "Control Lost Focus" (KillFocus?) and you could recheck in this moment if still arrow-keys held (GetAsyncKeyState) and set focus back to picturebox, image, canvas etc.

    As I read on some MS-doc it's not recommended to set focus (f.e. back to the old control) within the Got-focus-event so one might do it already if the old control loses focus and before it's set to the new control.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by ReneMiner; 11-04-2014 at 10:31.
    I think there are missing some Forum-sections as beta-testing and support

  3. #3
    Ah, thanks very much sharing this -- I can use it ;-)

    Well, I first tried to change the object in focus inside the main timer loop (in RendermyImage ...) , but this only works if the refresh rate of this event is long enough to read another event. (= slow broken animations). If the refresh rate is very fast, the buttons , textboxes etc... can not be reached ....

    But a "set focus" call after each key is read seems to do the trick ...

    thanks again,

    Rob
    Attached Files Attached Files

  4. #4
    Member
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    406
    Rep Power
    56
    Cool Robby 3D Lorenz.

  5. #5
    Hello Rob,

    This one is really cool, thanks a lot!

    thinBasic uses "dialog" windows for its UI and indeed, this window class has inter-control focus-handling logic prebuilt in it, as ReneMiner notes correctly above. This is very convenient for document-handling interfaces but may become a nuisance for other tasks even if you use the SetFocus() API.

    An alternative way will be to create your own "frame" windows from scratch using CreateWindowEx() with your own custom window message handling. Frame windows are more generic than dialogs and they don't switch keyboard focus between controls automatically. You will be however responsible for creating your own keyboard focus scheme from ground up in any way you like. It may seem too complicated to do in every little demo but you can design an include file once and for all and simply add it to your new projects making minor adjustments to it only as needed for a particular application. Designing such an include file will however be a separate project unto itself and would require considerable effort and a lot of debugging and polishing.

    You can also change the behavior of keyboard focus for a particular standard control by subclassing its window and handling its window messages in your own custom event-handling function. This is however hardcore Windows programming that should be done only for some specific task in a given project.

    I don't think that such small snippets as we publish on the forum are really worthy of hardcore programming efforts. This means we should simply bear with these minor inconveniences as there is no easy way to remedy them immediately.

    Regards,
    Mike
    (3.6GHz i5 Core Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, x64 Windows 7 Ultimate Sp1)

  6. #6
    Thanks Peter,

    Hi Mike,
    Ah, ok .. I'm rather softcore these days... What's your opinion . did MS could have made it more complete ??
    With textboxes is not that of a disaster, but if sliders or in focus that's something else (they also react on the arrow-keys) - I also wonder why it specifically takes a certain object to correspondent with these keys ?
    Enfin, never mind - a SetFocus just after the key hit seems a cure. I also notice a difference between in and outside a timer loop .. !?

    Thanks for answering , Rob

  7. #7
    My advice is take a day off of mathematics, read up on RegisterClassEx()/CreateWindowEx()/WNDCLASSEX - they contain all the info needed to create user-defined frame windows. These windows don't have a hardcoded keyboard focus behavior and will allow you to use the arrow and letter keys for navigation and other purposes regardless of sliders and similar common controls.

    All this may, and can, be implemented in thinBasic and/or OxygenBasic scripts. Once done, you won't be restricted to the language's prebuilt functionality any more.

    [EDIT] I can't code in thinBasic fast enough but here's a quick and dirty sample written in FBSL. It can be reproduced easily in any BASIC that has access to WinAPI and variable/function pointers, including thinBasic and Oxygen. It generates a raw frame window whose handle (hMyWnd in this case) can be used to accomodate raw or language-specific controls. The controls will not however be governed by thinBasic's predefined dialog-based keyboard focus so your arrow and character keys may be used for navigation. Yet the focus may still be directed to a particular control by clicking it with the mouse or surfing the window with Tab presses till the focus reaches the control in question.
    Attached Files Attached Files
    Last edited by mike lobanovsky; 12-04-2014 at 01:04. Reason: Code snippet added
    Mike
    (3.6GHz i5 Core Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, x64 Windows 7 Ultimate Sp1)

  8. #8
    Thanks Mike,
    Already read the first links this night - downloaded your example now and I will study it.
    It seems it's even possible to create an extended window out of a non extended class registration (but I'll have to read this all again to absorb it).
    Somewhat complicated but IMHO the SetFocus switches also should work and doing the trick with a small amount of extra code. The only slight problem is of course when an object is used by the mouse it automatically gets the focus , this has to switched back to something where key activity is "void" .
    Attached something clearer than my explanation (Albert Einstein once said, if someone gives you a difficult explanation , he doesn't understand what he is talking about ;-) --

    best Rob.
    FBSL is still in the garage -- (I'm afraid of C , postponing learning it for many decades ))))
    (we had Pascal @ school / Lisp @ the job )
    Attached Files Attached Files
    Last edited by RobbeK; 12-04-2014 at 10:53.

  9. #9
    Rob,

    Using raw SetFocus() is not the best, and certainly not the most elegant, idea. It should be used in a subclassing scenario to completely preclude focus shifting to an unwanted target.

    So here's a more elaborate example to finish off this topic. It uses two buttons on a frame window. On app start, the focus can be toggled between the both buttons with Tab and arrow keys. You can see it by watching the focus rectangle switching from one button to the other (snapshot 1 below).

    Now when the focus is on the upper button, click it with the mouse or press Space to trigger its click. The click will subclass the lower button to reject keyboard focus completely. Now you will not be able to move the focus rectangle to it with either Tab or arrow keys and pressing Enter or Space will always trigger the upper button only (snapshot 2 below). However, you'll still be able to fire the lower button with a mouse click but not with a keyboard key press.

    The code uses one more function similar to the frame window function which replaces the lower button's original message handler routine with a user-defined function. Such replacement is called "subclassing". All the messages that the new handler doesn't process are transmitted to the button's original message handler. The original message handler should always be, and actually is, restored before the application quits. The code is commented and additional info and particularities can be googled in the MSDN.

    These techniques are natural to Windows programming in any language that permits them, and they can easily be reproduced in thinBasic and OxygenBasic too. This has nothing to do with FBSL's DynC and once you understand the logic of the process, you will be no more restricted to peculiarities of dialog windows which thinBasic is built around.

    Hope this helps,
    Attached Images Attached Images
    Attached Files Attached Files
    Mike
    (3.6GHz i5 Core Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, x64 Windows 7 Ultimate Sp1)

  10. #10
    Member
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    406
    Rep Power
    56
    here's another button test.
    Attached Files Attached Files

Page 1 of 2 12 LastLast

Similar Threads

  1. Lorenz Attractor2
    By peter in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 0
    Last Post: 06-04-2014, 16:31
  2. Lorenz Attractor
    By peter in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 0
    Last Post: 02-04-2014, 21:15
  3. Lorenz Butterfly
    By mike lobanovsky in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 7
    Last Post: 17-12-2013, 01:52
  4. C to TB question
    By Michael Clease in forum Other languages
    Replies: 2
    Last Post: 03-06-2010, 12:11
  5. UDT question
    By sandyrepope in forum thinBasic General
    Replies: 3
    Last Post: 18-02-2008, 22:33

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
  •