PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 10
 1 
 on: November 12, 2019, 01:10:23 PM 
Started by Paul Squires - Last post by Paul Squires
If I select a row with the mouse, it is highlighted blue, if programmatically, it is highlighted grey.

It shows blue because it has focus. If the control loses focus then you'll get the grey. In code you can do this to set the selected index and also the focus to the control.

Code: [Select]
   frmMain.ListView1.SelectedIndex = 0
   frmMain.ListView1.Focused = true

Quote
Is there a simple ratio between font size and row height in Pixels? If so what is it? Does the grid effect this?
Windows automatically adjusts ListView row heights based on the font defined for the control. I don't know what magically forumla that is used. To set our own row height would entail having to write the ListView as an OwnerDrawn control and that is outside my scope of development for this ListView control.

 2 
 on: November 12, 2019, 01:00:42 PM 
Started by Paul Squires - Last post by Paul Squires
I just these new Events:

- Added: ListView DoubleClick, RightClick events.
- Added: ListView Click event will now also fire if ENTER is pressed on a ListView line.

 3 
 on: November 11, 2019, 05:00:32 PM 
Started by raymw - Last post by Johan Klassen
hello raymw
if you are using the FreeBASIC compiler and the -gen gcc option and also use optimizations then your empty loops could be eliminated entirely it could also happen if your loop does some calculations that are simple enough for gcc to determine the end result or the calculations in the loop are never used outside the loop.
by default, gcc does not optimize to that extent, only if you use -O 2 or -O 3 more so with -O 3, please note that -O 2 is the same as -Wc -O2

 4 
 on: November 11, 2019, 04:10:57 PM 
Started by raymw - Last post by raymw
It depends. If you have a few million lines of data that you are parsing, as Paul has mentioned, using MID$ may not be the best option. If it takes, say three minutes to run, then you alter it and it takes  4 minutes, then to get to the actual time of a single line, say, then it becomes meaningless/tedious, unless you put said line in a loop or two. But then you still get variations, depending on the background tasks that windows does, etc. Also, over the years, I've found that the generally perceived facts, are often not true in every case. (For example, in the TRS 80 basic manual, it was stated that if you were using a number more than once or twice, it was faster to set a variable name to that number and use the variable name. They didn't say that for numbers less than 16, it was quicker to use the number directly. But back then, you would wait 20 minutes, listening to an audio cassette tape loading a program, trying to hear where it failed, and it normally did. Later, it was the same stillness required when burning cd's on a windows pc, you daren't breathe, or move the mouse, or your chair, and then 6 month's later, the cd, if Philips brand, was toast - they didn't protect the silver layer properly, it turned black). Just saying time is relative.

So, in the example code, I was showing if it was quicker to use a string equal to its own UCASE value, or whether to use another string. It does not always pay to modify the original data. For that specific string, would you think that running it as LCASE would be quicker, if so by how much? easy enough to plug in any code you want to test/compare  wrt speed

 5 
 on: November 11, 2019, 03:02:38 PM 
Started by jermy - Last post by jermy
that works, why didn't I think about that myself?

Tnx Josť

 6 
 on: November 11, 2019, 02:54:52 PM 
Started by jermy - Last post by Josť Roca
> I forgot to add something?.

Yes. Put

#define _WIN32_WINNT &h0602

before the includes.

 7 
 on: November 11, 2019, 02:34:17 PM 
Started by raymw - Last post by SeaVipe
Hi Ray, Timing for my purposes does not need to be overly accurate so I'm comfortable using GetTickCount() (DWORD)
Code: [Select]

#Include Once "windows.bi"
Dim As Long lStartTime = GetTickCount()
' some code...
? "Time to process - GetTickCount: " & GetTickCount - lStartTime

 8 
 on: November 11, 2019, 02:10:02 PM 
Started by jermy - Last post by jermy
Why i cant use QueryFullProcessImageName?

Main.bas
Code: [Select]
#Include Once "windows.bi"   
#Include Once "win/winbase.bi"
#Include Once "win/wincrypt.bi"
#Include Once "Form1.inc"
''
''  Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(Form1)

Form1.inc
Code: [Select]
''
''
Function Form1_Button1_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT

Dim Ret as WINBOOL
    Ret = FindClose(0)                                                   'winbase.bi
    Ret = IsDebuggerPresent                                          'winbase.bi 

   Ret = QueryFullProcessImageName(0, 0, 0, 0)            'winbase.bi

   print AfxGetWinErrMsg(GetLastError)

   Function = 0
End Function

The compiler says 'error 42: Variable not declared , QueryFullProcessImageName ...
I forgot to add something?.

 9 
 on: November 11, 2019, 11:05:50 AM 
Started by raymw - Last post by raymw
Going back a few years, to the Tandy/Radioshack TRS80 Basic, when Basic was an interpretted language, not compiled, it was often critical to know the time that certain operations took. It used to be common to put the code under test inside a for-next loop and note the time to complete the iterations, but you also had to take account of the loop counter itself - e.g. get the time for the empty loop. This is still very relevant if you are programming microprocessors (which today are usually far more powerful than the trs80 z80 cpu). Generally, things have progressed in PC hardware such that often the time taken for operations is reduced by having  more powerful processors, faster memory, etc, and it is only when dealing with larger amounts of data, that the time taken  for individual statements becomes important.
I've written a simple program that allows two different chunks of code to be inserted and compared wrt length of time to complete, and I thought it may be useful to others, or get a discussion going.
One of the things that I found interesting, is the apparent random results, most likely due to windows deciding to go and play with the mouse, or similar.

Code: [Select]
'runs some loopds to test speeds of statements

dim as double t0,t1,tt0,tt1,tt2    'times
dim as long j0             'loop counters
dim as long tot,jtot       'number of iteratations
dim as string ret          'check for inkey to do repeat
 
tot=1000000     'size of test loop
jtot=20         'number of iterations for average

again:
  tt0=0
  tt1=0
  tt2=0

                        'run blank loop
for j as integer =1 to jtot
  t0=timer
    for j0= 1 to tot        ' for blank loop
    next j0
  t1=timer
  tt0=tt0+t1-t0
next j
         ?"empty loop done ";
 '''''''''''''''''''''''''''''''''''''''''
                          'set variables for test loops
       dim a as String
       dim b as String
       a="the quick brown fox jumps over the lazy dog"
       
 ''''''''''''''''''''''''''''''''''''''''     
for j as integer =1 to jtot
  t0=timer
    for j0= 1 to tot        '  first test loop
      b=Ucase(a)        'enter first test code here
    next j0
  t1=timer
  tt1=tt1+t1-t0
next j
         ?" first test done ";     
'''''''''''''''''''''''''''''''''''''''''''
for j as integer =1 to jtot
  t0=timer
    for j0= 1 to tot        ' for second test
      a=ucase(a)        'enter second test code here
    next j0
  t1=timer
  tt2=tt2+t1-t0
next j
          ?" second test done "
''''''''''''''''''''''''''''''''''''''''''
? tt0/jtot,"time for empty loop"
 
? tt1/jtot,"time for first test"

? tt2/jtot,"time for second test"
   ?
  if tt2>tt1 then ?(tt2-tt1)/jtot ,"second test longer than first test"
  if tt1>tt2 then ?(tt1-tt2)/jtot ,"first test longer than second test"
  if tt1=tt2 then ?" both tests equal time - a very unlikely result"
 ?
       
 ? " any key to repeat"
 ret=""
 while ret=""
 ret=inkey
 wend
 ?"repeating"
 goto again

 10 
 on: November 10, 2019, 06:06:56 PM 
Started by Paul Squires - Last post by raymw
If I select a row with the mouse, it is highlighted blue, if programmatically, it is highlighted grey. Is it possible to be able to select these colours, possibly in designer toolbox properties? Is there a simple ratio between font size and row height in Pixels? If so what is it? Does the grid effect this?

Pages: [1] 2 3 ... 10