Recent

Author Topic: listbox working as in windows  (Read 8446 times)

Blue1987

  • Full Member
  • ***
  • Posts: 165
listbox working as in windows
« on: August 06, 2012, 07:32:55 pm »
I am porting an application I wrote for windows into linux... (in particular, I am using bodhilinux, a distro of ubuntu)
but I noticed that listbox works differently than in windows... in particular, in the same panel, if I select an item of, say, listbox1 the itemindex of listbox2 is automatically set to -1.

how can I change that?


thank you,
Paolo

Leledumbo

  • Hero Member
  • *****
  • Posts: 8274
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: listbox working as in windows
« Reply #1 on: August 06, 2012, 07:54:29 pm »
That should never happen, unless there's a relationship between the two listboxes. Please post a compilable example.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: listbox working as in windows
« Reply #2 on: August 07, 2012, 01:42:16 pm »
you are right... I tried to create a brand new application with 2 listbox and it works well..

so there is a problem with my application...
https://dl.dropbox.com/u/23296086/C4E_0511%2B.zip
https://dl.dropbox.com/u/23296086/C4E_0511code.tar.gz

there is something weird with that... it gives a sivseg error when you go on.. but I cannot understand where...
in windows it works well, so I do not understand the problem...


PS. I am completely refactoring the application dividing it in different units and forms, and this is the previous version I am not working on anymore... but I was trying to port it in linux before keeping working on the following refactored version of it!
« Last Edit: August 07, 2012, 11:28:43 pm by Blue1987 »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8274
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: listbox working as in windows
« Reply #3 on: August 07, 2012, 01:53:56 pm »
Do both listboxes point to the same, say OnChange, event? Probably you'll need to ensure it.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: listbox working as in windows
« Reply #4 on: August 07, 2012, 02:49:08 pm »
Do both listboxes point to the same, say OnChange, event? Probably you'll need to ensure it.



ehr, no... they don't... mmh...

if you compile and run it (you just need bgrabitmaps and bgracontrols) and click "new game" button, you understand what I mean...
I think the problem is here (though I am not sure... because I do not understand what the SIVSEG error refers to)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8274
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: listbox working as in windows
« Reply #5 on: August 07, 2012, 04:51:16 pm »
Quote
I think the problem is here (though I am not sure... because I do not understand what the SIVSEG error refers to)
Sorry I don't have bgracontrols installed (and too lazy to download one now :p) so I'll just try guessing. SIGSEGV is a signal for segmentation fault, sent when you're trying to access memory area outside of what your application has allocated or a nil pointer. If you run under debugger, it can show you where exactly it comes from (assuming the problematic code is compiled with debug info).

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: listbox working as in windows
« Reply #6 on: August 07, 2012, 05:18:49 pm »
I admit I do not know how the debugger works  :-[
it comes up with the assembler... but I do not know how to read it  :-[

I guess it is the listbox, because I try to access arrays like array[listbox7.itemindex]... and if listbox7.itemindex = -1 (while I set it 0) it should try to access a wrong memory allocation...

I will write a lot of showmessage(inttostr(listbox7.itemindex)) and try to understand where the problem is :D
(I know... a bit brutal as solution... but do not know how to do it differently...)



btw, is it possible that a listbox does not show any item selected even if, for instance, listbox.itemindex = 2 ??

Knipfty

  • Full Member
  • ***
  • Posts: 230
Re: listbox working as in windows
« Reply #7 on: August 07, 2012, 05:47:20 pm »
Hi Blue,

You did not mention if the list boxes are set up at design time or runtime.  IF its runtime, can you post the code for us to look at.

Thanks

Knipfty
32-bit Lazarus 1.0 FPC 2.6.0, 64-bit Win 7, Advantage DB 10.10

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: listbox working as in windows
« Reply #8 on: August 07, 2012, 05:52:30 pm »
sorry, but they are designed in the form...

Knipfty

  • Full Member
  • ***
  • Posts: 230
Re: listbox working as in windows
« Reply #9 on: August 07, 2012, 06:17:46 pm »
Did you check ListBox7.Items.Count?  Assuming that there is at least one item in the list, then you should be ablt to set the itemindex to zero.  I'm doing this in Windows, it could be a problem in Linux.
32-bit Lazarus 1.0 FPC 2.6.0, 64-bit Win 7, Advantage DB 10.10

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: listbox working as in windows
« Reply #10 on: August 07, 2012, 11:32:17 pm »
Did you check ListBox7.Items.Count?  Assuming that there is at least one item in the list, then you should be ablt to set the itemindex to zero.  I'm doing this in Windows, it could be a problem in Linux.

ops, I did wrote a wrong link... here the source code https://dl.dropbox.com/u/23296086/C4E_0511code.tar.gz

items are more than one (I add them one by one with items.add), then I manually set listbox.itemindex:=0 on runtime...

Leledumbo

  • Hero Member
  • *****
  • Posts: 8274
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: listbox working as in windows
« Reply #11 on: August 08, 2012, 12:02:40 am »
Quote
it comes up with the assembler... but I do not know how to read it
If this happens, you've reached the framework part (probably compiled without debug info). Open up call stack window and look for first entry pointing to your own source code, that's where the error comes from in your code.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: listbox working as in windows
« Reply #12 on: August 08, 2012, 01:09:03 am »
Quote
it comes up with the assembler... but I do not know how to read it
If this happens, you've reached the framework part (probably compiled without debug info). Open up call stack window and look for first entry pointing to your own source code, that's where the error comes from in your code.

ehr, sorry... but... where do I have to click?

p.s. the list-assembler does not scroll! therefore I have some problem if I want to navigate the lines...

avra

  • Hero Member
  • *****
  • Posts: 2012
    • Additional info
Re: listbox working as in windows
« Reply #13 on: August 08, 2012, 09:06:52 am »
I admit I do not know how the debugger works  :-[
it comes up with the assembler... but I do not know how to read it  :-[
You should really take a time and learn how to debug Pascal source, how to put breakpoints in your code, how to execute single step, how to use watches, inspect local variables... Time spent on this will get back to you 100 times. You don't have to deal with assembler at all if you set your environment right.
http://wiki.lazarus.freepascal.org/Category:Debugging
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: listbox working as in windows
« Reply #14 on: August 08, 2012, 01:07:13 pm »
I am trying to learn how to use the debugger... now I think the listbox is not the problem... but errors comes in lines of the source code which does not make sense to me!! I think it is better if I stop porting the application, and start the refactoring (which have to be made in any case) directly in linux!

thank you for your support!!

 

TinyPortal © 2005-2018