Skip to content

Instantly share code, notes, and snippets.

Avatar

Carl T. Barnes CarlTBarnes

View GitHub Profile
@CarlTBarnes
CarlTBarnes / ReportManualPaging.clw
Last active Apr 30, 2021
Report Manual Paging Class and Template
View ReportManualPaging.clw
!This CLASS was written to **replace page checking code** in reports that was in many places
!For most all people the **replace** comment will NOT apply.
!
!This is not an easy an easy thing to do. I cannot explain it all here.
!
! Steps to Implement ManRpt Class
!
!1. Add the Extension Template ReportLineHeightMaxSet Template so all lines have
! a. Sets all DETAIL PROP:MaxHeight=Height so line Height is exactly correct
! b. For all DETAILs defines LnHt_Label LONG variable and sets = DETAIL PROP:Height for use with Height calcs
@CarlTBarnes
CarlTBarnes / Option2DropList.clw
Last active Apr 30, 2021
Replace OPTION with LIST,DROP - find all OPTION controls on a Window and generate a LIST,DROP() with FROM('Text#Value') as the RADIO('Text'),Value('valuie') plus PROMPT
View Option2DropList.clw
! Version 2 - DROP and No DROP in one procedure. FORMAT() and ~Header option
! Generate LIST,DROP,FROM() reading OPTION and RADIOs -- or LIST without DROP
! Option + Radio's take mnore space that a LIST,DROP,FROM('radio|radio|radio')
! The Option can be easier for the User and more obvious of all the choices without dropping
! Some times you don't have the space, or too many Options can be visual clutter
!
PROGRAM
MAP
Option2DropList PROCEDURE() !Add this to your program and a button on the Window to call it,
MODULE('RTL') !Global MAP Requires this
@CarlTBarnes
CarlTBarnes / DropListPretty.clw
Last active Apr 28, 2021
Find all LIST with DROP and make easier to see. Color light yellow like Tool Tip, add margin, grid lines lighter
View DropListPretty.clw
!See https://clarionhub.com/t/how-to-make-drop-list-more-visible-on-the-window/3760?u=carlbarnes
!Make Drop lists more visible coloring like Tool Tip, easier to see with Format and +1 Line Spacing
!-------------------------
DropListPretty PROCEDURE
Fld LONG,AUTO
LstFEQ LONG,AUTO !Drop List is separate control Fld{PROP:Drop}
CODE
Fld=0
LOOP
Fld=0{PROP:NextField,Fld}
@CarlTBarnes
CarlTBarnes / MenuOpenMessage.clw
Last active Apr 13, 2021
Menu Open Message WM_INITMENU to modify menus before opening
View MenuOpenMessage.clw
!Often right when Menus are being opened you want to change the Menus
!based on the other variables and things.
!Simple example of SubClass Window to get a WM_INITMENU Message before Menus display
!This adds Time to an Item text to show it changing at time it opens
!It also adds Time when closed, you get a Message when window close also WM_EXITMENULOOP
PROGRAM
INCLUDE 'TplEqu.CLW'
INCLUDE 'KeyCodes.CLW'
MAP
View Manifest_Windows10.Manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="x86"
name="CompanyName.ProductName.ApplicationName"
type="win32"
/>
<description>Application with Visual Styles for Windows 10</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
@CarlTBarnes
CarlTBarnes / Bak_and_Zip_Sample1.bat
Last active Jan 20, 2021
Backup Clarion Project BAT files
View Bak_and_Zip_Sample1.bat
@REM This will backup the File Extensions listed below for ROBOCOPY to a subfolder
@REM then zip using PowerShell to a file named: ProjName_Date_Time.ZIP
@REM I place this BAT file in the Project folder named: _Bak_and_Zip_ProjBane.bat
@REM This backs up to a sub folder named _Bak_ under the project, some times I place this folder elsewhere
@REM This saves the CLW that allows for doing a code compare
@REM -----------------------------------------------------------------
@echo off
for /f %%I in ('wmic os get localdatetime ^|find "20"') do set dt=%%I
REM dt format is now YYYYMMDDhhmmss...
@CarlTBarnes
CarlTBarnes / ChooseColorAPI.clw
Last active Jan 20, 2021
ChooseColor API function instead of Clarion ColorDialog()
View ChooseColorAPI.clw
!Clarion's ColorDialog() does not have the deatures of the API ChooseColor like saving the 16 custom colors
!From https://www.icetips.com/showarticle.php?articleid=272
!A few changes to Larry's code by Carl:
! Set cc.rgbResult = W{PROP:Color} before call. Should CC_RGBINIT be conditional?
! Check for ChooseColor returning True with IF ccBool THEN .
! Comment UnlockThread.
! Prototype a (LONG cc) so no need for type at Map level. Add DLL(1)
!-----------------------------------------
!Windows API: Saving and restoring custom colors for ColorDialog
@CarlTBarnes
CarlTBarnes / RemoveDirectoryOfFiles.clw
Last active Jan 14, 2021
Remove Directory of Files using Directory() and API DeleteFile
View RemoveDirectoryOfFiles.clw
RemoveDirectoryFiles(STRING FolderPath,STRING Specs2Purge,LONG ShowWindow=0,<*LONG OutCountRemoved>),LONG,PROC ! Returns Error Cnt
DB(STRING DBString) !OutputDebugString wrapper DebugOutput.clw https://gist.github.com/CarlTBarnes/d3c7a3779b094f0ed48186d04a9b45e6
MODULE('Win32')
DeleteFileA(*cstring lpFileName),BOOL,RAW,PROC,PASCAL,DLL(1)
GetLastError(),LONG,PASCAL,DLL(1)
END
!Specs2Purge can be multiple using semicolon e.g. *.tmp;*.$$$;*.xxx
@CarlTBarnes
CarlTBarnes / ExistsDirectory_or_ExistsFile.clw
Last active Oct 15, 2020
ExistsDirectory() or ExistsFile() using GetFileAttributes() instead of Clarion Exists()
View ExistsDirectory_or_ExistsFile.clw
! Clarion EXISTS() returns True for File or Directory.
! Sometimes you need to know you have a Directory, or a File
!-----------------------------------------------------------------------------------------------------
MAP
ExistsDirectory PROCEDURE(STRING pDirName),BOOL !True if Directory and Not file
ExistsFile PROCEDURE(STRING pFileName),BOOL !True if File and Not Directory
MODULE('win32.lib')
GetFileAttributes(*CSTRING FileName),LONG,PASCAL,DLL(1),RAW,NAME('GetFileAttributesA') !Returns Attribs
END
@CarlTBarnes
CarlTBarnes / FileAttributes.clw
Last active Oct 15, 2020
File Attributes Strip Read Only - GetFileAttributes / SetFileAttributes
View FileAttributes.clw
MAP
FileStripReadOnly PROCEDURE(string _filename),BOOL !True if Worked
MODULE('win32.lib')
SetFileAttributes(*CSTRING FileName,LONG NewFileAttribs),BOOL,PROC,PASCAL,DLL(1),RAW,NAME('SetFileAttributesA')
GetFileAttributes(*CSTRING FileName),LONG,PASCAL,DLL(1),RAW,NAME('GetFileAttributesA') !Returns Attribs
END
!--------------------------------------------------------
FileStripReadOnly PROCEDURE(string _filename) !,BOOL
Attrs LONG,AUTO