Skip to content

Instantly share code, notes, and snippets.

View CarlTBarnes's full-sized avatar

Carl T. Barnes CarlTBarnes

View GitHub Profile
@CarlTBarnes
CarlTBarnes / DebugOutput.clw
Last active August 3, 2023 22:35
OutputDebugString wrapper for Clarion String
DB PROCEDURE(STRING xMsg)
Prfx EQUATE('Prefix: ')
sz CSTRING(SIZE(Prfx)+SIZE(xMsg)+3),AUTO
CODE
sz=Prfx & CLIP(xMsg) & '<13,10>'
OutputDebugString(sz)
!----------------------------------------
DB PROCEDURE(STRING xMessage)
Prfx EQUATE('PrefixText: ') !All output gets this
sz CSTRING(SIZE(Prfx)+SIZE(xMessage)+3),AUTO
@CarlTBarnes
CarlTBarnes / Clarion110.red
Last active August 8, 2020 21:11
Clarion 11 RED file to Copy Debug ClaRUN.DLL to Project Folder during Debug builds
-- #################### Clarion110.RED #################### --
-- Project Redirection for Clarion 11.0 to Copy the Clarion10\Bin\Debug DLLs only for Debug builds
-- This RED has a [Copy] *.dll = %BIN%\debug
{include clarion_DebugDllCopy.red}
-- this includes the normal RED --
{include %REDDIR%\%REDNAME%}
-- review: https://clarionhub.com/t/how-to-improve-the-call-stack-when-your-program-gpfs/188
@CarlTBarnes
CarlTBarnes / ManifestFixupFunction.clw
Last active June 8, 2020 16:49
Manifest Fixup Controls for Hand Code
ManifestFixup PROCEDURE(BYTE SheetNoTheme=1, BYTE ColorAsWindow=0)
FEQ LONG,AUTO
CODE !Changes VistaManifest.TPW Template makes ...
FEQ=0
LOOP
FEQ=0{PROP:NextField,FEQ} ; IF ~FEQ THEN BREAK.
CASE FEQ{PROP:Type}
OF Create:sheet
IF SheetNoTheme THEN FEQ{PROP:NoTheme}=1. !%ForceSHEETNoTheme
OF Create:OPTION OROF Create:GROUP OROF Create:RADIO
@CarlTBarnes
CarlTBarnes / LoadLibraryExample.clw
Last active July 5, 2020 20:22
LoadLibrary Example
!--Step 1.-- Define MAP with Function that has DLL(1) or DLL(_fp_), and must have NAME() that matches LONG in step 2
MAP
GetProcsByName PROCEDURE(BYTE ShowErrors=0),BOOL
MODULE('Win32')
SetWindowDisplayAffinity PROCEDURE(SIGNED hWnd, UNSIGNED dwAffinity),BOOL,PROC,PASCAL,DLL(_fp_),NAME('SetWinDspAff')
! ^^^^ ^^^^^^^^^^^^
LoadLibraryA PROCEDURE(*CSTRING pszModuleFileName),LONG,RAW,PASCAL,DLL(1)
FreeLibrary PROCEDURE(LONG hModule),BOOL,PASCAL,DLL(1),PROC
GetModuleHandleA PROCEDURE(*CSTRING lpModuleName),LONG,RAW,PASCAL,DLL(1)
@CarlTBarnes
CarlTBarnes / CloseWindowHook.clw
Created June 9, 2020 21:02
Prop:CloseWindowHook Example Clarion
!An update program used MANY procedures and the tree was not well defined.
!Some were Process Templates that had a Cancel button showing. I wanted to hide the Cancel buttons.
!How to find the procedures?
!I used PROP:CloseWindowHook and checked for a PROGRESS and BUTTON that was Visible and Enabled
!------------------------------------------------------------------------------------------------
!My Templates have been modified after Open(Window) to store the procedure name in a user Property
!This is handy at times for Debug
!
! STANDARD.TPW
@CarlTBarnes
CarlTBarnes / FileExtensionFromName.clw
Last active June 14, 2020 23:33
Find the File .EXT on the end of a File Name after last period
MAP
FileExtension PROCEDURE(*STRING FN),STRING
MODULE('RTL')
LenFastClip PROCEDURE(CONST *STRING Text2Measure),LONG,NAME('Cla$FASTCLIP')
END
END
!--------------------------------------
FileExtension PROCEDURE(*STRING FN)!,STRING
L USHORT,AUTO
@CarlTBarnes
CarlTBarnes / DebugViewDetect.clw
Last active June 18, 2020 20:58
Debug Viewer Detection
!From https://clarionhub.com/t/how-to-detect-if-an-outputdebugstring-viewer-is-running/241
!I have not tested this code
PROGRAM
!INCLUDE('Windows.inc'),ONCE
MAP
OutputDebugStringNotReady(),BOOL !0=Ready, Non-Zero indicates Not Ready
MODULE('Standard Windows APIs')
@CarlTBarnes
CarlTBarnes / CascadeMdiChildren.clw
Last active June 24, 2020 15:39
Cascade open MDI Child windows like Clarion RTL STD:CascadeWindow
MAP
MODULE('Win32')
SendMessageA(LONG hWnd, LONG nMsg, LONG wParam, LONG lParam),LONG,PROC,PASCAL,DLL(1)
!https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-mdicascade
. .
CascadeWindows ROUTINE !Like STD:CascadeWindow Clarion RTL
!Message must be sent to the Frame MDI Client Handle and not the Frame Handle
SendMessageA( AppFrame{PROP:ClientHandle} , 0227H, 4, 0)
EXIT
@CarlTBarnes
CarlTBarnes / Hex8_FromLong.clw
Last active July 13, 2022 18:34
Hex conversion from LONG
MAP
Hex8(LONG Lng),STRING !Return 8 digit hex with trailing 'h'
HexFmt(LONG Lng),STRING !Return minimum hex pairs w/o 'h'
HexDigits(ULONG Lng),STRING !Return minimum Hex Digits, may be odd
HexPairs(ULONG Lng),STRING !Return minimum Hex Pairs
HexClarion(ULONG Lng),STRING !Clarion Valid Hex with trailing 'h', plus leading '0' for A-F
END
!=================================
Hex8 PROCEDURE(LONG Lng)!,STRING !Return 8 digit hex with trailing 'h'
@CarlTBarnes
CarlTBarnes / TimeSplitAndJoin.clw
Created July 4, 2020 21:20
TimeHMSh (Hour,Min,Sec) like DATE(). Also TimeSplit() Faster than using Hoiur() Minute() Second()
TimeSplit PROCEDURE(LONG Time2Split, *? OutHour, *? OutMinute, <*? OutSecond>, <*? OutHundred>)
TimeHMS PROCEDURE(SHORT Hours, SHORT Mins, SHORT Secs=0, SHORT Hundredths=0),LONG !Time Join H:M:S.D
TimeHMS2 PROCEDURE(BYTE Hours, BYTE Mins, BYTE Secs=0, BYTE Hundredths=0),LONG !Must have valid H,M,S
DateSplit PROCEDURE(LONG Date2Split, *? OutMonth, *? OutDay, *? OutYear)
!==========================================================================================================
TimeHMS PROCEDURE(SHORT H, SHORT M, SHORT S=0, SHORT Hundredths=0)!,LONG
!This allows out of range HMS values, e.g. you can pass 90 minutes
CODE
RETURN (H * 60*60*100) + |
(M * 60*100) + |