Skip to content

Instantly share code, notes, and snippets.

Avatar

Carl T. Barnes CarlTBarnes

View GitHub Profile
@CarlTBarnes
CarlTBarnes / 00_Index_GIST_.txt
Last active Sep 22, 2022
00 Index of my GIST because there does not seem to be options to list them by file name or description
View 00_Index_GIST_.txt
Backup_CW_Project.BAT https://gist.github.com/CarlTBarnes/bbb936e418226d55ff8651bb1bfbf7e4 Backup Clarion Project BAT files
CBAltWin7Fix.tpl https://gist.github.com/CarlTBarnes/5e0e7d5a3e3f0b5c991e8f0601e69004 Fix Alt key lockup problem with the latest version of Windows 10 that I wrote and published in ClarionMag
CascadeMdiChildren.clw https://gist.github.com/CarlTBarnes/ed29557b7142ec4695f7d460cabef3fd Cascade open MDI Child windows like Clarion RTL STD:CascadeWindow using Windows API
Clarion_Hub_Interesting.txt https://gist.github.com/CarlTBarnes/aabb812d5a34fcfe69d2421702799aef Clarion Hub links of interest
CloseWindowHook.clw https://gist.github.com/CarlTBarnes/f86f6b695276b2b3327f5959e5c57682 Prop:CloseWindowHook Example Clarion
DateSplit.clw
@CarlTBarnes
CarlTBarnes / GroupMoveChildren.clw
Last active Sep 22, 2022
GROUP Move and also All Child Controls X,Y Position
View GroupMoveChildren.clw
!When a GROUP X/Y Position is changed it does NOT move the Child Controls
!This loops through the child controls and moves each one
!
!The XAdjust / YAdjust parameters allow some extra move from the TO Control X/Y
!------------------------------------------------------------------------------------
MAP
GroupMoveChildren(LONG FromGroup, LONG ToControl, LONG XAdjust=0, LONG YAdjust=0)
END
@CarlTBarnes
CarlTBarnes / Scratch.clw
Last active Sep 14, 2022
Scratch source I use when I want to write a quick test of some code
View Scratch.clw
PROGRAM !Scratch program by Carl Barnes - Version 8/1/2020 - Download https://git.io/JtPKE
INCLUDE('TplEqu.CLW')
INCLUDE('KeyCodes.CLW')
MAP
main PROCEDURE()
DB PROCEDURE(STRING DebugMessage)
DBClear PROCEDURE() !Clear DebugView Buffer
Hex8 PROCEDURE(LONG LongInt),STRING
@CarlTBarnes
CarlTBarnes / Get_SetWindowLong.CLW
Created Sep 7, 2022
GetWindowLong() then SetWindowLong() applying an OFF and ON Bitmask
View Get_SetWindowLong.CLW
MAP
GetSetWindowLongFEQ_GWL_Style Procedure(LONG ControlFEQ, LONG BitsOFF, LONG BitsON) ,LONG,PROC
GetSetWindowLongFEQ Procedure(LONG ControlFEQ, LONG WLnIndex, LONG BitsOFF, LONG BitsON) ,LONG,PROC
GetSetWindowLongHnd Procedure(LONG WndHandle, LONG WLnIndex, LONG BitsOFF, LONG BitsON) ,LONG,PROC
module('win32')
GetWindowLong(SIGNED hWnd, SIGNED nIndex ),PASCAL,RAW,LONG,PROC,NAME('GetWindowLongA'),DLL(1)
SetWindowLong(SIGNED hWnd, SIGNED nIndex, LONG dwNewLong ),PASCAL,RAW,LONG,PROC,NAME('SetWindowLongA'),DLL(1)
end
END
@CarlTBarnes
CarlTBarnes / RemoveMinButton.clw
Last active Jul 17, 2022
Remove Minimize button so window can have ICON() but user cannot minimize. Also CloseButtonDisable()
View RemoveMinButton.clw
! This way your Window can have a pretty Icon() but not a Minimize button that causes end users to lose the form
MAP
RemoveMinButton() !Remove Minimize button on the Current Window so can have Icon() but no Minimize
MinButtonHide(BOOL HideMinimize=True),BOOL,PROC !Hide Minimize button (False Unhide) on the Current Window. Returns True if state changed.
MODULE('Win32')
GetWindowLong(LONG HndWindow, LONG nIndex),LONG,PASCAL,DLL(1),NAME('GetWindowLongA')
SetWindowLong(LONG HndWindow, LONG nIndex, LONG dwNewLong),LONG,PROC,PASCAL,DLL(1),NAME('SetWindowLongA')
END
@CarlTBarnes
CarlTBarnes / Hex8_FromLong.clw
Last active Jul 13, 2022
Hex conversion from LONG
View Hex8_FromLong.clw
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 / RemoveFileWithAPI.clw
Last active May 17, 2022
REMOVE() in RTL has bugs and is very slow using ShFileOperation(). My replacement uses API DeleteFile() and sets Clarion ErrorCode() so can replace REMOVE().
View RemoveFileWithAPI.clw
!There are a few Remove() things here, what you want is FileApiRemove FUNCTION(STRING Fn2Delete),LONG,PROC
!
!In C8 Clarion REMOVE() was enhanced a second parameter with flags to allow wildcards, recursion, etc
!It was changed from calling API DeleteFile() to use the much more complicated ShFileOperation()
!This makes it much slower and more bug prone
!
!My replacement FileApiRemove() uses API DeleteFile() then sets the Claion Error so it can replace
!an existing REMOVE() in Clarion code. If you are using Remove(FILE) you'll need REMOVE(Name(File))
!or you can create a FileApi2Remove(FILE FileRef) that calls FileApiRemove(FileRef{PROP:Name}) or NAME()
!I named it "FileApiRemove(" so if you are searching "REMOVE(" you'll file it, versus RemoveUsingAPI() would not.
@CarlTBarnes
CarlTBarnes / CBDropListLEFT.clw
Last active Feb 8, 2022
DROP List is Left Aligned by Class for Combo/List Control. Normally RTL aligns Right. CBDropLeftClass
View CBDropListLEFT.clw
MEMBER()
!--------------------------
! CBDropLeftClass - by Carl Barnes - Release under the MIT License
!--------------------------
INCLUDE('EQUATES.CLW')
INCLUDE('CBDropListLEFT.INC'),ONCE
CBRect GROUP,TYPE
Left SIGNED
Top SIGNED
@CarlTBarnes
CarlTBarnes / PathExists.clw
Last active Jan 3, 2022
Path Exists or File Exists functions versus Clarion Exists()
View PathExists.clw
!Clarion Exists() returns True whethere File or Directory. These functions will check explicitly for File or Path.
MAP
FileExists(STRING FileName,<*LONG OutAttributes>),BOOL !Return 1 if FileName exists and is File not Directory
PathExists(STRING PathName,<*LONG OutAttributes>),BOOL !Return 1 if PathName exists and is Directory not File
ExistsFileOrPath(STRING FileOrPathName,<*LONG OutAttributes>),BYTE !Return 1=File 2=Path 0=N/A
MODULE('Win32')
GetFileAttributes(*CSTRING FileName),LONG,PASCAL,RAW,DLL(1),NAME('GetFileAttributesA')
END
View ReplaceString.clw
!Search and Replace inside a STRING
MAP
ReplaceInto PROCEDURE(*STRING Into, STRING FindTxt,STRING ReplaceTxt,BYTE ClipInto=0),LONG,PROC !Returns Count
ReplaceText PROCEDURE(STRING InText,STRING FindTxt,STRING ReplaceTxt,BYTE ClipInto=0),STRING !Returns Strng with FindTxt Replaced
END
!------------------------------------------------------------------------------------------------------
ReplaceInto PROCEDURE(*STRING Into, STRING Find,STRING Repl,BYTE ClipInto=0)!,LONG,PROC !Returns Count
X LONG,AUTO
L LONG,AUTO