$ filename "ezedit_bcx.exe"
'#include "$/inc/RTL32.inc"
'#include "$/inc/RTL64.inc"
#include "$/inc/MinWin.inc"
#include "$/inc/console.inc"
'cr=chr(13,10)
type MSG_
sys hwnd
int message
sys wParam
sys lParam
dword time
POINT pt
end type
type SIZE
long cx
long cy
end type
#define COLOR_BTNFACE 15
#define ICC_LISTVIEW_CLASSES 0x00000001
#define ICC_TREEVIEW_CLASSES 0x00000002
#define ICC_BAR_CLASSES 0x00000004
#define ICC_TAB_CLASSES 0x00000008
#define ICC_UPDOWN_CLASS 0x00000010
#define ICC_PROGRESS_CLASS 0x00000020
'#define ICC_HOTKEY_CLASS 0x00000040
'#define ICC_ANIMATE_CLASS 0x00000080
'#define ICC_WIN95_CLASSES 0x000000FF
#define ICC_DATE_CLASSES 0x00000100
#define ICC_USEREX_CLASSES 0x00000200
#define WM_GETFONT 0x0031
#define DEFAULT_GUI_FONT 17
'=========
'MAIN CODE
'=========
dim cmdline as asciiz ptr, hInst as sys
&cmdline=GetCommandLine
hInst=GetModuleHandle(0)
function RGB(int r,g,b) as int
return r + g*256 + b*65536
end function
function MAKELPARAM (long a, dword b)
return a | (b << 16)
end function
function MAKEWPARAM (long a, dword b)
return a | (b << 16)
end function
! GetActiveWindow lib "user32.dll" () as sys
! GetClassInfoEx lib "user32.dll" alias "GetClassInfoExA" (sys hinst, char* lpszClass, WNDCLASSEX *lpwcx) as bool
! IsWindow lib "user32.dll" (sys hWnd) as bool
! IsDialogMessage lib "user32.dll" alias "IsDialogMessageA" (sys hDlg, sys lpMsg) as bool
! GetTextExtentPoint32 lib "gdi32.dll" alias "GetTextExtentPoint32A" (sys hdc, char* lpString, int cbString, SIZE *lpSize) as bool
! MapDialogRect lib "user32.dll" (sys hDlg, RECT *lpRect) as bool
! RedrawWindow lib "user32.dll" (sys hWnd, sys lprcUpdate, sys hrgnUpdate, uint flags) as bool
// *********************************************************************
// Created with BCX32 - BASIC To C/C++ Translator (V) BCX 7.2.4 (2015/08/21)
// BCX (c) 1999 - 2015 by Kevin Diggins
// *********************************************************************
// ***************************************************
// *************************************************
// User's GLOBAL ENUM blocks
// *************************************************
// *************************************************
// System Defined Constants
// *************************************************
#define cSizeOfDefaultString 2048
// *************************************************
// User Defined Constants
// *************************************************
#define Edit1_ID 101
#define Button1_ID 102
// *************************************************
// Standard Prototypes
// *************************************************
// *************************************************
// User Global Variables
// *************************************************
static sys BcxFont;
static float BCX_ScaleX;
static float BCX_ScaleY;
static sys BCX_hInstance;
static sys BCX_hwndMDIClient;
static WNDCLASSEX BCX_WndClass;
static BOOL BCX_GUI_Init;
static string BCX_ClassName = nuls * cSizeOfDefaultString
static sys Form1;
static sys Button1;
static sys Edit1;
static string buffer = nuls * cSizeOfDefaultString
// *************************************************
// Standard Macros
// *************************************************
' #define Show(Window)RedrawWindow(Window,0,0,0);ShowWindow(Window,SW_SHOW);
macro Show(Window)
RedrawWindow(Window, 0, 0, 0)
ShowWindow(Window, SW_SHOW)
end macro
// *************************************************
// User Prototypes
// *************************************************
// *************************************************
// Runtime Functions
// *************************************************
function BCX_Form(optional string Caption, optional int X=0,optional int Y=0,optional int W=250,optional int H=150,optional int Style=-1, optional int Exstyle=0) as sys
int xf,yf,wf,hf
if Style=-1 then
Style= WS_MINIMIZEBOX | WS_SIZEBOX | WS_CAPTION |
WS_MAXIMIZEBOX | WS_POPUP | WS_SYSMENU
end if
xf=X*BCX_ScaleX : yf=Y*BCX_ScaleY : wf=(4+W)*BCX_ScaleX : hf=(12+H)*BCX_ScaleY
sys A = CreateWindowEx(Exstyle, BCX_ClassName, Caption, Style,
xf, yf, wf, hf,
NULL, NULL,BCX_hInstance,NULL)
if A = NULL then
MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION or MB_OK)
ExitProcess(1)
end if
'' sys fnt
'' if BcxFont=0 then fnt=GetStockObject(DEFAULT_GUI_FONT) else fnt = BcxFont end if
'' SendMessage(A, WM_SETFONT, fnt, 0)
SendMessage(A, WM_SETFONT, GetStockObject(DEFAULT_GUI_FONT), 0)
return A
end function
function GetTextSize(string text, optional sys hWnd=0, optional sys fnt=0) as sys 'SIZE*
sys hdc=GetDC(hWnd)
if fnt=0 then fnt=SendMessage(hWnd,WM_GETFONT,0,0)
sys sobj=SelectObject(hdc,fnt)
static SIZE sz
le=len(text)
GetTextExtentPoint32(hdc, text, le, sz)
SelectObject(hdc,sobj)
ReleaseDC(hWnd,hdc)
return (&sz)
end function
function BCX_Button(string Text,sys hwnd,int id,int X, Y,optional int W=0,optional int H=0,optional int Style=0,optional int Exstyle=-1) as sys
int xc,yc,wc,hc
if Style=0 then
Style=WS_CHILD | WS_VISIBLE | BS_MULTILINE | BS_PUSHBUTTON | WS_TABSTOP
end if
if Exstyle=-1 then
Exstyle=WS_EX_STATICEDGE
end if
xc=X*BCX_ScaleX : yc=Y*BCX_ScaleY : wc=W*BCX_ScaleX : hc=H*BCX_ScaleY
sys A = CreateWindowEx(Exstyle,"button", Text,Style,
xc,yc,wc,hc,
hwnd,id,BCX_hInstance,NULL)
if A = NULL then
MessageBox(NULL, "Button Creation Failed!", "Error!", MB_ICONEXCLAMATION or MB_OK)
ExitProcess(1)
end if
'' SendMessage(A,(UINT)WM_SETFONT, DefaultFont(hwnd), MAKELPARAM(FALSE,0))
SendMessage(A,(UINT)WM_SETFONT, GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(FALSE,0))
if W=0 then
psiz = GetTextSize(Text,A)
SIZE siz at psiz
xc=X*BCX_ScaleX : yc=Y*BCX_ScaleY: wc=siz.cx+24: hc=siz.cy+12
MoveWindow(A, xc, yc, wc, hc, TRUE)
end if
return A
end function
function BCX_Edit(string Text,sys hWnd,int id,int X,int Y,int W,int H,optional int Style=0,optional int Exstyle=-1) as sys
int xc,yc,wc,hc
sys A
if Style=0 then
Style = WS_CHILD | WS_VISIBLE | ES_WANTRETURN |
WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL
end if
if Exstyle=-1 then Exstyle = WS_EX_CLIENTEDGE
xc=X*BCX_ScaleX : yc=Y*BCX_ScaleY : wc=W*BCX_ScaleX : hc=H*BCX_ScaleY
A = CreateWindowEx(Exstyle,"edit",Text, Style,
xc,yc,wc,hc,
hWnd,id,BCX_hInstance,NULL)
if A = NULL then
MessageBox(NULL, "Edit Creation Failed!", "Error!", MB_ICONEXCLAMATION or MB_OK)
ExitProcess(1)
end if
'' SendMessage(A,WM_SETFONT,DefaultFont(hwnd),0)
SendMessage(A,(UINT)WM_SETFONT, GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(FALSE,0))
return A
end function
void BCX_InitGUI (void)
{
INITCOMMONCONTROLSEXt iccex;
if(BCX_GUI_Init)
{
return;
}
RECT rc={0,0,4,8};
MapDialogRect(NULL, rc);
BCX_ScaleX=rc.right/2;
BCX_ScaleY=rc.bottom/4;
BCX_hInstance=GetModuleHandle(NULL);
BCX_hwndMDIClient=NULL;
BCX_WndClass.cbSize=sizeof(BCX_WndClass);
BCX_WndClass.style=CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
BCX_WndClass.cbClsExtra=0;
BCX_WndClass.cbWndExtra=0;
BCX_WndClass.hIcon= LoadIcon(NULL,IDI_WINLOGO);;
BCX_WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
BCX_WndClass.hbrBackground=(COLOR_BTNFACE+1);
BCX_WndClass.lpszMenuName=NULL;
BCX_WndClass.hIconSm=NULL;
iccex.dwSize=sizeof(INITCOMMONCONTROLSEXt);
iccex.dwICC=ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES | ICC_BAR_CLASSES | ICC_TAB_CLASSES | ICC_UPDOWN_CLASS | ICC_PROGRESS_CLASS | ICC_USEREX_CLASSES | ICC_DATE_CLASSES;
InitCommonControlsEx( iccex);
BCX_GUI_Init=TRUE;
}
sub BCX_SetMetric (string metric)
if not BCX_GUI_Init then BCX_InitGUI()
if ucase(metric) = "PIXELS" then
BCX_ScaleX=1
BCX_ScaleY=1
else
RECT rc={0,0,4,8}
MapDialogRect(NULL, rc)
BCX_ScaleX=rc.right/2
BCX_ScaleY=rc.bottom/4
end if
end sub
sub BCX_RegWnd (string classname, sys *Form_WndProc)
if classname="" then
MessageBox (GetActiveWindow(),"Empty String For BCX_ClassName NOT Allowed","Empty ClassName",0)
ExitProcess(1)
end if
if GetClassInfoEx( BCX_hInstance, strptr classname, BCX_WndClass) <> 0 then
if not Form_WndProc then
UnregisterClass(classname,BCX_hInstance)
end if
return
end if
if not BCX_GUI_Init then
BCX_InitGUI()
end if
if BCX_ScaleX=0 && BCX_ScaleY = 0 then
BCX_SetMetric("Pixels")
end if
BCX_ClassName = classname
BCX_WndClass.lpfnWndProc=@Form_WndProc
BCX_WndClass.hInstance=BCX_hInstance
BCX_WndClass.lpszClassName=strptr(classname)
if not RegisterClassEx(&BCX_WndClass) then
MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION or MB_OK)
ExitProcess(1)
end if
end sub
// ************************************
// User Subs and Functions
// ************************************
void FormLoad (void)
{
Form1= BCX_Form("BCX_FORM and Edit Box", 0, 0, 210, 150);
Button1= BCX_Button("Ok", Form1, Button1_ID, 60, 110, 60, 20 );
Edit1= BCX_Edit("Insert text here...", Form1, Edit1_ID, 0, 0, 200, 100);
Show(Form1);
}
sys WndProc (HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam) callback
{
if(Msg==WM_COMMAND )
{
if(LOWORD(wParam)==Button1_ID )
{
SendMessage(Edit1,(UINT)WM_GETTEXT, len(buffer), buffer);
MessageBox (GetActiveWindow(),buffer,"Information",0 );
}
goto L1000;
}
if(Msg==WM_CLOSE )
{
DestroyWindow(Form1);
return 0;
}
if(Msg==WM_DESTROY )
{
PostQuitMessage(0);
return 0;
}
L1000:; // SelectState[PusherSelectState].CaseFlag 2
if(Msg==WM_DESTROY)
{
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,Msg,wParam,lParam); // endevents
}
// **********************************
int WinMain(sys hInst, hPrev,asciiz *CmdLine,int CmdShow)
{
MSG_ Msg;
BCX_ClassName ="EZEdit";
BCX_SetMetric("");
BCX_InitGUI();
BCX_hInstance = hInst;
BCX_WndClass.hIcon = LoadIcon(NULL,IDI_WINLOGO);
BCX_RegWnd( BCX_ClassName, @WndProc );
// ******************************************
FormLoad();
// ******************************************
while(GetMessage(&Msg,NULL,0,0))
{
sys hActiveWindow = GetActiveWindow();
if(not IsWindow(hActiveWindow) || not IsDialogMessage(hActiveWindow,&Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return Msg.wParam;
}
WinMain(hInst, 0, cmdline, SW_NORMAL )