BBC BASIC for Windows
Programming >> User Interface >> Windows Text box (dissection for understanding)
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1459812887

Windows Text box (dissection for understanding)
Post by michael on Apr 4th, 2016, 11:34pm

I think this is going to work well.

I had to make REM statements all over the original sample program to get this far and then I modified the text input and window..
Also I modified the text input to have a user sample code supplied..
So the program can supply the text box with a message and this will work nicely
But
1) I need to have at least 3 lines of information showing at a time for my tool and it must scroll like in a normal editor
2) Each line must be its own string (like in a IDE)
3) I must be able to insert a new string in the editor at the active line ( for POV draw to code insertion)
4) I must be able to place this input control anywhere and it must not interfere with main window function
( I could use mouse click to edit it, but it would be nice to just type and press enter to give my game a command)

( remember the good old days in gaming?)
"open box"
"The box is empty"
"kill dragon"
"Its too big and devours you"
"game over"
Code:
     
 REM. Program to demonstrate a Dialogue Box
      INSTALL @lib$+"WINLIB2"

      BS_DEFPUSHBUTTON = &1
      CB_ADDSTRING = &143
      CB_SETCURSEL = &14E
      CBS_DROPDOWNLIST = &3
      ES_AUTOHSCROLL = &80
      ES_NUMBER = &2000
      LB_ADDSTRING = &180
      LB_GETCURSEL = &188
      UDM_SETRANGE = &465
      UDS_ALIGNRIGHT = &4
      UDS_AUTOBUDDY = &10
      UDS_SETBUDDYINT = &2
      WS_CHILD = &40000000
      WS_GROUP = &20000
      WS_VISIBLE = &10000000
      ES_MULTILINE = 500
      REM  dlg%=FN_newdialog("", 20, 20, 160, 128, 8, 560)
      dlg%=FN_newdialog("", 20, 20, 800, 50, 8, 560)
      activemessage$="FOR X = 1 TO 1000"
      REM PROC_editbox(dlg%, activemessage$, 101, 1, 20, 104, 12, ES_AUTOHSCROLL)
      REM *******************************x, y,  h  ,v  ,  ?, autoscroll is self explained.
      PROC_editbox(dlg%, activemessage$, 101, 1, 1, 700, 12, ES_AUTOHSCROLL)
      PROC_showdialog(dlg%)
      ON CLOSE PROC_closedialog(dlg%):QUIT
      ON ERROR PROC_closedialog(dlg%):PRINT'REPORT$:END
      Click%=0
      ON SYS Click% = @wparam% : RETURN
      REPEAT
        WAIT 1
        click%=0
        SWAP Click%, click%
      UNTIL click%=1 OR click%=2 OR !dlg%=0

      IF click%=1 THEN
        PRINT "OK pressed, settings were:"'
  
        DIM text% 255
        SYS "GetDlgItemText", !dlg%, 101, text%, 255
        PRINT "Text box contained """$$text%""""
  
      ELSE
        PRINT "Program exited"
      ENDIF

      PROC_closedialog(dlg%)
      END
 

Re: Windows Text box (dissection for understanding
Post by Zaphod on Apr 4th, 2016, 11:55pm

Just to mention that in BB4W, unlike LB, it is designed so that can put things in the main window, and probably would. So you need to look at WINLIB5. Indeed LBB editor is actually run as two RichEdit Controls in the Main window.
Code:
H2%=FN_createwindow("RichEdit20W", "", 0, T1%, @vdu%!208, @vdu%!212-T1%-y%, 0, &B00044, 0)
I2%=FN_createwindow("RichEdit20A", "", @vdu%!208/2, T1%, @vdu%!208/2, @vdu%!212-T1%-y%, 0, &10B00804, 0) 

Re: Windows Text box (dissection for understanding
Post by michael on Apr 5th, 2016, 12:08am

Even in LB I didn't learn to do this. Its the same story concerning APIs.. I always avoided them. (mostly)

Mainly because I am always looking for simple one line commands that allow me to have complete control of the entire function within the command.

I really am trying to break this bad habit, because I avoid many beneficial things by reinventing things..
It would be good for me to learn how to break it down into small functional snippets for people who are new to programming.
( newer than me. and I know there are people like that who would come here..)
I am a beginner in BBC Basic, but there are people who really have no programming experience at all that would need really simple examples that do ONE function at a time.
The examples provided don't all have that kind of break down. Its normally many functions in one.
The sample file list would be HUGE if they did that.

But the sample I got this from was easy enough that I could extract this.

With your help I can help make that list.

Re: Windows Text box (dissection for understanding
Post by Zaphod on Apr 5th, 2016, 12:39am

There are lots of programs in the Yahoo group files

https://groups.yahoo.com/neo/groups/bb4w/files

Richard has recently closed that again for messages, as he does from time to time when he gets annoyed with people or yahoo, but the files remain open to members. There are some gems and a lot of other stuff there, but plenty to learn from. There are some great program listings on Richard's web site. I am not sure what you expected to find. Programming for windows without using the Windows API is what the libraries are for.