Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Problem with New Development, Maybe?

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

  • Problem with New Development, Maybe?

    Hi,

    This Sub Routine worked yesterday before upgrade to PBWIN80 VER 8.04? I think?
    Now, the mouse click on [Cancel] button will not close?
    Code:
    DIALOG NEW PIXELS, 0, "", , , 660,700, _ 
            %WS_SYSMENU OR %WS_OVERLAPPEDWINDOW OR %WS_CLIPCHILDREN, 0 TO hDlg43  
    CONTROL ADD GRAPHIC, hDlg43, %ID_FRAM, "",        0, 0, 660, 700    
    CONTROL ADD BUTTON, hDlg43, %IDC_CAN, "&Cancel",300,670,80,20 
    GRAPHIC ATTACH hDlg43, %ID_FRAM
    GRAPHIC RENDER "PICT\BaloonBorder2.bmp", (0, 0)-(660,700)
    CONTROL ADD TEXTBOX, hDlg43, %IDS_TEXT, "",      45,45,570,680, _      
           %ES_MULTILINE OR %ES_READONLY OR %ES_AUTOHSCROLL OR %ES_WANTRETURN, %WS_EX_CLIENTEDGE  
    
    '------------------------------------------------------------------
    CALLBACK FUNCTION BirthAnnivCALLBACK()
          SELECT CASE CBMSG
          CASE %WM_INITDIALOG                         ' <- sent right before the dialog is displayed.
            CONTROL SET FOCUS CBHNDL, %IDC_CAN        ' Added 10-10-2007 or button didn't work?
              CASE %WM_COMMAND                        ' <- a control is calling
                SELECT CASE CBCTL                     ' <- look at control's id
                   CASE %IDCANCEL
                      IF CBCTLMSG = %BN_CLICKED THEN  ' end prog on Esc
                         DIALOG END CBHNDL, 0         ' Means go back to SUB BirthAnniv
                      END IF
                   CASE %IDC_CAN                      ' end prog on Stop [Cancel]
                      IF CBCTLMSG = %BN_CLICKED THEN
                       SLEEP 500
                       DIALOG END CBHNDL, 1           ' Means go back to SUB BirthAnniv
                      END IF
                END SELECT
          END SELECT
        END FUNCTION
    Last edited by BRENT GARDNER; 10 Oct 2007, 11:12 AM.

  • #2
    Code not close to being a compilable example, but

    > but mouse left click on button closes.

    In your callback, clicks on either button for which code is written engender a DIALOG END, which is designed to "close" the dialog.

    >DIALOG END CBHNDL, 0 ' Means go back to SUB ...

    Only true if you used DIALOG SHOW MODAL in subject SUB, code not shown.

    Of course...
    Code:
    DIALOG END CBHNDL, 0         ' Means go back to SUB BirthAnniv
    ...
    DIALOG END CBHNDL, 1           ' Means go back to SUB BirthAnniv
    .. depending on which button is clicked, the return code (as in "DIALOG SHOW MODAL hDlg TO lresult&" ) is different, and we can't tell what affect that has on your program because... you guessed it..."Code Not Shown."

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

    Comment


    • #3
      Definetly something is wrong. Now my sub routine that selects paper
      tray will not function? It has a "GRAPHIC CONTROL". The Add Graphic control is not acting properely?

      Comment


      • #4
        >Now my sub routine that selects paper tray will not function

        Compilable example demonstrating problem not shown.
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Shouldn't there be an %SS_NOTIFY flag for the control if you want to capture the mouse clicks?
          C'ya
          Don

          http://www.ImagesBy.me

          Comment


          • #6
            Don,

            You saved the day, what is left of it. Just about ready to trash
            software and computer. I have never had to use %ss_notify in
            previous versions but the 8.04 needs it. I tried the %ss_notify
            earlier, but had a typo in the case statement and so disregarded
            as not being answer.

            Thank you, Thank you,

            Would be nice if Power Basic would have mentioned it. Got email
            from support and they said nothing had changed with the CONTROL
            ADD GRAPHIC. It now NEEDS %SS_NOTIFY!!!!!!!!

            Comment


            • #7
              From the PB/Win 8.03 help file:
              A graphic control will only send notification messages to a callback if the %SS_NOTIFY style is used.
              If you make use of undocumented behaviour, it's your problem if this changes at the next update!

              Comment


              • #8
                Even though this is probably obvious to most, it would be helpful for beginners if a snippet showing the code correction(s) was posted. Thanks.

                Comment


                • #9
                  Now, problem is user can click anywhere on Graphic control to close.
                  They don't have to click on button to close? But without %SS_NOTIFY Style on Graphic control, mouse left click on button will not execute.?
                  What a mess! This affects entire 4 programs I'am working on.

                  Comment


                  • #10
                    Have you used a constant of the same value for 2 different controls? You seem to use both %IDC_CAN and %IDCANCEL to identify your button in different parts of the code!

                    Otherwise I can't see how adding %SS_NOTIFY to CONTROL ADD GRAPHIC can affect your cancel button (you should only need this style to pick up clicks on the graphic control itself - clicks on buttons notify the callback by default).

                    Comment


                    • #11
                      My guess, as Simon's, is that a duplicate control ID is being used, or the ID is not checked in response to WM_COMMAND, in this code shown it is, so it's more than likely a duplicate ID.
                      Last edited by Kev Peel; 11 Oct 2007, 10:24 AM.
                      kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                      Comment


                      • #12
                        OK Guys here's the problem.

                        Through out my program, I have buttons on top of a Graphic Control.
                        Usually just to show user how to close, instead of clicking the "x" in upper right hand corner. I checked duplicate id's, not so. After further
                        testing, If button is added before Graphic control(and no notify), then of
                        course it is covered by Graphic control, but if I click in area where it is,
                        it shows up and closes. If button is added after Graphic control, it shows on screen, but when you left mouse click on it, nothing happens. So, with this version 8.04, you have to add %SS_NOTIFY to graphic
                        control to get button to execute. It will not execute if it is on top of Graphic control unless Graphic control has %SS_NOTIFY style. Then in CALLBACK FUNCTION, you have to do a Dialog end cbhndl FOR THE GRAPHIC
                        CONTROL - or button does nothing.
                        Last edited by BRENT GARDNER; 11 Oct 2007, 12:50 PM.

                        Comment


                        • #13
                          Well, having 'active' controls overlapping is non-standard, so expect non-standard behavior! If two controls that both react to mouse clicks overlap, I guess it is undefined which one gets the message if you click in the area common to both (or which one's ID is passed to the dialog callback).

                          But that doesn't explain why your DIALOG END procedure is being called when you click within the graphic control but outside the area of the Cancel button, since you are specifically testing for that button's ID in your callback.

                          I suggest you move the Cancel button temporarily away from the graphic control for testing puposes, to eliminate problems caused by the overlap. Any remaining problems are then down to more straightforward coding errors.

                          Comment


                          • #14
                            Simon,

                            Have already tested button below graphic control and will work, but that doesn't solve my 4 programs worth of buttons on graphics. I can't just
                            change all code. It would not look good either. I had a line control on
                            opening page of program that required user to click in a specific area
                            to open program. Now that won't work either. I ....in trouble...
                            Just wished I would have known that a button on a graphic control is not supposed to execute. Can't see why this change had to be made
                            anyway. Looks like it is limiting my program capilities enormously!!

                            Comment


                            • #15
                              IMGBUTTONX instead of stacked image and button controls?
                              Dale

                              Comment


                              • #16
                                Im still having problems after the 8.04 update with mouse clicks.
                                Now the buttons work fine as before but I have a graphic (to which I added
                                %SS_NOTIFY) after reading the posts here.

                                Before, (without ss_notify) wm_lbuttondown and wm_rbuttondown in the callback worked fine. Now neither works and i tried using a case
                                %STN_CLICKED in the callback and that doesnt work either. I tried wm_L/R/buttonup too.

                                anyone ?
                                Last edited by Fred Buffington; 12 Oct 2007, 12:04 AM.
                                Client Writeup for the CPA

                                buffs.proboards2.com

                                Links Page

                                Comment


                                • #17
                                  I got double click to work by putting
                                  Code:
                                  IF CBCTLMSG=1 THEN
                                    SendMessage hDlgPreview,%WM_COMMAND,304&,0 
                                  END IF
                                  after
                                  CASE %WM_COMMAND
                                  and before SELECT CASE CBCTL

                                  304 is a button which does zoom in/out


                                  but still doesnt get the single click to work

                                  If i try using IF CBCTLMSG=%BN_CLICKED the program bombs.

                                  Actually the code ...CBCTLMSG=1... works with or without %SS_NOTIFY in the
                                  control add graphic statement

                                  So, does someone have an example that works with a single click on a graphic ?
                                  Last edited by Fred Buffington; 12 Oct 2007, 01:13 AM.
                                  Client Writeup for the CPA

                                  buffs.proboards2.com

                                  Links Page

                                  Comment


                                  • #18
                                    Fred,

                                    Not with a CONTROL GRAPHIC. Just revised one of my sub routines
                                    with callback to get it to work like before with CONTROL ADD GRAPHIC. Have to use API calls. See example of code you may be able to use:
                                    Code:
                                    LOCAL PicTMap AS LONG 
                                          DIALOG NEW PIXELS, 0, "", , , 660,700, _
                                                      %WS_OVERLAPPEDWINDOW OR %WS_CLIPCHILDREN, %WS_EX_TOPMOST TO hDlg46
                                     IF ERR OR hDlg46 = 0 THEN EXIT SUB  ' Error occurred
                                     CONTROL ADD LABEL, hDlg46, %IDS_BUT, "", 0, 0, 660, 700,  %SS_BITMAP                                                        
                                     PicTMap = LoadImage(%Null,"PICT\GoldFrame1.bmp"  , %IMAGE_BITMAP,0,0, %LR_LOADFROMFILE)
                                     CONTROL SEND hDlg46, %IDS_BUT, %STM_SETIMAGE, %IMAGE_BITMAP, PicTMap
                                     CONTROL ADD TEXTBOX, hDlg46, %IDS_TEXT, "",      37,35,585,628, _  '45,45,570,622, _
                                         %WS_CHILD OR %WS_VISIBLE OR %ES_MULTILINE OR %ES_AUTOVSCROLL _
                                         OR %ES_READONLY OR %ES_WANTRETURN, %WS_EX_CLIENTEDGE ' These styles allow mousewheel
                                     CONTROL ADD BUTTON, hDlg46, 1, "&Stop", 300,665,80,20
                                    
                                    IN CALLBACK:
                                    LOCAL fBmp AS DWORD  
                                    CASE %WM_INITDIALOG  
                                            pBmp = LoadImage(%Null, "PICT\GoldFrame1.bmp", %IMAGE_BITMAP,0,0, %LR_LOADFROMFILE)
                                            CONTROL SEND CBHNDL, %IDS_BUT, %STM_SETIMAGE, %IMAGE_BITMAP, pBmp

                                    Comment


                                    • #19
                                      Here is a portion of my code
                                      Code:
                                           DIALOG NEW %HWND_DESKTOP, "Report Preview ", , , GPHW&+10, GPHH&+40,_ '293, 340, _
                                             %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlgPreview
                                      'msgbox str$(ghHandle)
                                           SendMessage hDlgPreview, %WM_SETICON, %ICON_SMALL, LoadIcon(ghHandle, "PROGRAM") ''"BUFF") ''PROGRAM")
                                           CONTROL ADD GRAPHIC, hDlgPreview, %IDC_GRAPHIC1, "", 3, 20, GPHW&,GPHH&,%SS_NOTIFY
                                      '%SS_NOTIFY doesnt seem to make a difference even added stn_clicked in callback but may have handled that incorrectly.
                                           CONTROL ADD IMGBUTTONX, hDlgPreview,301,"P1",     2,2,50,14 '30,16 'Print
                                           CONTROL ADD  BUTTON,hDlgPreview,302,"Next Page",054,2,45,16 '047,2,45,16
                                           CONTROL ADD BUTTON, hDlgPreview,303,"Prev Page",101,2,45,16 '097,2,45,16
                                           CONTROL ADD BUTTON, hDlgPreview,304,"Zoom in",  148,2,45,16 '147,2,45,16
                                           CONTROL ADD BUTTON, hDlgPreview,305,"Page Down",195,2,45,16
                                           CONTROL ADD IMGBUTTONX, hDlgPreview,306,"C1",   242,2,50,14 '30,16 'cancel
                                           CONTROL DISABLE hDlgPreview,303
                                           CONTROL DISABLE hDlgPreview,305
                                      
                                           DIALOG SHOW MODAL hDlgPreview CALL DlgProc1
                                      here is a portion of dlgproc
                                      Code:
                                        SELECT CASE CBMSG
                                          CASE %WM_INITDIALOG
                                             hCurZoom  = LoadCursor(GetModuleHandle(modulename), Cursorname) '"ZOOM")
                                            hPreview = GetDlgItem(hDlgPreview, %IDC_Graphic1) 'PREVIEW)
                                            hCursor1 = GetClassLong(hPreview, %GCL_HCURSOR)
                                            SetClassLong hPreview, %GCL_HCURSOR, hCurZoom 'Cursor2
                                            PageBeingViewed&=1
                                            PagesPreviewed&=1
                                            lResult&=previewit(coid$,pagesPreviewed&)
                                      
                                          CASE %WM_MOUSEMOVE  ' Ensure zoom cursor is used
                                             IF GetCursor <> hCurZoom THEN SetCursor hCurZoom
                                          CASE %WM_DESTROY
                                            DestroyCursor hCursor1
                                            DestroyCursor hCurZoom
                                          CASE %STN_CLICKED
                                            SendMessage hDlgPreview,%WM_COMMAND,304&,0
                                          CASE %WM_LBUTTONDOWN 'no longer works after update
                                                SendMessage hDlgPreview,%WM_COMMAND,304&,0
                                          CASE %WM_RBUTTONDOWN 'no longer works after update
                                              IF zoom&=1 THEN
                                                SendMessage hDlgPreview,%WM_COMMAND,304&,0
                                              END IF
                                          CASE %WM_COMMAND
                                      'inserted to at least make double click work
                                        IF CBCTLMSG=1 THEN 
                                          SendMessage hDlgPreview,%WM_COMMAND,304&,0
                                        END IF
                                      Client Writeup for the CPA

                                      buffs.proboards2.com

                                      Links Page

                                      Comment


                                      • #20
                                        Fred,

                                        Just took a quick look at your lastest post and it looks like the button is
                                        on or in the same area as your graphic control? If this is true, from my
                                        testing, button will not execute. It has to be outside of Graphic Control.
                                        This ofcourse is for ver 8.04 only.

                                        Comment

                                        Working...
                                        X