Announcement

Collapse
No announcement yet.

Need Help with ERROR 546

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

  • Michael Mattias
    replied
    >Yes Fred, my windows program are much like DOS

    You may want them to 'look and feel' like MS-DOS programs, but you can't write 'em like you write MS-DOS programs.....

    .. except....

    ..you should probably look at the PB Console Compiler. Even when you do 'graphic' things with the new GRAPHIC WINDOW support, these are coded much like MS-DOS programs are coded, where you rather than the user control the program flow.

    The basic difference between writing "GUI" programs and writing "Console" style programs in the user interface area is, with Console/MS-DOS programs you ASK if the user has clicked a button or typed a character; in GUI programs Windows TELLS you these things have happened and you must react.

    MCM

    Leave a comment:


  • Robert Alvarez
    replied
    Yes Fred, my windows program are much like DOS. Since windows came out I have never liked all the extra clicking to run simple programs.

    At my work I use many window programs including CAD programs which are complex to use, and I see many ways in which the programs could be simplified if they operated in some way like DOS.

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Originally posted by Fred Buffington View Post
    I am, by no means, the expert here. Others, MCM, Gosta, and others are much more knowledgable about windows programming than I am so listen to them. They know of what they speak.
    {laughing}Fred, that just make laugh out loud. {still laughing} Unless your intent was to irk MCM, which I'm sure it (putting me in the same league, much less ballpark, as him when it comes to Win programming) does.

    Geez, I'm still laughing. Probably the extra glee I feel thinking about MCM getting irked.

    ========================
    "Always do right
    this will gratify some
    and astonish the rest."
    Mark Twain (1835-1910)
    ========================

    Leave a comment:


  • Fred Buffington
    replied
    Robert, It sounds like you are wanting your program to react like a MS-DOS counterpart would react. Many functions and subs will do just that but not when dealing with dialogs(DDT-SDK)/windows (SDK CreateWindow etc).

    Windows programming in those instances is a 'different animal'.
    A quick example might give you some insight.
    If you have a callback function that handles all the controls and you put text in a textbox lets say. Under that select case statement for that control, if you
    put an exit function statement, the program will not actually exit the function.
    Well that may be oversimplification. Perhaps a better explanation would be that it will go back to the callback function until the dialog is ended (modal dialog assumed). That may be a bad example but it shows that windows programming is not the same as MS-DOS programming where windows are concerned.

    I am, by no means, the expert here. Others, MCM, Gosta, and others are much more knowledgable about windows programming than I am so listen to them. They know of what they speak.

    Leave a comment:


  • Michael Mattias
    replied
    I have run into this [attempting to call a CALLBACK FUNCTION from code ] before and fixed it by using FUNCTION instead of CALLBACK FUNCTION. But ...
    But..... you did not FIX anything. While it 'can' be done and sometimes 'is' done, Window procedures - CALLBACK FUNCTIONS - are not intended to be used as procedures you call directly from your code. There are 'things' you never see which happen in window procedures , and those should only be allowed to happen when that procedure is called 'as normally called' which is 'automatically as a result of user actions or other events'

    If you really want to call a CALLBACK FUNCTION directly from your code, you can fool the compiler into performing that action easily enough with CALL DWORD. However, the compiler edit which prevents you from coding a simple call of a CALLBACK FUNCTION is there for a good reason.

    MCM

    Leave a comment:


  • Robert Alvarez
    replied
    Yes that was the wrong thing to do. I have run into this before and fixed it by using FUNCTION instead of CALLBACK FUNCTION. But in this case I had a 'SELECT CASE CBMSG ' in the RECORDS1 code and that gave an error since that needs a CALLBACK FUNCTION to work.

    The PBMAIN=15 was just what is shown in the help file for PBMAIN function. Guess there may things in sample files that are not needed.

    Leave a comment:


  • Rodney Hicks
    replied
    Robert
    When Fred asked:
    Robert, at the place the program fails you are calling a callback function.

    Why would you do that ?
    he was referring to 'calling a callback" when the help file explicitly states:

    It may never be called directly from your code.
    Further, this line:
    Code:
    PBMAIN=15
    is merely assigning an error number to the return value, you'll find your program runs just as well without it, since you aren't experiencing that error yet.(If it exists at all)

    Leave a comment:


  • Robert Alvarez
    replied
    'DIALOG SHOW STATE hDlg, showstate&' was the fix I was looking for. Below are changes made to sample test file.

    Fred you asked 'why I would do that'. In my programs when I open another dialog box I close the last one. I like to work on my desktop with only one dialog box and not have multiple dialog boxes which have disabled buttons or dialogs box that are disabled while filling out information on other dialog box.

    Only time I have two dialog boxes is when the program puts out a warning or message.

    Code:
    #COMPILE EXE
    #DIM ALL
    
    GLOBAL hDlg, hDlg2 AS LONG, TEXT1 AS STRING
    
    CALLBACK FUNCTION RecordInputCANCEL() AS LONG
    DIALOG END hDlg2, 1
    DIALOG SHOW STATE hDlg, %SW_RESTORE                          '<< CODE ADDED
    END FUNCTION
    
    CALLBACK FUNCTION RecordInput() AS LONG
    LOCAL result2 AS LONG
    DIALOG SHOW STATE hDlg, %SW_HIDE                              '<< CODE ADDED
    DIALOG NEW 0, "RECORD INPUT",,, 520, 200, 0, 0 TO hDlg2       '<< CODE CHANGED  hDlg2
    CONTROL ADD BUTTON, hDlg2, 100,"XXXX",430, 10, 60, 14, 'CALL XXXX
    CONTROL ADD BUTTON, hDlg2, 101,"&CANCEL" ,430, 30, 60, 14, CALL RecordInputCANCEL
    CONTROL SET FOCUS   hDlg2, 101
    DIALOG SHOW MODAL  hDlg2 TO result2
    END FUNCTION
    
    CALLBACK FUNCTION RECORD1CANCEL() AS LONG
    DIALOG END hDlg, 1
    CALL MAINMENU
    END FUNCTION
    
    CALLBACK FUNCTION Record1() AS LONG
    SELECT CASE CBMSG
     CASE %WM_COMMAND AND CBCTL = 100
           CONTROL GET TEXT hDlg, 100 TO TEXT1
    END SELECT
    
    DIALOG END hDlg, 1
    LOCAL result AS LONG
    DIALOG NEW 0, "RECORDS1",,, 520, 200, 0, 0 TO hDlg
    CONTROL ADD BUTTON, hDlg, 100,"RECORDS INPUT",430, 10, 80, 14, CALL RECORDINPUT
    CONTROL ADD BUTTON, hDlg, 101,"&CANCEL" ,430, 30, 60, 14, CALL RECORD1CANCEL
    CONTROL SET FOCUS   hDlg, 101
    DIALOG SHOW MODAL  hDlg TO result
    END FUNCTION
    
    CALLBACK FUNCTION ENDPROG()
    DIALOG END hDlg, 1
    DIALOG END CBHNDL, 15
    END FUNCTION
    
    FUNCTION MAINMENU() AS LONG
    DIALOG END hDlg, 1
    LOCAL result AS LONG           '
    DIALOG NEW 0, "Test1"  ,,,400, 270,, 0 TO hDlg
    CONTROL ADD BUTTON,hDlg,100,"Records"    ,155, 50, 90, 14, CALL Record1
    CONTROL ADD BUTTON,hDlg,101,"End Program",155,200, 90, 14, CALL ENDPROG
    CONTROL SET FOCUS hDlg, 101
    DIALOG SHOW MODAL hDlg TO result
    END FUNCTION
    
    FUNCTION PBMAIN () AS LONG
    PBMAIN=15
    CALL MAINMENU
    END FUNCTION

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Robert, in your example you are using a Callback to call another Callback -
    Code:
     
    [B]CallBack Function [/B]RecordInputCANCEL() As Long
    Dialog End hDlg, 1
    Call [B]Record1[/B]                                  '<<  error 546 HERE, want to go back to  Record1, if change to MAINMENU no error
    End Function 
    ...
    [B]CallBack Function Record1[/B]() As Long
    Select Case CbMsg            'this code would be ignored or skeped on second call
     Case %WM_COMMAND And CbCtl = 100
           Control Get Text hDlg, 100 To TEXT1
    End Select
    I don't think that's allowed. As Fred said if you Rem the call to Record1 it will work as it is supposed to.

    Leave a comment:


  • Fred Buffington
    replied
    Robert, at the place the program fails you are calling a callback function.

    Why would you do that ?

    If you rem out CALL Record1

    Code:
    CALLBACK FUNCTION RecordInputCANCEL() AS LONG
        DIALOG END hDlg, 1
        'CALL Record1                                  '<<  error 546 HERE, want to go back to  Record1, if change to MAINMENU no error
    END FUNCTION
    The program seems to work with the call record1 remmed (or deleted)

    The only place you normally 'call' a callback function in a modal dialog (in DDT) is in the dialog show statement.
    But, since you have separate callbacks for each control rather than one callback for all controls; that is, of course, not necessary. I also changed GLOBAL hDlg as LONG to GLOBAL hDlg AS DWORD which has been the preferred way since ver 7.
    If you are still using version 6 or below then hdlg AS LONG is correct.
    Last edited by Fred Buffington; 26 Sep 2009, 11:01 AM.

    Leave a comment:


  • Rodney Hicks
    replied
    Rather than closing the dialog, maybe try the
    Code:
    DIALOG SHOW STATE hDlg, showstate&

    Leave a comment:


  • Robert Alvarez
    replied
    thanks eveyone for you responses.

    Rodney, I tested you code and it does what wanted, but I like to close dialog boxes as I open a new one, keeping only the current dialog box open.

    I tried adding
    FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
    DIALOG END hDlg, 1 '<< my code
    to all dialogshow functions but it did not close any dialogs.

    You code is more advance than my simple code that I do. I could ask many question but before asking I need to study your code to better understand many parts of it.

    I have PBforms but have not master this one yet. For now I only use it to cut and paste code from it on new dialog designs I might need.

    Leave a comment:


  • Rodney Hicks
    replied
    I've quickly redone your code using PBForms, try running this to see if it does what you want, at least for the most part.

    Code:
    #PBFORMS CREATED V1.51
    '------------------------------------------------------------------------------
    ' The first line in this file is a PB/Forms metastatement.
    ' It should ALWAYS be the first line of the file. Other
    ' PB/Forms metastatements are placed at the beginning and
    ' end of "Named Blocks" of code that should be edited
    ' with PBForms only. Do not manually edit or delete these
    ' metastatements or PB/Forms will not be able to reread
    ' the file correctly.  See the PB/Forms documentation for
    ' more information.
    ' Named blocks begin like this:    #PBFORMS BEGIN ...
    ' Named blocks end like this:      #PBFORMS END ...
    ' Other PB/Forms metastatements such as:
    '     #PBFORMS DECLARATIONS
    ' are used by PB/Forms to insert additional code.
    ' Feel free to make changes anywhere else in the file.
    '------------------------------------------------------------------------------
    
    #COMPILE EXE
    #DIM ALL
    
    '------------------------------------------------------------------------------
    '   ** Includes **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN INCLUDES
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #PBFORMS END INCLUDES
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Constants **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN CONSTANTS
    %IDD_DIALOG1      =  101
    %IDC_ENDPROGRAM   = 1002
    %IDC_RECORDS      = 1001
    %IDCANCEL         =    2
    %IDD_DIALOG2      =  102
    %IDC_RECORDSINPUT = 1003
    %IDD_DIALOG3      =  103
    %IDC_XXXX         = 1004
    #PBFORMS END CONSTANTS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Main Application Entry Point **
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
        ShowDIALOG1 %HWND_DESKTOP
        
        
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** CallBacks **
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                SELECT CASE AS LONG CBCTL
                    CASE %IDC_RECORDS
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
    '                        MSGBOX "%IDC_RECORDS=" + FORMAT$(%IDC_RECORDS), _
    '                            %MB_TASKMODAL
                           ShowDIALOG2 %HWND_DESKTOP     'calls your records1
                        END IF
    
                    CASE %IDC_ENDPROGRAM
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            MSGBOX "%IDC_ENDPROGRAM=" + FORMAT$(%IDC_ENDPROGRAM), _
                                %MB_TASKMODAL
                        END IF
    
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG2Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                SELECT CASE AS LONG CBCTL
                    CASE %IDC_RECORDSINPUT
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
    '                        MSGBOX "%IDC_RECORDSINPUT=" + _
    '                            FORMAT$(%IDC_RECORDSINPUT), %MB_TASKMODAL
                           ShowDIALOG3 %HWND_DESKTOP   'calls your records input
                        END IF
    
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG3Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                SELECT CASE AS LONG CBCTL
                    CASE %IDC_XXXX
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            MSGBOX "%IDC_XXXX=" + FORMAT$(%IDC_XXXX), _
                                %MB_TASKMODAL
                        END IF
    
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 0
                        END IF
    
                END SELECT
        END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Dialogs **
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW hParent, "Test1", 0, 0, 400, 270, %WS_POPUP OR %WS_BORDER OR _
            %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS _
            OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE _
            OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
            %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_RECORDS, "Records", 155, 50, 90, 14
        CONTROL ADD BUTTON, hDlg, %IDC_ENDPROGRAM, "End Program", 155, 200, 90, _
            14
        CONTROL ADD BUTTON, hDlg, %IDCANCEL, "EXIT", 175, 225, 50, 15
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG2(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG2->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW hParent, "Records1", 0, 0, 520, 200, %WS_POPUP OR %WS_BORDER _
            OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _
            %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_RECORDSINPUT, "Records Input", 430, 10, _
            80, 14
        CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 430, 30, 60, 14
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG2Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG2
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG3(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG3->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW hParent, "RecordInput", 0, 0, 520, 200, %WS_POPUP OR _
            %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _
            %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_XXXX, "XXXX", 430, 10, 60, 14
        CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 430, 30, 60, 14
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG3Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG3
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------

    Leave a comment:


  • Rodney Hicks
    replied
    From the help file: (my bold)
    CALLBACK
    Specifies that this is a callback function, which is used only to receive messages from the operating system. It may never be called directly from your code. Details about the message sent to the callback are retrieved using the CB group of PowerBASIC functions. Callback functions may not include parameters, and always return a long integer result. For example:

    CALLBACK FUNCTION DlgProc AS LONG
    ' Callback code goes here
    END FUNCTION

    Callback functions have the unique ability to optionally return two distinct values when necessary for certain Windows messages. This allows them to return the value zero (0) as a function result, while still specifying that the message has been processed. See the section CALLBACK RETURN VALUE (below) and the CALLBACKS page for more details.

    Leave a comment:


  • Robert Alvarez
    replied
    ok here is the sample test code that shows error 546 and would like to see if there is a way to fix it.

    Code:
    #COMPILE EXE
    #DIM ALL
    
    GLOBAL hDlg  AS LONG, TEXT1 AS STRING
    
    CALLBACK FUNCTION RecordInputCANCEL() AS LONG
    DIALOG END hDlg, 1
    CALL Record1                                  '<<  error 546 HERE, want to go back to  Record1, if change to MAINMENU no error
    END FUNCTION
    
    CALLBACK FUNCTION RecordInput() AS LONG
    LOCAL result AS LONG
    DIALOG END hDlg, 1
    DIALOG NEW 0, "RECORD INPUT",,, 520, 200, 0, 0 TO hDlg
    CONTROL ADD BUTTON, hDlg, 100,"XXXX",430, 10, 60, 14, 'CALL XXXX  << this would process code and end like  RecordInputCANCEL error
    CONTROL ADD BUTTON, hDlg, 101,"&CANCEL" ,430, 30, 60, 14, CALL RecordInputCANCEL
    CONTROL SET FOCUS   hDlg, 101
    DIALOG SHOW MODAL  hDlg TO result
    END FUNCTION
    
    CALLBACK FUNCTION RECORD1CANCEL() AS LONG
    DIALOG END hDlg, 1
    CALL MAINMENU
    END FUNCTION
    
    CALLBACK FUNCTION Record1() AS LONG
    SELECT CASE CBMSG            'this code would be ignored or skeped on second call
     CASE %WM_COMMAND AND CBCTL = 100
           CONTROL GET TEXT hDlg, 100 TO TEXT1
    END SELECT
    
    DIALOG END hDlg, 1
    LOCAL result AS LONG
    DIALOG NEW 0, "RECORDS1",,, 520, 200, 0, 0 TO hDlg
    CONTROL ADD BUTTON, hDlg, 100,"RECORDS INPUT",430, 10, 80, 14, CALL RECORDINPUT
    CONTROL ADD BUTTON, hDlg, 101,"&CANCEL" ,430, 30, 60, 14, CALL RECORD1CANCEL
    CONTROL SET FOCUS   hDlg, 101
    DIALOG SHOW MODAL  hDlg TO result
    END FUNCTION
    
    CALLBACK FUNCTION ENDPROG()
    DIALOG END hDlg, 1
    DIALOG END CBHNDL, 15
    END FUNCTION
    
    FUNCTION MAINMENU() AS LONG
    DIALOG END hDlg, 1
    LOCAL result AS LONG           '
    DIALOG NEW 0, "Test1"  ,,,400, 270,, 0 TO hDlg
    CONTROL ADD BUTTON,hDlg,100,"Records"    ,155, 50, 90, 14, CALL Record1
    CONTROL ADD BUTTON,hDlg,101,"End Program",155,200, 90, 14, CALL ENDPROG
    CONTROL SET FOCUS hDlg, 101
    DIALOG SHOW MODAL hDlg TO result
    END FUNCTION
    
    FUNCTION PBMAIN () AS LONG
    PBMAIN=15
    CALL MAINMENU
    END FUNCTION

    Leave a comment:


  • Michael Mattias
    replied
    The DM_xxxx would appear to conflict with a 'WM_USER + 0' minimum, for a private message posted to a window of the dialog class .

    WM_USER + 1 would only be a problem for a message sent to a Toolbar control

    So maybe WM_USER + 100 would be a better 'minimum.'

    I guess the SDK doc does not think of 'dialogs' as 'windows'.. or at the very least treats them as second-class windows.


    >Self-inflicted [conflict]?
    ===>
    Code:
    %WM_MY_FIRST_MESSAGE    =  WM_USER + 10
    %WM_MY_SECOND_MESSAGE =  WM_USER + 10

    Leave a comment:


  • Dominic Mitchell
    replied
    There should not be any conflicts (other than self-inflicted) with messages greater than WM_USER plus zero.
    Self-inflicted?
    Posting or sending messages in the range WM_USER + 0x0000 - WM_USER + 0x0064 to a window is going to get
    you into trouble with the dialog box manager. For example, the IsDialogMessage function sends the following
    messages to a window to deal with default buttons.
    Code:
    DM_GETDEFID      = WM_USER + 0
    DM_SETDEFID      = WM_USER + 1
    The following message handles the positioning of a top-level dialog.
    Code:
    DM_REPOSITION    = WM_USER + 2
    That quote from the Help file is a strange one.
    For example, the TB_ENABLEBUTTON message that is used to enable or disable a button in the common control
    kown as the toolbar is defined thus
    Code:
    TB_ENABLEBUTTON             = WM_USER + 1
    This is a class-specific message. That is, it is a message that is sent to a toolbar. The only way a conflict
    can arise is if a programmer subclasses or superclasses a toolbar, sends a user defined message with the same
    value as TB_ENABLEBUTTON to the toolbar, writes code that sings his praises, and then wonders why he or she
    can no longer enable or disable a button.

    Leave a comment:


  • Robert Alvarez
    replied
    Looks like the fix is going to be complex. I am working on a small sample test program to post, hope to finish during weekend. The program I am working on is to large to post (about 8700 lines).

    Leave a comment:


  • Rodney Hicks
    replied
    FWIW from the SDK:
    Windows reserves message-identifier values in the range 0x0000 through 0x03FF (the value of WM_USER - 1) and 0x8000 through 0xBFFF for system-defined messages. Applications cannot use these values for private messages.
    Values in the range 0x0400 (the value of WM_USER) through 0x7FFF are available for message identifiers defined by an application for its own use. Values in the range 0xC000 through 0xFFFF are available for message identifiers defined by an application for use in communicating with windows in other applications.

    Leave a comment:


  • Michael Mattias
    replied
    Using messages with a numeric value of less then %WM_USER + 500 may conflict with Windows Common Control messages.
    ???

    Just off the top of my head, there is but one (1) Common Controls notification message: WM_NOTIFY (value 0x4E, which is less than WM_USER at 0x400).

    And when you SEND a message to a control, who cares what its value is? So what if a button does not do the same thing with a message numbered 1234 as will a listbox or toolbar?

    Oh, well, I guess this help file suggestion shall just have to remain one of Life's Great Mysteries.

    MCM

    Leave a comment:

Working...
X