Set Windows' Styles

.


Demonstrate "+" versus "OR" Source Code
'"+" is not an appropriate way to merge styles.
' [code]
#compile exe
#dim all
%ID_static  = 99
%ID_ExitBtn = 1000
callback function DlgCB() as long
  if cb.msg = %wm_command then
    if cb.ctl = %ID_ExitBtn then
      if cb.ctlmsg = %bn_clicked then
        dialog end cb.hndl
      end if
    end if
  end if
end function
function pbmain () as long
  local hDlg as dword
  local DlgCnt as long
  local DlgCaption, MBCaption as wstring
  dialog default font "Microsoft Sans Serif", 12, 0, 1
  DlgCaption = "Why use ""OR"" demonstration dialog "$$
  MBCaption = "Styles merged using ""+"" vs ""OR"" introduction."$$
  '
  '=============================================================================
  'Example DIALOG 1
  msgbox "First is a dialog with PB's built-in default styles."$$ + $$crlf + _
         "This is for reference before comparing dialogs with"$$ + $$crlf + _
         "styles merged by ""+"" versus ""OR""."$$ + $$crlf + $$crlf + _
         "Click ""OK"" for demo dialog."$$, %mb_ok or %mb_taskmodal, _
         MBCaption
  dialog new 0, DlgCaption + "1."$$, , , 180, 100 to hDlg
  control add label, hDlg, %ID_static,  _
     "This DIALOG uses the default styles.", _
     5, 5, 200, 10
  control add label, hDlg, %ID_static, _
     "To stay with the PB defaults I've not even used %WS_SYSMENU."$$ + _
     $$crlf + _
     "So there is a ""Continue"" button to close this dialog and go the "$$ + _
     "next."$$, 5, 16, 170, 60
  control add button, hDlg, %ID_ExitBtn, "Continue"$$, 5, 80, 38, 15
  '
  dialog show modeless hDlg call DlgCB
  do
    dialog doevents to DlgCnt
  loop while DlgCnt
  '
  '=============================================================================
  'Example DIALOG 2
  msgbox "The next dialog uses the default styles combined with ""+"" op"$$ + _
          $$crlf + $$crlf + "Click ""OK"" to show second dialog.", _
          %mb_ok or %mb_taskmodal, MBCaption
  dialog new 0, DlgCaption + "2."$$, , , 210, 100, %ds_3dlook + _
     %ds_modalframe + %ds_nofailcreate + %ds_setfont + %ws_caption + _
     %ws_clipsiblings + %ws_dlgframe + %ws_popup, %ws_ex_left + _
     %ws_ex_ltrreading to hDlg
  control add label, hDlg, %ID_static, _
     "%WS_CAPTION plus %WS_DLGFRAME gives %WS_MAXIMIZE, no caption and  "$$ + _
     "no frame."$$ + $$crlf, 5, 5, 170, 60
  control add button, hDlg, %ID_ExitBtn, "Continue"$$, 5, 80, 38, 15
  '
  dialog show modeless hDlg call DlgCB
  do
    dialog doevents to DlgCnt
  loop while DlgCnt
  '
  '=============================================================================
  msgbox "The last dialog uses the same styles as the previous "$$ + $$crlf + _
         "two, but merges the styles with ""OR""."$$ + $$crlf + $$crlf, _
         %mb_ok or %mb_taskmodal, MBCaption
  dialog new 0, DlgCaption + "3."$$, , , 210, 100, %ds_3dlook or _
     %ds_modalframe or %ds_nofailcreate or %ds_setfont or %ws_caption or _
     %ws_clipsiblings or %ws_dlgframe or %ws_popup, _
     %ws_ex_left or %ws_ex_ltrreading to hDlg
  control add label, hDlg, %ID_static, _
     "Using ""OR"" as help says, there is a caption bar and the dialog is "$$ + _
     "not maximized, just like the first."$$ + $$crlf + _
     "The difference is in how bitwise and arithmetic operators work. " + _
     "If don't ""get it"", print, or write, the styles as binary in a "$$ + _
     "vertical column and do the operations yourself."$$, 5, 5, 170, 60
  control add button, hDlg, %ID_ExitBtn, "Exit Demo"$$, 5, 80, 38, 15
  '
  dialog show modeless hDlg call DlgCB
  do
    dialog doevents to DlgCnt
  loop while DlgCnt
  '
end function '[/code]
'The deficient individual that inspired creation of this demo, also said "XOR"
'works. That is [b]wrong[/b] too! As another bitwise op there is no carry, but
'if the same bit is set by another style, it cleared by "XOR" with the current
'one being merged.win32 

Created on 23 December 2024.

To Domain Home.

home
To Dale's Notebook index.
notebook
To Programs index.
programs