Last active
February 8, 2022 16:48
-
-
Save CarlTBarnes/6b2812bf95e9b8de1cc84f934efcd969 to your computer and use it in GitHub Desktop.
DROP List is Left Aligned by Class for Combo/List Control. Normally RTL aligns Right. CBDropLeftClass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MEMBER() | |
!-------------------------- | |
! CBDropLeftClass - by Carl Barnes - Release under the MIT License | |
!-------------------------- | |
INCLUDE('EQUATES.CLW') | |
INCLUDE('CBDropListLEFT.INC'),ONCE | |
CBRect GROUP,TYPE | |
Left SIGNED | |
Top SIGNED | |
Right SIGNED | |
Bottom SIGNED | |
END | |
MAP | |
MODULE('Win32') | |
CBGetWindowRect(SIGNED hWnd, *CBRect lpRect),BOOL,RAW,PASCAL,DLL(1),PROC,NAME('GetWindowRect') | |
END | |
END | |
!----------------------------------- | |
CBDropLeftClass.Init PROCEDURE(LONG FEQ) | |
CODE | |
IF FEQ AND FEQ{PROP:ListFEQ} THEN | |
RegisterEvent(Event:DroppingDown, Address(SELF.TakeDroppingDown), Address(SELF),,FEQ) | |
END | |
RETURN | |
!----------------------------------- | |
CBDropLeftClass.InitAllDropList PROCEDURE() | |
Fld LONG | |
CODE | |
LOOP | |
Fld=0{PROP:NextField,Fld} ; IF ~Fld THEN BREAK. | |
CASE Fld{PROP:Type} | |
OF CREATE:List OROF CREATE:Combo | |
! ??? This should check that this is a Drop list that has a Width ? 02/08/2022 | |
! ??? IF Fld{PROP:Drop}=0 OR Fld{PROP:DropWidth}=0 THEN CYCLE. 02/08/2022 Does this work for Combo? | |
SELF.Init(Fld) | |
END | |
END | |
RETURN | |
!----------------------------------- | |
CBDropLeftClass.TakeDroppingDown PROCEDURE()!,BYTE | |
Pix STRING(1),AUTO | |
ListFEQ LONG,AUTO | |
DropFEQ LONG,AUTO | |
RCList GROUP(CBRect),AUTO | |
END | |
RCDrop GROUP(CBRect),AUTO | |
END | |
CODE | |
ListFEQ = FIELD() | |
DropFEQ = ListFEQ{PROP:ListFEQ} | |
IF DropFEQ THEN | |
IF CBGetWindowRect(ListFEQ{PROP:Handle},RCList) THEN | |
IF CBGetWindowRect(DropFEQ{PROP:Handle},RCDrop) THEN | |
Pix = 0{PROP:Pixels} | |
0{PROP:Pixels} = TRUE | |
!Keep Drop List at original Y Pos incase near bottom and drop positioned above List by Windows | |
SETPOSITION(DropFEQ, RCList.left, RCDrop.top) | |
0{PROP:Pixels} = Pix | |
END | |
END | |
END | |
RETURN(0) !0=Level:Benign Calls other handlers and the ACCEPT loop, if available. | |
!----------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OMIT('_EndOfInclude_',_IFDef_CBListDropLeft_) | |
_IFDef_CBListDropLeft_ EQUATE(1) | |
!------------------------------------------------------------------------------ | |
! CBDropLeftClass by Carl Barnes. Based on code posted in DiscussSV by Jeff Slarve | |
! | |
! When have DROP(10,Width) it aligns with Right side. This aligns it Left side | |
!------------------------------------------------------------------------------ | |
!How to Use: Just declare class, and .Init(?List) or .InitAllDropList(). | |
! | |
! INCLUDE('CBListDropLEFT.INC'),ONCE | |
!DropLEFTcls CBDropLeftClass !Class to Align DROP List with Left side | |
! DropLEFTcls.Init(?List) !Apply to specific control | |
! DropLEFTcls.InitAllDropList() !Find all LIST and COMBO with DROP | |
!------------------------------------------------------------------------ | |
CBDropLeftClass CLASS,TYPE,MODULE('CBDropListLEFT.CLW'),LINK('CBDropListLEFT.CLW') | |
Init PROCEDURE(LONG ListOrComboFEQ) !Registers Event:DroppingDown to call .TakeDroppingDown() | |
InitAllDropList PROCEDURE() !Find ALL LIST and COMBO and call .Init() | |
TakeDroppingDown PROCEDURE(),BYTE,PROTECTED !On Event:DroppingDown Position the LIST to align Left | |
END | |
_EndOfInclude_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!Example by Carl Barnes - | |
!List/Combo DROP align on right side, this shows simple class that align LEFT side | |
PROGRAM !See #1 #2 #3 lines of code needed to make this work | |
INCLUDE('CBDropListLEFT.INC'),ONCE !<--- #1. INCLUDE Class that makes this work | |
MAP | |
MODULE('RTL') | |
ClaFieldNameRTL PROCEDURE(LONG pFEQ),CSTRING,RAW,NAME('Cla$FIELDNAME'),DLL(dll_mode) | |
END | |
END | |
Window WINDOW('Drop Align LEFT - CBDropLeftClass'),AT(,,234,154),CENTER,GRAY,SYSTEM,FONT('Segoe UI',9) | |
STRING('COMBO Drop() - No Width'),AT(5,19) | |
STRING('Width 100'),AT(100,19) | |
STRING('Width 200'),AT(171,19) | |
COMBO(@s24),AT(20,31,60,14),USE(?C1),DROP(7),VSCROLL | |
COMBO(@s24),AT(86,31,60,14),USE(?C2),DROP(7,100),VSCROLL | |
COMBO(@s24),AT(159,31,60,14),USE(?C3),DROP(7,200),VSCROLL | |
STRING('LIST Drop()'),AT(5,102) | |
LIST,AT(20,117,60,14),USE(?L1),DROP(7),VSCROLL | |
LIST,AT(86,117,60,14),USE(?L2),DROP(7,100),VSCROLL | |
LIST,AT(159,117,60,14),USE(?L3),DROP(7,200),VSCROLL | |
CHECK('DropLeft .Init(?) Combos '),AT(19,3),USE(?LeftFix_Init),TIP('Init() 3 COMBOs for LEFT Align') | |
CHECK('DropLeft ALL .InitAllDropList()'),AT(122,3),USE(?LeftFix_ALL) | |
STRING('Move Window Near Monitor Edges and See Drop is visible'),AT(29,139) | |
END | |
DropLEFTcls CBDropLeftClass !<--- #2. Declare Class that makes this work | |
Fld LONG | |
FeqName CSTRING(255) | |
CODE | |
SYSTEM{PROP:PropVScroll}=1 | |
OPEN(WINDOW) | |
LOOP Fld=FIRSTFIELD() TO LASTFIELD() | |
Fld{PROP:From}='Alberta|British Columbia|Manitoba|New Brunswick|Newfoundland and Labrador|Northwest Territories|Nova Scotia|Nunavut|Ontario|Prince Edward Island|Quebec|Saskatchewan|Yukon' | |
FeqName = ClaFieldNameRTL(Fld) | |
Fld{PROP:Tip}='FEQ Name: ' & FeqName & | | |
'<13,10>Drop Width: ' & Fld{PROP:DropWidth} &| | |
'<13,10>Drop FEQ: ' & Fld{PROP:ListFEQ} | |
END | |
ACCEPT | |
CASE ACCEPTED() | |
OF ?LeftFix_ALL | |
DISABLE(?) ; DISABLE(?LeftFix_Init) | |
DropLEFTcls.InitAllDropList() !<--- #3a. This Finds all DROP and calls .Init() ..... | |
OF ?LeftFix_Init | |
DISABLE(?) | |
DropLEFTcls.init(?c1) !<--- #3b. ... Or specify each Control with DROP to handle | |
DropLEFTcls.init(?c2) | |
DropLEFTcls.init(?c3) | |
END | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment