Expert Software Company : News

joi, 13 mai 2010

Pentru probleme de afisare in Vista si Win 7

DEFINE CLASS VistaForm AS Form

PROCEDURE Init
DO CASE
CASE NOT OS(1) == "Windows 6.00"
* No Vista, no problem.
CASE EMPTY(SYS( 1271, m.Thisform ))
* No SCX form, no problem.
CASE m.Thisform.ShowWindow == 0 && In Screen.
ACTIVATE WINDOW (m.Thisform.Name) IN SCREEN NOSHOW
CASE m.Thisform.ShowWindow == 1 && In Top-Level Form.
LOCAL lcWindowName
lcWindowName = m.Thisform.GetTopLevelFormName()
ACTIVATE WINDOW (m.Thisform.Name) IN WINDOW (m.lcWindowName) NOSHOW
OTHERWISE && As Top-Level Form.
* Top-level forms are not affected.
ENDCASE
ENDPROC

PROCEDURE GetTopLevelFormName
* Get the top level form this form is
* running in (might be the Vfp Screen).
DECLARE INTEGER GetParent IN Win32Api INTEGER ThisHWnd
LOCAL lnParentHWnd, i, lcParentName
lnParentHWnd = GetParent(GetParent( m.Thisform.HWnd ))
IF INLIST( m.lnParentHWnd, _Vfp.HWnd, _Screen.HWnd )
lcParentName = "Screen"
ELSE
FOR i = 1 TO _Screen.FormCount
IF _Screen.Forms[ i ].HWnd == m.lnParentHWnd
lcParentName = _Screen.Forms[ i ].Name
EXIT
ENDIF
ENDFOR
ENDIF
RETURN m.lcParentName
ENDPROC

ENDDEFINE

*=======================================================
DEFINE CLASS VistaCombo AS Combobox

nOriginalColumnCount = -1

PROCEDURE Init
m.This.VistaBugWorkaround()
ENDPROC

PROCEDURE VistaBugWorkaround
* Only on Vista.
IF NOT OS(1) == "Windows 6.00"
RETURN
ENDIF
WITH This
* Remember original ColumCount.
IF .nOriginalColumnCount == -1 ;
AND .ColumnCount < 2
.nOriginalColumnCount = .ColumnCount
ENDIF
* Make sure ColumnCount >= 2.
DO CASE
CASE .RowSourceType == 1 && Value.
IF .ColumnCount < 2
.ColumnCount = 2
.ColumnLines = .F.
* Trigger RowSource_Assign().
.RowSource = .RowSource
ENDIF
CASE .RowSourceType == 5 && Array.
IF .ColumnCount < 2
.ColumnCount = 2
.ColumnLines = .F.
IF .ColumnWidths == ""
.ColumnWidths = LTRIM(STR( .Width ))
ENDIF
IF NOT "," $ .ColumnWidths
.ColumnWidths = .ColumnWidths + ",0"
ENDIF
ENDIF
CASE .RowSourceType == 6 && Fields.
IF .ColumnCount < 2
.ColumnCount = 2
.ColumnLines = .F.
ENDIF
ENDCASE
ENDWITH
ENDPROC

PROCEDURE RowSource_Assign
LPARAMETERS tcRowSource
WITH This
IF .RowSourceType == 1 ; && Value.
AND .ColumnCount == 2 ;
AND BETWEEN( .nOriginalColumnCount, 0, 1 )
.RowSource = STRTRAN( m.tcRowSource, ",", ",," ) + ","
ELSE
.RowSource = m.tcRowSource
ENDIF
ENDWITH
ENDPROC

ENDDEFINE
*=============================================================
In programul main al aplicatiei:

DECLARE integer GdiSetBatchLimit IN WIN32API integer
GdiSetBatchLimit(1)


In metoda INIT a formularului:

LOCAL lnBorderStyle

lnBorderStyle = this.BorderStyle

ACTIVATE WINDOW (THIS.NAME) IN SCREEN NOSHOW

this.BorderStyle = lnBorderStyle

Niciun comentariu:

Trimiteți un comentariu