Sign in to follow this  
Followers 0
simbo

Creating simple editable tables with a vertical scrollbar

1 post in this topic

Hi All,

I've written this very simple program for printing address labels. You type the addresses into the table and they get printed on sheets of labels like mailmerging in MS Word. I've worked out how to store the addresses in a file and retrieve them back again etc. In fact, I've sussed it all bar the prob below:-

I created what appears to be a table, but is actually a large number of input boxes squashed together.

I've used $ws_scroll to put a vertical scroll bar in my GUI, but I can't get it to work, the ID for the whole of the scroll bar is the same, so how does autoit know whether I'm clicking up or down? And how would I handle such a thing?

I've tried using listviews which scroll fine, but I can't edit them

This is my first proper Autoit program and I be very grateful if someone could point me in the right direction. Here's my code (sorry about the lack of clever stuff concerning screen resolutions!)

Many thanks in advance,

Matt

#include <GUIConstants.au3>

$number_of_rows=100 ;one row equals one address record

$number_of_columns=7

call ("create_gui")

Do

$happenings=GUIGetMsg()

for $row_number=1 to $number_of_rows

Select

case $happenings=$GUI_EVENT_CLOSE ;close window pressed

call ("close_window")

;most of the rest of my awesome code goes here

EndSelect

Next

until 1=0

func close_window()

Exit

EndFunc

func create_gui()

$row_number=0

$window_styles=BitOR($ws_sysmenu,$ws_minimizebox,$ws_vscroll)

guicreate("Addresses",200,200,-1,-1,$window_styles)

guisetstate (@SW_SHOW)

GUISetState (@SW_MAXIMIZE)

;create sample address for first line in yellow

$tableheader=guictrlcreatelistview("Name |Address1 |Address2 |Address3 |TOWN |County |Postcode",30,80,725,22)

guictrlcreateinput("Mr and Mrs Fred Example", 30,100+$row_number*20,150,20,$ES_READONLY)

GUICtrlSetBkColor(-1,0xffff00)

guictrlcreateinput("115 Imaginary Avenue", 180,100+$row_number*20,120,20,$ES_READONLY)

GUICtrlSetBkColor(-1,0xffff00)

guictrlcreateinput("", 300,100+$row_number*20,100,20,$ES_READONLY)

GUICtrlSetBkColor(-1,0xffff00)

guictrlcreateinput("", 400,100+$row_number*20,100,20,$ES_READONLY)

GUICtrlSetBkColor(-1,0xffff00)

guictrlcreateinput("Nowhereville", 500,100+$row_number*20,100,20,$ES_READONLY)

GUICtrlSetBkColor(-1,0xffff00)

guictrlcreateinput("Madeupshire", 600,100+$row_number*20,90,20,$ES_READONLY)

GUICtrlSetBkColor(-1,0xffff00)

guictrlcreateinput("AB12 3CD", 690,100+$row_number*20,64,20,$ES_READONLY)

GUICtrlSetBkColor(-1,0xffff00)

;create the "table" of input boxes

for $row_number=1 to $number_of_rows

guictrlcreateinput("", 30,100+$row_number*20,150,20)

guictrlcreateinput("", 180,100+$row_number*20,120,20)

guictrlcreateinput("", 300,100+$row_number*20,100,20)

guictrlcreateinput("", 400,100+$row_number*20,100,20)

guictrlcreateinput("", 500,100+$row_number*20,100,20)

guictrlcreateinput("", 600,100+$row_number*20,90,20)

guictrlcreateinput("", 690,100+$row_number*20,64,20)

next

EndFunc

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0