Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Flexgrid GDI memory eak in '98?
Message
From
01/05/2001 15:12:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00502144
Message ID:
00502178
Views:
21
>This one has been kicking me for some time. It appears that there is a GDI memory leak with the flexgrid object with FoxPro and Windows '98. I would like to point thee to the following code snippit (greatly simplified for this example):
>
>
>with ThisForm.OleControl1
>  .rows = 1000
>  .cols = 10
>
>  local lnRows, lnCols, lnRow, lnCol
>  lnRows = .Rows - 1
>  lnCols = .Cols - 1
>	
>  for lnRow = 1 to lnRows
>    for lnCol = 1 to lnCols
>      .row = lnRow
>      .col = lnCol
>      .cellfontitalic = .F.
>      .Text = ltrim(str(lnRow)) + ", " + ltrim(str(lnCol))
>    next
>  next
>endwith
>
>
>In my case I made a small project with a single modal form and pasted this code into the init method. Then I compiled the EXE and tested it on some Windows '98 machines. As I scroll down the grid the cell text starts to go bold, and when I attempt to close the project I get the error "Not enough memory to complete this operation.". By using a performance monitor I was able to determine that the available GDI memory goes to zero just before the fonts start mucking up.
>
>The line marked in red is the bad monkey that seems to cause all the problems. Removing it stops the GDI leak and prevents any other strange mishaps.
>
>It's slowly becoming harder and harder to work around (and test) this problem. I am unable to duplicate it at all on a Windows 2k machine, and I don't have a Win '95 machine to test on.
>
>Has anybody else experienced this? And if so, did you find a solution to it (besides removing the formatted line of course ;)
>
>
>Thanks muchly for your time!
>- Kevin Yockey

Kevin,
You simplified it for here and hope could this be applied in real situation :
  lnRows = .Rows - 1
  lnCols = .Cols - 1
  .row = 1
  .col = 1
  .RowSel = lnRows
  .ColSel = lnCols 
  .cellfontitalic = .t.	
  for lnRow = 1 to lnRows
    for lnCol = 1 to lnCols
      .row = lnRow
      .col = lnCol
      .Text = ltrim(str(lnRow)) + ", " + ltrim(str(lnCol))
Setting individual cells in flexgrid is a pain. Instead try binding to an ADO recordset or set text values directly in textmatrix array. Merging rows-cols as appropriate should also help.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform