curly
Full Member
Posts: 161
|
Post by curly on Jun 17, 2021 8:20:48 GMT -5
Hi all,
I'm back! I'm looking for an easy fix if one exists? I have a mix of 70 textboxes and comboboxes where the user enters data. They make mistakes (like me) and when they think they are finished, my validation system looks at all the data entered and throws up notices asking them to check the relevant boxes for typos. In the hope of not having to double up all the gui objects, is there a way to draw the users attention to the boxes that are in query?
I also have a general query, is there a 'super expert' in the UK I can hire to help me with my project? I've already said I'm really old, but it's taking me too long to progress, and I'm happy to pay for such help? I can be reached through the email address held on file for my licence.
Kind regards, David
|
|
|
Post by mknarr on Jun 17, 2021 8:42:18 GMT -5
Will the !setfocus command work. It should put the blinking carrot in the appropriate text box and any keystrokes will appear in that box.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jun 17, 2021 9:02:23 GMT -5
Hi mknar, Thank you for your instant reply. I'm afraid not, I need to attract attention to two or more boxes, possibly 5? I think I'm resigned to doubling up the GUI objects and create hide and show routines, but I was just hoping and praying there would be a simple solution?
|
|
|
Post by Rod on Jun 17, 2021 10:35:53 GMT -5
You could have a graphical or a checkbox tick beside the text box that shows green tick or Red Cross, you could surround the text box with a slightly larger graphicbox and fill it with red amber of green or just buttonface and red.
You could also stop them progressing till each text box passes the test. Just beep and loop back to the text box input till they get it right.
|
|
|
Post by Walt Decker on Jun 17, 2021 10:39:51 GMT -5
There is no real solution. Only one window can have the focus at a time; therefore you can only draw attention to one erroneous entry at a time. However, you can do the following: 1: validate each entry when it is entered. If valid, move to the next entry if not notify the user 2: validate the entries at the end. Store the handles of the invalid entry boxes 2a: create another window with the number of invalid edit control entries. 2b: indicate what is expected in each. 2c: check the revised entries. 2d: do whatever is necessary next.
PS:
I am not in the UK, but I will offer help, no charge.
|
|
|
Post by Rod on Jun 17, 2021 10:40:19 GMT -5
If you hire an expert be prepared for them to throw away all that you have created so far. It is never in an experts interest to produce a quick fix. Dripping roasts are far preferable.
I exclude Walt from my dissing comment about paid programmers.
|
|
|
Post by Rod on Jun 17, 2021 14:53:23 GMT -5
This works on a button but could be used on any control.
button #main.arrow, "A Button", [Clicked], UL, 10, 10, 100,20 graphicbox #main.gb 5, 5, 110,30 open "Button Example" for window as #main #main "trapclose [quit]" #main.gb "down ; fill red ; flush ; hide" wait
[Clicked] #main.gb "show" wait
[quit] close #main end
|
|
|
Post by Brandon Parker on Jun 17, 2021 15:20:54 GMT -5
If you hire an expert be prepared for them to throw away all that you have created so far. It is never in an experts interest to produce a quick fix. Dripping roasts are far preferable. I exclude Walt from my dissing comment about paid programmers. Hmmmm.... I've been paid for LB programming work... What are you trying to say Rod? {:0) Brandon Parker
|
|
|
Post by tsh73 on Jun 17, 2021 16:18:25 GMT -5
I am not versed in Windows API/stylebits but could border be turned on/off for existing textbox, combobox?
Probably stylebits will not do - they work on control creation
anything else, some window message may be?
I just tried C# winForms - textBox has BorderStyle, which could be changed from the code (Fixed3D|FixedSingle|None) and combpBox has FlatStyle which could be changed from the code (Flat|Popup|Standard, but I see two distinct forms only) -- anyway, changes in appearance are pretty visible. (not 5 pix red border, of course)
I understand C# is too far from base Win32, but may be where is an API way?
|
|
|
Post by Walt Decker on Jun 17, 2021 16:51:05 GMT -5
To change the style of an edit control, combo box, or list box on the fly use the user32dll api setwindowlongA(ctlhndl, gwl_style, newstyle) and/or setwindowlongA(ctlhndl, gwl_styleex, newstyle). No matter how you cut it you have to know which control(s) contain inaccurate data. In LB, this may be a problem, especially with edit controls.
|
|
|
Post by Brandon Parker on Jun 17, 2021 17:29:26 GMT -5
No matter how you cut it you have to know which control(s) contain inaccurate data. In LB, this may be a problem, especially with edit controls. I think the OP is already checking the validity of each control, so he is most likely using the control's handle to issue the LB command which retrieves the data. In short, I think the OP already knows which ones are incorrect and simply wants to alert the user to that fact. Another API option might be to use the MoveWindow function to resize the control up/down several times in a loop to get the user's attention. You could set it up such that the center of the control stays put and the control appears to expand in X and Y. Here's the function. If I get a chance I will create an example of how it might be done. Right now my 19 month old just woke up from here nap... Function MoveWindow(hWnd, winX, winY, wWidth, wHeight, bRepaint) CallDLL #user32, "MoveWindow", hWnd As ulong, _ winX As long, _ winY As long, _ wWidth As long, _ wHeight As long, _ bRepaint As long, _ MoveWindow As long End Function
{:0) Brandon Parker
|
|
|
Post by Brandon Parker on Jun 17, 2021 17:37:33 GMT -5
Ok, I just knocked this out real quick...
NoMainWin Button #main.arrow, "Flashy", [Clicked], UL, 10, 10, 100, 20
Open "Flashy Button" For Window As #main #main "trapclose [quit]" wait
[Clicked] For i = 1 To 10 If (i Mod 2) = 0 Then result = MoveWindow(Hwnd(#main.arrow), 10, 10, 100, 20, 1) Else result = MoveWindow(Hwnd(#main.arrow), 5, 5, 110, 30, 1) End If Scan result = Sleep(50) Next i Wait
[quit] Close #main End
Function MoveWindow(hWnd, winX, winY, wWidth, wHeight, bRepaint) CallDLL #user32, "MoveWindow", hWnd As ulong, _ winX As long, _ winY As long, _ wWidth As long, _ wHeight As long, _ bRepaint As long, _ MoveWindow As long End Function
Function Sleep(milliseconds) CallDLL #kernel32, "Sleep", milliseconds As ulong, _ ret As void End Function
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Jun 17, 2021 17:55:09 GMT -5
I am not a professional coder by any stretch of the imagination, just a broken down retarded engineering geologist. Mr. Parker, I suggest a small modification to your MoveWindow function. Function MoveWindow(CtlHndl)
STRUCT tCli, _ X as long, _ Y as long, _ X1 as long, _ Y1 as long
CALLDLL #USER32, "GetWindowRect", CtlHndl AS LONG, tCli AS STRUCT, RetVal AS VOID Xpos = tCli.X.struct Ypos = tCli.Y.struct
xsize = tCli.X1.struct - tCli.X.struct
ysize = tCli.Y1.struct - tCli.Y.struct
CALLDLL #USER32, "MoveWindow", CtlHndl AS LONG, Xpos AS LONG, Ypos AS LONG, xsize AS LONG, ysize AS LONG, 1 AS LONG, RetVal AS VOID
Since there are so many controls, probably many of different sizes, I think the above would be more appropriate.
|
|
|
Post by Brandon Parker on Jun 17, 2021 21:36:55 GMT -5
Walt, I was attempting to not overwhelm someone who might not be too versed in API calls...
Unfortunately, what you show will not really work. The GetWindowRect function returns the values in Screen Coordinates and the MoveWindow function expects Client Window Coordinates for child controls. Also, it is a good idea to always use ulong for Windows handles in LB...
In order to make it work for any control sent to the routine (assuming this is what you were trying to do), one should use the ScreenToClient function to convert what is returned from the GetWindowRect function to client coordinates prior to sending it to the MoveWindow function.
Here is how I would do it. I have also converted the example to use Subroutines/Functions. I added another button for demonstration purposes as well.
Note that there are more functions than required, but the OP might find them useful.
NoMainWin
'Create the structs for the GetWindowRect, GetClientRect, and ScreenToClient functions Struct rect, left As long, _ top As long, _ right As long, _ bottom As long
Struct tagPoint, x As long, _ y As long
Button #main.btnFlashy, "Flashy", activateFlash, UL, 10, 10, 100, 20 Button #main.btnFlashy2, "Flashy 2", activateFlash, UL, 120, 10, 100, 20 Open "Flashy Button" For Window As #main #main "TrapClose quit" Wait
Sub activateFlash handle$ 'Get the rectangle of the control result = GetWindowRect(Hwnd(#handle$))
'Set the upper-left coordinates to the Point Structure tagPoint.x.struct = rect.left.struct tagPoint.y.struct = rect.top.struct 'Convert this X & Y Point to Client coordinates result = ScreenToClient(Hwnd(#main)) 'Set our temporary original X & Y origX = tagPoint.x.struct origY = tagPoint.y.struct
'Set the lower-right coordinates to the Point Structure tagPoint.x.struct = rect.right.struct tagPoint.y.struct = rect.bottom.struct 'Convert this X & Y Point to Client coordinates result = ScreenToClient(Hwnd(#main)) 'Calculate and set our temporary original width and height origWidth = (tagPoint.x.struct - origX) origHeight = (tagPoint.y.struct - origY)
For i = 1 To 10 If (i Mod 2) = 0 Then result = MoveWindow(Hwnd(#handle$), origX, origY, origWidth, origHeight, 1) Else result = MoveWindow(Hwnd(#handle$), (origX - 5), (origY - 5), (origWidth + 10), (origHeight + 10), 1) End If Scan result = Sleep(50) Next i End Sub
Sub quit handle$ Close #main End End Sub
Function MoveWindow(hWnd, winX, winY, wWidth, wHeight, bRepaint) CallDLL #user32, "MoveWindow", hWnd As ulong, _ winX As long, _ winY As long, _ wWidth As long, _ wHeight As long, _ bRepaint As long, _ MoveWindow As long End Function
Function ScreenToClient(hWnd) CallDLL #user32, "ScreenToClient", hWnd As ulong, _ tagPoint As struct, _ ScreenToClient As long End Function
Function GetClientRect(hWnd) 'Get ClientRectangle CallDLL #user32, "GetClientRect", hWnd As ulong, _ rect As struct, _ GetClientRect As ulong End Function
Function GetWindowRect(hWnd) 'Get WindwRectangle CallDLL #user32, "GetWindowRect", hWnd As ulong, _ rect As struct, _ GetWindowRect As ulong End Function
Function Sleep(milliseconds) CallDLL #kernel32, "Sleep", milliseconds As ulong, _ ret As void End Function
{:0)
Brandon Parker
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jun 18, 2021 3:49:07 GMT -5
I am overwhelmed! I think I will start with Brandon's last post, and work my way up to see what I can achieve.
For the record, I am an aged electrical engineer who started my electrical contracting company in 1992. My daughter has taken over as MD, and I am the interferring Chairman. Along with other similar contractors, we carry out inspections and test electrical systems, and provide reports and certificates to our customers. Having been asked by a friend to look at a certificate provided by another contractor, I discovered the test results were rubbish, indicating many circuits were non-comliant and potentially dangerous. It then dawned on me that all the available software in the market relied on the inspecting engineer to analyse his test results himself, and I tried to create a simple piece of software that would validate the results in such certificates and reports so the client could see what rubbish he was getting, and raise the possibility of us getting more business. My software has grown out of all proportion, you guys have already steered me to learn so much, and I'm now looking to complete a full blown proramme that creates the certificates, but also validates every bit of data that is entered, primarily for our own use. As I'm learning more about LB, I'm finding I am now deleting large sections I have written in a most convoluted way to make it simpler with less bugs. That's why I was looking for paid help? I have no idea if landlords in the USA have a legal obligation to test the electrical systems in their tenanted homes?
|
|