Announcement

Collapse
No announcement yet.

Program does not display dialog but is in memory?

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

  • Program does not display dialog but is in memory?

    Just started a new program. Copied some code from an old program that works to start off this new program..

    Problem , program does not display dialog. I am puzzled with this, just do not see what is wrong?

    The program runs with no error.

    Sample code below:

    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "WIN32API.INC"
    
    %BU1=201: %BU2=202: %BU3=203: %BU4=204: %BU5=205: %BU6=206: %BU7=207: %BU8=208: %BU9=209: %BU10=210
    
    GLOBAL hDlg AS DWORD
    
    
    CALLBACK FUNCTION ENDPROG()
     DIALOG END CBHNDL, 1
    END FUNCTION
    
    SUB PROG_BUTTONS
     CONTROL ADD BUTTON, hDlg, %BU1, "&Add", 5,   310, 36, 15, 'CALL Add
     CONTROL ADD BUTTON, hDlg, %BU10,"&Exit",392, 310, 36, 15, CALL ENDPROG
     CONTROL SET FOCUS  hDlg, %BU10
    END SUB
    
    
    FUNCTION PBMAIN()
     Main_Dlg %HWND_DESKTOP
    END FUNCTION
    
    
    FUNCTION Main_Dlg(BYVAL hParent AS DWORD) AS LONG
     LOCAL LRSLT AS LONG
    
     DIALOG NEW PIXELS, 0, "TEST PROG",,, 912, 682, %WS_CAPTION OR %WS_SYSMENU, %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg
    
     PROG_BUTTONS
    
     DIALOG SHOW MODAL hDlg, TO LRSLT
    END FUNCTION
    Robert

  • #2
    No MSG selection in callback! Any message will end dialog before you see it.
    Dale

    Comment


    • #3
      Hi Robert!

      Do this instead ...

      Code:
       Dialog New Pixels, 0, "TEST PROG",,, 912, 682, %WS_Caption Or %WS_SysMenu To hDlg

      Comment


      • #4
        Dale,
        Yes, but no message occurs at startup so it can start with the change I mention.

        Comment


        • #5
          %ws_minimizebox puts minimize button on caption bar, %ws_minimize starts dialog in minimized state.
          Dale

          Comment


          • #6
            For one, %wm_initdialog will hit callback and end dialog IMMEDIATELY!!!
            Dale

            Comment


            • #7
              Gary that worked , but does not show the system menu minimize box. [ - ]
              Robert

              Comment


              • #8
                Hi Dale!

                His callback is for a control, not for the dialog. So initdialog does not go there.

                What you say would be true for the dialog callback, which he does not use.

                Robert,
                Yes, that's because you chose to use %WM_SysMenu. It inhibits the minimize box. Try just %WM_OverlappedWindow

                Comment


                • #9
                  Doing what Gary said helped because you had styles in extended style area.
                  Dale

                  Comment


                  • #10
                    %ws_sysmenu does not ihhibit the minimize box
                    %WS_SYSMENU Create a dialog that has a System-menu box in its title bar. Must be used with the %WS_CAPTION style.
                    Dale

                    Comment


                    • #11
                      ((and yes, I missed that the dialog had no callback and button did.))
                      Dale

                      Comment


                      • #12
                        Hi Dale!

                        This hides the minimize box. Maybe we're not talking apples to apples?

                        Code:
                        #Include "Win32API.inc"
                        Global hDlg As Dword
                        
                        Function PBMain() As Long
                           Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_SysMenu To hDlg
                           Dialog Show Modal hDlg
                        End Function

                        Comment


                        • #13
                          That does not hide the minimize box! It does not create it in the first place. And using just %ws_sysmenu deletes the other default styles.
                          Dale

                          Comment


                          • #14
                            Code from post #1 adjusted to actually show the dialog, have the default styles and have minimize box. (unknown values in extended style caused unexpected results)
                            Code:
                            #compile exe
                            #dim all
                            
                            #include "win32api.inc"
                            
                            %BU1=201: %BU2=202: %BU3=203: %BU4=204: %BU5=205: %BU6=206: %BU7=207: %BU8=208
                            %BU9=209: %BU10=210
                            
                            global ghDlg as dword
                            
                            callback function ENDPROG()
                              dialog end cbhndl, 1
                            end function
                            
                            sub PROG_BUTTONS
                              control add button, ghDlg, %BU1, "&Add", 5,   310, 36, 15
                              control add button, ghDlg, %BU10,"&Exit",392, 310, 36, 15, call ENDPROG
                              control set focus ghDlg, %BU10
                            end sub
                            
                            function pbmain()
                              Main_Dlg %hwnd_desktop
                            end function
                            
                            function Main_Dlg(byval hParent as dword) as long
                              local LRSLT as long
                              'a dialog that still has default styles (need to include them when ANY style is
                              'used), plus %ws_sysmenu and (grammerical and) %ws_minimizebox which are BOTH
                              'needed to have a minimize box on the caption. If any style is used, you must
                              'also use extended default styles if you want them.
                              dialog new pixels, 0, "TEST PROG",,, 912, 682, %ds_3dlook or %ds_modalframe _
                                 or %ds_nofailcreate or %ds_setfont or %ws_caption or %ws_clipsiblings or _
                                 %ws_dlgframe or %ws_popup or %ws_sysmenu or %ws_minimizebox, _
                                 %ws_ex_left or %ws_ex_ltrreading or %ws_ex_rightscrollbar to ghDlg
                            
                              PROG_BUTTONS
                            
                              dialog show modal ghDlg, to LRSLT
                            end function
                            Dale

                            Comment


                            • #15
                              As stated in Dales post #9
                              > Doing what Gary said helped because you had styles in extended style area.
                              Code:
                              FUNCTION PBMAIN()
                               LOCAL hDlg AS DWORD
                              'DIALOG NEW PIXELS, 0, "TEST PROG",,, 912, 682, %WS_CAPTION OR %WS_SYSMENU,   %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg
                               DIALOG NEW PIXELS, 0, "TEST PROG",,, 912, 682, %WS_CAPTION OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg
                               DIALOG SHOW MODAL hDlg
                              END FUNCTION
                              https://duckduckgo.com instead of google

                              Comment


                              • #16
                                Actually the program in post #1 does display a dialog. The taskbar icon is visible. The "&Exit" button does respond to Alt+E to close the dialog too (icon removed from Taskbar and Task Manger list).

                                The problem is that the dialog is shown as a Layered Window that is fully transparent

                                This happens as a result of the mistake which placed the %WS_SYSMENU (&H00080000) style value in the Extended style position of the DIALOG NEW statement.
                                The value &H00080000 equates to %WS_EX_LAYERED in the Extended style position which creates a translucent dialog.

                                Just for fun, you can prove that by adding the following line just after 'PROG BUTTONS' in the source code to adjust the dialog's level of transparency to 50%.
                                Code:
                                SetLayeredWindowAttributes(hDlg, 0, (255 * 50) / 100, %LWA_ALPHA)
                                Rgds, Dave

                                Comment


                                • #17
                                  **********
                                  gary tried this

                                  DIALOG NEW PIXELS, 0, "TEST PROG",,, 912, 682, %WS_CAPTION OR %WM_OverlappedWindow TO hDlg

                                  got undefined equate
                                  **********


                                  below is what I had copied to use in the new program. Did not produce invisible dialog?

                                  ***********
                                  DIALOG NEW PIXELS ,hParent, "Employee Work Schedule Main Menu",,,1285, 680, %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg

                                  tried 0 instead of hParent and both worked fine in old program. dialogs displayed fine in both cases, has minimize [-] and [x]

                                  DIALOG NEW PIXELS ,0, "Employee Work Schedule Main Menu",,,1285, 680, %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg
                                  ***********

                                  above worked fine in window 7 and 10. after see all response see that my error was missing OR in "OR %WS_SYSMENU, %WS_MINIMIZEBOX OR"



                                  *****
                                  Dale thats quite of code for dialog new pixels , I have not used any code like that in some of my old programs. Would that create problems if I use a more simple code?
                                  *****


                                  below mike doty and my original code fixed by adding one OR
                                  ****
                                  DIALOG NEW PIXELS, hParent, "Milage Keeper",,, 912, 682, %WS_CAPTION OR %WS_SYSMENU, %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg 'see that i miss one OR
                                  DIALOG NEW PIXELS, 0, "TEST PROG" ,,, 912, 682, %WS_CAPTION OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg 'Mike code
                                  ****


                                  after looking at all the help code and mine also almost lost where my original error happened
                                  *****
                                  DIALOG NEW PIXELS, hParent, "Milage Keeper",,, 912, 682, %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg 'this works
                                  ****
                                  but this was the original error code of mine, missing one OR
                                  DIALOG NEW PIXELS, 0, "TEST PROG",,, 912, 682, %WS_CAPTION OR %WS_SYSMENU, %WS_MINIMIZEBOX OR %WS_SYSMENU TO hDlg
                                  ****

                                  Dave that is some strange behavoir that you spotted, transparent dialog?

                                  Thanks everyone for your help.
                                  Robert

                                  Comment


                                  • #18
                                    **********
                                    gary tried this
                                    DIALOG NEW PIXELS, 0, "TEST PROG",,, 912, 682, %WS_CAPTION OR %WM_OverlappedWindow TO hDlg
                                    got undefined equate
                                    **********
                                    should be %WS_OverlappedWindow
                                    Dale thats quite of code for dialog new pixels , I have not used any code like that in some of my old programs. Would that create problems if I use a more simple code?
                                    *****
                                    ??? standard code to have default styles and for dialog to have the minimizebox, and correct default extended styles. The rest is just the code you started with.
                                    Dale

                                    Comment


                                    • #19
                                      Dave that is some strange behavoir that you spotted, transparent dialog?
                                      Transparency is not that strange Here's some test code for experimentation..
                                      Code:
                                      #COMPILE EXE
                                      #DIM ALL
                                      #INCLUDE "WIN32API.INC"
                                      
                                      %LblClr        = %RGB_GRAY     ' Note can be any colour but needs to be shade of Gray if click-through rqd
                                      %IDC_Label1    =  101
                                      %OPT_Opaque    = 1001
                                      %OPT_TransDlg  = 1002
                                      %OPT_TransLbl  = 1003
                                      %OPT_TransBoth = 1004
                                      '------------------
                                      
                                      SUB SetTranslucent(hWnd AS DWORD, bAlpha AS INTEGER, OPT BYVAL crKey AS DWORD, BYVAL dwFlags AS DWORD)
                                      'SetWindowLong and SetLayeredWindowAttributes are API functions, see MSDN for details
                                      'setting opacity and transparency color key of a layered window...
                                      ' NB *** Set color key to Grey for complete transparency - ie Mouse clicks effective behind transparent area
                                        LOCAL ExStyle AS LONG
                                      
                                         ExStyle = GetWindowLong(hWnd, %GWL_EXSTYLE)
                                         IF (ExStyle AND %WS_EX_LAYERED) <> %WS_EX_LAYERED THEN
                                          SetWindowLong hWnd, %GWL_EXSTYLE, ExStyle OR %WS_EX_LAYERED
                                         END IF
                                         dwFlags AND= %LWA_COLORKEY OR %LWA_ALPHA ' Both / Either
                                       '   crKey =  RGB(214, 214, 214)
                                         SetLayeredWindowAttributes hWnd, _         ' Dword. Handle to layered window
                                                                    crKey, _        ' Dword Transparent color key
                                                                    bAlpha, _       ' Byte Opacity 0(Tansparent) - 255(Opaque)
                                                                    dwFlags         ' Use crKey as transparent key color    NB ***
                                      END SUB                                       ' Use bAlpha for whole window opacity
                                      '------------------/SetTranslucent
                                      
                                      
                                      CALLBACK FUNCTION DlgProc()
                                        SELECT CASE AS LONG CBMSG
                                          CASE %WM_INITDIALOG
                                            CONTROL SET OPTION CB.HNDL, %OPT_Opaque, %OPT_Opaque, %OPT_TransBoth  ' Set initial state
                                      
                                          CASE %WM_COMMAND
                                            SELECT CASE AS LONG CBCTL
                                              CASE %OPT_Opaque TO %OPT_TransBoth
                                                IF CBCTLMSG = %BN_CLICKED THEN
                                                 LOCAL lRes AS LONG
                                                  CONTROL GET CHECK CB.HNDL, CB.CTL TO lRes
                                                  IF lRes THEN
                                                    SELECT CASE CB.CTL
                                                      CASE %OPT_Opaque
                                                        SetTranslucent CB.HNDL, 255
                                                      CASE %OPT_TransDlg
                                                        SetTranslucent CB.HNDL, 200, %LblClr, %LWA_ALPHA
                                                      CASE %OPT_TransLbl
                                                        SetTranslucent CB.HNDL, 200, %LblClr, %LWA_COLORKEY
                                                      CASE %OPT_TransBoth
                                                        SetTranslucent CB.HNDL, 200, %LblClr, %LWA_COLORKEY OR %LWA_ALPHA
                                                    END SELECT
                                                  END IF
                                                END IF
                                      
                                              CASE %IDCANCEL              ' Esc
                                                IF CBCTLMSG = %BN_CLICKED THEN
                                                  DIALOG END CBHNDL
                                                END IF
                                            END SELECT
                                      
                                          CASE %WM_SysCommand
                                            IF (CBWPARAM AND &HFFF0) = %SC_CLOSE THEN
                                              DIALOG END CBHNDL
                                            END IF
                                      
                                        END SELECT
                                      END FUNCTION
                                      '------------------/DlgProc
                                      
                                      FUNCTION PBMAIN()
                                       LOCAL hDlg  AS DWORD
                                        DIALOG FONT "Arial", 12
                                        DIALOG NEW 0, "Transparency Test", 213, 129, 260, 240, %WS_CAPTION OR %WS_SYSMENU, %WS_EX_TOPMOST, TO hDlg
                                          CONTROL ADD LABEL,  hDlg, %IDC_Label1, $CR + "Click through Label if Grey", 25, 25, 210, 100
                                          CONTROL SET COLOR   hDlg, %IDC_Label1, -1, %LblClr
                                          CONTROL ADD OPTION, hDlg, %OPT_Opaque, "Opaque", 25, 140, 90, 10
                                          CONTROL ADD OPTION, hDlg, %OPT_TransDlg, "Translucent Dialog", 25, 160, 90, 10
                                          CONTROL ADD OPTION, hDlg, %OPT_TransLbl, "Transparent Label", 25, 180, 90, 10
                                          CONTROL ADD OPTION, hDlg, %OPT_TransBoth, "Mixed Translucent w/Transparent colour", 25, 195, 150, 20
                                      
                                        DIALOG SHOW MODAL hDlg, CALL DlgProc
                                      END FUNCTION
                                      '------------------/PbMain
                                      Rgds, Dave

                                      Comment


                                      • #20
                                        Dave , have not checked your code yet but Transparency for a dialog is neat. Thinking can make a dialog fade in and open or fade out and close. Thanks for the code.
                                        Robert

                                        Comment

                                        Working...
                                        X