Skip to content

Instantly share code, notes, and snippets.

Avatar

Carl T. Barnes CarlTBarnes

View GitHub Profile
@CarlTBarnes
CarlTBarnes / ManifestFixupFunction.clw
Last active Jun 8, 2020
Manifest Fixup Controls for Hand Code
View ManifestFixupFunction.clw
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 / CloseWindowHook.clw
Created Jun 9, 2020
Prop:CloseWindowHook Example Clarion
View CloseWindowHook.clw
!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 Jun 14, 2020
Find the File .EXT on the end of a File Name after last period
View FileExtensionFromName.clw
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 Jun 18, 2020
Debug Viewer Detection
View DebugViewDetect.clw
!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 Jun 24, 2020
Cascade open MDI Child windows like Clarion RTL STD:CascadeWindow
View CascadeMdiChildren.clw
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 / TimeSplitAndJoin.clw
Created Jul 4, 2020
TimeHMSh (Hour,Min,Sec) like DATE(). Also TimeSplit() Faster than using Hoiur() Minute() Second()
View TimeSplitAndJoin.clw
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) + |
@CarlTBarnes
CarlTBarnes / DayOfWeek.clw
Created Jul 4, 2020
Day of Week from Clarion Date
View DayOfWeek.clw
DowName PROCEDURE(LONG pDate)!,STRING
CODE
RETURN CHOOSE( pDate % 7 + 1,'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','???')
@CarlTBarnes
CarlTBarnes / MonthName.clw
Last active Jul 5, 2020
Month name from Date or Month number
View MonthName.clw
MonthName PROCEDURE(LONG DateOrMonth),STRING !Pass Clarion Date or Month Number 1 to 12 - Month name from @d04
MonthName2 PROCEDURE(LONG DateOrMonth),STRING !Pass Clarion Date or Month Number 1 to 12 - Month name English Only
MonthName PROCEDURE(LONG DateOrMonth)!,STRING
N STRING(32),AUTO
CODE
IF DateOrMonth <= 12 THEN
DateOrMonth=DATE(DateOrMonth,1,2000)
END
N=FORMAT(DateOrMonth,@d04) !Format Month ##, YYYY
View LoadLibraryExample.clw
!--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 / CBAltWin7Fix.tpl
Created Jul 5, 2020
A fix for the Alt key lockup problem with the latest version of Windows 10 that I wrote and published in ClarionMag
View CBAltWin7Fix.tpl
#TEMPLATE (CBAltFix, 'Carl Barnes fix for Alt Key Lockup in Windows 7'),FAMILY('ABC','CW20')
#!===========================================================================
#! Warning! Version 2 of the template changes things.
#! The Global template AltWin7Fix_Global has been removed and is no longer needed.
#! The Frame template AltWin7Fix_Frame has been renamed because it has new questions
#! Only the Frame Extension template is required, it is where you specify all choices.
#! It has a new name AltWin7Fix_Frame2 so you must populate it again on the Frame.
#! If you used the first version of the template you will get errors when you open
#! an APP. Ignore the errors, you should open the Frame, go to Extenstions and add the new template.
#! *** Removed ===>#EXTENSION (AltWin7Fix_Global,'Fix Windows 7 Alt Key Lockup-Global-by Carl Barnes'), APPLICATION