For Programmers: Free Programming Magazines  


Home > Archive > PowerBuilder > March 2004 > changing datawindow font at runtime









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author changing datawindow font at runtime
madcap

2004-03-27, 12:22 am

Hi,

I am creating a datawindow at runtime as follows. Can I change the
font of the datawindow and set to whatever the user wants? Can I also
change the width of each column?

Thanks in advance!

// code to create a datawindow at runtime
string ERRORS, sql_syntax
string presentation_str, dwsyntax_str

sql_syntax = mle_sql.text
presentation_str = "style(type=grid)"
dwsyntax_str = SQLCA.SyntaxFromSQL(sql_syntax, presentation_str,
ERRORS)
IF Len(ERRORS) > 0 THEN
MessageBox("Caution", "SyntaxFromSQL caused these errors: " +
ERRORS)
RETURN
END IF

dw_output.Create(dwsyntax_str, ERRORS)

IF Len(ERRORS) > 0 THEN
MessageBox("Caution", "Create cause these errors: " + ERRORS)
RETURN
ELSE
dw_output.Object.DataWindow.ReadOnly="Yes"
dw_output.settransobject(sqlca)
dw_output.retrieve()
sle_qryrows.Text = string(dw_output.RowCount())
END IF
Bruce Armstrong [TeamSybase]

2004-03-27, 12:22 am

Sure. Just use the Modify function once the datawindow is created.

madcap wrote:
>
> Hi,
>
> I am creating a datawindow at runtime as follows. Can I change the
> font of the datawindow and set to whatever the user wants? Can I also
> change the width of each column?
>
> Thanks in advance!
>
> // code to create a datawindow at runtime
> string ERRORS, sql_syntax
> string presentation_str, dwsyntax_str
>
> sql_syntax = mle_sql.text
> presentation_str = "style(type=grid)"
> dwsyntax_str = SQLCA.SyntaxFromSQL(sql_syntax, presentation_str,
> ERRORS)
> IF Len(ERRORS) > 0 THEN
> MessageBox("Caution", "SyntaxFromSQL caused these errors: " +
> ERRORS)
> RETURN
> END IF
>
> dw_output.Create(dwsyntax_str, ERRORS)
>
> IF Len(ERRORS) > 0 THEN
> MessageBox("Caution", "Create cause these errors: " + ERRORS)
> RETURN
> ELSE
> dw_output.Object.DataWindow.ReadOnly="Yes"
> dw_output.settransobject(sqlca)
> dw_output.retrieve()
> sle_qryrows.Text = string(dw_output.RowCount())
> END IF


--
Bruce Armstrong [TeamSybase]
http://www.teamsybase.com

Who uses PowerBuilder in 2003?
http://www.visual-expert.com/us/info/survey_pb_2003.htm

Two new books on developing with PowerBuilder
http://www.pb9books.com?source=newsgroups

Got code samples? Check out CodeXchange:
http://www.codexchange.sybase.com

ISUG Enhancement Requests
http://www.isug.com/cgi-bin/ISUG2/submit_enhancement

Preach the gospel at all times. If necessary, use words. - Francis of
Assisi
http://www.needhim.org
madcap

2004-03-27, 12:22 am

Can you give me an example? Thanks.

"Bruce Armstrong [TeamSybase]" <NOCANSPAM_bruce.armstrong@teamsybase.com> wrote in message news:<40043A44.7A9CC6B6@teamsybase.com>...
> Sure. Just use the Modify function once the datawindow is created.
>
> madcap wrote:
>
> --

Jim Douglas

2004-03-27, 12:22 am

Take your datawindow and export it, view the exported code with notepad,
find where the font is defined. Now either use dot notation or dwmodify to
change the font, same goes for the columns width.

"madcap" <madcap@email.com> wrote in message
news:2d98adf1.0401111000.7ccf9130@posting.google.com...
> Hi,
>
> I am creating a datawindow at runtime as follows. Can I change the
> font of the datawindow and set to whatever the user wants? Can I also
> change the width of each column?
>
> Thanks in advance!
>
> // code to create a datawindow at runtime
> string ERRORS, sql_syntax
> string presentation_str, dwsyntax_str
>
> sql_syntax = mle_sql.text
> presentation_str = "style(type=grid)"
> dwsyntax_str = SQLCA.SyntaxFromSQL(sql_syntax, presentation_str,
> ERRORS)
> IF Len(ERRORS) > 0 THEN
> MessageBox("Caution", "SyntaxFromSQL caused these errors: " +
> ERRORS)
> RETURN
> END IF
>
> dw_output.Create(dwsyntax_str, ERRORS)
>
> IF Len(ERRORS) > 0 THEN
> MessageBox("Caution", "Create cause these errors: " + ERRORS)
> RETURN
> ELSE
> dw_output.Object.DataWindow.ReadOnly="Yes"
> dw_output.settransobject(sqlca)
> dw_output.retrieve()
> sle_qryrows.Text = string(dw_output.RowCount())
> END IF



Bruce Armstrong [TeamSybase]

2004-03-27, 12:22 am

Here's an example using dot notation:

dw_1.object.column_a.font.face = "Comic Sans MS"
dw_1.object.column_a.font.family = 2
dw_1.object.column_b.font.face = "Comic Sans MS"
dw_1.object.column_b.font.family = 2
dw_1.object.column_c.font.face = "Comic Sans MS"
dw_1.object.column_c.font.family = 2
dw_1.object.column_d.font.face = "Comic Sans MS"
dw_1.object.column_d.font.family = 2
dw_1.object.column_a_t.font.face = "Comic Sans MS"
dw_1.object.column_a_t.font.family = 2
dw_1.object.column_b_t.font.face = "Comic Sans MS"
dw_1.object.column_b_t.font.family = 2
dw_1.object.column_c_t.font.face = "Comic Sans MS"
dw_1.object.column_c_t.font.family = 2
dw_1.object.column_d_t.font.face = "Comic Sans MS"
dw_1.object.column_d_t.font.family = 2



madcap wrote:[color=darkred]
>
> Can you give me an example? Thanks.
>
> "Bruce Armstrong [TeamSybase]" <NOCANSPAM_bruce.armstrong@teamsybase.com> wrote in message news:<40043A44.7A9CC6B6@teamsybase.com>...

--
Bruce Armstrong [TeamSybase]
http://www.teamsybase.com

Who uses PowerBuilder in 2003?
http://www.visual-expert.com/us/info/survey_pb_2003.htm

Two new books on developing with PowerBuilder
http://www.pb9books.com?source=newsgroups

Got code samples? Check out CodeXchange:
http://www.codexchange.sybase.com

ISUG Enhancement Requests
http://www.isug.com/cgi-bin/ISUG2/submit_enhancement

Preach the gospel at all times. If necessary, use words. - Francis of
Assisi
http://www.needhim.org
Bruce Armstrong [TeamSybase]

2004-03-27, 12:22 am

Here's a bit more generic method:

string ls_objects, ls_object, ls_font, ls_modify
long ll_pos

ls_objects = dw_1.Object.DataWindow.Objects
ll_pos = Pos ( ls_objects, '~t' )
DO WHILE ll_pos > 0
ls_object = Left ( ls_objects, ll_pos - 1 )
ls_objects = Mid ( ls_objects, ll_pos + 1 )
ls_font = dw_1.Describe ( ls_object + '.font.face' )
CHOOSE CASE ls_font
CASE '?', '!'
//Do nothing
CASE ELSE
ls_modify = ls_object + ".font.face='Comic Sans MS' " + ls_object +
".font.family=4"
dw_1.Modify ( ls_modify )
END CHOOSE
ll_pos = Pos ( ls_objects, '~t' )
LOOP

ls_font = dw_1.Describe ( ls_objects + '.font.face' )
CHOOSE CASE ls_font
CASE '?', '!'
//Do nothing
CASE ELSE
ls_modify = ls_objects + ".font.face='Comic Sans MS' " + ls_objects +
".font.family=4"
dw_1.Modify ( ls_modify )
END CHOOSE


madcap wrote:[color=darkred]
>
> Can you give me an example? Thanks.
>
> "Bruce Armstrong [TeamSybase]" <NOCANSPAM_bruce.armstrong@teamsybase.com> wrote in message news:<40043A44.7A9CC6B6@teamsybase.com>...

--
Bruce Armstrong [TeamSybase]
http://www.teamsybase.com

Who uses PowerBuilder in 2003?
http://www.visual-expert.com/us/info/survey_pb_2003.htm

Two new books on developing with PowerBuilder
http://www.pb9books.com?source=newsgroups

Got code samples? Check out CodeXchange:
http://www.codexchange.sybase.com

ISUG Enhancement Requests
http://www.isug.com/cgi-bin/ISUG2/submit_enhancement

Preach the gospel at all times. If necessary, use words. - Francis of
Assisi
http://www.needhim.org
madcap

2004-03-27, 12:22 am

Bruce,

Thanks a lot for your help! This is what I was exactly looking for.

I had to do a minor change in your code. Right now, your code will
not modify the last column. So had to add the below code before the
LOOP statement

if ll_pos = 0 and len(ls_objects) > 0 then // this is the last column
ll_pos = len(ls_objects) + 1
end if

Thanks again Bruce!


"Bruce Armstrong [TeamSybase]" <NOCANSPAM_bruce.armstrong@teamsybase.com> wrote in message news:<4005CE1D.6CB971B9@teamsybase.com>...
> Here's a bit more generic method:
>
> string ls_objects, ls_object, ls_font, ls_modify
> long ll_pos
>
> ls_objects = dw_1.Object.DataWindow.Objects
> ll_pos = Pos ( ls_objects, '~t' )
> DO WHILE ll_pos > 0
> ls_object = Left ( ls_objects, ll_pos - 1 )
> ls_objects = Mid ( ls_objects, ll_pos + 1 )
> ls_font = dw_1.Describe ( ls_object + '.font.face' )
> CHOOSE CASE ls_font
> CASE '?', '!'
> //Do nothing
> CASE ELSE
> ls_modify = ls_object + ".font.face='Comic Sans MS' " + ls_object +
> ".font.family=4"
> dw_1.Modify ( ls_modify )
> END CHOOSE
> ll_pos = Pos ( ls_objects, '~t' )
> LOOP
>
> ls_font = dw_1.Describe ( ls_objects + '.font.face' )
> CHOOSE CASE ls_font
> CASE '?', '!'
> //Do nothing
> CASE ELSE
> ls_modify = ls_objects + ".font.face='Comic Sans MS' " + ls_objects +
> ".font.family=4"
> dw_1.Modify ( ls_modify )
> END CHOOSE
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com