Jose's Read Only Forum 2023

IT-Consultant: James C. Fuller => bc9Basic => Topic started by: James C. Fuller on November 25, 2016, 03:52:43 PM

Title: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 03:52:43 PM
A study on ease of use versus application size. Generally it takes a lot more typing of source code to produce smaller exe files. Where is the tipping point where you give up smaller exe size and use binary or source code libraries to accomplish the same feat.
I will present a number of examples that produce equivalent Windows applications.
With the release of the Free PowerBasic classic compilers it also gives an opportunity to include these in my study. PowerBASIC has always been marketed as producing very small executables so I chose it and one of it's demos as the base application.

The PowerBASIC DDT dialogs use MS San Serif,8 for their font.
As of Vista MS switched to Segoe UI, 9 for its default font. I use this for all the bc9Basic demos so you will notice a difference in window and control sizes.

I also discovered what I consider a bug in the latest Visual Studio 2015 Community vc++ compiler.
After much discussion and research I have not found a suitable explanation or documentation on the change.
http://forums.codeguru.com/showthread.php?557721-Display-issues
http://www.jose.it-berater.org/smfforum/index.php?topic=5161.0
http://www.objreader.com/index.php?topic=73.0
http://stackoverflow.com/questions/11783086/get-exact-window-region-size-createwindow-window-size-isnt-correct-size-of-wi
http://stackoverflow.com/questions/27928254/adjustwindowrectex-and-getwindowrect-give-wrong-size-with-ws-overlapped

To begin the process I compiled and ran the PBWin9 HelloDDT.bas demo.
While running I fired up PBWinSpy and used it to created SDK source from the running HelloDDT.
I plopped this code into a new PbWin 9 source window, added callback code, named it HelloSDK and compiled it.
I used these SDK coordinates for all the bc9Basic SDK and CW apps.
Last I took the coordinates from HelloDDT and created a resource dialog using KetilO's resource editor:
https://svn.code.sf.net/p/fbedit/code/ResEd22

One thing to note is PowerBASIC 6/10 has dead code removal and an updated CWindow library which decreases the overall exe size.

All the bc9Basic demos are compiled as 64bit c++ unicode applications except Tiny C  and Pelles C.

What follows are the individual sources and the compiled exe sizes.

A composite will be presented at the end of the topic.


James
Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 03:53:59 PM

This is the original.
PbWin 9 HelloDDT : Exe Size 20,480



'==============================================================================
'
'  HELLODDT.BAS for PowerBASIC for Windows
'  Copyright (c) 1997-2008 PowerBASIC, Inc.
'  All Rights Reserved.
'
'  A simple DDT dialog example.
'
'==============================================================================
' Metastatements
'
#COMPILER PBWIN 9
#COMPILE EXE
#DIM ALL
'------------------------------------------------------------------------------
' Equates and global variables
'
%IDOK       = 1
%IDCANCEL   = 2
%IDTEXT     = 100
%BS_DEFAULT = 1
GLOBAL UserName AS STRING
'------------------------------------------------------------------------------
' OK button callback
'
CALLBACK FUNCTION OkButton () AS LONG
    IF CB.CTLMSG = %BN_CLICKED THEN
        CONTROL GET TEXT CB.HNDL, %IDTEXT TO UserName
        DIALOG END CB.HNDL, 1
        FUNCTION = 1
    END IF
END FUNCTION
'------------------------------------------------------------------------------
' Cancel button callback
CALLBACK FUNCTION CancelButton () AS LONG

    IF CB.CTLMSG = %BN_CLICKED THEN
        DIALOG END CB.HNDL, 0
        FUNCTION = 1
    END IF
END FUNCTION
'------------------------------------------------------------------------------
' Main application entry point...
FUNCTION PBMAIN() AS LONG
    LOCAL hDlg   AS DWORD
    LOCAL Result AS LONG
    '  Create a new dialog template
    DIALOG NEW 0, "What is your name?",,, 160, 50 TO hDlg
    '----------------------------------------------------------------
    '  Add controls to it
    CONTROL ADD TEXTBOX, hDlg, %IDTEXT, "", 14,  12, 134, 12
    CONTROL ADD BUTTON, hDlg, %IDOK, "OK", 34, 32, 40, 14,%BS_DEFAULT OR %WS_TABSTOP CALL OkButton
    CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 84, 32, 40, 14 CALL CancelButton
    '----------------------------------------------------------------
    '  Display the dialog
    DIALOG SHOW MODAL hDlg TO Result
    '----------------------------------------------------------------
    '  Check the Result at exit
    IF Result THEN
        MSGBOX "Hello " + UserName
    END IF
END FUNCTION


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 03:55:29 PM

PowerBASIC PbWin 9 SDK version.
  Exe Size: 25,600


'======================================================================
' Declares
'----------------------------------------------------------------------
#COMPILE EXE
'----------------------------------------------------------------------
#IF %PB_REVISION < &H1000 ' if compiler PBWIN9 or earlier
    %USEMACROS = 1
#ENDIF
#INCLUDE "WIN32API.INC"
'----------------------------------------------------------------------
%IDC_EDIT100       = 100
GLOBAL UserName AS STRING

'======================================================================
FUNCTION WINMAIN (BYVAL hInst AS DWORD, BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpszCmdLine AS ASCIIZ PTR, BYVAL nCmdShow AS LONG) AS LONG
'----------------------------------------------------------------------
' Program entrance
'----------------------------------------------------------------------
  LOCAL hDlg AS DWORD, hCtl AS DWORD, hEdit As DWORD ,hFont AS DWORD, _
        sBuf AS STRING, wc AS WndClassEx, szClassName AS ASCIIZ * 80

  hFont = GetStockObject(%DEFAULT_GUI_FONT)

  szClassName      = "MyClassName"
  wc.cbSize        = SIZEOF(wc)
  wc.style         = %CS_HREDRAW OR %CS_VREDRAW
  wc.lpfnWndProc   = CODEPTR(WndProc)
  wc.cbClsExtra    = 0
  wc.cbWndExtra    = 0
  wc.hInstance     = hInst
  wc.hIcon         = LoadIcon  (%NULL, BYVAL %IDI_APPLICATION)
  wc.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
  wc.hbrBackground = %COLOR_3DFACE + 1
  wc.lpszMenuName  = %NULL
  wc.lpszClassName = VARPTR(szClassName)
  wc.hIconSm       = LoadIcon  (%NULL, BYVAL %IDI_APPLICATION)
  CALL RegisterClassEx (wc)

  hDlg = CreateWindowEx(%WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE, szClassName, "What is your name?", _
              %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION OR _
              %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT OR %DS_MODALFRAME OR _
              %DS_CENTER, _
              (GetSystemMetrics(%SM_CXSCREEN) - 246) / 2, _
              (GetSystemMetrics(%SM_CYSCREEN) - 110) / 2, _
               246, 110, 0, 0, GetModuleHandle(""), BYVAL %NULL)

  hEdit = CreateWindowEx(%WS_EX_CLIENTEDGE, "Edit", BYVAL %NULL, _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL, _
               21, 20, 201, 19, _
               hDlg, %IDC_EDIT100, GetModuleHandle(""), BYVAL %NULL)

  IF hFont THEN SendMessage hEdit, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "OK", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               51, 52, 60, 23, _
               hDlg, %IDOK, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "Cancel", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               126, 52, 60, 23, _
               hDlg, %IDCANCEL, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  ShowWindow hDlg, nCmdShow
  SetFocus(hEdit)
  UpdateWindow hDlg


  LOCAL Msg AS tagMsg
  WHILE GetMessage(Msg, %NULL, 0, 0)
      IF IsDialogMessage(hDlg,Msg) = 0 Then
          TranslateMessage Msg
          DispatchMessage Msg
      END IF
  WEND
  If msg.wParam Then
      MSGBOX "Hello " + UserName
  End If
  FUNCTION = msg.wParam
END FUNCTION


'======================================================================
FUNCTION WndProc (BYVAL hWnd AS DWORD,  BYVAL wMsg AS DWORD, _
                  BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
'----------------------------------------------------------------------
' Main Window procedure
'----------------------------------------------------------------------
  STATIC RetVal AS LONG
  SELECT CASE wMsg
  CASE %WM_CREATE
      'A good place to initiate things, declare variables,
      'create controls and read/set settings from a file, etc.
      '-------------------------------------------------------

  CASE %WM_COMMAND
      'Messages from controls and menu items are handled here.
      '-------------------------------------------------------
      SELECT CASE LOWRD(wParam)
      CASE %IDCANCEL  ' <- Esc key also triggers %IDCANCEL
          IF HIWRD(wParam) = %BN_CLICKED OR HIWRD(wParam) = 1 THEN
              SendMessage hWnd, %WM_DESTROY, wParam, lParam
              RetVal = 0
              FUNCTION = 0 : EXIT FUNCTION
          END IF

      CASE %IDOK      ' <- Enter key usually triggers %IDOK
         IF HIWRD(wParam) = %BN_CLICKED OR HIWRD(wParam) = 1 THEN
           CONTROL GET TEXT hWnd,%IDC_EDIT100 To UserName
           RetVal = 1
           SendMessage hWnd, %WM_DESTROY, wParam, lParam
         END IF
      END SELECT


  CASE %WM_DESTROY
      ' is sent when program ends - a good place to delete any created objects and
      ' store settings in file for next run, etc. Must send PostQuitMessage to end
      ' properly in SDK-style dialogs. The PostQuitMessage function sends a WM_QUIT
      ' message to the program's (thread's) message queue, and then WM_QUIT causes
      ' the GetMessage function to return zero in WINMAIN's message loop.
      '----------------------------------------------------------------------------
      PostQuitMessage RetVal
      FUNCTION = 0 : EXIT FUNCTION


  END SELECT

  FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 03:57:44 PM

PowerBASIC PBWin 9 HelloRES using a resource dialog.
  Exe Size: 14,336


#COMPILER PBWIN 9
#COMPILE EXE
#DIM ALL
#INCLUDE "Win32API.inc"
#RESOURCE "HelloRes.pbr"
'==============================================================================
%IDD_DLG1 = 1000
%IDC_TEXT = 1001
%IDC_OK = 1002
%IDC_CANCEL = 1003
'==============================================================================
GLOBAL UserName As ASCIIZ * 255
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG
    DIM RetVal AS LONG
    RetVal = DialogBoxParam(hInstance, BYVAL %IDD_DLG1, 0, CODEPTR(DlgProc), BYVAL 0)
    If RetVal = -1 Then
        MsgBox "ERROR"
        Exit Function
    End If
    If RetVal = 1 Then
        MsgBox "Hello " & UserName
    End If
End Function
'==============================================================================
FUNCTION DlgProc(BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    Select Case uMsg
        Case %WM_COMMAND
            Select Case LO(WORD,wParam)
                Case %IDC_OK
                    GetWindowText(GetDlgItem(hwnd,%IDC_TEXT),UserName,255)
                    EndDialog(hwnd,1)
                Case %IDC_CANCEL
                    EndDialog(hwnd,0)
            End Select       
    End Select
    Function = 0
END FUNCTION


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 03:59:09 PM

PowerBASIC PBWin 9 HelloCW which uses an early version of José Roca's CWindow framework.
Exe Size: 66,048


#COMPILE EXE[/color]
#DIM ALL
#INCLUDE ONCE "CWindow.Inc"
#INCLUDE ONCE "WinCtrl.inc"
'==============================================================================
%IDC_OK = 1001
%IDC_CANCEL = 1002
%IDC_TEXT = 1003
'------------------------------------------------------------------------------
GLOBAL UserName As ASCIIZ * 255
'------------------------------------------------------------------------------
Function PbMain()
    Local RetVal As Long
    Local hFont As Long
    Local pWindow As IWindow
    Local dwStyle As DWORD,dwStyleEx As DWORD
      Local hCtl As DWORD
    dwStyle = %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION
    dwStyleEx = %WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE
    pWindow = CLASS "CWindow"
    IF ISNOTHING(pWindow) THEN EXIT FUNCTION
    pWindow.CreateWindow(%NULL,"What's your name?",0,0,246,110,dwStyle,DwStyleEx,CODEPTR(WindowProc))
    dwStyle = %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL
    dwStyleEx = %WS_EX_CLIENTEDGE
    hCtl = pWindow.AddControl("Edit",pWindow.hwnd,%IDC_TEXT,"",21,20,201,19,dwStyle,dwStyleEx)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    hCtl = pWindow.AddControl("Button",pWindow.hwnd,%IDC_OK,"OK",51,52,60,23,-1,-1)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    hCtl = pWindow.AddControl("Button",pWindow.hwnd,%IDC_CANCEL,"Cancel",126,52,60,23,-1,-1)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    Window_Center(pWindow.hwnd)
    SetFocus(GetDlgItem(pWindow.hwnd,%IDC_TEXT))
    RetVal = pWindow.DoEvents()
    If RetVal = 1 Then
        MsgBox "Hello " & UserName
    End If
End Function
'==============================================================================
FUNCTION WindowProc (BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    STATIC Retval As Long
    SELECT CASE uMsg
        CASE %WM_COMMAND
            SELECT CASE LO(WORD, wParam)
                CASE %IDC_CANCEL
                   ' // If the Escape key has been pressed...
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      RetVal = 0
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                   END IF
                CASE %IDC_OK
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      RetVal = 1
                      GetWindowText(GetDlgItem(hwnd,%IDC_TEXT),UserName,255)
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                   END IF
                   
            END SELECT
    CASE %WM_DESTROY
        ' // End the application
        PostQuitMessage Retval
        EXIT FUNCTION
    END SELECT
   
    FUNCTION = DefWindowProc(hwnd, uMsg, wParam, lParam)
End Function

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:00:29 PM

PowerBASIC PBCC 6 HelloJcfDlg using my in memory dialog code to mimic PBWin DDT code.
  Exe Size: 26,112


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloJcfDlg
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#COMPILE EXE
#DIM ALL
#CONSOLE OFF

#INCLUDE "WIN32API.INC"
#INCLUDE "JCFRTDLG.BAS"
'==============================================================================
GLOBAL ghInst         AS LONG
GLOBAL ghDlg          AS LONG
GLOBAL gsDlgTemplate  AS STRING
GLOBAL UserName       As ASCIIZ *255
'==============================================================================
%IDC_OK       = 1001
%IDC_CANCEL   = 1002
%IDC_TEXT     = 1003
'==============================================================================
FUNCTION PBMAIN () AS LONG
  DIM RetVal            AS DWORD, _
      Dlg_Style         AS DWORD, _
      Dlg_ExStyle       AS DWORD, _
      Dlg_HelpId        AS DWORD, _
      Dlg_Left          AS INTEGER, _
      Dlg_Top           AS INTEGER, _
      Dlg_Width         AS INTEGER, _
      Dlg_Height        AS INTEGER, _
      Dlg_Menu          AS STRING, _
      Dlg_Class         AS STRING, _
      Dlg_Caption       AS STRING, _
      Font_PointSize    AS INTEGER, _
      Font_Weight       AS INTEGER, _
      Font_Italic       AS INTEGER, _
      Font_TypeFace     AS STRING

    DIM Ctl_Left      AS INTEGER, _
        Ctl_Top       AS INTEGER, _
        Ctl_Width     AS INTEGER, _
        Ctl_Height    AS INTEGER, _
        Ctl_Id        AS DWORD, _
        Ctl_HelpId    AS DWORD, _
        Ctl_Style     AS DWORD, _
        Ctl_ExStyle   AS DWORD, _
        Ctl_Class     AS STRING, _
        Ctl_Text      AS STRING, _
        Ctl_Extra     AS STRING
    DIM lpDlgProc         AS DWORD
    lpDlgProc = CODEPTR(Dlg_Proc )

    Dlg_Style = %WS_BORDER OR _
                %WS_CAPTION OR _
                %DS_MODALFRAME OR _
                %DS_SETFONT OR _
                %WS_VISIBLE OR _
                %WS_SYSMENU OR _
                %WS_POPUP
    Dlg_ExStyle = 0
    Dlg_HelpId = 0
    Dlg_Left = 0
    Dlg_Top = 0
    Dlg_Width = 160
    Dlg_Height = 50

    Dlg_Menu = ""
    Dlg_Caption = "What's your name?"
    Font_PointSize = 8
    Font_Weight = 400
    Font_Italic = 0
    Font_TypeFace = "MS Sans Serif"

  DlgTemplate_Create gsDlgTemplate, _
                     Dlg_Style, _
                     Dlg_ExStyle, _
                     Dlg_HelpId, _
                     Dlg_Left, _
                     Dlg_Top, _
                     Dlg_Width, _
                     Dlg_Height, _
                     Dlg_Menu, _
                     Dlg_Class, _
                     Dlg_Caption, _
                     Font_PointSize, _
                     Font_Weight, _
                     Font_Italic, _
                     Font_TypeFace
    Ctl_Style = %ES_LEFT OR %WS_CHILD OR %WS_BORDER OR %WS_TABSTOP OR %WS_VISIBLE
    Ctl_Id = %IDC_TEXT
    Ctl_Class = "EDIT"
    Ctl_Left = 14
    Ctl_Top = 12
    Ctl_Width = 134
    Ctl_Height = 12
    GOSUB AddControl

    Ctl_Style = %BS_PUSHBUTTON OR %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP
    Ctl_Class = "BUTTON"
    Ctl_Left = 34
    Ctl_Top = 32
    Ctl_Height = 14
    Ctl_Width = 40
    Ctl_Id = %IDC_OK
    Ctl_Text = "Ok"
    GOSUB AddControl

    Ctl_Left = 84
    Ctl_Id = %IDC_CANCEL
    Ctl_Text = "Cancel"
    GOSUB AddControl

    RetVal = DialogBoxIndirectParam(ghInst, BYVAL STRPTR(gsDlgTemplate), 0, lpDlgProc, 0)
    IF RetVal = -1 THEN
        PRINT "No Go"
        WAITKEY$
    END IF
    If RetVal = 1 Then
        MessageBox(0,"Hello " & UserName,"What's your Name",%MB_OK)
    End If

    EXIT FUNCTION


AddControl:
  DlgTemplate_AddControl gsDlgTemplate, _
                           Ctl_Left, _
                           Ctl_Top, _
                           Ctl_Width, _
                           Ctl_Height, _
                           Ctl_Id, _
                           Ctl_HelpId, _
                           Ctl_Style, _
                           Ctl_ExStyle, _
                           Ctl_Class, _
                           Ctl_Text, _
                           Ctl_Extra
RETURN

END FUNCTION
'==============================================================================
FUNCTION Dlg_Proc(BYVAL hDlg AS DWORD,BYVAL wMsg AS DWORD,BYVAL wParam AS DWORD,BYVAL lParam AS LONG) AS LONG
    SELECT CASE wMsg
        CASE %WM_INITDIALOG
            CenterWindow(hDlg)
        CASE %WM_COMMAND
            SELECT CASE LO(WORD,wParam)
                CASE %IDC_OK
                    GetWindowText(GetDlgItem(hDlg,%IDC_TEXT),UserName,255)
                    EndDialog(hDlg,1)
                CASE %IDC_CANCEL
                    EndDialog(hDlg,2)
            END SELECT
    END SELECT
    FUNCTION = 0
END FUNCTION

'==============================================================================

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:01:23 PM

PowerBASIC PBCC 6 HelloSDK
  Exe Size: 21,504



#COMPILE EXE[/color]
#DIM ALL
#CONSOLE OFF
%USEMACROS = 1
#INCLUDE "Win32API.inc"
%IDC_OK = 1001
%IDC_CANCEL = 1002
%IDC_TEXT = 1003
GLOBAL UserName As ASCIIZ * 255
'==============================================================================
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG


    LOCAL Msg       AS tagMsg
    LOCAL wce       AS WndClassEx
    LOCAL szAppName AS ASCIIZ * 80
    LOCAL hWnd      AS DWORD,hEdit As DWORD, hCtl As DWORD ,hFont As DWORD
       hFont = GetStockObject(%DEFAULT_GUI_FONT)
    szAppName         = "HelloWin"
    wce.cbSize        = SIZEOF(wce)
    wce.STYLE         = %CS_HREDRAW OR %CS_VREDRAW
    wce.lpfnWndProc   = CODEPTR(WndProc)
    wce.cbClsExtra    = 0
    wce.cbWndExtra    = 0
    wce.hInstance     = hInstance
    wce.hIcon         = %NULL
    wce.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
    wce.hbrBackground = %COLOR_BTNFACE + 1
    wce.lpszMenuName  = %NULL
    wce.lpszClassName = VARPTR(szAppName)
    wce.hIconSm       = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)

    RegisterClassEx wce

  hWnd = CreateWindowEx(%WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE, szAppName, "What is your name?", _
              %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION OR _
              %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT OR %DS_MODALFRAME OR _
              %DS_CENTER, _
              (GetSystemMetrics(%SM_CXSCREEN) - 246) / 2, _
              (GetSystemMetrics(%SM_CYSCREEN) - 110) / 2, _
               246, 110, 0, 0, GetModuleHandle(""), BYVAL %NULL)

  hEdit = CreateWindowEx(%WS_EX_CLIENTEDGE, "Edit", BYVAL %NULL, _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL, _
               21, 20, 201, 19, _
               hWnd, %IDC_TEXT, GetModuleHandle(""), BYVAL %NULL)

  IF hFont THEN SendMessage hEdit, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "OK", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               51, 52, 60, 23, _
               hWnd, %IDC_OK, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "Cancel", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               126, 52, 60, 23, _
               hWnd, %IDC_CANCEL, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  ShowWindow hWnd, iCmdShow
  SetFocus(hEdit)
  UpdateWindow hWnd



    ' Display the window on the screen
    ShowWindow hWnd, iCmdShow
    UpdateWindow hWnd
    DO WHILE GetMessage(Msg, %NULL, 0, 0)
        If IsDialogMessage(hWnd, Msg) = 0 Then
            TranslateMessage Msg
            DispatchMessage Msg
        End If
    LOOP

    If msg.wParam = 1 Then
        MessageBox(0,"Hello " & UserName,"What's your Name",%MB_OK)
    End If
    Function = 0
END FUNCTION
'==============================================================================
FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _
                  BYVAL wParam AS DWORD, BYVAL lParam AS LONG) EXPORT AS LONG
    STATIC RetVal AS LONG

  SELECT CASE wMsg

  CASE %WM_COMMAND
      'Messages from controls and menu items are handled here.
      '-------------------------------------------------------
      SELECT CASE LOWRD(wParam)
      CASE %IDC_CANCEL  ' <- Esc key also triggers %IDCANCEL
          IF HIWRD(wParam) = %BN_CLICKED THEN
              RetVal = 0
              SendMessage hWnd, %WM_CLOSE,0,0
              FUNCTION = 0 : EXIT FUNCTION
          END IF

      CASE %IDC_OK      ' <- Enter key usually triggers %IDOK
         IF HIWRD(wParam) = %BN_CLICKED THEN
           'CONTROL GET TEXT hWnd,%IDC_TEXT To UserName
           GetWindowText(GetDlgItem(hWnd,%IDC_TEXT),UserName$,255)
           RetVal = 1
           SendMessage hWnd, %WM_CLOSE, 0,0
             FUNCTION = 0 : EXIT FUNCTION
         END IF
      END SELECT
  CASE %WM_CLOSE
      DestroyWindow(hWnd)
      Function = 0
  CASE %WM_DESTROY
      ' is sent when program ends - a good place to delete any created objects and
      ' store settings in file for next run, etc. Must send PostQuitMessage to end
      ' properly in SDK-style dialogs. The PostQuitMessage function sends a WM_QUIT
      ' message to the program's (thread's) message queue, and then WM_QUIT causes
      ' the GetMessage function to return zero in WINMAIN's message loop.
      '----------------------------------------------------------------------------
      PostQuitMessage RetVal
      FUNCTION = 0 : EXIT FUNCTION


  END SELECT



    FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
'==============================================================================

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:02:39 PM

PowerBASIC PBCC 6 HelloRES using a resource dialog
  Exe Size: 19,968


#COMPILE EXE
#DIM ALL
#CONSOLE OFF
%USEMACROS = 1
#INCLUDE "Win32API.inc"
#RESOURCE RES,"HelloRES.RES"
%IDD_DLG1 = 1000
%IDC_TEXT = 1001
%IDC_OK = 1002
%IDC_CANCEL = 1003
'==============================================================================
GLOBAL UserName As ASCIIZ * 255
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG
    DIM RetVal AS LONG
    UserName = SPACE$(0)
    RetVal = DialogBoxParam(hInstance, BYVAL %IDD_DLG1, 0, CODEPTR(DlgProc), BYVAL 0)
    If RetVal = -1 Then
        MessageBox(0, "ERROR","ERROR",%MB_OK)
        Exit Function
    End If
    If RetVal = 1 Then
        MessageBox(0, "Hello " & UserName,"What's your name?",%MB_OK)
    End If
End Function
'==============================================================================
FUNCTION DlgProc(BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    Select Case uMsg
        Case %WM_COMMAND
            Select Case LO(WORD,wParam)
                Case %IDC_OK
                    GetWindowText(GetDlgItem(hwnd,%IDC_TEXT),UserName,255)
                    EndDialog(hwnd,1)
                Case %IDC_CANCEL
                    EndDialog(hwnd,0)
            End Select       
    End Select
    Function = 0
END FUNCTION


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:03:42 PM

PowerBASIC PBCC 6 HelloCW using José Roca's CWindow Framework
Exe Size 36,864


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloCW
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#COMPILE EXE
#DIM ALL
#CONSOLE OFF
#INCLUDE ONCE "CWindow.Inc"
'==============================================================================
%IDC_OK = 1001
%IDC_CANCEL = 1002
%IDC_TEXT = 1003
'------------------------------------------------------------------------------
GLOBAL UserName As ASCIIZ * 255
'------------------------------------------------------------------------------
Function PbMain()
    Local RetVal As Long
    Local hFont As Long
    Local pWindow As IWindow
    Local dwStyle As DWORD,dwStyleEx As DWORD
      Local hCtl As DWORD
    dwStyle = %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION
    dwStyleEx = %WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE
    pWindow = CLASS "CWindow"
    IF ISNOTHING(pWindow) THEN EXIT FUNCTION
    pWindow.CreateWindow(%NULL,"What's your name?",0,0,246,110,dwStyle,dwStyleEx,CODEPTR(WindowProc))
    dwStyle = %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL
    dwStyleEx = %WS_EX_CLIENTEDGE
    hCtl = pWindow.AddControl("Edit",pWindow.hwnd,%IDC_TEXT,"",21,20,201,19,dwStyle,dwStyleEx)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    hCtl = pWindow.AddControl("Button",pWindow.hwnd,%IDC_OK,"OK",51,52,60,23,-1,-1)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    hCtl = pWindow.AddControl("Button",pWindow.hwnd,%IDC_CANCEL,"Cancel",126,52,60,23,-1,-1)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    AfxCenterWindow(pWindow.hwnd)
    SetFocus(GetDlgItem(pWindow.hwnd,%IDC_TEXT))
    RetVal = pWindow.DoEvents()
    If RetVal = 1 Then
        MessageBox(0, "Hello " & UserName,"What's your name?",%MB_OK)
    End If
End Function
'==============================================================================
FUNCTION WindowProc (BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    STATIC Retval As Long
    SELECT CASE uMsg
        CASE %WM_COMMAND
            SELECT CASE LO(WORD, wParam)
                CASE %IDC_CANCEL
                   ' // If the Escape key has been pressed...
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      RetVal = 0
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                   END IF
                CASE %IDC_OK
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      RetVal = 1
                      GetWindowText(GetDlgItem(hwnd,%IDC_TEXT),UserName,255)
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                   END IF
                   
            END SELECT
    CASE %WM_DESTROY
        ' // End the application
        PostQuitMessage Retval
        EXIT FUNCTION
    END SELECT
   
    FUNCTION = DefWindowProc(hwnd, uMsg, wParam, lParam)
End Function

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:05:15 PM

PowerBASIC PbWin 10 HelloDDT:
  Exe Size 48,128


'==============================================================================
'
'  HELLODDT.BAS for PowerBASIC for Windows
'  Copyright (c) 1997-2008 PowerBASIC, Inc.
'  All Rights Reserved.
'
'  A simple DDT dialog example.
'
'==============================================================================
' Metastatements
'
#COMPILER PBWIN 10
#COMPILE EXE
#DIM ALL
'------------------------------------------------------------------------------
' Equates and global variables
'
%IDOK       = 1
%IDCANCEL   = 2
%IDTEXT     = 100
%BS_DEFAULT = 1
GLOBAL UserName AS STRING
'------------------------------------------------------------------------------
' OK button callback
'
CALLBACK FUNCTION OkButton () AS LONG
    IF CB.CTLMSG = %BN_CLICKED THEN
        CONTROL GET TEXT CB.HNDL, %IDTEXT TO UserName
        DIALOG END CB.HNDL, 1
        FUNCTION = 1
    END IF
END FUNCTION
'------------------------------------------------------------------------------
' Cancel button callback
CALLBACK FUNCTION CancelButton () AS LONG

    IF CB.CTLMSG = %BN_CLICKED THEN
        DIALOG END CB.HNDL, 0
        FUNCTION = 1
    END IF
END FUNCTION
'------------------------------------------------------------------------------
' Main application entry point...
FUNCTION PBMAIN() AS LONG
    LOCAL hDlg   AS DWORD
    LOCAL Result AS LONG
    '  Create a new dialog template
    DIALOG NEW 0, "What is your name?",,, 160, 50 TO hDlg
    '----------------------------------------------------------------
    '  Add controls to it
    CONTROL ADD TEXTBOX, hDlg, %IDTEXT, "", 14,  12, 134, 12
    CONTROL ADD BUTTON, hDlg, %IDOK, "OK", 34, 32, 40, 14,%BS_DEFAULT OR %WS_TABSTOP CALL OkButton
    CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 84, 32, 40, 14 CALL CancelButton
    '----------------------------------------------------------------
    '  Display the dialog
    DIALOG SHOW MODAL hDlg TO Result
    '----------------------------------------------------------------
    '  Check the Result at exit
    IF Result THEN
        MSGBOX "Hello " + UserName
    END IF
END FUNCTION


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:06:47 PM

PowerBASIC PBWin 10 HelloSDK
  Exe Size 20,480



#COMPILE EXE
#DIM ALL
%USEMACROS = 1
#INCLUDE "Win32API.inc"
%IDC_OK = 1001
%IDC_CANCEL = 1002
%IDC_TEXT = 1003
GLOBAL UserName As ASCIIZ * 255
'==============================================================================
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG


    LOCAL Msg       AS tagMsg
    LOCAL wce       AS WndClassEx
    LOCAL szAppName AS ASCIIZ * 80
    LOCAL hWnd      AS DWORD,hEdit As DWORD, hCtl As DWORD ,hFont As DWORD
       hFont = GetStockObject(%DEFAULT_GUI_FONT)
    szAppName         = "HelloWin"
    wce.cbSize        = SIZEOF(wce)
    wce.STYLE         = %CS_HREDRAW OR %CS_VREDRAW
    wce.lpfnWndProc   = CODEPTR(WndProc)
    wce.cbClsExtra    = 0
    wce.cbWndExtra    = 0
    wce.hInstance     = hInstance
    wce.hIcon         = %NULL
    wce.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
    wce.hbrBackground = %COLOR_BTNFACE + 1
    wce.lpszMenuName  = %NULL
    wce.lpszClassName = VARPTR(szAppName)
    wce.hIconSm       = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)

    RegisterClassEx wce

  hWnd = CreateWindowEx(%WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE, szAppName, "What is your name?", _
              %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION OR _
              %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT OR %DS_MODALFRAME OR _
              %DS_CENTER, _
              (GetSystemMetrics(%SM_CXSCREEN) - 246) / 2, _
              (GetSystemMetrics(%SM_CYSCREEN) - 110) / 2, _
               246, 110, 0, 0, GetModuleHandle(""), BYVAL %NULL)

  hEdit = CreateWindowEx(%WS_EX_CLIENTEDGE, "Edit", BYVAL %NULL, _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL, _
               21, 20, 201, 19, _
               hWnd, %IDC_TEXT, GetModuleHandle(""), BYVAL %NULL)

  IF hFont THEN SendMessage hEdit, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "OK", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               51, 52, 60, 23, _
               hWnd, %IDC_OK, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "Cancel", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               126, 52, 60, 23, _
               hWnd, %IDC_CANCEL, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  ShowWindow hWnd, iCmdShow
  SetFocus(hEdit)
  UpdateWindow hWnd



    ' Display the window on the screen
    ShowWindow hWnd, iCmdShow
    UpdateWindow hWnd
    DO WHILE GetMessage(Msg, %NULL, 0, 0)
        If IsDialogMessage(hWnd, Msg) = 0 Then
            TranslateMessage Msg
            DispatchMessage Msg
        End If
    LOOP

    If msg.wParam = 1 Then
        MessageBox(0,"Hello " & UserName,"What's your Name",%MB_OK)
    End If
    Function = 0
END FUNCTION
'==============================================================================
FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _
                  BYVAL wParam AS DWORD, BYVAL lParam AS LONG) EXPORT AS LONG
    STATIC RetVal AS LONG

  SELECT CASE wMsg

  CASE %WM_COMMAND
      'Messages from controls and menu items are handled here.
      '-------------------------------------------------------
      SELECT CASE LOWRD(wParam)
      CASE %IDC_CANCEL  ' <- Esc key also triggers %IDCANCEL
          IF HIWRD(wParam) = %BN_CLICKED THEN
              RetVal = 0
              SendMessage hWnd, %WM_CLOSE,0,0
              FUNCTION = 0 : EXIT FUNCTION
          END IF

      CASE %IDC_OK      ' <- Enter key usually triggers %IDOK
         IF HIWRD(wParam) = %BN_CLICKED THEN
           'CONTROL GET TEXT hWnd,%IDC_TEXT To UserName
           GetWindowText(GetDlgItem(hWnd,%IDC_TEXT),UserName$,255)
           RetVal = 1
           SendMessage hWnd, %WM_CLOSE, 0,0
             FUNCTION = 0 : EXIT FUNCTION
         END IF
      END SELECT
  CASE %WM_CLOSE
      DestroyWindow(hWnd)
      Function = 0
  CASE %WM_DESTROY
      ' is sent when program ends - a good place to delete any created objects and
      ' store settings in file for next run, etc. Must send PostQuitMessage to end
      ' properly in SDK-style dialogs. The PostQuitMessage function sends a WM_QUIT
      ' message to the program's (thread's) message queue, and then WM_QUIT causes
      ' the GetMessage function to return zero in WINMAIN's message loop.
      '----------------------------------------------------------------------------
      PostQuitMessage RetVal
      FUNCTION = 0 : EXIT FUNCTION

  END SELECT

    FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
'==============================================================================

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:07:38 PM

PowerBASIC PbWin 10 HelloRES using a resource dialog
  Exe Size 18,944


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloRES
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#COMPILER PBWIN 10
#COMPILE EXE
#DIM ALL
#INCLUDE "Win32API.inc"
#RESOURCE RES "HelloRES.RES"
'==============================================================================
%IDD_DLG1 = 1000
%IDC_TEXT = 1001
%IDC_OK = 1002
%IDC_CANCEL = 1003
'==============================================================================
GLOBAL UserName As ASCIIZ * 255
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG
    DIM RetVal AS LONG
    UserName = SPACE$(0)
    RetVal = DialogBoxParam(hInstance, BYVAL %IDD_DLG1, 0, CODEPTR(DlgProc), BYVAL 0)
    If RetVal = -1 Then
        MsgBox "ERROR"
        Exit Function
    End If
    If RetVal = 1 Then
        MsgBox "Hello " & UserName
    End If
End Function
'==============================================================================
FUNCTION DlgProc(BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    Select Case uMsg
        Case %WM_COMMAND
            Select Case LO(WORD,wParam)
                Case %IDC_OK
                    GetWindowText(GetDlgItem(hwnd,%IDC_TEXT),UserName,255)
                    EndDialog(hwnd,1)
                Case %IDC_CANCEL
                    EndDialog(hwnd,0)
            End Select       
    End Select
    Function = 0
END FUNCTION


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:08:24 PM

PowerBASIC PBWin 10 HelloCW using José Roca's CWindow Framework.
  Exe Size: 36,352


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloCW 36,352
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#COMPILE EXE
#DIM ALL
#INCLUDE ONCE "CWindow.Inc"
'==============================================================================
%IDC_OK = 1001
%IDC_CANCEL = 1002
%IDC_TEXT = 1003
'------------------------------------------------------------------------------
GLOBAL UserName As ASCIIZ * 255
'------------------------------------------------------------------------------
Function PbMain()
    Local RetVal As Long
    Local hFont As Long
    Local pWindow As IWindow
    Local dwStyle As DWORD,dwStyleEx As DWORD
      Local hCtl As DWORD
    dwStyle = %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION
    dwStyleEx = %WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE
    pWindow = CLASS "CWindow"
    IF ISNOTHING(pWindow) THEN EXIT FUNCTION
    pWindow.CreateWindow(%NULL,"What's your name?",0,0,246,110,dwStyle,dwStyleEx,CODEPTR(WindowProc))
    dwStyle = %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL
    dwStyleEx = %WS_EX_CLIENTEDGE
    hCtl = pWindow.AddControl("Edit",pWindow.hwnd,%IDC_TEXT,"",21,20,201,19,dwStyle,dwStyleEx)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    hCtl = pWindow.AddControl("Button",pWindow.hwnd,%IDC_OK,"OK",51,52,60,23,-1,-1)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    hCtl = pWindow.AddControl("Button",pWindow.hwnd,%IDC_CANCEL,"Cancel",126,52,60,23,-1,-1)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    AfxCenterWindow(pWindow.hwnd)
    SetFocus(GetDlgItem(pWindow.hwnd,%IDC_TEXT))
    RetVal = pWindow.DoEvents()
    If RetVal = 1 Then
        MsgBox "Hello " & UserName
    End If
End Function
'==============================================================================
FUNCTION WindowProc (BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    STATIC Retval As Long
    SELECT CASE uMsg
        CASE %WM_COMMAND
            SELECT CASE LO(WORD, wParam)
                CASE %IDC_CANCEL
                   ' // If the Escape key has been pressed...
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      RetVal = 0
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                   END IF
                CASE %IDC_OK
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      RetVal = 1
                      GetWindowText(GetDlgItem(hwnd,%IDC_TEXT),UserName,255)
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                   END IF
                   
            END SELECT
    CASE %WM_DESTROY
        ' // End the application
        PostQuitMessage Retval
        EXIT FUNCTION
    END SELECT
   
    FUNCTION = DefWindowProc(hwnd, uMsg, wParam, lParam)
End Function

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:09:24 PM

PowerBASIC PBCC 6 HelloJcfDlg using my in memory dialog code to mimic PBWin DDT code.
  Exe Size: 26,112


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloJcfDlg
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#COMPILE EXE
#DIM ALL
#CONSOLE OFF

#INCLUDE "WIN32API.INC"
#INCLUDE "JCFRTDLG.BAS"
'==============================================================================
GLOBAL ghInst         AS LONG
GLOBAL ghDlg          AS LONG
GLOBAL gsDlgTemplate  AS STRING
GLOBAL UserName       As ASCIIZ *255
'==============================================================================
%IDC_OK       = 1001
%IDC_CANCEL   = 1002
%IDC_TEXT     = 1003
'==============================================================================
FUNCTION PBMAIN () AS LONG
  DIM RetVal            AS DWORD, _
      Dlg_Style         AS DWORD, _
      Dlg_ExStyle       AS DWORD, _
      Dlg_HelpId        AS DWORD, _
      Dlg_Left          AS INTEGER, _
      Dlg_Top           AS INTEGER, _
      Dlg_Width         AS INTEGER, _
      Dlg_Height        AS INTEGER, _
      Dlg_Menu          AS STRING, _
      Dlg_Class         AS STRING, _
      Dlg_Caption       AS STRING, _
      Font_PointSize    AS INTEGER, _
      Font_Weight       AS INTEGER, _
      Font_Italic       AS INTEGER, _
      Font_TypeFace     AS STRING

    DIM Ctl_Left      AS INTEGER, _
        Ctl_Top       AS INTEGER, _
        Ctl_Width     AS INTEGER, _
        Ctl_Height    AS INTEGER, _
        Ctl_Id        AS DWORD, _
        Ctl_HelpId    AS DWORD, _
        Ctl_Style     AS DWORD, _
        Ctl_ExStyle   AS DWORD, _
        Ctl_Class     AS STRING, _
        Ctl_Text      AS STRING, _
        Ctl_Extra     AS STRING
    DIM lpDlgProc         AS DWORD
    lpDlgProc = CODEPTR(Dlg_Proc )

    Dlg_Style = %WS_BORDER OR _
                %WS_CAPTION OR _
                %DS_MODALFRAME OR _
                %DS_SETFONT OR _
                %WS_VISIBLE OR _
                %WS_SYSMENU OR _
                %WS_POPUP
    Dlg_ExStyle = 0
    Dlg_HelpId = 0
    Dlg_Left = 0
    Dlg_Top = 0
    Dlg_Width = 160
    Dlg_Height = 50

    Dlg_Menu = ""
    Dlg_Caption = "What's your name?"
    Font_PointSize = 8
    Font_Weight = 400
    Font_Italic = 0
    Font_TypeFace = "MS Sans Serif"

  DlgTemplate_Create gsDlgTemplate, _
                     Dlg_Style, _
                     Dlg_ExStyle, _
                     Dlg_HelpId, _
                     Dlg_Left, _
                     Dlg_Top, _
                     Dlg_Width, _
                     Dlg_Height, _
                     Dlg_Menu, _
                     Dlg_Class, _
                     Dlg_Caption, _
                     Font_PointSize, _
                     Font_Weight, _
                     Font_Italic, _
                     Font_TypeFace
    Ctl_Style = %ES_LEFT OR %WS_CHILD OR %WS_BORDER OR %WS_TABSTOP OR %WS_VISIBLE
    Ctl_Id = %IDC_TEXT
    Ctl_Class = "EDIT"
    Ctl_Left = 14
    Ctl_Top = 12
    Ctl_Width = 134
    Ctl_Height = 12
    GOSUB AddControl

    Ctl_Style = %BS_PUSHBUTTON OR %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP
    Ctl_Class = "BUTTON"
    Ctl_Left = 34
    Ctl_Top = 32
    Ctl_Height = 14
    Ctl_Width = 40
    Ctl_Id = %IDC_OK
    Ctl_Text = "Ok"
    GOSUB AddControl

    Ctl_Left = 84
    Ctl_Id = %IDC_CANCEL
    Ctl_Text = "Cancel"
    GOSUB AddControl

    RetVal = DialogBoxIndirectParam(ghInst, BYVAL STRPTR(gsDlgTemplate), 0, lpDlgProc, 0)
    IF RetVal = -1 THEN
        PRINT "No Go"
        WAITKEY$
    END IF
    If RetVal = 1 Then
        MessageBox(0,"Hello " & UserName,"What's your Name",%MB_OK)
    End If

    EXIT FUNCTION


AddControl:
  DlgTemplate_AddControl gsDlgTemplate, _
                           Ctl_Left, _
                           Ctl_Top, _
                           Ctl_Width, _
                           Ctl_Height, _
                           Ctl_Id, _
                           Ctl_HelpId, _
                           Ctl_Style, _
                           Ctl_ExStyle, _
                           Ctl_Class, _
                           Ctl_Text, _
                           Ctl_Extra
RETURN

END FUNCTION
'==============================================================================
FUNCTION Dlg_Proc(BYVAL hDlg AS DWORD,BYVAL wMsg AS DWORD,BYVAL wParam AS DWORD,BYVAL lParam AS LONG) AS LONG
    SELECT CASE wMsg
        CASE %WM_INITDIALOG
            CenterWindow(hDlg)
        CASE %WM_COMMAND
            SELECT CASE LO(WORD,wParam)
                CASE %IDC_OK
                    GetWindowText(GetDlgItem(hDlg,%IDC_TEXT),UserName,255)
                    EndDialog(hDlg,1)
                CASE %IDC_CANCEL
                    EndDialog(hDlg,2)
            END SELECT
    END SELECT
    FUNCTION = 0
END FUNCTION

'==============================================================================

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:10:46 PM

PowerBASIC PBCC 6 HelloSDK
  Exe Size: 21,504



#COMPILE EXE
#DIM ALL
#CONSOLE OFF
%USEMACROS = 1
#INCLUDE "Win32API.inc"
%IDC_OK = 1001
%IDC_CANCEL = 1002
%IDC_TEXT = 1003
GLOBAL UserName As ASCIIZ * 255
'==============================================================================
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG


    LOCAL Msg       AS tagMsg
    LOCAL wce       AS WndClassEx
    LOCAL szAppName AS ASCIIZ * 80
    LOCAL hWnd      AS DWORD,hEdit As DWORD, hCtl As DWORD ,hFont As DWORD
       hFont = GetStockObject(%DEFAULT_GUI_FONT)
    szAppName         = "HelloWin"
    wce.cbSize        = SIZEOF(wce)
    wce.STYLE         = %CS_HREDRAW OR %CS_VREDRAW
    wce.lpfnWndProc   = CODEPTR(WndProc)
    wce.cbClsExtra    = 0
    wce.cbWndExtra    = 0
    wce.hInstance     = hInstance
    wce.hIcon         = %NULL
    wce.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
    wce.hbrBackground = %COLOR_BTNFACE + 1
    wce.lpszMenuName  = %NULL
    wce.lpszClassName = VARPTR(szAppName)
    wce.hIconSm       = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)

    RegisterClassEx wce

  hWnd = CreateWindowEx(%WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE, szAppName, "What is your name?", _
              %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION OR _
              %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT OR %DS_MODALFRAME OR _
              %DS_CENTER, _
              (GetSystemMetrics(%SM_CXSCREEN) - 246) / 2, _
              (GetSystemMetrics(%SM_CYSCREEN) - 110) / 2, _
               246, 110, 0, 0, GetModuleHandle(""), BYVAL %NULL)

  hEdit = CreateWindowEx(%WS_EX_CLIENTEDGE, "Edit", BYVAL %NULL, _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL, _
               21, 20, 201, 19, _
               hWnd, %IDC_TEXT, GetModuleHandle(""), BYVAL %NULL)

  IF hFont THEN SendMessage hEdit, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "OK", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               51, 52, 60, 23, _
               hWnd, %IDC_OK, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "Cancel", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               126, 52, 60, 23, _
               hWnd, %IDC_CANCEL, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  ShowWindow hWnd, iCmdShow
  SetFocus(hEdit)
  UpdateWindow hWnd



    ' Display the window on the screen
    ShowWindow hWnd, iCmdShow
    UpdateWindow hWnd
    DO WHILE GetMessage(Msg, %NULL, 0, 0)
        If IsDialogMessage(hWnd, Msg) = 0 Then
            TranslateMessage Msg
            DispatchMessage Msg
        End If
    LOOP

    If msg.wParam = 1 Then
        MessageBox(0,"Hello " & UserName,"What's your Name",%MB_OK)
    End If
    Function = 0
END FUNCTION
'==============================================================================
FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _
                  BYVAL wParam AS DWORD, BYVAL lParam AS LONG) EXPORT AS LONG
    STATIC RetVal AS LONG

  SELECT CASE wMsg

  CASE %WM_COMMAND
      'Messages from controls and menu items are handled here.
      '-------------------------------------------------------
      SELECT CASE LOWRD(wParam)
      CASE %IDC_CANCEL  ' <- Esc key also triggers %IDCANCEL
          IF HIWRD(wParam) = %BN_CLICKED THEN
              RetVal = 0
              SendMessage hWnd, %WM_CLOSE,0,0
              FUNCTION = 0 : EXIT FUNCTION
          END IF

      CASE %IDC_OK      ' <- Enter key usually triggers %IDOK
         IF HIWRD(wParam) = %BN_CLICKED THEN
           'CONTROL GET TEXT hWnd,%IDC_TEXT To UserName
           GetWindowText(GetDlgItem(hWnd,%IDC_TEXT),UserName$,255)
           RetVal = 1
           SendMessage hWnd, %WM_CLOSE, 0,0
             FUNCTION = 0 : EXIT FUNCTION
         END IF
      END SELECT
  CASE %WM_CLOSE
      DestroyWindow(hWnd)
      Function = 0
  CASE %WM_DESTROY
      ' is sent when program ends - a good place to delete any created objects and
      ' store settings in file for next run, etc. Must send PostQuitMessage to end
      ' properly in SDK-style dialogs. The PostQuitMessage function sends a WM_QUIT
      ' message to the program's (thread's) message queue, and then WM_QUIT causes
      ' the GetMessage function to return zero in WINMAIN's message loop.
      '----------------------------------------------------------------------------
      PostQuitMessage RetVal
      FUNCTION = 0 : EXIT FUNCTION

  END SELECT

    FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
'==============================================================================

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:11:38 PM

PowerBASIC PBCC 6 HelloRES using a resource dialog
  Exe Size: 19,968


#COMPILE EXE
#DIM ALL
#CONSOLE OFF
%USEMACROS = 1
#INCLUDE "Win32API.inc"
#RESOURCE RES,"HelloRES.RES"
%IDD_DLG1 = 1000
%IDC_TEXT = 1001
%IDC_OK = 1002
%IDC_CANCEL = 1003
'==============================================================================
GLOBAL UserName As ASCIIZ * 255
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG
    DIM RetVal AS LONG
    UserName = SPACE$(0)
    RetVal = DialogBoxParam(hInstance, BYVAL %IDD_DLG1, 0, CODEPTR(DlgProc), BYVAL 0)
    If RetVal = -1 Then
        MessageBox(0, "ERROR","ERROR",%MB_OK)
        Exit Function
    End If
    If RetVal = 1 Then
        MessageBox(0, "Hello " & UserName,"What's your name?",%MB_OK)
    End If
End Function
'==============================================================================
FUNCTION DlgProc(BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    Select Case uMsg
        Case %WM_COMMAND
            Select Case LO(WORD,wParam)
                Case %IDC_OK
                    GetWindowText(GetDlgItem(hwnd,%IDC_TEXT),UserName,255)
                    EndDialog(hwnd,1)
                Case %IDC_CANCEL
                    EndDialog(hwnd,0)
            End Select       
    End Select
    Function = 0
END FUNCTION


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:12:24 PM

PowerBASIC PBCC 6 HelloCW using José Roca's CWindow Framework
Exe Size 36,864


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloCW
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#COMPILE EXE
#DIM ALL
#CONSOLE OFF
#INCLUDE ONCE "CWindow.Inc"
'==============================================================================
%IDC_OK = 1001
%IDC_CANCEL = 1002
%IDC_TEXT = 1003
'------------------------------------------------------------------------------
GLOBAL UserName As ASCIIZ * 255
'------------------------------------------------------------------------------
Function PbMain()
    Local RetVal As Long
    Local hFont As Long
    Local pWindow As IWindow
    Local dwStyle As DWORD,dwStyleEx As DWORD
      Local hCtl As DWORD
    dwStyle = %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION
    dwStyleEx = %WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE
    pWindow = CLASS "CWindow"
    IF ISNOTHING(pWindow) THEN EXIT FUNCTION
    pWindow.CreateWindow(%NULL,"What's your name?",0,0,246,110,dwStyle,dwStyleEx,CODEPTR(WindowProc))
    dwStyle = %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL
    dwStyleEx = %WS_EX_CLIENTEDGE
    hCtl = pWindow.AddControl("Edit",pWindow.hwnd,%IDC_TEXT,"",21,20,201,19,dwStyle,dwStyleEx)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    hCtl = pWindow.AddControl("Button",pWindow.hwnd,%IDC_OK,"OK",51,52,60,23,-1,-1)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    hCtl = pWindow.AddControl("Button",pWindow.hwnd,%IDC_CANCEL,"Cancel",126,52,60,23,-1,-1)
    SendMessage hCtl,%WM_SETFONT,pWindow.hFont,0
    AfxCenterWindow(pWindow.hwnd)
    SetFocus(GetDlgItem(pWindow.hwnd,%IDC_TEXT))
    RetVal = pWindow.DoEvents()
    If RetVal = 1 Then
        MessageBox(0, "Hello " & UserName,"What's your name?",%MB_OK)
    End If
End Function
'==============================================================================
FUNCTION WindowProc (BYVAL hwnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    STATIC Retval As Long
    SELECT CASE uMsg
        CASE %WM_COMMAND
            SELECT CASE LO(WORD, wParam)
                CASE %IDC_CANCEL
                   ' // If the Escape key has been pressed...
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      RetVal = 0
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                   END IF
                CASE %IDC_OK
                   IF HI(WORD, wParam) = %BN_CLICKED THEN
                      ' // ... close the application by sending a WM_CLOSE message
                      RetVal = 1
                      GetWindowText(GetDlgItem(hwnd,%IDC_TEXT),UserName,255)
                      SendMessage hwnd, %WM_CLOSE, 0, 0
                   END IF
                   
            END SELECT
    CASE %WM_DESTROY
        ' // End the application
        PostQuitMessage Retval
        EXIT FUNCTION
    END SELECT
   
    FUNCTION = DefWindowProc(hwnd, uMsg, wParam, lParam)
End Function

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:13:49 PM

bc9Basic Hellobc9Dlg using Pelles C 8.0
  Exe size: 33,280


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
' Hellobc9Dlg
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$NOMAIN
$ONEXIT "PEL.BAT $FILE$ -m64 gui"
'==============================================================================
Dim UserName$
'------------------------------------------------------------------------------
ENUM
    ID_OK = 1001
    ID_CANCEL
    ID_TEXT
END ENUM
'==============================================================================
Function WinMain()
    Dim As int RetVal
    Dim lpdp As PDLGTEMPLATEEX
    lpdp = bc9_Dialog("What is your name",0,0,160,50,0,0,"Segoe UI",9)
    bc9_Input("",&lpdp,ID_TEXT,14,12,134,12)
    bc9_Button("OK",&lpdp,ID_OK,34,32,40,14)
    bc9_Button("Cancel",&lpdp,ID_CANCEL,84,32,40,14)
    RetVal = bc9_DlgShowModal(lpdp,MDlgProc)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = EXIT_FAILURE
    EndIf
    If RetVal = 1 Then
        MsgBox("Hello " & UserName$)
    EndIf
    Function = EXIT_SUCCESS
End Function
'==============================================================================
Begin Modal Dialog As MDlgProc
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case ID_OK
                    GetWindowText(CTLHNDL(ID_TEXT),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
                Case ID_CANCEL   
                    EndDialog(CBHNDL,0)
            End Select
    End Select
End Dialog
'==============================================================================


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:14:34 PM

bc9Basic HelloSDK using PellesC 8.0
  Exe Size: 30,208



'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloSDK
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$ONEXIT "PEL.BAT $FILE$ -m64 gui"
'==============================================================================
$HEADER
    #include <windows.h>
    #pragma comment(lib,"User32.lib")
    #pragma comment(lib,"gdi32.lib")       
$HEADER

CONST    IDC_OK = 1001
CONST    IDC_CANCEL = 1002
CONST    IDC_TEXT = 1003

Dim UserName$
Function WinMain()
    Local As WNDCLASSEX wcx
    Local As MSG uMsg
    Local As HWND hWin,hText,hOk,hCancel
    Local As DWORD dwStyle,dwStyleEx
    Local As HFONT hFont
    Dim As NONCLIENTMETRICS ncm
    ncm.cbSize = sizeof(ncm)
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0)
    hFont = CreateFontIndirect(&(ncm.lfMessageFont))

    Raw As char szClassName[]     =  "MyClassName"
    With wcx
        .cbSize        =  SIZEOF(wcx)
        .style         =  CS_HREDRAW | CS_VREDRAW
        .lpfnWndProc   =  WndProc
        .cbClsExtra    =  0
        .cbWndExtra    =  0
        .hInstance     =  hInst
        .hIcon         =  LoadIcon  (NULL, IDI_APPLICATION)
        .hCursor       =  LoadCursor(NULL, IDC_ARROW)
        .hbrBackground =  (HBRUSH)(COLOR_BTNFACE+1)
        .lpszMenuName  =  0
        .lpszClassName =  szClassName
        .hIconSm       =  LoadIcon  (NULL,IDI_APPLICATION)
    End With
    RegisterClassEx(&wcx)
    dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE
   
    hWin = CreateWindowEx(dwStyleEx,szClassName$,"What is your name? ", _
                          dwStyle, _
                          (GetSystemMetrics(SM_CXSCREEN) - 246) / 2, _
                          (GetSystemMetrics(SM_CYSCREEN) - 110) / 2, _
                          246, 110, 0,0, hInst, NULL)
                             
   
    hText = CreateWindowEx(WS_EX_CLIENTEDGE, _
                           "Edit", _
                           "", _
                           WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL, _
                           21,20,201,19, _
                           hWin,IDC_TEXT,hInst,NULL)
    SendMessage(hText,WM_SETFONT,hFont,0)
    hOk = CreateWindowEx(0,"Button","OK", _
                         WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                         51,52,60,23,hWin,IDC_OK,hInst,NULL)
    SendMessage(hOk,WM_SETFONT,hFont,0)
    hCancel = CreateWindowEx(0,"Button","Cancel", _
                             WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                             126,52,60,23,hWin,IDC_CANCEL,hInst,NULL)
    SendMessage(hCancel,WM_SETFONT,hFont,0)

    SetFocus(hText)
   
    ShowWindow(hWin,SW_SHOW)
   
    While GetMessage(&uMsg,NULL,0,0)
        If IsDialogMessage(hWin,&uMsg) Then
            Iterate
        EndIf
        TranslateMessage(&uMsg)
        DispatchMessage(&uMsg)
    Wend
    If uMsg.wParam = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your Name",MB_OK)
    EndIf
    If hFont Then
        DeleteObject(hFont)
    End If   
    Function = uMsg.wParam
End Function
'==============================================================================
Callback Function WndProc()
    Static As int RetVal
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDC_CANCEL
                    RetVal = 0
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
                Case IDC_OK
                    RetVal = 1
                    GetWindowText(GetDlgItem(CBHNDL,IDC_TEXT),UserName$,255)
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
        Case WM_DESTROY
            PostQuitMessage(RetVal)
            Exit Function
    End Select
End Function
   

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:15:22 PM

bc9Basic HelloRES using Pelles C 8.0
  Exe Size: 28,672


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Pb HelloDDT clone using a resource dialog script
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'$ZTRACE
$NOMAIN
$ONEXIT "PEL.BAT $FILE$ -m64 gui"
'==============================================================================
$HEADER
    #include <windows.h>
    #pragma comment(lib,"User32.lib")
    #pragma comment(lib,"gdi32.lib")       
$HEADER
'==============================================================================
ENUM
    IDD_DLG1 =               1000
    IDC_EDT1
    IDC_BTN1
    IDC_BTN2
END ENUM
Dim UserName$
'==============================================================================
Function WinMain()
    Dim As int RetVal
    RetVal = DialogBoxParam(hInst,MAKEINTRESOURCE(IDD_DLG1),0,(DLGPROC)DlgProc,0)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = EXIT_FAILURE
    EndIf

    If RetVal = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your name?",MB_OK)
    EndIf

    Function = EXIT_SUCCESS
End Function
'==============================================================================
DlgCallBack DlgProc()
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDCANCEL,IDC_BTN2
                    EndDialog(CBHNDL,0)
                Case IDC_BTN1
                    GetWindowText(CTLHNDL(IDC_EDT1),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
            End Select
    End Select
End Function
'==============================================================================



Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:17:07 PM

bc9Basic Hellobc9Dlg using 64 bit Tiny C
  Exe Size: 8,704


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
' bc9Basic version HelloDDT
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$NOMAIN
$ONEXIT "TC926_64.BAT $FILE$"
'==============================================================================
Dim UserName$
'------------------------------------------------------------------------------
ENUM
    ID_OK = 1001
    ID_CANCEL
    ID_TEXT
END ENUM
'==============================================================================
Function WinMain()
    Dim As int RetVal
    Dim lpdp As PDLGTEMPLATEEX
    lpdp = bc9_Dialog("What is your name",0,0,160,50,0,0,"Segoe UI",9)
    bc9_Input("",&lpdp,ID_TEXT,14,12,134,12)
    bc9_Button("OK",&lpdp,ID_OK,34,32,40,14)
    bc9_Button("Cancel",&lpdp,ID_CANCEL,84,32,40,14)
    RetVal = bc9_DlgShowModal(lpdp,MDlgProc)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = 1
    EndIf
    If RetVal = 1 Then
        MsgBox("Hello " & UserName$)
    EndIf
    Function = 0
End Function
'==============================================================================
Begin Modal Dialog As MDlgProc
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case ID_OK
                    GetWindowText(CTLHNDL(ID_TEXT),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
                Case ID_CANCEL   
                    EndDialog(CBHNDL,0)
            End Select
    End Select
End Dialog
'==============================================================================


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:17:55 PM


bc9Basic HelloSDK using 64 bit Tiny C
  exe size: 7,168


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloSDK
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$ONEXIT "TC926_64.BAT $FILE$ -m64"
'==============================================================================
$HEADER
    #include <windows.h>
$HEADER

CONST    IDC_OK = 1001
CONST    IDC_CANCEL = 1002
CONST    IDC_TEXT = 1003

Dim UserName$
Function WinMain()
    Local As WNDCLASSEX wcx
    Local As MSG uMsg
    Local As HWND hWin,hText,hOk,hCancel
    Local As DWORD dwStyle,dwStyleEx
    Local As HFONT hFont
    Local As LOGFONT lf
    Dim As NONCLIENTMETRICS ncm
    Local As HDC hDc
    ncm.cbSize = sizeof(ncm)
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0)
    hFont = CreateFontIndirect(&(ncm.lfMessageFont))

    Raw As char szClassName[]     =  "MyClassName"
    With wcx
        .cbSize        =  SIZEOF(wcx)
        .style         =  CS_HREDRAW | CS_VREDRAW
        .lpfnWndProc   =  WndProc
        .cbClsExtra    =  0
        .cbWndExtra    =  0
        .hInstance     =  hInst
        .hIcon         =  LoadIcon  (NULL, IDI_APPLICATION)
        .hCursor       =  LoadCursor(NULL, IDC_ARROW)
        .hbrBackground =  (HBRUSH)(COLOR_BTNFACE+1)
        .lpszMenuName  =  0
        .lpszClassName =  szClassName
        .hIconSm       =  LoadIcon  (NULL,IDI_APPLICATION)
    End With
    RegisterClassEx(&wcx)
    dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE
   
    hWin = CreateWindowEx(dwStyleEx,szClassName$,"What is your name? ", _
                          dwStyle, _
                          (GetSystemMetrics(SM_CXSCREEN) - 246) / 2, _
                          (GetSystemMetrics(SM_CYSCREEN) - 110) / 2, _
                          246, 110, 0,0, hInst, NULL)
                             
   
    hText = CreateWindowEx(WS_EX_CLIENTEDGE, _
                           "Edit", _
                           "", _
                           WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL, _
                           21,20,201,19, _
                           hWin,IDC_TEXT,hInst,NULL)
    SendMessage(hText,WM_SETFONT,hFont,0)
    hOk = CreateWindowEx(0,"Button","OK", _
                         WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                         51,52,60,23,hWin,IDC_OK,hInst,NULL)
    SendMessage(hOk,WM_SETFONT,hFont,0)
    hCancel = CreateWindowEx(0,"Button","Cancel", _
                             WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                             126,52,60,23,hWin,IDC_CANCEL,hInst,NULL)
    SendMessage(hCancel,WM_SETFONT,hFont,0)

    SetFocus(hText)
   
    ShowWindow(hWin,SW_SHOW)
   
    While GetMessage(&uMsg,NULL,0,0)
        If IsDialogMessage(hWin,&uMsg) Then
            Iterate
        EndIf
        TranslateMessage(&uMsg)
        DispatchMessage(&uMsg)
    Wend
    If uMsg.wParam = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your Name",MB_OK)
    EndIf
    If hFont Then
        DeleteObject(hFont)
    End If   
    Function = uMsg.wParam
End Function
'==============================================================================
Callback Function WndProc()
    Static As int RetVal
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDC_CANCEL
                    RetVal = 0
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
                Case IDC_OK
                    RetVal = 1
                    GetWindowText(GetDlgItem(CBHNDL,IDC_TEXT),UserName$,255)
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
        Case WM_DESTROY
            PostQuitMessage(RetVal)
            Exit Function
    End Select
End Function
   

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 04:18:43 PM

bc9Basic HelloRES using 64 bit Tiny C with a resource dialog.
  exe size: 5,120


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Pb HelloDDT clone using a resource dialog script
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

$NOMAIN
$ONEXIT "TC926_64.BAT $FILE$"   
$HEADER
#include <windows.h>
$HEADER
'==============================================================================
ENUM
    IDD_DLG1 =               1000
    IDC_EDT1
    IDC_BTN1
    IDC_BTN2
END ENUM

'==============================================================================
Function WinMain()
    Dim As int RetVal
    Global UserName$ * 128
    RetVal = DialogBoxParam(hInst,MAKEINTRESOURCE(IDD_DLG1),0,(DLGPROC)DlgProc,0)
    If  RetVal = -1 Then
        MessageBox(0,"DialogBoxparam error","ERROR",MB_OK)
        Function = 1
    EndIf

    If RetVal = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your name?",MB_OK)
    EndIf

    Function = 0
End Function
'==============================================================================
DlgCallBack DlgProc()
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDCANCEL,IDC_BTN2
                    EndDialog(CBHNDL,0)
                Case IDC_BTN1
                    GetWindowText(CTLHNDL(IDC_EDT1),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
            End Select
    End Select
End Function
'==============================================================================



Title: Re: Ease vs Size
Post by: Patrice Terrier on November 25, 2016, 05:00:01 PM
James--

Are you aware that your SDK code is not safe, because the class registration could failed, as well as the creation of the window itself.
Also it is considered a good practice (but not realy needed) to unregister a class when you do not use it anymore.

And about Ease vs Size, i would say that Size doesn't really matter when you start from an existing Template, it is just as easy as using cut and paste (except for the first time, of course).  :)

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:41:27 PM
Patrice,
  Yeah a bit of an oversight but this is just an article comparing methods not a tutor on windows programming. ( I don't think I have ever had it fail??)
No matter how you get the code (typing or cut and paste) it just reflects what's needed.

James

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:43:22 PM

bc9Basic Hellobc9Dlg using an in memory dynamic dialog and Visual Studio 2015.
  Exe Size 87,552


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPP
$NOMAIN
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "VSCPP.BAT $FILE$ -m64 gui"
'==============================================================================

Dim UserName$
'------------------------------------------------------------------------------
ENUM
    ID_OK = 1001
    ID_CANCEL
    ID_TEXT
END ENUM
'==============================================================================
Function WinMain()
    Dim As int RetVal
    Dim lpdp As PDLGTEMPLATEEX
    SetProcessDPIAware()
    lpdp = bc9_Dialog("What is your name",0,0,160,50,0,0,"Segoe UI",9)
    bc9_Input("",&lpdp,ID_TEXT,14,12,134,12)
    bc9_Button("OK",&lpdp,ID_OK,34,32,40,14)
    bc9_Button("Cancel",&lpdp,ID_CANCEL,84,32,40,14)
    RetVal = bc9_DlgShowModal(lpdp,MDlgProc)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = EXIT_FAILURE
    EndIf
    If RetVal = 1 Then
        MsgBox("Hello " & UserName$)
    EndIf
    Function = EXIT_SUCCESS
End Function
'==============================================================================
Begin Modal Dialog As MDlgProc
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case ID_OK
                    GetWindowText(CTLHNDL(ID_TEXT),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
                Case ID_CANCEL   
                    EndDialog(CBHNDL,0)
            End Select
    End Select
End Dialog
'==============================================================================


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:44:34 PM

bc9Basic HelloSDK using Visual Studio 2015
  Exe File Size 88,576


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloSDK
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "VSCPP.BAT $FILE$ -m64 gui"
'==============================================================================

CONST    IDC_OK = 1001
CONST    IDC_CANCEL = 1002
CONST    IDC_TEXT = 1003

Dim UserName$
'==============================================================================
'Because of a bug (feature) in vc++ 19.
'==============================================================================
Sub SetClientSize(hwnd As HWND,nWidth As Long,nHeight,rxRatio = 1 As Single,ryRatio = 1 As Single)
    Dim As RECT rc,rcTemp
   ' // Convert the client rectangle to a window rectangle.
   ' // The AdjustWindowRectEx function cannot take menu wrapping into account
   ' // because it doesn't know which menu we are using.
    SetRect(&rc,0,0,nWidth * rxRatio,nHeight * ryRatio)
    Raw As HANDLE hMenu = GetMenu(hwnd)
    Raw As DWORD dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE)
    AdjustWindowRectEx(&rc, dwStyle, (hMenu <> NULL), GetWindowLongPtr(hwnd, GWL_EXSTYLE))
   ' // If there is a menu, we need to check how much wrapping occurs when we set
   ' // the window to the width specified by AdjustWindowRectEX and an infinite
   ' // amount of height. An infinite height allows us to see every single menu wrap.
    If hMenu <> NULL Then
        rcTemp = rc
        rcTemp.bottom = 0x7FFF   ' // "Infinite" height
        SendMessage(hwnd, WM_NCCALCSIZE, 0, (LPARAM) &rcTemp)
        ' // Adjust our previous calculation to compensate for menu wrapping.
        rc.bottom = rc.bottom + rcTemp.top
    EndIf
   ' // The AdjustWindowRectEx function does not take the WS_VSCROLL or WS_HSCROLL
   ' // styles into account. To account for the scroll bars, we need to call the
   ' // GetSystemMetrics function with SM_CXVSCROLL or SM_CYHSCROLL.
    If (dwStyle & WS_HSCROLL) = WS_HSCROLL Then
        rc.bottom = rc.bottom + GetSystemMetrics(SM_CYHSCROLL)
    End If
    If (dwStyle & WS_VSCROLL) = WS_VSCROLL THEN
        rc.right = rc.right + GetSystemMetrics(SM_CXVSCROLL)
    End If
    Raw As Long cx  = rc.right - rc.left, cy = rc.bottom - rc.top

    SetWindowPos(hwnd, NULL, 0, 0, cx, cy, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE)
   
End Sub
'==============================================================================
Function WinMain()
    Local As WNDCLASSEX wcx
    Local As MSG uMsg
    Local As HWND hWin,hText,hOk,hCancel
    Local As DWORD dwStyle,dwStyleEx
    Local As HFONT hFont,hCurFont
    Local As LOGFONT lf
    Dim As NONCLIENTMETRICS ncm
    Local As HDC hDc
    'This should return the Segoe UI,9 font
    ncm.cbSize = sizeof(ncm)
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0)
    hFont = CreateFontIndirect(&(ncm.lfMessageFont))

    Raw As char szClassName[]     =  "MyClassName"
    With wcx
        .cbSize        =  SIZEOF(wcx)
        .style         =  CS_HREDRAW | CS_VREDRAW
        .lpfnWndProc   =  WndProc
        .cbClsExtra    =  0
        .cbWndExtra    =  0
        .hInstance     =  hInst
        .hIcon         =  LoadIcon  (NULL, IDI_APPLICATION)
        .hCursor       =  LoadCursor(NULL, IDC_ARROW)
        .hbrBackground =  (HBRUSH)(COLOR_BTNFACE+1)
        .lpszMenuName  =  0
        .lpszClassName =  szClassName
        .hIconSm       =  LoadIcon  (NULL,IDI_APPLICATION)
    End With
    RegisterClassEx(&wcx)
    dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE
   
    hWin = CreateWindowEx(dwStyleEx,szClassName$,"What is your name? ", _
                          dwStyle, _
                          0, _
                          0, _
                          0, 0, NULL,NULL, hInst, NULL)
                             
    SetClientSize(hWin,240,81)
   
    hText = CreateWindowEx(WS_EX_CLIENTEDGE, _
                           "Edit", _
                           "", _
                           WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL, _
                           21,20,201,19, _
                           hWin,IDC_TEXT,hInst,NULL)
    SendMessage(hText,WM_SETFONT,hFont,0)
    hOk = CreateWindowEx(0,"Button","OK", _
                         WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                         51,52,60,23,hWin,IDC_OK,hInst,NULL)
    SendMessage(hOk,WM_SETFONT,hFont,0)
    hCancel = CreateWindowEx(0,"Button","Cancel", _
                             WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                             126,52,60,23,hWin,IDC_CANCEL,hInst,NULL)
    SendMessage(hCancel,WM_SETFONT,hFont,0)
    hDc = GetDC(hWin)
   
    ReleaseDC(hWin,hDc)
    SetFocus(hText)
    Center(hWin)
   
    ShowWindow(hWin,SW_SHOW)
   
    While GetMessage(&uMsg,NULL,0,0)
        If IsDialogMessage(hWin,&uMsg) Then
            Iterate
        EndIf
        TranslateMessage(&uMsg)
        DispatchMessage(&uMsg)
    Wend
    If uMsg.wParam = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your Name",MB_OK)
    EndIf
    If hFont Then
        DeleteObject(hFont)
    End If   
    Function = uMsg.wParam
End Function
'==============================================================================
Callback Function WndProc()
    Static As int RetVal
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDC_CANCEL
                    RetVal = 0
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
                Case IDC_OK
                    RetVal = 1
                    GetWindowText(GetDlgItem(CBHNDL,IDC_TEXT),UserName$,255)
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
        Case WM_DESTROY
            PostQuitMessage(RetVal)
            Exit Function
    End Select
End Function
   

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:45:32 PM

bc9Basic HelloRES using a resource dialog and Visual Studio 2015 Community
  Exe Size: 86,528


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Pb HelloDDT clone using a resource dialog script
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

$NOMAIN
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "VSCPP.BAT $FILE$ -m64 gui"   
'==============================================================================
ENUM
    IDD_DLG1 =               1000
    IDC_EDT1
    IDC_BTN1
    IDC_BTN2
END ENUM
Dim UserName$
'==============================================================================
Function WinMain()
    Dim As int RetVal
    RetVal = DialogBoxParam(hInst,MAKEINTRESOURCE(IDD_DLG1),0,(DLGPROC)DlgProc,0)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = EXIT_FAILURE
    EndIf

    If RetVal = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your name?",MB_OK)
    EndIf

    Function = EXIT_SUCCESS
End Function
'==============================================================================
DlgCallBack DlgProc()
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDCANCEL,IDC_BTN2
                    EndDialog(CBHNDL,0)
                Case IDC_BTN1
                    GetWindowText(CTLHNDL(IDC_EDT1),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
            End Select
    End Select
End Function
'==============================================================================



Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:46:54 PM
bc9Basic using HelloCW José Roca's CWindow Framework and Visual Studio 2015 Community
  Exe Size: 123,904


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'CWindow version of PBWin HelloDDT
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$NOMAIN
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "VSCPP.BAT $FILE$ -m64 gui"   
'==============================================================================
' CWindow source
$Include <Afx/CWindow.bi>
'==============================================================================
Dim UserName$
'------------------------------------------------------------------------------
ENUM
    ID_OK = 1001
    ID_CANCEL
    ID_TEXT
END ENUM
'==============================================================================
Function WinMain()
    Dim As int iRetVal
    Dim As HWND hWin,hEdit
    Raw As CWindow pWindow
    Dim As DWORD dwStyle,dwStyleEx
    dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE

    hWin = pWindow.Create(NULL, "What is your name?", &WndProc,0,0,296,143,dwStyle,dwStyleEx)
    hEdit = pWindow.AddControl("Edit",hWin,ID_TEXT,"",25,24,235,24)
    pWindow.AddControl("Button",hWin,ID_OK,"OK",60,64,70,28)
    pWindow.AddControl("Button",hWin,ID_CANCEL,"Cancel",147,64,70,28)
    pWindow.Center()
    SetFocus(hEdit)
    iRetVal = pWindow.Do_Events(CmdShow)
    If iRetVal = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your name?",MB_OK)
    EndIf
End Function
'==============================================================================
CallBack Function WndProc()
    Static RetVal
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case ID_OK
                    GetWindowText(CTLHNDL(ID_TEXT),UserName$,SizeOf(UserName$))
                    RetVal = 1
                    PostMessage(CBHNDL,WM_CLOSE,0,0)
                Case ID_CANCEL
                    RetVal = 0
                    PostMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
        Case WM_DESTROY
            PostQuitMessage(RetVal)
    End Select
End Function


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:48:12 PM

bc9Basic  Hellobc9Dlg using an in memory dynamic dialog with the NUWEN g++ distro.
  Exe Size: 86,528



'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
' bc9Basic version of PBWin9/10 HelloDDT
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPP
$NOMAIN
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER.TXT"
$ONEXIT "NUWENGPP.BAT $FILE$ -m64 gui -municode"
'==============================================================================
Dim UserName$
'------------------------------------------------------------------------------
ENUM
    ID_OK = 1001
    ID_CANCEL
    ID_TEXT
END ENUM
'==============================================================================
Function WinMain()
    Dim As int RetVal
    Dim lpdp As PDLGTEMPLATEEX
    'SetProcessDPIAware()
    lpdp = bc9_Dialog("What is your name",0,0,160,50,0,0,"Segoe UI",9)
    bc9_Input("",&lpdp,ID_TEXT,14,12,134,12)
    bc9_Button("OK",&lpdp,ID_OK,34,32,40,14)
    bc9_Button("Cancel",&lpdp,ID_CANCEL,84,32,40,14)
    RetVal = bc9_DlgShowModal(lpdp,MDlgProc)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = EXIT_FAILURE
    EndIf
    If RetVal = 1 Then
        MsgBox("Hello " & UserName$)
    EndIf
    Function = EXIT_SUCCESS
End Function
'==============================================================================
Begin Modal Dialog As MDlgProc
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case ID_OK
                    GetWindowText(CTLHNDL(ID_TEXT),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
                Case ID_CANCEL   
                    EndDialog(CBHNDL,0)
            End Select
    End Select
End Dialog
'==============================================================================


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:49:40 PM

bc9Basic HelloSDK using the NUWEN g++ distro.
  Exe size:22,528


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloSDK
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER.TXT"
$ONEXIT "NUWENGPP.BAT $FILE$ -m64 gui -municode"
'==============================================================================
$HEADER
    #include <windows.h>
    #include <tchar.h>
$HEADER

CONST    IDC_OK = 1001
CONST    IDC_CANCEL = 1002
CONST    IDC_TEXT = 1003

Dim UserName$
Function WinMain()
    Local As WNDCLASSEX wcx
    Local As MSG uMsg
    Local As HWND hWin,hText,hOk,hCancel
    Local As DWORD dwStyle,dwStyleEx
    Local As HFONT hFont
    Local As LOGFONT lf
    Dim As NONCLIENTMETRICS ncm
    Local As HDC hDc
    ncm.cbSize = sizeof(ncm)
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0)
    hFont = CreateFontIndirect(&(ncm.lfMessageFont))

    Raw As char szClassName[]     =  "MyClassName"
    With wcx
        .cbSize        =  SIZEOF(wcx)
        .style         =  CS_HREDRAW | CS_VREDRAW
        .lpfnWndProc   =  WndProc
        .cbClsExtra    =  0
        .cbWndExtra    =  0
        .hInstance     =  hInst
        .hIcon         =  LoadIcon  (NULL, IDI_APPLICATION)
        .hCursor       =  LoadCursor(NULL, IDC_ARROW)
        .hbrBackground =  (HBRUSH)(COLOR_BTNFACE+1)
        .lpszMenuName  =  0
        .lpszClassName =  szClassName
        .hIconSm       =  LoadIcon  (NULL,IDI_APPLICATION)
    End With
    RegisterClassEx(&wcx)
    dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE
   
    hWin = CreateWindowEx(dwStyleEx,szClassName$,"What is your name? ", _
                          dwStyle, _
                          (GetSystemMetrics(SM_CXSCREEN) - 246) / 2, _
                          (GetSystemMetrics(SM_CYSCREEN) - 110) / 2, _
                          246, 110, 0,0, hInst, NULL)
                             
   
    hText = CreateWindowEx(WS_EX_CLIENTEDGE, _
                           "Edit", _
                           "", _
                           WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL, _
                           21,20,201,19, _
                           hWin,IDC_TEXT,hInst,NULL)
    SendMessage(hText,WM_SETFONT,hFont,0)
    hOk = CreateWindowEx(0,"Button","OK", _
                         WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                         51,52,60,23,hWin,IDC_OK,hInst,NULL)
    SendMessage(hOk,WM_SETFONT,hFont,0)
    hCancel = CreateWindowEx(0,"Button","Cancel", _
                             WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                             126,52,60,23,hWin,IDC_CANCEL,hInst,NULL)
    SendMessage(hCancel,WM_SETFONT,hFont,0)

    SetFocus(hText)
   
    ShowWindow(hWin,SW_SHOW)
   
    While GetMessage(&uMsg,NULL,0,0)
        If IsDialogMessage(hWin,&uMsg) Then
            Iterate
        EndIf
        TranslateMessage(&uMsg)
        DispatchMessage(&uMsg)
    Wend
    If uMsg.wParam = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your Name",MB_OK)
    EndIf
    If hFont Then
        DeleteObject(hFont)
    End If   
    Function = uMsg.wParam
End Function
'==============================================================================
Callback Function WndProc()
    Static As int RetVal
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDC_CANCEL
                    RetVal = 0
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
                Case IDC_OK
                    RetVal = 1
                    GetWindowText(GetDlgItem(CBHNDL,IDC_TEXT),UserName$,255)
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
        Case WM_DESTROY
            PostQuitMessage(RetVal)
            Exit Function
    End Select
End Function
   

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:50:39 PM

bc9Basic HelloRES using a resource dialog and the NUWEN g++ distro
  Exe Size: 21,504


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Pb HelloDDT clone using a resource dialog script
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

$NOMAIN
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER.TXT"
$ONEXIT "NUWENGPP.BAT $FILE$ -m64 gui -municode"   
'==============================================================================
ENUM
    IDD_DLG1 =               1000
    IDC_EDT1
    IDC_BTN1
    IDC_BTN2
END ENUM

'==============================================================================
Function WinMain()
    Dim As int RetVal
    Global UserName$ * 128
    RetVal = DialogBoxParam(hInst,MAKEINTRESOURCE(IDD_DLG1),0,(DLGPROC)DlgProc,0)
    If  RetVal = -1 Then
        MessageBox(0,"DialogBoxparam error","ERROR",MB_OK)
        Function = EXIT_FAILURE
    EndIf

    If RetVal = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your name?",MB_OK)
    EndIf

    Function = EXIT_SUCCESS
End Function
'==============================================================================
DlgCallBack DlgProc()
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDCANCEL,IDC_BTN2
                    EndDialog(CBHNDL,0)
                Case IDC_BTN1
                    GetWindowText(CTLHNDL(IDC_EDT1),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
            End Select
    End Select
End Function
'==============================================================================



Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:51:33 PM

bc9Basic HelloCW using José Roca's CWindow Framework with the NUWEN g++ distro
  exe size: 164,352


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'CWindow version of PBWin HelloDDT
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$NOMAIN
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER.TXT"
$ONEXIT "NUWENGPP.BAT $FILE$ -m64 gui -municode -Wno-write-strings"
$HEADER
    #define _tmemcpy wmemcpy
$HEADER
'==============================================================================
$Include <Afx/CWindow.bi>
'==============================================================================
Dim UserName$
'------------------------------------------------------------------------------
ENUM
    ID_OK = 1001
    ID_CANCEL
    ID_TEXT
END ENUM
'==============================================================================
Function WinMain()
    Dim As int iRetVal
    Dim As HWND hWin
    Raw As HWND hEdit
    Raw As CWindow pWindow
    Dim As DWORD dwStyle,dwStyleEx
    dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE

    hWin = pWindow.Create(NULL, "What is your name?", &WndProc,0,0,296,143,dwStyle,dwStyleEx)
    hEdit = pWindow.AddControl("Edit",hWin,ID_TEXT,"",25,24,235,24)
    pWindow.AddControl("Button",hWin,ID_OK,"OK",60,64,70,28)
    pWindow.AddControl("Button",hWin,ID_CANCEL,"Cancel",147,64,70,28)
    pWindow.Center()
    SetFocus(hEdit)
    iRetVal = pWindow.Do_Events(CmdShow)
    If iRetVal = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your name?",MB_OK)
    EndIf
End Function
'==============================================================================
CallBack Function WndProc()
    Static RetVal
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case ID_OK
                    GetWindowText(CTLHNDL(ID_TEXT),UserName$,SizeOf(UserName$))
                    RetVal = 1
                    PostMessage(CBHNDL,WM_CLOSE,0,0)
                Case ID_CANCEL
                    RetVal = 0
                    PostMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
        Case WM_DESTROY
            PostQuitMessage(RetVal)
    End Select
End Function


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:55:09 PM

bc9Basic Hellobc9Dlg using in memory dialog with The Fred Harris TCLib.
  Exe Size: 7,168


$CPP
$NOMAIN
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "TCLIB.BAT $FILE$"
'==============================================================================
Dim UserName$
'------------------------------------------------------------------------------
ENUM
    ID_OK = 1001
    ID_CANCEL
    ID_TEXT
END ENUM
'==============================================================================
Function WinMain()
    Dim As int RetVal
    Dim lpdp As PDLGTEMPLATEEX
    SetProcessDPIAware()
    lpdp = bc9_Dialog("What is your name",0,0,160,50,0,0,"Segoe UI",9)
    bc9_Input("",&lpdp,ID_TEXT,14,12,134,12)
    bc9_Button("OK",&lpdp,ID_OK,34,32,40,14)
    bc9_Button("Cancel",&lpdp,ID_CANCEL,84,32,40,14)
    RetVal = bc9_DlgShowModal(lpdp,MDlgProc)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = EXIT_FAILURE
    EndIf
    If RetVal = 1 Then
        MsgBox("Hello " & UserName$)
    EndIf
    Function = EXIT_SUCCESS
End Function
'==============================================================================
Begin Modal Dialog As MDlgProc
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case ID_OK
                    GetWindowText(CTLHNDL(ID_TEXT),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
                Case ID_CANCEL   
                    EndDialog(CBHNDL,0)
            End Select
    End Select
End Dialog
'==============================================================================


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:56:05 PM

bc9Baisc HelloSDK using SDK style code with the Fred Harris TCLib
  Exe Size: 8,192



'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloSDK
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "TCLIB.BAT $FILE$"
$HEADER
    #pragma comment(lib,"gdi32.lib")        /*'ForCreateFont*
$HEADER
'==============================================================================
CONST    IDC_OK = 1001
CONST    IDC_CANCEL = 1002
CONST    IDC_TEXT = 1003

Dim UserName$
'==============================================================================
'Because of a bug (feature) in vc++ 19.
'==============================================================================
Sub SetClientSize(hwnd As HWND,nWidth As Long,nHeight,rxRatio = 1 As Single,ryRatio = 1 As Single)
    Dim As RECT rc,rcTemp
   ' // Convert the client rectangle to a window rectangle.
   ' // The AdjustWindowRectEx function cannot take menu wrapping into account
   ' // because it doesn't know which menu we are using.
    SetRect(&rc,0,0,nWidth * rxRatio,nHeight * ryRatio)
    Raw As HANDLE hMenu = GetMenu(hwnd)
    Raw As DWORD dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE)
    AdjustWindowRectEx(&rc, dwStyle, (hMenu <> NULL), GetWindowLongPtr(hwnd, GWL_EXSTYLE))
   ' // If there is a menu, we need to check how much wrapping occurs when we set
   ' // the window to the width specified by AdjustWindowRectEX and an infinite
   ' // amount of height. An infinite height allows us to see every single menu wrap.
    If hMenu <> NULL Then
        rcTemp = rc
        rcTemp.bottom = 0x7FFF   ' // "Infinite" height
        SendMessage(hwnd, WM_NCCALCSIZE, 0, (LPARAM) &rcTemp)
        ' // Adjust our previous calculation to compensate for menu wrapping.
        rc.bottom = rc.bottom + rcTemp.top
    EndIf
   ' // The AdjustWindowRectEx function does not take the WS_VSCROLL or WS_HSCROLL
   ' // styles into account. To account for the scroll bars, we need to call the
   ' // GetSystemMetrics function with SM_CXVSCROLL or SM_CYHSCROLL.
    If (dwStyle & WS_HSCROLL) = WS_HSCROLL Then
        rc.bottom = rc.bottom + GetSystemMetrics(SM_CYHSCROLL)
    End If
    If (dwStyle & WS_VSCROLL) = WS_VSCROLL THEN
        rc.right = rc.right + GetSystemMetrics(SM_CXVSCROLL)
    End If
    Raw As Long cx  = rc.right - rc.left, cy = rc.bottom - rc.top

    SetWindowPos(hwnd, NULL, 0, 0, cx, cy, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE)
   
End Sub
'==============================================================================
Function WinMain()
    Local As WNDCLASSEX wcx
    Local As MSG uMsg
    Local As HWND hWin,hText,hOk,hCancel
    Local As DWORD dwStyle,dwStyleEx
    Local As HFONT hFont
    Local As LOGFONT lf
    Dim As NONCLIENTMETRICS ncm
    'Local As HDC hDc
    ncm.cbSize = sizeof(ncm)
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0)
    hFont = CreateFontIndirect(&(ncm.lfMessageFont))

    Raw As char szClassName[]     =  "MyClassName"
    With wcx
        .cbSize        =  SIZEOF(wcx)
        .style         =  CS_HREDRAW | CS_VREDRAW
        .lpfnWndProc   =  WndProc
        .cbClsExtra    =  0
        .cbWndExtra    =  0
        .hInstance     =  hInst
        .hIcon         =  LoadIcon  (NULL, IDI_APPLICATION)
        .hCursor       =  LoadCursor(NULL, IDC_ARROW)
        .hbrBackground =  (HBRUSH)(COLOR_BTNFACE+1)
        .lpszMenuName  =  0
        .lpszClassName =  szClassName
        .hIconSm       =  LoadIcon  (NULL,IDI_APPLICATION)
    End With
    RegisterClassEx(&wcx)
    dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE
   
    hWin = CreateWindowEx(dwStyleEx,szClassName$,"What is your name? ", _
                          dwStyle, _
                          0, _
                          0, _
                          0, 0, NULL,NULL, hInst, NULL)
                             
    SetClientSize(hWin,240,81)
   
    hText = CreateWindowEx(WS_EX_CLIENTEDGE, _
                           "Edit", _
                           "", _
                           WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL, _
                           21,20,201,19, _
                           hWin,IDC_TEXT,hInst,NULL)
    SendMessage(hText,WM_SETFONT,hFont,0)
    hOk = CreateWindowEx(0,"Button","OK", _
                         WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                         51,52,60,23,hWin,IDC_OK,hInst,NULL)
    SendMessage(hOk,WM_SETFONT,hFont,0)
    hCancel = CreateWindowEx(0,"Button","Cancel", _
                             WS_CHILD | WS_VISIBLE | WS_TABSTOP, _
                             126,52,60,23,hWin,IDC_CANCEL,hInst,NULL)
    SendMessage(hCancel,WM_SETFONT,hFont,0)
    SetFocus(hText)
    Center(hWin)
   
    ShowWindow(hWin,SW_SHOW)
   
    While GetMessage(&uMsg,NULL,0,0)
        If IsDialogMessage(hWin,&uMsg) Then
            Iterate
        EndIf
        TranslateMessage(&uMsg)
        DispatchMessage(&uMsg)
    Wend
    If uMsg.wParam = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your Name",MB_OK)
    EndIf
    If hFont Then
        DeleteObject(hFont)
    End If   
    Function = uMsg.wParam
End Function
'==============================================================================
Callback Function WndProc()
    Static As int RetVal
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDC_CANCEL
                    RetVal = 0
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
                Case IDC_OK
                    RetVal = 1
                    GetWindowText(GetDlgItem(CBHNDL,IDC_TEXT),UserName$,255)
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
        Case WM_DESTROY
            PostQuitMessage(RetVal)
            Exit Function
    End Select
End Function
   

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:56:59 PM

bc9Basic HelloRES using a resource dialog with the Fred Harris TCLib.
  Exe Size: 5,632



'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Pb HelloDDT clone using a resource dialog script
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$NOMAIN
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "TCLIB.BAT $FILE$"   
'==============================================================================
ENUM
    IDD_DLG1 =               1000
    IDC_EDT1
    IDC_BTN1
    IDC_BTN2
END ENUM
Dim UserName$
'==============================================================================
Function WinMain()
    Dim As int RetVal
    RetVal = DialogBoxParam(hInst,MAKEINTRESOURCE(IDD_DLG1),0,(DLGPROC)DlgProc,0)
    If  RetVal = -1 Then
        MsgBox("BAD")
        Function = EXIT_FAILURE
    EndIf

    If RetVal = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your name?",MB_OK)
    EndIf

    Function = EXIT_SUCCESS
End Function
'==============================================================================
DlgCallBack DlgProc()
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDCANCEL,IDC_BTN2
                    EndDialog(CBHNDL,0)
                Case IDC_BTN1
                    GetWindowText(CTLHNDL(IDC_EDT1),UserName$,SizeOf(UserName$))
                    EndDialog(CBHNDL,1)
            End Select
    End Select
End Function
'==============================================================================



Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 05:57:42 PM

bc9Basic HelloCW using José Roca's CWindow framework and the Fred Harris TCLib
  Exe Size: 17,920


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'CWindow version of PBWin HelloDDT
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$NOMAIN
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "TCLIB.BAT $FILE$"   
'==============================================================================
$HEADER
    #include <commctrl.h>                    / *'ForCWindow
    #pragma comment(lib,"comctl32.lib")        /*'ForCWindow*
    #pragma comment(lib,"gdi32.lib")        /*'ForCWindow*
    #pragma comment(lib,"advapi32.lib")        /*'ForDPIaware check*/
$HEADER
'==============================================================================
$Include <Afx/CWindow.bi>
'==============================================================================
Dim UserName$
'------------------------------------------------------------------------------
ENUM
    ID_OK = 1001
    ID_CANCEL
    ID_TEXT
END ENUM
'==============================================================================
Function WinMain()
    Dim As int iRetVal
    Dim As HWND hWin,hEdit
    Raw As CWindow pWindow
   
    Raw As DWORD dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION
    Raw As DWORD dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE

    hWin = pWindow.Create(NULL, "What is your name?", &WndProc,0,0,296,143,dwStyle,dwStyleEx)
    hEdit = pWindow.AddControl("Edit",hWin,ID_TEXT,"",25,24,235,24)
    pWindow.AddControl("Button",hWin,ID_OK,"OK",60,64,70,28)
    pWindow.AddControl("Button",hWin,ID_CANCEL,"Cancel",147,64,70,28)
    pWindow.Center()
    SetFocus(hEdit)
    iRetVal = pWindow.Do_Events(CmdShow)
    If iRetVal = 1 Then
        MessageBox(0,"Hello " & UserName$,"What's your name?",MB_OK)
    EndIf
End Function
'==============================================================================
CallBack Function WndProc()
    Static RetVal
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case ID_OK
                    GetWindowText(CTLHNDL(ID_TEXT),UserName$,SizeOf(UserName$))
                    RetVal = 1
                    PostMessage(CBHNDL,WM_CLOSE,0,0)
                Case ID_CANCEL
                    RetVal = 0
                    PostMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
        Case WM_DESTROY
            PostQuitMessage(RetVal)
    End Select
End Function


Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 06:00:37 PM
Here is the composite of all the tests

PbWin9
  HelloDDT      20,480
  HelloSDK      25,600
  HelloRES      14,336
  HelloCW       66,048
PbCC5
  HelloJcfDlg   17,408
  HelloSDK      12,800
  HelloRES      10,240
  HelloCW       66,560
PbWin10
  HelloDDT      48,128  (Pbwin9 source)     
  HelloSDK      20,480
  HelloRES      18,944
  HelloCW       36,352
PBCC6
  HelloJcfDlg   26,112
  HelloSDK      21,504
  HelloRES      19,968
  HelloCW       36,864
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
bc9Basic using PellesC 8.0
  Hellobc9Dlg   33,280 (dpi aware, win ver,Common Controls manifest )
  HelloSDK      30,208 (dpi aware, win ver,Common Controls manifest )
  HelloRES      28,672
  HelloCW         NA  CWindow is c++ only

bc9Basic using Visual Studio 2015 libraries
  Hellobc9Dlg   87,552
  HelloSDK      86,528 (no manifest)
  HelloSDK      87,040 (Common Controls manifest)
  HelloSDK      88,576 (dpi aware, win ver,Common Controls manifest )
  HelloRES      86,528 (dpi aware, win ver,Common Controls manifest )
  HelloCW      123,904 (dpi aware, win ver,Common Controls manifest )

bc9Basic using NUWEN g++ distro
  Hellobc9Dlg   23,552 (dpi aware, win ver,Common Controls manifest )
  HelloSDK      19,456 (no manifest)
  HelloSDK      20,992 (Common Controls manifest)
  HelloSDK      22,528 (dpi aware, win ver,Common Controls manifest )
  HelloRES      21,504 (dpi aware, win ver,Common Controls manifest )
  HelloCW      164,352 (dpi aware, win ver,Common Controls manifest )

bc9Basic using 64bit Tiny C
  Hellobc9Dlg    8,704 (no manifest)
  Hellobc9Dlg    9,216 (Common Controls manifest)
  HelloSDK       7,168 (no manifest)
  HelloSDK       7,680 (Common Controls manifest)
  HelloSDK       9,216 (dpi aware, win ver,Common Controls manifest )
  HelloRES       5,120 (no manifest)
  HelloRES       5,632 (Common Controls manifest)
  HelloRES       7,680 (dpi aware, win ver,Common Controls manifest )
  HelloCW          NA  CWindow is c++ only

bc9Basic using TCLib
  Hellobc9Dlg    7,168 (no manifest)
  Hellobc9Dlg    7,680 (Common Controls manifest)
  Hellobc9Dlg    9,126 (dpi aware, win ver,Common Controls manifest ) 
  HelloSDK       8,192 (no manifest)
  HelloSDK       8,704 (Common Controls manifest)
  HelloSDK      10,240 (dpi aware, win ver,Common Controls manifest )
  HelloRES       5,632 (no manifest)
  HelloRES       6,144 (Common Controls manifest)
  HelloRES       8,192 (dpi aware, win ver,Common Controls manifest )
  HelloCW       17,920
  HelloCW       19,968 (dpi aware, win ver,Common Controls manifest )
Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 06:15:37 PM
After doing all these tests my preference is José's CWindow framework along with my version on Fred's TCLib. It adds about 10k to your app but I'm happy with the trade off as the Framework is dynamite.
If you want/need REALLY small apps, resource dialogs are the way to go.
If you use a full manifest they will be dpi aware. They will not size exactly the same as using CWindow as they are based on the font/size used. My tests show the text to NOT be fuzzy.

I want to thank José and Fred for the work they have done on their respective projects.

James



Title: Re: Ease vs Size
Post by: Frederick J. Harris on November 25, 2016, 07:34:08 PM
Just a note about your first PowerBASIC Windows 9 SDK example.  Its this one...


#COMPILE EXE
'----------------------------------------------------------------------
#IF %PB_REVISION < &H1000 ' if compiler PBWIN9 or earlier
    %USEMACROS = 1
#ENDIF
#INCLUDE "WIN32API.INC"
'----------------------------------------------------------------------
%IDC_EDIT100       = 100
GLOBAL UserName AS STRING
Global szBuffer As Asciiz*64

'======================================================================
FUNCTION WINMAIN (BYVAL hInst AS DWORD, BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpszCmdLine AS ASCIIZ PTR, BYVAL nCmdShow AS LONG) AS LONG
'----------------------------------------------------------------------
' Program entrance
'----------------------------------------------------------------------
  LOCAL hDlg AS DWORD, hCtl AS DWORD, hEdit As DWORD ,hFont AS DWORD, _
        sBuf AS STRING, wc AS WndClassEx, szClassName AS ASCIIZ * 80

  hFont = GetStockObject(%DEFAULT_GUI_FONT)

  szClassName      = "MyClassName"
  wc.cbSize        = SIZEOF(wc)
  wc.style         = %CS_HREDRAW OR %CS_VREDRAW
  wc.lpfnWndProc   = CODEPTR(WndProc)
  wc.cbClsExtra    = 0
  wc.cbWndExtra    = 0
  wc.hInstance     = hInst
  wc.hIcon         = LoadIcon  (%NULL, BYVAL %IDI_APPLICATION)
  wc.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
  wc.hbrBackground = %COLOR_3DFACE + 1
  wc.lpszMenuName  = %NULL
  wc.lpszClassName = VARPTR(szClassName)
  wc.hIconSm       = LoadIcon  (%NULL, BYVAL %IDI_APPLICATION)
  CALL RegisterClassEx (wc)

  hDlg = CreateWindowEx(%WS_EX_DLGMODALFRAME OR %WS_EX_CONTROLPARENT OR %WS_EX_WINDOWEDGE, szClassName, "What is your name?", _
              %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION OR _
              %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT OR %DS_MODALFRAME OR _
              %DS_CENTER, _
              (GetSystemMetrics(%SM_CXSCREEN) - 246) / 2, _
              (GetSystemMetrics(%SM_CYSCREEN) - 110) / 2, _
               246, 110, 0, 0, GetModuleHandle(""), BYVAL %NULL)

  hEdit = CreateWindowEx(%WS_EX_CLIENTEDGE, "Edit", BYVAL %NULL, _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL, _
               21, 20, 201, 19, _
               hDlg, %IDC_EDIT100, GetModuleHandle(""), BYVAL %NULL)

  IF hFont THEN SendMessage hEdit, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "OK", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               51, 52, 60, 23, _
               hDlg, %IDOK, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  hCtl = CreateWindowEx(0, "Button", "Cancel", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
               126, 52, 60, 23, _
               hDlg, %IDCANCEL, GetModuleHandle(""), BYVAL %NULL)
  IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

  ShowWindow hDlg, nCmdShow
  SetFocus(hEdit)
  UpdateWindow hDlg


  LOCAL Msg AS tagMsg
  WHILE GetMessage(Msg, %NULL, 0, 0)
      IF IsDialogMessage(hDlg,Msg) = 0 Then
          TranslateMessage Msg
          DispatchMessage Msg
      END IF
  WEND
  If msg.wParam Then
      MSGBOX "Hello " + szBuffer
  End If
  FUNCTION = msg.wParam
END FUNCTION


'======================================================================
FUNCTION WndProc (BYVAL hWnd AS DWORD,  BYVAL wMsg AS DWORD, _
                  BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
'----------------------------------------------------------------------
' Main Window procedure
'----------------------------------------------------------------------
  STATIC RetVal AS LONG
  SELECT CASE wMsg
  CASE %WM_CREATE
      'A good place to initiate things, declare variables,
      'create controls and read/set settings from a file, etc.
      '-------------------------------------------------------

  CASE %WM_COMMAND
      'Messages from controls and menu items are handled here.
      '-------------------------------------------------------
      SELECT CASE LOWRD(wParam)
      CASE %IDCANCEL  ' <- Esc key also triggers %IDCANCEL
          IF HIWRD(wParam) = %BN_CLICKED OR HIWRD(wParam) = 1 THEN
              SendMessage hWnd, %WM_DESTROY, wParam, lParam
              RetVal = 0
              FUNCTION = 0 : EXIT FUNCTION
          END IF

      CASE %IDOK      ' <- Enter key usually triggers %IDOK
         IF HIWRD(wParam) = %BN_CLICKED OR HIWRD(wParam) = 1 THEN
           'CONTROL GET TEXT hWnd,%IDC_EDIT100 To UserName
           GetWindowText(GetDlgItem(hWnd,%IDC_EDIT100),szBuffer,64)
           RetVal = 1
           SendMessage hWnd, %WM_DESTROY, wParam, lParam
         END IF
      END SELECT


  CASE %WM_DESTROY
      ' is sent when program ends - a good place to delete any created objects and
      ' store settings in file for next run, etc. Must send PostQuitMessage to end
      ' properly in SDK-style dialogs. The PostQuitMessage function sends a WM_QUIT
      ' message to the program's (thread's) message queue, and then WM_QUIT causes
      ' the GetMessage function to return zero in WINMAIN's message loop.
      '----------------------------------------------------------------------------
      PostQuitMessage RetVal
      FUNCTION = 0 : EXIT FUNCTION


  END SELECT

  FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION


When I compiled that 'as is' with PB 10, I got a 50,176 byte executable.  The reason I tested it was because I immediately noted that while you claimed it to be SDK, it wasn't, as you have one DDT statement in it, which causes the whole DDT code from the compiler to be pulled in.  The offending statement is the Control Get Text statement to pull the text out of the edit control.  If you substitute GetWindowText() as I've done above, the executable shrinks to 10,752 bytes, that is, 40 K less.
Title: Re: Ease vs Size
Post by: Frederick J. Harris on November 25, 2016, 07:45:27 PM
I see that Control Get Text must have just slipped in unbeknownst to you Jim, as some of your other SDK examples use GetWindowText().  Sorry!
Title: Re: Ease vs Size
Post by: Frederick J. Harris on November 25, 2016, 07:51:27 PM
By the way, I'm seeing 5,120 ansi with my x64 Visual Studio 2008 (vc15) - TCLib, but without a manifest.  Actually (and now I'm revealing my real ignorance), I don't even know how to include that xptheme manifest in my programs.  I tried it but what I tried didn't work.  Doesn't matter.  I dislike everything about the modern interface look, so I just ignore it.  It isn't necessary for my work.  I don't sell any software, and as I said, I prefer the older look.
Title: Re: Ease vs Size
Post by: Frederick J. Harris on November 25, 2016, 08:02:52 PM
Your work here is certainly interesting Jim.  But I keep falling back on the idea that to really compare programming languages, one has to use examples where string handling is involved.  You know, to avoid an apples to oranges comparison.

In the case of String Classes, for a long time I wondered why the C++ Standard Library String Class had to be so much larger than mine in terms of what it adds to an executable.  For a time I thought it might simply be because of the way it was constructed, having a base class of basic_string or whatever it is; I forget.  But it only recently dawned on me the reason is really because of C++ Exception Handling.  That's really a complicated and sophisticated affair, and makes just about any comparison with other languages an apples to oranges comparison, i.e., all is not equal.

Your point about windows created with resource dialogs is well taken.  Its easy to understand how that's an efficient approach as all the functionality is within Windows dlls; one doesn't have to write code to create the windows. 
Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 08:17:59 PM
Fred,
  Here is my TCLIB batch file.
It will auto compile and add an rc file of the same name as the c++ file located in the same directory.
James


::=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
:: Batch file for creating 64 bit applications with TCLib targeted c++ source.
:: usage: TCLIB.BAT MainFile  (no ext .cpp assumed)
::=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
@setlocal enableextensions enabledelayedexpansion
@ECHO OFF
REM ==============================================================================
REM For use with Vista+
SET WIN_VER=/DWINVER=_WIN32_WINNT_VISTA /D_WIN32_WINNT=_WIN32_WINNT_VISTA
REM ==============================================================================

SET F=%~nx1
IF EXIST "%F%.cpp" (
  SET FN="%F%.cpp"
  GOTO start
)
GOTO usage

:start

SET XTYPE=x86_amd64
CALL "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %XTYPE%

IF EXIST "%F%.rc" (
  ECHO Compiling resources.....
  Rc "%F%"
  SET VRES="%F%.res"
)
:: DO IT
cl %FN%  /O1 /Os /Gy /GS- /GR- /Gs9999999 /Zc:sizedDealloc- %WIN_VER% /link /OPT:REF /STACK:0x100000,0x100000 TCLib.lib kernel32.lib user32.lib %VRES% %2 %3 %4 %5 %6


ECHO Finished!
IF EXIST "%F%.obj" del "%F%.obj"
IF EXIST "Strings.obj" del "Strings.obj"

GOTO done

:usage
ECHO **************************************************************
ECHO  Usage:  TCLIB.BAT MainFile  no ext .cpp assumed
ECHO **************************************************************
:done

Title: Re: Ease vs Size
Post by: James C. Fuller on November 25, 2016, 08:23:10 PM
Fred,
  I think you can leave out the theme stuff but still get dpi compatibility and no fuzzy text by using this manifest?
James


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">

      <assemblyIdentity version="1.0.0.0"
         processorArchitecture="amd64"
         name="ApplicationName"
         type="win32"/>
      <description>Optional description of your application</description>

      <asmv3:application>
         <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
            <dpiAware>true</dpiAware>
         </asmv3:windowsSettings>
      </asmv3:application>

      <!-- Compatibility section -->
      <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
         <application>
            <!--The ID below indicates application support for Windows Vista -->
            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
            <!--The ID below indicates application support for Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
            <!--This Id value indicates the application supports Windows 8 functionality-->
            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
            <!--This Id value indicates the application supports Windows 8.1 functionality-->
            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
            <!-- This Id value indicates the application supports Windows 10 functionality-->
            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>           
         </application>
       </compatibility>

      <!-- Trustinfo section -->
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
         <security>
            <requestedPrivileges>
               <requestedExecutionLevel
                  level="asInvoker"
                  uiAccess="false"/>
               </requestedPrivileges>
         </security>
      </trustInfo>


   </assembly>

Title: Re: Ease vs Size
Post by: Frederick J. Harris on November 26, 2016, 04:59:16 AM
Thanks Jim.  I'll try them out.
Title: Re: Ease vs Size
Post by: James C. Fuller on November 28, 2016, 01:13:04 PM

Here is a version using PellesC 8 with the built in BCX wrappers.
  Exe Size: 32,256
==============================================================================



'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloBCX using BCX wrappers
'  exe size: 32,256
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$ONEXIT "ULEX.EXE $FILE$.C TCHARXLATER_VC.TXT"
$ONEXIT "PEL.BAT $FILE$ -m64 gui"
'==============================================================================
GUI "MyClassName", PIXELS

CONST    IDC_OK = 1001
CONST    IDC_CANCEL = 1002
CONST    IDC_TEXT = 1003
Dim UserName$
'==============================================================================
Sub FormLoad
    Dim AS HWND hWin,hCtl
    Raw As DWORD dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION, _
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE

    BCXFONT = BCX_SET_FONT("Segoe UI",9)
    hWin = BCX_FORM("What is your name?",0,0,246,110,dwStyle,dwStyleEx)
    hCtl = BCX_INPUT("",hWin,IDC_TEXT,21,20,201,19)
    BCX_BUTTON("OK",hWin,IDC_OK,51,52,60,23,0,0)
    BCX_BUTTON("Cancel",hWin,IDC_CANCEL,126,52,60,23,0,0)
    Center(hWin)
    SetFocus(hCtl)
    Show(hWin) 
End Sub
'==============================================================================
Begin Events
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDC_CANCEL
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
                Case IDC_OK
                    GetWindowText(GetDlgItem(CBHNDL,IDC_TEXT),UserName$,255)
                    If Len(UserName$) Then
                        MessageBox(CBHNDL,"Hello " & UserName$,"What's your Name",MB_OK)
                    End If   
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
            Exit Function
    End Select
End Events


Title: Re: Ease vs Size
Post by: James C. Fuller on November 28, 2016, 01:37:17 PM
After posting the BCX Pelles 8 request I decide to give it a go with TCLib:
  Exe Size: 10,752


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'HelloBCX with TCLib
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
$CPP
$ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
$ONEXIT "TCLIB.BAT $FILE$"
$HEADER
    #include <commctrl.h>                   
    #pragma comment(lib,"comctl32.lib")       
    #pragma comment(lib,"gdi32.lib")       
$HEADER
'==============================================================================
GUI "MyClassName", PIXELS

CONST    IDC_OK = 1001
CONST    IDC_CANCEL = 1002
CONST    IDC_TEXT = 1003
Dim UserName$
'==============================================================================
Sub FormLoad
    Dim AS HWND hWin,hCtl
    Raw As DWORD dwStyle = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION, _
    dwStyleEx = WS_EX_DLGMODALFRAME | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE

    BCXFONT = BCX_SET_FONT("Segoe UI",9)
    hWin = BCX_FORM("What is your name?",0,0,246,110,dwStyle,dwStyleEx)
    hCtl = BCX_INPUT("",hWin,IDC_TEXT,21,20,201,19)
    BCX_BUTTON("OK",hWin,IDC_OK,51,52,60,23,0,0)
    BCX_BUTTON("Cancel",hWin,IDC_CANCEL,126,52,60,23,0,0)
    Center(hWin)
    SetFocus(hCtl)
    Show(hWin) 
End Sub
'==============================================================================
Begin Events
    Select Case CBMSG
        Case WM_COMMAND
            Select Case CBCTL
                Case IDC_CANCEL
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
                Case IDC_OK
                    GetWindowText(GetDlgItem(CBHNDL,IDC_TEXT),UserName$,255)
                    If Len(UserName$) Then
                        MessageBox(CBHNDL,"Hello " & UserName$,"What's your Name",MB_OK)
                    End If   
                    SendMessage(CBHNDL,WM_CLOSE,0,0)
            End Select
            Exit Function
    End Select
End Events


Title: Re: Ease vs Size
Post by: Frederick J. Harris on November 30, 2016, 11:54:24 PM
I've modified my version of Jim's test app as follows...

1)   Added AdjustWindowRect() functionality so that one can place controls right up against the bottom or right edge of their parent when designing the layout and not have them clipped when used on other operating systems other than the one on which form design took place;

2)   Added XP Theme functionality as in the original HelloDDT.bas sample app being emulated by SDK techniques;

3)   Added DPI Awareness by calling SetProcessDPIAware() or adding it to the manifest and performing the necessary modifications to window and control sizings. 

The smallest sizes I can get the app down to using VC15 and VC19 with various compilation/linkage setups are as follows...


//  9,216 UNICODE, x64, VC19, TCLib, DPI Awareness Set In Manifest (Adds 1024 Bytes!!!)
//  8,192 UNICODE, x64, VC19, TCLib, DPI Awareness Set SetProcessDPIAware() Api
//  7,680 UNICODE, x64, VC15, TCLib
//  8,192 ANSI,    x64, VC19, TCLib
//  7,680 ANSI,    x64, VC15, TCLib
//  6,144 UNICODE, x64, VC15, TCLib, DPI Aware, But No Dialog Fonts, AdjustWindowsRect(), Or XPThemes
// 90,112 UNICODE, x64, VC19, LIBCMT
// 42,496 UNICODE, x64, VC15, LIBCMT


Interestingly, setting DPI Awareness via a manifest as opposed to calling SetProcessDPIAware() adds 1 k or 1,024 bytes to the executable, i.e., 9,216 bytes verses 8,192 bytes in VC19 (Visual Studio 2015).  That kind of surprised me.  I was wondering if by setting both DPI Awareness and Themes in the manifest and removing the SetProcessDPIAware() and associated function calls in the Cpp file I could perhaps shave a half kilobyte or full kilobyte from the executable.  But it seems to work the other way around.  It costs more to do it via the manifest, seemingly.

Here are all my code files...

// XPtheme.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
  xmlns="urn:schemas-microsoft-com:asm.v1"
  manifestVersion="1.0">
  <assemblyIdentity
    name="HelloSdk"
    processorArchitecture="amd64"
    version="5.1.0.0"
    type="win32"/>
    <description>Windows Shell</description>
    <dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="amd64"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
  </dependency>
</assembly>


Note in the above that the processorArchitecture setting has to be changed to "amd64" from the original "x86" in the PowerBASIC version.  Also, if DPI Awareness is set in the manifest (which adds 1,024 bytes), this XPTheme.xml file must be used for it to work on Windows 10 (Win 8 too I guess)...


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
   xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
  xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
  >
  <assemblyIdentity
    name="HelloSdk"
    processorArchitecture="amd64"
    version="5.1.0.0"
    type="win32"
  />
 
  <description>
    Windows Shell
  </description>
 
  <!-- Compatibility section -->
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
     <application>
        <!--The ID below indicates application support for Windows Vista -->
        <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
        <!--The ID below indicates application support for Windows 7 -->
        <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
        <!--This Id value indicates the application supports Windows 8 functionality-->
        <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
        <!--This Id value indicates the application supports Windows 8.1 functionality-->
        <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
        <!--This Id value indicates the application supports Windows 10 functionality-->
        <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
     </application>
  </compatibility>
 
  <dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="amd64"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
  </dependency>
 
  <!-- DPI Aware -->
  <asmv3:application>
     <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
       <dpiAware>true</dpiAware>
     </asmv3:windowsSettings>
  </asmv3:application>
</assembly>


Here is Hello.rc...

// Hello.rc

// Hello.rc
1 24 "xptheme.xml"


// Hello.h

//Hello.h
#ifndef Hello_h
#define Hello_h

#define IDC_TEXT                    2000
#define IDC_OK                      2005
#define IDC_CANCEL                  2010
#define dim(x)                      (sizeof(x) / sizeof(x[0]))
#define SizX(x)                     (int)(x * rxRatio)          // For DPI Scaling Calculations And Purposes
#define SizY(y)                     (int)(y * ryRatio)          // For DPI Scaling Calculations And Purposes

struct WndEventArgs
{
HWND                               hWnd;
WPARAM                             wParam;
LPARAM                             lParam;
HINSTANCE                          hIns;
};

LRESULT fnWndProc_OnCreate         (WndEventArgs& Wea);
LRESULT fnWndProc_OnCommand        (WndEventArgs& Wea);
LRESULT fnWndProc_OnDestroy        (WndEventArgs& Wea);

struct EVENTHANDLER
{
unsigned int                      iMsg;
LRESULT                           (*fnPtr)(WndEventArgs&);
};

const EVENTHANDLER EventHandler[]=
{
{WM_CREATE,                        fnWndProc_OnCreate},
{WM_COMMAND,                       fnWndProc_OnCommand},
{WM_DESTROY,                       fnWndProc_OnDestroy}
};
#endif


// HelloSdk.cpp

// HelloSdk.cpp
// cl  Hello.cpp /O1 /Os /GS- /GR- /FeHelloSdk.exe TCLib.lib Kernel32.lib User32.lib Gdi32.lib Comctl32.lib HelloRes.obj
// cl  Hello.cpp /O1 /Os /GS- /MT /FeHelloSdk.exe Kernel32.lib User32.lib gdi32.lib Comctl32.lib HelloRes.obj
//  8,192 UNICODE, x64, VC19, TCLib
//  7,680 UNICODE, x64, VC15, TCLib
//  8,192 ANSI,    x64, VC19, TCLib
//  7,680 ANSI,    x64, VC15, TCLib
// 90,112 UNICODE, x64, VC19, LIBC
// 42,496 UNICODE, x64, VC15, LIBC
#define TCLib
#ifndef UNICODE
   #define UNICODE
#endif
#ifndef _UNICODE
   #define _UNICODE
#endif   
#include <windows.h>
#include <commctrl.h>
#ifdef TCLib
   #include   "stdio.h"
   #include   "string.h"
   #include   "tchar.h"
   extern "C" int _fltused=1;
#else
   #include   <cstdio>
   #include   <string.h>
   #include   <tchar.h>
#endif
#include "Hello.h"


void SetMyProcessDpiAware()
{
BOOL (__stdcall *pFn)(void);

HINSTANCE hInstance=LoadLibrary(_T("user32.dll"));
if(hInstance)
{
    pFn=(BOOL (__stdcall*)(void))GetProcAddress(hInstance,"SetProcessDPIAware");
    if(pFn)
       pFn();
    FreeLibrary(hInstance);
}
}


LRESULT fnWndProc_OnCreate(WndEventArgs& Wea)
{
double               dpiX            = 0.0;
double               dpiY            = 0.0;
double               rxRatio         = 0.0;
double               ryRatio         = 0.0;
HWND                 hCtl            = NULL;
HFONT                hFont           = NULL;
HDC                  hDC             = NULL;
RECT                 rc;
INITCOMMONCONTROLSEX uCC;   

Wea.hIns=((LPCREATESTRUCT)Wea.lParam)->hInstance;
uCC.dwSize = sizeof(uCC),    uCC.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&uCC);
hDC = GetDC(NULL);
dpiX=GetDeviceCaps(hDC, LOGPIXELSX);
dpiY=GetDeviceCaps(hDC, LOGPIXELSY);
rxRatio=(dpiX/96);
ryRatio=(dpiY/96);
ReleaseDC(NULL,hDC);
rc.left = 0, rc.top = 0, rc.right = SizX(240), rc.bottom = SizY(81);
AdjustWindowRect(&rc, WS_CAPTION|WS_VISIBLE, FALSE);
long w = rc.right - rc.left;
long h = rc.bottom - rc.top;
long x = max((GetSystemMetrics(SM_CXSCREEN) - w) / 2, 0);
long y = max((GetSystemMetrics(SM_CYSCREEN) - h) / 2, 0);
MoveWindow(Wea.hWnd,x,y,w,h,FALSE);
hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
hCtl = CreateWindowEx(WS_EX_CLIENTEDGE,_T("Edit"),_T(""),WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,SizX(21),SizY(20),SizX(201),SizY(19),Wea.hWnd,(HMENU)IDC_TEXT,Wea.hIns,NULL);
SendMessage(hCtl, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)0);
SetFocus(hCtl);
hCtl = CreateWindow(_T("Button"),_T("OK"), WS_CHILD|WS_VISIBLE|WS_TABSTOP,SizX(51),SizY(52),SizX(60),SizY(23),Wea.hWnd,(HMENU)IDC_OK,Wea.hIns,NULL);
SendMessage(hCtl, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)0);
hCtl = CreateWindow(_T("Button"),_T("Cancel"), WS_CHILD|WS_VISIBLE|WS_TABSTOP,SizX(126),SizY(52),SizX(60),SizY(23),Wea.hWnd,(HMENU)IDC_CANCEL,Wea.hIns,NULL);
SendMessage(hCtl, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)0);

return 0;
}


LRESULT fnWndProc_OnCommand(WndEventArgs& Wea)
{
switch(LOWORD(Wea.wParam))
{
   case IDC_OK:
     {   
        TCHAR szText[128];
        TCHAR szString[128];
        GetWindowText(GetDlgItem(Wea.hWnd,IDC_TEXT),szText,128);
        _tcscpy(szString,_T("Hello, "));
        _tcscat(szString,szText);
        _tcscat(szString,_T("!"));
        MessageBox(Wea.hWnd,szString,_T("Greetings!"),MB_OK);
        break;
     }
   case IDC_CANCEL:
     {
        SendMessage(Wea.hWnd,WM_CLOSE,0,0);
        break;
     }
}
 
return 0;
}


LRESULT fnWndProc_OnDestroy(WndEventArgs& Wea)
{
PostQuitMessage(0);
return 0;
}


LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
WndEventArgs Wea;

for(size_t i=0; i<dim(EventHandler); i++)
{
     if(EventHandler[i].iMsg==msg)
     {
        Wea.hWnd=hwnd, Wea.lParam=lParam, Wea.wParam=wParam;
        return (*EventHandler[i].fnPtr)(Wea);
     }
}

return (DefWindowProc(hwnd, msg, wParam, lParam));
}


int WINAPI WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
TCHAR szClassName[]=_T("HelloSdk");
WNDCLASSEX wc;
HWND hWnd;
MSG msg;

SetMyProcessDpiAware();
wc.lpszClassName = szClassName;                     wc.lpfnWndProc = fnWndProc;
wc.cbSize        = sizeof(WNDCLASSEX);              wc.style       = 0;
wc.hIcon         = LoadIcon(NULL,IDI_APPLICATION);  wc.hInstance   = hIns;
wc.hIconSm       = 0;                               wc.hCursor     = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;         wc.cbWndExtra  = 0;
wc.lpszMenuName  = NULL;                            wc.cbClsExtra  = 0;
RegisterClassEx(&wc);
hWnd=CreateWindowEx(0,szClassName,_T("What Is Your Name?"),WS_CAPTION|WS_VISIBLE,0,0,0,0,HWND_DESKTOP,0,hIns,0);
ShowWindow(hWnd,iShow);
while(GetMessage(&msg, NULL, 0, 0))
{
    if(!IsDialogMessage(hWnd, &msg))
    {
       TranslateMessage(&msg);
       DispatchMessage(&msg);
    }
}

return msg.wParam;
}


To build the version with DPI Awareness set in manifest, comment out the SetProcessDPIAware() in WinMain(), and remove function SetMyProcessDpiAware().

To compile the resource script into a resource file I do this...


rc.exe /v /foHelloRes.res Hello.rc


That creates a HelloRes.res file.  Then use cvtres.exe to create an obj file...


cvtres.exe /MACHINE:X64 /v HelloRes.res


That HelloRes.obj file then gets fed into the linker with the rest of the libs/object code as seen in my compilation strings at the top of HelloSdk.cpp.

I think that size is pretty terrible for such a simple app as this.  Its 7.5 k with VC15 and 8 k with VC19 – UNICODE or ANSI.  As I mentioned its 9 k if DPI Awareness is set in the manifest.  For something as trivial as this I'd expect about 5 k as being reasonable with TCLib.  Which got me to wondering why it is so big?  And I guess I have to accept Jim's statement that resource editor created apps beat SDK style apps size wise.  Or do I?

Well, in ruminating about it for awhile I decided there's a whole lot of stuff going on in that app that I would never do.  Its there because I simply copied code that Jim provided with his test app.  For example, all this stuff in my fnWndProc_OnCreate()...


hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
// hCtl = CreateWindowEx( for edit control )
SendMessage(hCtl, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)0);
// hCtl = CreateWindowEx( for OK Button )
SendMessage(hCtl, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)0);
// hCtl = CreateWindowEx( for Cancel Button )
SendMessage(hCtl, (UINT)WM_SETFONT, (WPARAM)hFont, (LPARAM)0);

   
...which changes the font of the three child window controls.  What purpose does that serve?  I can't see any whatsoever.  What I'm guessing is that Jim is attempting to exactly emulate the fonts used in resource created dialogs.  But why is that the standard to which SDK created windows must conform?  By dropping those four Api function calls my 7,680 byte VC15 created app loses 512 bytes and comes in 7,168 bytes.  And the resulting app looks better in my opinion than the one emulating resource dialog fonts.

Next in line for abscission would be all the AdjustWindowRect() stuff.  I have to admit I'm real glad I now know about that function (and AdjustWindowRectEx() too), but by simply refraining from placing controls right up against the bottom or right hand border of the window one can easily dispense with it to no ill effect.  With that gone and all its associated baggage and variables, our fnWndProc_OnCreate() reduces to simply this....


LRESULT fnWndProc_OnCreate(WndEventArgs& Wea)
{
double               dpiX            = 0.0;
double               dpiY            = 0.0;
double               rxRatio         = 0.0;
double               ryRatio         = 0.0;
HWND                 hCtl            = NULL;
HDC                  hDC             = NULL;
RECT                 rc;
INITCOMMONCONTROLSEX uCC;   

Wea.hIns=((LPCREATESTRUCT)Wea.lParam)->hInstance;
uCC.dwSize = sizeof(uCC),    uCC.dwICC = ICC_STANDARD_CLASSES;
InitCommonControlsEx(&uCC);
hDC = GetDC(NULL);
dpiX=GetDeviceCaps(hDC, LOGPIXELSX);
dpiY=GetDeviceCaps(hDC, LOGPIXELSY);
rxRatio=(dpiX/96);
ryRatio=(dpiY/96);
ReleaseDC(NULL,hDC);
MoveWindow(Wea.hWnd,SizX(300),SizY(200),SizX(270),SizY(120),FALSE);
hCtl = CreateWindowEx(WS_EX_CLIENTEDGE,_T("Edit"),_T(""),WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,SizX(21),SizY(15),SizX(220),SizY(22),Wea.hWnd,(HMENU)IDC_TEXT,Wea.hIns,NULL);
SetFocus(hCtl);
hCtl = CreateWindow(_T("Button"),_T("OK"), WS_CHILD|WS_VISIBLE|WS_TABSTOP,SizX(64),SizY(52),SizX(60),SizY(23),Wea.hWnd,(HMENU)IDC_OK,Wea.hIns,NULL);
hCtl = CreateWindow(_T("Button"),_T("Cancel"), WS_CHILD|WS_VISIBLE|WS_TABSTOP,SizX(138),SizY(52),SizX(60),SizY(23),Wea.hWnd,(HMENU)IDC_CANCEL,Wea.hIns,NULL);
 
return 0;
}


...which is 28 lines compared to the original of 39 lines.  Unfortunately, I'm still at 7,168 bytes. 

Next, for me at least, I'd be happy to settle for just buttons and edit controls without all the XP Theme stuff.  Horrified by that comment, and thinking I'm some kind of cave man or something?  Completely lacking all aesthetic sensibilities of what is right and beautiful?  Maybe So.

By removing the XPTheme manifest file and the calls to InitCommonControlsEx() and that associated baggage (no need for rc or cvtres) we're down to simply this as a fnWndProc_OnCreate()...


LRESULT fnWndProc_OnCreate(WndEventArgs& Wea)
{
double               dpiX            = 0.0;
double               dpiY            = 0.0;
double               rxRatio         = 0.0;
double               ryRatio         = 0.0;
HWND                 hCtl            = NULL;
HDC                  hDC             = NULL;
 
Wea.hIns=((LPCREATESTRUCT)Wea.lParam)->hInstance;
hDC = GetDC(NULL);
dpiX=GetDeviceCaps(hDC, LOGPIXELSX);
dpiY=GetDeviceCaps(hDC, LOGPIXELSY);
rxRatio=(dpiX/96);
ryRatio=(dpiY/96);
ReleaseDC(NULL,hDC);
MoveWindow(Wea.hWnd,SizX(300),SizY(200),SizX(270),SizY(120),FALSE);
hCtl = CreateWindowEx(WS_EX_CLIENTEDGE,_T("Edit"),_T(""),WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,SizX(21),SizY(15),SizX(220),SizY(22),Wea.hWnd,(HMENU)IDC_TEXT,Wea.hIns,NULL);
SetFocus(hCtl);
hCtl = CreateWindow(_T("Button"),_T("OK"), WS_CHILD|WS_VISIBLE|WS_TABSTOP,SizX(64),SizY(52),SizX(60),SizY(23),Wea.hWnd,(HMENU)IDC_OK,Wea.hIns,NULL);
hCtl = CreateWindow(_T("Button"),_T("Cancel"), WS_CHILD|WS_VISIBLE|WS_TABSTOP,SizX(138),SizY(52),SizX(60),SizY(23),Wea.hWnd,(HMENU)IDC_CANCEL,Wea.hIns,NULL);
 
return 0;
}
 

...which is only 24 lines of code, and our exe is now only 6,144 bytes, is still High DPI Aware, UNICODE, x64 architecture, and will look quite satisfactory on any Windows Operating System (I've tested it on everything from Win 2000 on up).

So adding themes, AdjustWindowsRect() and stuff like that only costs two or three kilobytes which is certainly nothing.  But after all, this is just an academic exercise to see where bloat comes from! 

Title: Re: Ease vs Size
Post by: Frederick J. Harris on December 01, 2016, 12:10:52 AM
Jim,

On your Reply #22 where you posted a version using a resource dialog compiled with Tiny C, you got the smallest number by far, which I believe was 5,120 bytes.  I don't believe I ever tested TCLib with just a resource script created window, i.e., without RegisterClass(), CreateWindow() and so on.  Would you mind trying that or posting your rc file so I can try it?  Just curious!

Fred
Title: Re: Ease vs Size
Post by: James C. Fuller on December 01, 2016, 12:17:47 PM
Fred,
  I've done some serious hacking on your TCLib but I think this will compile with your version.
My batch file auto compiles a resource file with the same base name as the c++ file sent it.
This is not the file I used for comparisons as I was showcasing bc9Basic and TCLib so all the source in the tests are the same including  bc9Basic RTL code for string processing.
This one uses the "c" string copy and concat and it does reduce the size down to 5120.
Also note you do not need cvtres.exe. link is smart enough to link the *.res directly.
Check the first post for a link to a very good resource editor.

James

RC file
  My resource editor allows to save styles in hex so I don't have to include any windows *.h files in my rc scripts.

#define IDD_DLG1 1000
#define IDC_EDT1 1001
#define IDC_BTN1 1002
#define IDC_BTN2 1003

IDD_DLG1 DIALOGEX 10,10,160,50
CAPTION "What is your name?"
FONT 9,"Segoe UI",400,0,0
STYLE 0x10C80880
EXSTYLE 0x00000001
BEGIN
  CONTROL "",IDC_EDT1,"Edit",0x50010000,14,12,134,12,0x00000200
  CONTROL "OK",IDC_BTN1,"Button",0x50010000,34,32,40,14
  CONTROL "Cancel",IDC_BTN2,"Button",0x50010000,88,32,40,14
END


C++ file
  You will need to include your own headers

enum
{
    IDD_DLG1 =               1000,
    IDC_EDT1,
    IDC_BTN1,
    IDC_BTN2
};

int     WINAPI _tWinMain (HINSTANCE, HINSTANCE, LPWSTR, int);
INT_PTR CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI _tWinMain (HINSTANCE  hInst, HINSTANCE  hPrev, LPWSTR  CmdLine, int CmdShow)
{
    int      RetVal = {0};
    RetVal = DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_DLG1), 0, ( DLGPROC) DlgProc, 0);
    if(RetVal == -1 )
    {
        MessageBox (GetActiveWindow(), (_T("BAD")), _T(""), 0 );
        return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;
}


INT_PTR CALLBACK DlgProc (HWND hWnd, UINT Msg, WPARAM  wParam, LPARAM  lParam)
{
    if(Msg == WM_COMMAND )
    {
        if(LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDC_BTN2 )
        {
            EndDialog(hWnd, 0);
            goto L1001;
        }
        if(LOWORD(wParam) == IDC_BTN1 )
        {
            _TCHAR     szText[128];
            _TCHAR     szString[128];
            GetWindowText(GetDlgItem(hWnd,IDC_EDT1), szText, 128);
            _tcscpy(szString, _T("Hello, "));
            _tcscat(szString, szText);
            _tcscat(szString, _T("!"));
            MessageBox(hWnd, szString, _T("What's your name"), MB_OK);
            EndDialog(hWnd, 1);
        }
L1001:
        ;
    }
    return 0;
}



Title: Re: Ease vs Size
Post by: James C. Fuller on December 01, 2016, 01:40:16 PM
Fred,
  I changed the Tiny C version to use strcpy and strcat instead of the bc9Basic RTL string functions and it now comes in at 4608. But note this is 64 bit "c" ansi.

James