Announcement

Collapse
No announcement yet.

XPRINT and html file

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

  • #21
    I know, but I was desperate: if there was a %WM_NUKEITTOHELL, I would have tried it.
    I can even try RTFM, but how confing can it be if to delete a control, you need a DestroyWindow()?
    I'm going to miss DDT...
    Well, DestroyWindow() is the only way to delete a control from a screen. PB DDT only converts 'CONTROL KILL' into a call to DestroyWindow(). (If it's a PB GRAPHIC window, you use some other command, GRAPHIC END I think. I am not a PB DDT/GRAPHICS guy).

    BUT.... "Another technique" would be to HIDE the window and let it be destroyed when the parent window is destroyed.. often at the end of the program. User can't see it, it leaves the tab order and may as well not be there at all. But frankly if my app indicated the window should move into history, I'd just call DestroyWindow().

    As far as using DDT... there is some member here who is always insisting that PB users create at least one screen-type program using non-DDT methods of creating and managing a screen. Sounds like good advice to me, and you should probably pay more attention to that member.

    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #22
      Originally posted by Andrea Mariani View Post
      how confing can it be if to delete a control, you need a DestroyWindow()?
      To MS, a control IS a window:
      https://docs.microsoft.com/en-us/win...indow-controls
      "A control is a child window that an application uses in conjunction with another window to enable user interaction."

      there is some member here who is always insisting that PB users create at least one screen-type program using non-DDT methods of creating and managing a screen Sounds like good advice to me,
      Sounds like unnecessary elitism to me.
      In 20 odd years of professional development using PB, I've never needed to do so.

      Comment


      • #23
        For guys that started with SDK, their lexicon would be familiar.

        I am an "old" Commodore PET --> GWBASIC --> PDS 7.0 --> PB freetime user (professionally iSeies and RPG) and undertanding DSK dialect without any background is confusing at most.

        Even when I copy code from here to use and it's SDK, I find it hard to digest. So when I read DestrowWindow() I was reluctant to use it as I thought it's equivalent to DIALOG END.

        Then there is Jose Roca's toolkit which is even more confusing....

        I wish I could retire (10 more years) - Then I may sit down and study SDK.

        Now back to search how to use STN_CLICKED in my %WM_NOTIFY ad I need to trap a Click on a label.
        Andrea Mariani
        AS/400 expert
        Basic programmer @ Home

        Comment


        • #24
          Originally posted by Andrea Mariani View Post
          Now back to search how to use STN_CLICKED in my %WM_NOTIFY ad I need to trap a Click on a label.
          It's not %WM_NOTIFY.

          It's %SS_NOTIFY stye for the label and %STN_CLICKED in %WM_COMMAND.

          https://docs.microsoft.com/en-us/win...ls/stn-clicked
          "The STN_CLICKED notification code is sent when the user clicks a static control that has the SS_NOTIFY style. The parent window of the control receives this notification code through the WM_COMMAND message."


          Here's all that's needed:

          '
          Code:
           ...
           ' In Dialog builder
              CONTROL ADD LABEL, hDlg,   %IDC_lblItems  ,"Items", 75,50,50,20, %SS_NOTIFY OR _
                  %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_CENTERIMAGE, %WS_EX_LEFT OR _
                  %WS_EX_LTRREADING
           ...
          ' In Callback
              SELECT CASE AS LONG CB.MSG
                   CASE %WM_COMMAND
                      SELECT CASE AS LONG  CB.CTL
                             CASE  %IDC_lblItems
                              IF CB.CTLMSG  = %STN_CLICKED THEN
                                SHowItems
                              END IF
                      END SELECT
              END SELECT
          ...
          '

          Comment


          • #25
            Oh give me a hug! :-)

            Even PB guide is not clear:
            %SS_NOTIFY Send %STN_CLICKED and %STN_DBLCLK notification messages to the Callback Function when the user clicks or double-clicks the control.
            Being $SS_NOTIFY and mentioning notification messages, I assumed:

            case %wm_notify

            if cb.ctl >= %d02.tbunicode THEN

            select case cb.ctlmsg
            case %STN_CLICKED
            beep
            case %STN_DBLCLK
            ? format$(cb.ctl)
            end select
            end if


            And nothing happened. :-(

            I'll do as you suggest, I'm sure it will work. :-)

            BTW, how can I send a character to the keyboard, so that it writes that character where the cursor is?

            The idea is that I show a Unicode Table, and the user clicks on the Math symbol it needs.
            Plan B would be Clipboard Set Text...
            Andrea Mariani
            AS/400 expert
            Basic programmer @ Home

            Comment


            • #26
              Originally posted by Andrea Mariani View Post
              BTW, how can I send a character to the keyboard, so that it writes that character where the cursor is?

              The idea is that I show a Unicode Table, and the user clicks on the Math symbol it needs.
              Plan B would be Clipboard Set Text...[/FONT]
              If you want to add it to what has been entered in a texbox, then it's as simple as this.

              Code:
                  CASE %IDC_btnInfinity  'Infinity symbol
                      IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                          CONTROL GET TEXT ,CB.HNDL %IDC_txtFormula TO wstrTemp
                          CONTROL SET TEXT ,CB.HNDL %IDC_txtFormula, wstrTemp & CHR$$(8734)
                      END IF
              If you want to be able to enter it into the middle of a string of text, it gets a bit more complicated because you have to locate the cursor position and add the character there.

              You'll need to do a bit of work with
              CONTROL SEND hDlg, %ID_EDIT, %EM_SETSEL and : CONTROL SEND hDlg, %ID_EDIT, %EM_GETSEL
              before and after the SET TEXT

              Comment


              • #27
                Just knocked up a quick demo to insert the symbol at the current caret location on a button click.

                With a bit more work you can do the same sort of thing with a click on a cell in a listbox or listview or by selecting from some other control
                '
                Code:
                #COMPILE EXE
                #DIM ALL
                %UNICODE = 1
                #INCLUDE "WIN32API.INC"
                
                ENUM ctrls SINGULAR
                  IDC_Quit = 1001
                  IDC_btnInfinity
                  IDC_txtFormula
                  IDC_txtFormula2
                END ENUM
                
                FUNCTION PBMAIN() AS LONG
                    MainDLg 0
                END FUNCTION
                
                FUNCTION MainDlg (hParent AS DWORD) AS LONG
                   LOCAL lRslt AS LONG
                   LOCAL hDlg  AS DWORD
                    DIALOG DEFAULT FONT "Arial Unicode MS",12,0,0
                    DIALOG NEW hParent, "Add Symbol Demo", , , 150, 100, %WS_POPUP OR %WS_BORDER _
                        OR %WS_DLGFRAME OR %WS_MINIMIZEBOX OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR _
                        %DS_MODALFRAME, TO hDlg
                    CONTROL ADD TEXTBOX, hDlg, %IDC_txtFormula,"", 40,20,80,10
                    CONTROL ADD TEXTBOX, hDlg, %IDC_txtFormula2,"", 40,40,80,10
                    CONTROL ADD BUTTON , hDlg,%IDC_btnInfinity,CHR$$(8734),40,50,20,20
                    CONTROL ADD BUTTON , hDlg,%IDC_Quit,"Quit",40,70,80,20
                
                    DIALOG SHOW MODAL hDlg, CALL MainDlgCB TO lRslt
                END FUNCTION
                
                CALLBACK FUNCTION MainDlgCB()
                    STATIC LastControl AS LONG
                    SELECT CASE AS LONG CB.MSG
                        LOCAL wstrTemp AS WSTRING
                        LOCAL lngSelStart, lngSelEnd AS LONG
                        CASE %WM_INITDIALOG
                            LastControl = %IDC_txtFormula
                
                        CASE %WM_COMMAND
                            SELECT CASE AS LONG CB.CTL
                
                                CASE %IDC_txtFormula TO %IDC_txtFormula2
                                    IF CB.CTLMSG = %EN_SETFOCUS THEN LastControl = CB.CTL
                
                                CASE %IDC_QUIT
                                    IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                        DIALOG END CBHNDL
                                     END IF
                
                
                                 CASE %IDC_btnInfinity  'Infinity symbol
                                    IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                        CONTROL GET TEXT CB.HNDL ,LastControl TO wstrTemp
                                         CONTROL SEND CB.HNDL, LastControl, %EM_GETSEL,VARPTR(lngSelStart),VARPTR(lngSelEnd)
                                         wstrTemp = LEFT$(wstrTemp,lngSelSTart) & CHR$$(8734) & MID$(wstrTemp,lngSelEnd+1)
                                        CONTROL SET TEXT CB.HNDL ,LastControl, wstrTemp
                                        CONTROL SEND CB.HNDL, LastControl, %EM_SETSEL, lngSelStart+1,lngSelStart+1
                                        CONTROL SET FOCUS CB.HNDL, LastControl
                                    END IF
                            END SELECT
                    END SELECT
                END FUNCTION
                '
                Last edited by Stuart McLachlan; 10 Oct 2020, 10:31 AM. Reason: Added mutiple text box detection

                Comment


                • #28
                  Very nice and clear... But I have an issue:
                  My cursor could be in %IDC_Question or %IDC_MultipleChoice{1 to 4} or %IDC_FillIn{1-4} - I need to know in which %IDC my cursor is blinking.

                  If I read the manual correctly, %EM_GETHANDLE?
                  Andrea Mariani
                  AS/400 expert
                  Basic programmer @ Home

                  Comment


                  • #29
                    Originally posted by Andrea Mariani View Post
                    Very nice and clear... But I have an issue:
                    My cursor could be in %IDC_Question or %IDC_MultipleChoice{1 to 4} or %IDC_FillIn{1-4} - I need to know in which %IDC my cursor is blinking.

                    If I read the manual correctly, %EM_GETHANDLE?
                    One way would be to set a static (or global) variable to the control ID when any textbox gets an %EN_SETFOCUS message and use that in the button click.

                    Comment


                    • #30
                      I was on that path.
                      Thanks for confirming it. I will implement it.
                      Andrea Mariani
                      AS/400 expert
                      Basic programmer @ Home

                      Comment


                      • #31
                        I wish I could retire (10 more years) - Then I may sit down and study SDK.
                        Hmmm... I studied SDK so that I could retire.



                        Michael Mattias
                        Tal Systems Inc. (retired)
                        Racine WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #32
                          GetFocus returns handle of control in focus.
                          Combination GetDlgCtrlID(GetFocus) returns id of control in focus.

                          Comment


                          • #33
                            Code:
                            case %wm_notify
                            
                            if cb.ctl >= %d02.tbunicode THEN
                            ... nothing happened
                            CB.CTL is only the control ID when the message (CB.MSG) is WM_COMMAND. Under WM_NOTIFY you get the control ID from CB.NMID

                            FWIW, it would be kind of strange to look for a control ID which is equal to or greater than some target value. When the processing is the same for multiple controls I would suggest using ether a discrete set of values....

                            Code:
                            SELECT CASE CB.CTL ( or CB.NMID)
                               CASE %Control1, %Control2,%Control3 ...
                                   common action, these controls
                            OR a range ....
                            Code:
                                  SELECT CASE CB.CTL ( or CB.NMID)
                                    CASE %Control1 TO %control3
                                        common action, these controls


                            These become really handy when you go to change the program down the line. If you are fairly new I'd suggest tthis would be a good habit to acquire.

                            MCM
                            Last edited by Michael Mattias; 10 Oct 2020, 11:16 AM. Reason: Correct typos "CBN.MSG" to "CB.MSG" and "WIM_NOTIFY" to "WM_NOTIFY"
                            Michael Mattias
                            Tal Systems Inc. (retired)
                            Racine WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #34
                              Originally posted by Andrea Mariani View Post
                              Very nice and clear... But I have an issue:
                              My cursor could be in %IDC_Question or %IDC_MultipleChoice{1 to 4} or %IDC_FillIn{1-4} - I need to know in which %IDC my cursor is blinking.

                              If I read the manual correctly, %EM_GETHANDLE?
                              I've modified Post #27 to keep track of which textbox is in use.

                              Please don't ask another different question in this thread.

                              You've gone from XPRINT and HTML to destroying controls to adding content to text all in the same thread with the Subject "XPRINT and HTML" which makes it different for people to find the answers to these other questions later.

                              If you have a different question, please start a new thread with an appropriate title.

                              Comment


                              • #35
                                Code:
                                CASE %WM_COMMAND
                                ' Process control notifications
                                            IF CB.CTLMSG = %EN_SETFOCUS THEN
                                                SELECT CASE LONG CB.CTL
                                                    CASE %d02.tbQuestion, %d02.tbAnswer1, %d02.tbAnswer2, %d02.tbAnswer3, %d02.tbAnswer4
                                                        lIdc = CB.CTL
                                                    CASE ELSE
                                                       lIdc = 0
                                                END SELECT
                                            END IF
                                
                                            SELECT CASE AS LONG CB.CTL
                                                CASE %mnu.exit      ' Exit program                                                     
                                ...
                                                CASE %d02.CbUnicode
                                                    COMBOBOX GET SELECT CB.HNDL, %d02.cbUnicode TO r
                                                    IF r THEN
                                                        FOR y = 0 TO 15
                                                            FOR x = 0 TO 7
                                                                CONTROL SET TEXT CB.HNDL, %d02.tbUnicode + y*8+x, gzUnicode(r,x,y)
                                                            NEXT x
                                                        NEXT y
                                                    END IF
                                                CASE %d02.lbUnicode TO %d02.lbunicode + 127
                                                    IF CB.CTLMSG  = %STN_CLICKED THEN
                                                        IF lIdc THEN
                                                        zChar = GetText(CB.HNDL, CB.CTL)
                                                            IF LEN(zChar) THEN
                                                                CONTROL GET TEXT CB.HNDL, lIdc TO sTxt
                                                                CONTROL SEND CB.HNDL, lIdc, %EM_GETSEL,VARPTR(lSelStart),VARPTR(lSelEnd)
                                                                sTxt = LEFT$(sTxt,lSelStart) & zChar & MID$(sTxt, lSelEnd+1)
                                                                CONTROL SET TEXT CB.HNDL, lIdc, sTxt
                                                                CONTROL SEND CB.HNDL, lIdc, %EM_SETSEL, lSelStart+1, lSelStart+1
                                                                CONTROL SET FOCUS CB.HNDL, lIdc
                                                            END IF
                                                        END IF
                                Andrea Mariani
                                AS/400 expert
                                Basic programmer @ Home

                                Comment


                                • #36
                                  Originally posted by Borje Hagsten View Post
                                  GetFocus returns handle of control in focus.
                                  Combination GetDlgCtrlID(GetFocus) returns id of control in focus.
                                  But when you click the button, the textbox no longer has focus

                                  Comment


                                  • #37
                                    You are correct, that documentation under CONTROL ADD LABEL regarding the use of style SS_NOTIFY is, er, uh, "shaky."

                                    I made an improvement suggestion in the ON-line help forum which you may view here.......

                                    https://forum.powerbasic.com/forum/a...845#post800845


                                    MCM
                                    Michael Mattias
                                    Tal Systems Inc. (retired)
                                    Racine WI USA
                                    [email protected]
                                    http://www.talsystems.com

                                    Comment


                                    • #38
                                      Originally posted by Stuart McLachlan View Post

                                      But when you click the button, the textbox no longer has focus
                                      But mine are not buttons, they are labels, focus not lost.
                                      Downside I can't read the text label.

                                      But I have a workaround.

                                      Andrea Mariani
                                      AS/400 expert
                                      Basic programmer @ Home

                                      Comment


                                      • #39
                                        Originally posted by Stuart McLachlan View Post
                                        If you have a different question, please start a new thread with an appropriate title.
                                        I'm sorry, you are perfetcy right. I continued here because it is the same project I'm doing.

                                        I kindely request a moderator to split the thread.
                                        Andrea Mariani
                                        AS/400 expert
                                        Basic programmer @ Home

                                        Comment


                                        • #40
                                          Originally posted by Michael Mattias View Post
                                          [FONT=Courier New]
                                          CB.CTL is only the control ID when the message (CBN.MSG) is WM_COMMAND. Under WIM_NOTIFY you get the control ID from CB.NMID
                                          Noted. This is new info for me.

                                          FWIW, it would be kind of strange to look for a control ID which is equal to or greater than some target value. When the processing is the same for multiple controls I would suggest using ether a discrete set of values....
                                          That sniplet was for testing purposes only.
                                          It's now Case %d02.lbUnicode to %d02.lbunicode + 127

                                          And my ENUM is

                                          bnNext
                                          line1
                                          lbUnicode
                                          cbUnicode
                                          tbUnicode 'Must be last!
                                          END ENUM

                                          bnNext
                                          line1
                                          lbUnicode
                                          cbUnicode
                                          tbUnicode 'Must be last!
                                          END ENUM


                                          Andrea Mariani
                                          AS/400 expert
                                          Basic programmer @ Home

                                          Comment

                                          Working...
                                          X