Announcement

Collapse
No announcement yet.

Simple dialog crashes Win95/98 if WS_Group omitted

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

    Simple dialog crashes Win95/98 if WS_Group omitted

    Here's something that was time-consuming to debug, so I thought I'd share the problem (and its solution).

    When executing the code below, clicking one of the option buttons crashes the program if using Win95 or 98, but it is fine on Win XP. (The program fails to respond, presumably because it is in an infinite loop.)

    Code:
    #INCLUDE "Win32API.INC"
    FUNCTION PBMAIN()
    LOCAL hDlg,hDlg2 AS DWORD
    
       DIALOG NEW 0,"Options Test",,,250,150, %DS_MODALFRAME OR %WS_CAPTION OR %WS_SYSMENU TO hDlg
       CONTROL ADD OPTION, hDlg, 1001, "AA", 15,15,150,10,%WS_GROUP OR %WS_TABSTOP
       CONTROL ADD OPTION, hDlg, 1002, "BB", 15,27,150,10
       CONTROL ADD OPTION, hDlg, 1003, "CC", 15,39,150,10
    
       DIALOG NEW hDlg,"",0,50,250,50, %DS_CONTROL OR %WS_CHILD TO hDlg2
       CONTROL ADD LABEL, hDlg2, -1, "DD", 10,10,150,10
       DIALOG SHOW MODELESS hDlg2
       DIALOG SHOW MODAL hDlg
    END FUNCTION
    The solution is to add the %WS_GROUP style to the LABEL control on the child dialog (hDlg2). This is good practice anyway to get the option buttons to respond correctly to the arrow keys, but its omission shouldn't crash the computer. There is no problem if the superimposed child dialog is removed and all controls placed directly on the main one.
Working...
X
😀
🥰
🤢
😎
😡
👍
👎