1| ' ########################################################################################
     2| ' Microsoft Windows
     3| ' File: CW_CC_Button.bas
     4| ' Contents: CWindow button 
     5| ' Compiler: Ported to bc9Basic jcfuller 08/18/2016  
     6| ' Copyright (c) 2016 José Roca. Freeware. Use at your own risk.
     7| ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
     8| ' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
     9| ' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
    10| ' ########################################################################################
    11| $NOMAIN
    12| $CPP
    13| $ONEXIT "ULEX.EXE $FILE$.CPP TCHARXLATER_VC.TXT"
    14| $ONEXIT "TCLIB.BAT $FILE$"
    15| '==============================================================================    
    16| $HEADER
    17|     #include <commctrl.h>                    /*'For CWindow*/ 
    18|     #pragma comment(lib,"comctl32.lib")        /*'For CWindow*/
    19|     #pragma comment(lib,"gdi32.lib")        /*'For CWindow*/
    20|     #pragma comment(lib,"advapi32.lib")        /*'For DPI aware check*/
    21| $HEADER
    22| '==============================================================================
    23| '------------------------------------------------------------------------------
    24| $Include <Afx/CWindow.bi>
    25| '------------------------------------------------------------------------------
    26| '==============================================================================
    27| Function WinMain()
    28|     Dim As int iRetVal
    29|     Dim As HWND hWin,hButton
    30| 
    31|     Raw As CWindow pWindow
    32|     hWin = pWindow.Create(NULL, "CWindow with a button", &WndProc)
    33|     pWindow.SetClientSize(500,320)
    34|     pWindow.Center()
    35| 
    36|     'Add a button
    37|     hButton = pWindow.AddControl("Button",hWin , IDCANCEL, "&Close", 350, 250, 75, 23)
    38|     iRetVal = pWindow.Do_Events(CmdShow)
    39|     Function = iRetVal
    40| End Function
    41| '==============================================================================
    42| CallBack Function WndProc()
    43|     Select Case CBMSG
    44|         Case WM_COMMAND
    45|             Select Case CBCTL
    46|                 Case IDCANCEL
    47|                     If CBCTLMSG = BN_CLICKED Then
    48|                         SendMessage(CBHNDL,WM_CLOSE,0,0)
    49|                         Exit Function
    50|                     EndIf
    51|             End Select
    52|         Case WM_DESTROY
    53|             PostQuitMessage(0)
    54|             Exit Function
    55|     End Select
    56| End Function
    57|