Skip to content

Instantly share code, notes, and snippets.

View CarlTBarnes's full-sized avatar

Carl T. Barnes CarlTBarnes

View GitHub Profile
@CarlTBarnes
CarlTBarnes / Get_SetWindowLong.CLW
Last active April 14, 2024 21:42
GetWindowLong() then SetWindowLong() applying an OFF and ON Bitmask
MAP
GetSetWindowLongFEQ_GWL_Style Procedure(LONG ControlFEQ, LONG BitsOFF, LONG BitsON) ,LONG,PROC
GetSetWindowLongFEQ_GWL_ExStyle 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
@CarlTBarnes
CarlTBarnes / RemoveFileWithAPI.clw
Last active March 21, 2024 17:43
REMOVE() in RTL has bugs and is very slow using ShFileOperation(). My replacement uses API DeleteFile() and sets Clarion ErrorCode() so can replace REMOVE().
!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 / 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 / 00_Index_GIST_.txt
Last active September 22, 2022 14:47
00 Index of my GIST because there does not seem to be options to list them by file name or description
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 September 22, 2022 14:45
GROUP Move and also All Child Controls X,Y Position
!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 September 14, 2022 23:04
Scratch source I use when I want to write a quick test of some code
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 / RemoveMinButton.clw
Last active July 17, 2022 23:42
Remove Minimize button so window can have ICON() but user cannot minimize. Also CloseButtonDisable()
! 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 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 / CBDropListLEFT.clw
Last active February 8, 2022 16:48
DROP List is Left Aligned by Class for Combo/List Control. Normally RTL aligns Right. CBDropLeftClass
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 January 3, 2022 15:51
Path Exists or File Exists functions versus Clarion Exists()
!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