LB Booster
« Putting text into a listview "cell" - return value »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:06am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Putting text into a listview "cell" - return value  (Read 650 times)
datwill
Guest
xx Putting text into a listview "cell" - return value
« Thread started on: May 9th, 2015, 3:28pm »

Hi, I'm creating this programme with a listview and I try to add text into a "cell", but it isn't working... I've checked the return value of the DLL call with the debugger and it equals -1 ??? what does this mean? What I know for sure is that it didn't work because nothings being presented in the "cells"
Code:
nomainwin
global hwndListView1
tableHeight = DisplayHeight-62
stylebits #table, _WS_MAXIMIZE, 0, 0, 0
open "Awakening Errors" for window as #table
#table "trapclose [quit] ; resizehandler [resize]": hWin = hwnd(#table)
struct LVITEM, mask as ulong, iItem as long, iSubItem as long, state as ulong, stateMask as ulong, pszText$ as ptr, cchTextMax as long, iImage as long, lParam as long, iIndent as long
struct LVCOLUMN, mask as ulong, fmt as long, cx as long, pszText$ as ptr, cchTextMax as long, iSubItem as long, iImage as long, iorder as long
style = _WS_CHILD or _WS_VISIBLE or 32768 or 1 or 4 or 8
calldll #comctl32, "InitCommonControls", r as void
calldll #user32, "GetWindowLongA", hWin as ulong, _GWL_HINSTANCE as long, hInstance as ulong
calldll #user32, "CreateWindowExA", _WS_EX_CLIENTEDGE as long, "SysListView32" as ptr, "" as ptr, style as long, 0 as long, 0 as long, DisplayWidth as long, tableHeight as long, hWin as ulong, 0 as long, hInstance as ulong, "" as ptr, hwndListView1 as ulong
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4150 as long, 32 as long, 32 as long, re as long
LVCOLUMN.mask.struct = 2 or 4: LVCOLUMN.cx.struct = 45: LVCOLUMN.pszText$.struct = "Code"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 0 as long, LVCOLUMN as struct, r as long
LVCOLUMN.cx.struct = 200: LVCOLUMN.pszText$.struct = "Message"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 1 as long, LVCOLUMN as struct, r as long
LVCOLUMN.cx.struct = 400: LVCOLUMN.pszText$.struct = "What does this mean?"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 2 as long, LVCOLUMN as struct, r as long
LVCOLUMN.cx.struct = 260: LVCOLUMN.pszText$.struct = "How hard is it for this error to be made/occur?"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 3 as long, LVCOLUMN as struct, r as long
LVCOLUMN.cx.struct = 500: LVCOLUMN.pszText$.struct = "How is this so hard or easy?"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 4 as long, LVCOLUMN as struct, r as long
LVITEM.mask.struct = 1 'place all entries between here and the wait statement!
call cell 70, "Couldn't create tooltip structure", "This means Awakening could not create a block of memory used for the main menu tooltips (the boxes which appear over a list or button in a window which explain a bit about what it does)", 4, "This means there isn't enough memory on this computer to support this structure - very unlikely considering how much memory computer's have now a days!"
wait

[quit]
close #table: end

[resize]
calldll #user32, "MoveWindow", hwndListView1 as ulong, 0 as long, 0 as long, WindowWidth as long, WindowHeight as long, 1 as long, r as long
wait

sub cell errorCode, errorMessage$, errorAbout$, errorLevel, errorAboutLevel$
    LVITEM.iItem.struct = errorCode-70: LVITEM.pszText$.struct = str$(errorCode)
    calldll #user32, "SendMessageA", hwndListView1 as ulong, 4103 as long, 0 as long, LVITEM as struct, r as long
    LVITEM.iSubItem.struct = 1: LVITEM.pszText$.struct = errorMessage$
    calldll #user32, "SendMessageA", hwndListView1 as ulong, 4103 as long, 0 as long, LVITEM as struct, r as long
    LVITEM.iSubItem.struct = 2: LVITEM.pszText$.struct = errorAbout$
    calldll #user32, "SendMessageA", hwndListView1 as ulong, 4103 as long, 0 as long, LVITEM as struct, r as long
    LVITEM.iSubItem.struct = 3: LVITEM.pszText$.struct = word$("QUITE EASY,EASY,QUITE HARD,HARD", errorLevel, ",")
    calldll #user32, "SendMessageA", hwndListView1 as ulong, 4103 as long, 0 as long, LVITEM as struct, r as long
    LVITEM.iSubItem.struct = 4: LVITEM.pszText$.struct = errorAboutLevel$
    calldll #user32, "SendMessageA", hwndListView1 as ulong, 4103 as long, 0 as long, LVITEM as struct, r as long
end sub 
« Last Edit: May 9th, 2015, 3:37pm by datwill » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Putting text into a listview "cell" - return v
« Reply #1 on: May 9th, 2015, 5:08pm »

on May 9th, 2015, 3:28pm, Daniel Atwill wrote:
Hi, I'm creating this programme with a listview and I try to add text into a "cell", but it isn't working

The reason you are finding it difficult to debug is that you're using 'magic' constants like 4103 which give no indication of their function! If you used proper Windows Constants it would be immediately obvious why it isn't working - and there's no excuse not to because LBB has them built in.

Specifically, 4103 is _LVM_INSERTITEM which of course is correct for the first reference to the item - you are initially inserting it - but it isn't correct for the subsequent writes to the sub-items. At that stage you don't want _LVM_INSERTITEM you want _LVM_SETITEM!

So go through your program replacing the 'magic' numbers with the corresponding Windows Constants, and be careful where you use _LVM_INSERTITEM and where you use _LVM_SETITEM.

Richard.
User IP Logged

datwill
Guest
xx Re: Putting text into a listview "cell" - return v
« Reply #2 on: May 9th, 2015, 7:34pm »

Thank you for that, but it will not display the code number column :(
Here's the new code:
Code:
nomainwin
global hwndListView1
tableHeight = DisplayHeight-62
stylebits #table, _WS_MAXIMIZE, 0, 0, 0
open "Awakening Errors" for window as #table
#table "trapclose [quit] ; resizehandler [resize]": hWin = hwnd(#table)
struct LVITEM, mask as ulong, iItem as long, iSubItem as long, state as ulong, stateMask as ulong, pszText$ as ptr, cchTextMax as long, iImage as long, lParam as long, iIndent as long
struct LVCOLUMN, mask as ulong, fmt as long, cx as long, pszText$ as ptr, cchTextMax as long, iSubItem as long, iImage as long, iorder as long
style = _WS_CHILD or _WS_VISIBLE or 32768 or 1 or 4 or 8
calldll #comctl32, "InitCommonControls", r as void
calldll #user32, "GetWindowLongA", hWin as ulong, _GWL_HINSTANCE as long, hInstance as ulong
calldll #user32, "CreateWindowExA", _WS_EX_CLIENTEDGE as long, "SysListView32" as ptr, "" as ptr, style as long, 0 as long, 0 as long, DisplayWidth as long, tableHeight as long, hWin as ulong, 0 as long, hInstance as ulong, "" as ptr, hwndListView1 as ulong
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4150 as long, 32 as long, 32 as long, re as long
LVCOLUMN.mask.struct = 2 or 4: LVCOLUMN.cx.struct = 45: LVCOLUMN.pszText$.struct = "Code"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 0 as long, LVCOLUMN as struct, r as long
LVCOLUMN.cx.struct = 300: LVCOLUMN.pszText$.struct = "Message"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 1 as long, LVCOLUMN as struct, r as long
LVCOLUMN.cx.struct = 1010: LVCOLUMN.pszText$.struct = "What does this mean?"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 2 as long, LVCOLUMN as struct, r as long
LVCOLUMN.cx.struct = 260: LVCOLUMN.pszText$.struct = "How hard is it for this error to be made/occur?"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 3 as long, LVCOLUMN as struct, r as long
LVCOLUMN.cx.struct = 1350: LVCOLUMN.pszText$.struct = "How is this so hard or easy?"
calldll #user32, "SendMessageA", hwndListView1 as ulong, 4123 as long, 4 as long, LVCOLUMN as struct, r as long
LVITEM.mask.struct = 1 'place all entries between here and the wait statement!

for loopVar = 0 to 9
    LVITEM.iItem.struct = loopVar
    calldll #user32, "SendMessageA", hwndListView1 as ulong, _LVM_INSERTITEM as long, 0 as long, LVITEM as struct, r as long
next
call cell 70, "Couldn't create tooltip structure", "This means Awakening could not create a block of memory used for the main menu tooltips (the boxes which appear over a list or button in a window which explain a bit about what it does)", 4, "This means there isn't enough memory on this computer to support this structure - very unlikely considering how much memory computer's have now a days!"
call cell 71, "Couldn't create the main menu combobox array", "This is another block of data dedicated to display the options in the combobox which appears in the main menu", 4, "The same reasoning as code 70"
call cell 72, "Couldn't create local variables", "This means Awakening could not create the memory for data to do with the main menu window and other GUI elements", 4, "Again, the same reason as code 70"
call cell 73, "Couldn't create global variables", "This means Awakening could not create the memory for the actual game and for functions (see code 76) - this is "+chr$(34)+"more important"+chr$(34)+" then the local variables, but all data is important!", 4, "See code 70"
call cell 74, "Couldn't open the profile database", "Awakening was not able to load all the user's files!", 4, "This is hard to achieve as Awakening, even if it cannot find the game files.dat file, will create a new one - therefore the game doesn't crash. This is prone; however; to the loss of Awakening profiles (if the file is not found for whatever reason) so BE CAREFUL!"
call cell 75, "Couldn't create byte lengths to database entries", "Awakening creates appropriate character lengths for all the profile data (this is the reason for the 50 length for the name of your file!). This means Awakening wasn't able to perform this task", 4, "For this to not work, you'd have to do something hideously wrong with the application itself (edit the contents of it), which you should NEVER do!"
call cell 76, "Couldn't perform function: functionName()", "For whatever reason, Awakening wasn't able to call the function (a piece of code) named functionName()", 4, "See code 75"
call cell 77, "Couldn't form main menu UI", "The main menu window and all it's elements could not be created", 1, "See code 78"
call cell 78, "Couldn't create tooltips", "Awakening's tooltips could not be graphically constructed", 1, "This part uses things called DLLs, basically external functions (pieces of code) which are in files with extensions of .dll. This error can be made if you delete the appropriate DLL (which isn't in the Awakening folder) - this is worse than to mess around with the application (see code 75) and SHOULD NEVER BE DONE FOR ANY REASONS! If you do it will mess up the WHOLE computer, not just Awakening"
call cell 79, "Couldn't create the main menu status bar", "Awakening's footer bar in the main menu (which tells you which file you have selected out of the file list) could not be constructed", 1, "See code 78"
wait

[quit]
close #table: end

[resize]
calldll #user32, "MoveWindow", hwndListView1 as ulong, 0 as long, 0 as long, WindowWidth as long, WindowHeight as long, 1 as long, r as long
wait

sub cell errorCode, errorMessage$, errorAbout$, errorLevel, errorAboutLevel$
    LVITEM.iItem.struct = errorCode-70: LVITEM.pszText$.struct = str$(errorCode)
    calldll #user32, "SendMessageA", hwndListView1 as ulong, _LVM_SETITEM as long, 0 as long, LVITEM as struct, r as long
    LVITEM.iSubItem.struct = 1: LVITEM.pszText$.struct = errorMessage$
    calldll #user32, "SendMessageA", hwndListView1 as ulong, _LVM_SETITEM as long, 0 as long, LVITEM as struct, r as long
    LVITEM.iSubItem.struct = 2: LVITEM.pszText$.struct = errorAbout$
    calldll #user32, "SendMessageA", hwndListView1 as ulong, _LVM_SETITEM as long, 0 as long, LVITEM as struct, r as long
    LVITEM.iSubItem.struct = 3: LVITEM.pszText$.struct = word$("QUITE EASY,EASY,QUITE HARD,HARD", errorLevel, ",")
    calldll #user32, "SendMessageA", hwndListView1 as ulong, _LVM_SETITEM as long, 0 as long, LVITEM as struct, r as long
    LVITEM.iSubItem.struct = 4: LVITEM.pszText$.struct = errorAboutLevel$
    calldll #user32, "SendMessageA", hwndListView1 as ulong, _LVM_SETITEM as long, 0 as long, LVITEM as struct, r as long
end sub     
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Putting text into a listview "cell"
« Reply #3 on: May 9th, 2015, 7:38pm »

on May 9th, 2015, 7:34pm, Daniel Atwill wrote:
Thank you for that, but it will not display the code number column sad

Read my message again, and do what I said!

Richard.

User IP Logged

datwill
Guest
xx Re: Putting text into a listview "cell" - return v
« Reply #4 on: May 9th, 2015, 8:21pm »

Thank you, after a bit of editing it worked! I hope I didn't make you mad sad
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Putting text into a listview "cell"
« Reply #5 on: May 9th, 2015, 8:55pm »

on May 9th, 2015, 8:21pm, Daniel Atwill wrote:
I hope I didn't make you mad sad

Not at all. I hope you didn't mind me 'leading you to the answer'. My wife is a retired teacher! cheesy

Richard.
User IP Logged

datwill
Guest
xx Re: Putting text into a listview "cell" - return v
« Reply #6 on: May 9th, 2015, 9:10pm »

No I don't and I hope your happy together!
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls