UBBFriend: Email This Page to Someone!
  Computer Workshop User Forums
  EZGUI Source code
  Fake colored border around controls

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Fake colored border around controls
Chris Boss
Administrator
posted 11-05-2008 09:25 PM     Click Here to See the Profile for Chris Boss     Edit/Delete Message Reply w/Quote
Here is a nice trick to create a colored border around any rectangular shaped control.

First, don't add a border to the control (don't use F, S or R properties).

Now, use the subroutine I wrote in the sample below (AddColorBorder) in the controls %EZ_Loaded event.

This routine will simply get the size of the control and then create a shape control (which will be next in the zorder, so underneath the control) with the right size and color.

This will create a fake border of any color and from 1 to 4 pixels in width.

Heres the code:

code:



#COMPILE EXE
#DIM ALL ' This is helpful to prevent errors in coding
' --------------------
#INCLUDE "C:\ezgui40pro\includes\ezgui40.inc" ' EZGUI Include file for Declares
' --------------------
DECLARE FUNCTION Main_Initialize(BYVAL VerNum&) AS LONG
DECLARE SUB EZ_FORM1_Display(BYVAL Parent$)
DECLARE SUB EZ_FORM1_Design()
DECLARE SUB EZ_FORM1_ParseEvents(CID&, CMsg&, CVal&, Cancel&)
DECLARE SUB FORM1_Events(CID&, CMsg&, CVal&, Cancel&)
' ------------------------------------------------
%FORM1_LISTBOX1 = 100
DECLARE SUB FORM1_LISTBOX1_Events(MyID&, CMsg&, CVal&, Cancel&)
' --------------------
#INCLUDE "C:\ezgui40pro\includes\ezwmain.inc" ' EZGUI Include file for WinMain
' --------------------
'
SUB EZ_Main(VerNum&) ' (PROTECTED)
IF Main_Initialize(VerNum&) THEN
EZ_FORM1_Display ""
END IF
END SUB
'
SUB EZ_DesignWindow(FormName$) ' (PROTECTED)
SELECT CASE FormName$
CASE "FORM1"
EZ_FORM1_Design
CASE ELSE
END SELECT
END SUB
'
SUB EZ_Events(FormName$, CID&, CMsg&, CVal&, Cancel&) ' (PROTECTED)
SELECT CASE FormName$
CASE "FORM1"
EZ_FORM1_ParseEvents CID&, CMsg&, CVal&, Cancel&
CASE ELSE
END SELECT
END SUB
'
FUNCTION Main_Initialize(BYVAL VerNum&) AS LONG
LOCAL RV&
RV&=1
FUNCTION=RV&
END FUNCTION
'
SUB EZ_FORM1_Display(BYVAL Parent$) ' (PROTECTED)
EZ_Color -1, -1
EZ_Form "FORM1", Parent$, "EZGUI's simple event style coding", 0, 0, 84, 29, "C"
END SUB
'
SUB EZ_FORM1_Design() ' (PROTECTED)
LOCAL CText$
EZ_Color-1,-1
EZ_UseFont 4
EZ_ListBox %FORM1_LISTBOX1, 26.5, 8.75, 24.5, 5.75, "Apple|Orange|Grape|Watermellon|Peach|Grapefruit|Cherry|Pineapple", "^TV"
END SUB
'
SUB EZ_FORM1_ParseEvents(CID&, CMsg&, CVal&, Cancel&) ' (PROTECTED)
SELECT CASE CID&
CASE %EZ_Window
FORM1_Events CID&, CMsg&, CVal&, Cancel&
CASE %FORM1_LISTBOX1
FORM1_LISTBOX1_Events CID&, CMsg&, CVal&, Cancel&
CASE ELSE
FORM1_Events CID&, CMsg&, CVal&, Cancel&
END SELECT
END SUB
'
SUB FORM1_Events(CID&, CMsg&, CVal&, Cancel&)
SELECT CASE CID&
CASE %EZ_Window
SELECT CASE CMsg&
CASE %EZ_Close
CASE ELSE
END SELECT
CASE ELSE
END SELECT
END SUB
'
'<<SAVE>>
SUB AddColorBorder(BYVAL FormName$, BYVAL ID&, BYVAL ColorNum&, BYVAL BWidth&)
LOCAL C!, R!, W!, H!, P$
EZ_SubClass 0 ' just to make sure
EZ_GetSizeC FormName$, ID&,C!, R!, W!, H!
P$="["
IF BWidth&<1 OR BWidth&>4 THEN BWidth&=1
SELECT CASE BWidth&
CASE 2
P$="[2"
CASE 3
P$="[3"
CASE 4
P$="[4"
CASE ELSE
END SELECT
C!=C!-EZ_CX(BWidth&)
R!=R!-EZ_CY(BWidth&)
W!=W!+EZ_CX(BWidth&*2)
H!=H!+EZ_CY(BWidth&*2)
EZ_Color ColorNum&,0
EZ_Shape ID&+1,C!, R!, W!, H!, "", P$
END SUB
'<<END>>
'
SUB FORM1_LISTBOX1_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Change
CASE %EZ_Loaded
AddColorBorder "Form1", MyID&, 4, 4
CASE ELSE
END SELECT
END SUB


All times are EST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | Computer Workshop ( EZGUI ) Home Page

Copyright 2000 to 2007 Christopher R. Boss

Powered by: Ultimate Bulletin Board, Version 5.44
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.