Skip to content

Instantly share code, notes, and snippets.

View CarlTBarnes's full-sized avatar

Carl T. Barnes CarlTBarnes

View GitHub Profile
@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 / 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 / DayOfWeek.clw
Created July 4, 2020 21:34
Day of Week from Clarion Date
DowName PROCEDURE(LONG pDate)!,STRING
CODE
RETURN CHOOSE( pDate % 7 + 1,'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','???')
@CarlTBarnes
CarlTBarnes / MonthName.clw
Last active July 5, 2020 20:19
Month name from Date or Month number
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
@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 / CBAltWin7Fix.tpl
Created July 5, 2020 22:10
A fix for the Alt key lockup problem with the latest version of Windows 10 that I wrote and published in ClarionMag
#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
@CarlTBarnes
CarlTBarnes / ParseTokenStringIntoQueue.clw
Created July 5, 2020 22:39
Parse String with Delimited with Tokens into a Queue
MAP
ParseTokenStringIntoQueue(CONST *STRING pString,STRING pToken,*QUEUE OutQueue,BYTE pBlanksOk=0),LONG,PROC !Return Count
END
ParseTokenStringIntoQueue PROCEDURE(CONST *STRING pString,STRING pToken,*QUEUE OutQueue,BYTE pBlanksOk=0)!,LONG,PROC !Return Count
SLen LONG,AUTO !pString Length
Ndx LONG,AUTO
TokenVal BYTE,AUTO !When hunting for chars I like VAL compares
BegPos LONG(1) !BegPos = 1 required to work right
EndPos LONG,AUTO !EndPos = 0 required to work right