May 29, 2024, 06:04:10 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Database Program

Started by Brian, December 09, 2011, 12:05:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

December 09, 2011, 12:05:03 PM Last Edit: December 09, 2011, 12:06:34 PM by Brian Pugh
Hi,

I've been working lately on a little database program for work, so I'm sharing the result with you all

The icons, manifest and versioninfo files are loaded into the exe via a resource file

When you first run it, if there is no DB in the program's folder, it creates one

You can load in a text file to the DB using Import Data. At the moment, it extracts only the
records I need. The processed file is then moved to the Processed folder

Use the << and >> buttons to move up and down the database
Click View as List to see all the records on one listview screen

Double-clicking on a record will close the listview and drop you to that record

All the listview column headers are clickable to sort the columns

To do: Selecting a record will highlight all the records with the same Import Filename (anybody?)
Maybe then to print all the highlighted records

There is a small console program, test output.iwb, which generates the test text file

Hope this helps someone,

Brian

Forgot to say, valuable help from LarryMc, code from Sapero, and probably other people as well!


billhsln

In the kcOakland.iwb file, after the following code:

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1 'Click on a column header for sorting
IF @NOTIFYCODE=@LVNCOLUMNCLICK
ClickedColumn=*<NMLISTVIEW>@LPARAM.iSubItem
BeginSort()
ENDIF


Add:

' Color Listview
IF @NOTIFYCODE = NM_CUSTOMDRAW
SetWindowLongA(d1.hwnd,DWL_MSGRESULT,ColorListView(dView.hwnd,@LPARAM,dView,@CONTROLID))
RETURN TRUE
ENDIF


Then at the end of the program add: (This will require modification to work as you want it), this will color your listview.

'==================================================================
SUB ColorListView(hwnd:UINT,lParam:UINT,dial:DIALOG,contr:INT),UINT
'==================================================================
DEF rv:UINT
DEF row, item, bg, fg:INT

DEF BLACK, RED, GREEN, BLUE, YELLOW, CYAN, PINK, GREY, MAGENTA:UINT
DEF LBLUE, LYELLOW, WHITE, PURPLE, PURPLE2, GOLD, SILVER, BROWN:UINT

GOLD    = RGB(255,215,0)
YELLOW  = RGB(255,255,0)
LYELLOW = RGB(255,255,125)
GREEN   = RGB(0,255,0)
BLUE    = RGB(0,0,255)
RED     = RGB(255,0,0)
CYAN    = RGB(0,255,255)
PINK    = RGB(255,192,203)
GREY    = RGB(127,127,127)
LBLUE   = RGB(0,125,255)
'MAGENTA = RGB(255,0,255)
MAGENTA = 0x8D38C9
PURPLE  = RGB(128,0,128)
PURPLE2 = RGB(230,25,230)
BROWN   = 0x60A4F4
SILVER  = RGB(128,128,128)
WHITE   = RGB(255,255,255)
BLACK   = RGB(0,0,0)

row = *<NMLVCUSTOMDRAW>lParam.nmcd.dwItemSpec
SELECT *<NMLVCUSTOMDRAW>lParam.nmcd.dwDrawStage
CASE CDDS_PREPAINT
rv = CDRF_NOTIFYITEMDRAW
CASE CDDS_ITEMPREPAINT
'*<NMLVCUSTOMDRAW>lParam.nmcd.dwItemSpec is the zero based item the Control is drawing
'check To see If the item number is odd or even and point the colp Pointer
'To the required variable color1 or color2
'but we want To Color each column item (subitem) individually
rv = CDRF_NOTIFYSUBITEMDRAW
CASE CDDS_SUBITEMPREPAINT
'*<NMLVCUSTOMDRAW>lParam.iSubItem contains the zero based Sub item number
'on System with IE 4.0 or greater installed.
item = *<NMLVCUSTOMDRAW>lParam.iSubItem
CONTROLCMD(dial,contr,@LVGETTEXT,row,5,ctype)
SELECT ctype
CASE "c" : ' Common
fg = GREEN
bg = BLACK
CASE "e" : ' Energy
fg = YELLOW
bg = BLACK
CASE "f" : ' Foil
fg = CYAN
bg = BLACK
CASE "r" : ' Rare
fg = RED
bg = BLACK
CASE "t" : ' Toy
fg = PURPLE2
bg = BLACK
CASE "s" : ' Shiny
fg = BROWN
bg = BLACK
CASE "st" : ' Stickers
fg = GOLD
bg = BLACK
CASE "l" : ' Lxx
fg = LBLUE
bg = BLACK
CASE "p" : ' Premier
fg = PINK
bg = BLACK
ENDSELECT
' SELECT *<NMLVCUSTOMDRAW>lParam.iSubItem
' CASE 0 :' the ITEM Color
' *<NMLVCUSTOMDRAW>lParam.clrText = tcolor
' *<NMLVCUSTOMDRAW>lParam.clrTextBk = #colp :'set the text background Color For first item
' CASE 1 :' the first Sub item
' *<NMLVCUSTOMDRAW>lParam.clrText = tcolor
' *<NMLVCUSTOMDRAW>lParam.clrTextBk = #colp :'set the text background Color For this subitem
' DEFAULT :' the Color of the rest of the line
*<NMLVCUSTOMDRAW>lParam.clrText = fg
*<NMLVCUSTOMDRAW>lParam.clrTextBk = bg :'set the text background Color For this subitem
' ENDSELECT
' IF *<NMLVCUSTOMDRAW>lParam.iSubItem = 5
' *<NMLVCUSTOMDRAW>lParam.clrText = fg
' *<NMLVCUSTOMDRAW>lParam.clrTextBk = bg
' ELSE
' *<NMLVCUSTOMDRAW>lParam.clrText = CYAN
' *<NMLVCUSTOMDRAW>lParam.clrTextBk = BLACK
' ENDIF
rv = CDRF_NEWFONT
DEFAULT
rv = CDRF_DODEFAULT
ENDSELECT
RETURN rv
ENDSUB


This should help color your listview.

Bill


When all else fails, get a bigger hammer.

billhsln

Here is code that should select all the lines with the same Imported Filenames.  Put after

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1 'Click on a column header for sorting
IF @NOTIFYCODE=@LVNCOLUMNCLICK
ClickedColumn=*<NMLISTVIEW>@LPARAM.iSubItem
BeginSort()
ENDIF


IF @NOTIFYCODE=@NMCLICK
lvi=*<NMLISTVIEW>@LPARAM.iItem
CONTROLCMD(dView,1,@LVGETTEXT,lvi,5,look$)
count = CONTROLCMD(dView,1, @LVGETCOUNT)
FOR i = 0 to count - 1
CONTROLCMD(dView,1,@LVGETCOLUMNTEXT,5,text$)
IF look$ = text$
CONTROLCMD dView,1,@LVSETSELECTED,i
ENDIF
NEXT i
ENDIF


This should high light all the lines with the same value.

Bill
When all else fails, get a bigger hammer.

Brian

Bill,

Working on it now. . . . Will post updated code when finished

Many thanks,

Brian

Brian

Well, this should be working, but I can't see the text

What am I doing wrong? I tried plugging some code in from another program,
it seemed simple enough, but I can't see what the problem is

Brian

billhsln

December 10, 2011, 08:28:11 AM #5 Last Edit: December 10, 2011, 08:47:24 AM by billhsln
Made a few minor changes, let me know if this works.

Bill

Fixed a few more things to clean up a couple of errors.
When all else fails, get a bigger hammer.

billhsln

I finally got a little time and was able to play with your program.  It works for me, click on any entry and the selected come up in light blue (at least it looks like light blue to me).

Look for bkh, the lines below that are what I changed/put in.

Bill
When all else fails, get a bigger hammer.

billhsln

I went crazy and tried one other minor change:

   color1=0xFF0000
   color2=0x00FF00
   color3=0
   color4=0x0000FF

This really shows up good.  Maybe your colors are to close to being the same.  At least to me the initial screen comes up with a white back ground and black letters.  The difference between color1 and color2 needs to be a little more dramatic for my eyes to even be able to tell them apart.

For a test try some other colors for Color1 and 2.

Bill
When all else fails, get a bigger hammer.

Brian

Bill,

Thanks for looking again at the problem - still been trying, and was about to give up
on it, until I had seen this. Will try your fix tonight - fingers crossed!

Brian

billhsln

Check out:  http://cloford.com/resources/colours/500col.htm

It is a good site with lots of colors defined and the RGB values.

Bill
When all else fails, get a bigger hammer.

Brian

Bill - Yippee!

Great, the program works fine now, and does exactly what I wanted it to do

Just tidying up at the moment, and doing a few mods - I will post the whole
lot again when finished, maybe need a day or three

Many, many thanks - I was about to give up with the idea,

Brian

billhsln

Glad I could help.  Hope it looks as you expect.  Good luck on getting it working.

Bill
When all else fails, get a bigger hammer.

Brian

Bill,

The colour resources page is great - almost too many to choose from!

Try this one - I've used it for a long time, and it's free:

http://www.blacksunsoftware.com/colormania.html

Brian

Brian

Hi,

Thanks to Larry, Sapero and Bill, and maybe others, I think I have got where
I need to with this program at the moment

But there is a problem! If you use the vertical scroll grabber to move down the records
when in listview, no problem. But if you click in the blank area of the scrollbar, the listview
lines go all out of synch! Very untidy, and not what you would expect, as well

Am I missing something simple here?

Brian

PS: All the files you need are in the attached zip

billhsln

I don't see a @VSCROLL| on the Listview definition.

CONTROL dView,@LISTVIEW,"",6,6,788,560,@VSCROLL|0x50000001|@BORDER|@LVSSHOWSELALWAYS,1

Bill
When all else fails, get a bigger hammer.

Brian

Bill,

@VSCROLL doesn't make a difference - I did have it in, but took it out for testing

I'm on XP SP3 here. I think it looked OK at work on Vista when I tried it

The alternate colourings seem to get out of alignment with the gridlines

Brian

Brian

Which got me thinking: Why do I need LVS_EX_GRIDLINES when each alternate line
is a different colour anyway? Just don't need the gridlines at all

Took the style out, and everything looks OK to me

Brian

LarryMc

Kinda like the old doctor said,"If it hurts when you do that then don't do it!" ;D

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library