I have One Window application by Which User Can Print Their Product Barcode Value And Also Can Scan it,
Now i am searching for some threading or some other way,
If user Enter 5 value for Print after Printing First value, Function wait for user input in text box (i call textbox up event for capturing scanning value)
and if value is correct so, my function continue its execution or wait until user Scan Proper barcode,
so how can i make method or function which can wait for user input and then continue executions.
private void myFunction1()
{
for (i = 0; i < intPrintNo; i++) // Number Of Print
{
// here I write Code For Print My Barcode
// Now I want to wait For user Input in my text box
jumphere :
txtBarcode.Text = "";
txtBarcode.Enabled = true;
txtBarcode.Visible = true;
txtBarcode.Focus();
if (keyUp()== false)
{
txtBarcode.Text = "";
txtBarcode.Enabled = true;
goto jumphere;
}
// If return True than for loop Continue for next Printing
}
}
From what i've understood from your question, you want to print the barcode of value specified by the user and then user can scan the same to verify if printed properly or not.
You can achieve this functionality in Windows forms using following steps
User enters the value (to print barcode) in txtInput
Presses print button (btnPrint)
The print button event handler will first disable itself and the input textbox (btnPrint.Enabled = txtInput.Enabled = false; Application.DoEvents();) and then print the barcode and set focus on textbox txtVerify.
User will scan the barcode in textbox txtVerify.
User will click on verify button (btnVerify) which will compare the value in txtInput and txtVerify.
If everything fine, clear the txtInput, txtVerify, enable txtInput and btnPrint, set focus to txtInput for next value
If error, do the needful.
EDIT: As per OPs comment (minimum user effort)
You can change the setting of barcode scanner to suffix newline (Enter) after every scan (you can find how to do this setting in the manual provided with the barcode)...... so now,
step 4. User will scan the barcode in textbox txtVerify (the scanning will provide Enter press at the end of scan). txtVerify.TextChanged event handler will check if key pressed in Enter, if so, call the code to verify (compare the values in txtInput and txtVerify)
step 5. Remove this step from above
step 6. If everything fine, clear the txtInput, txtVerify, enable txtInput and btnPrint, set focus to txtInput for next value
step 7. If error, do the needful.
Also, you can modify the first textbox to print the barcode when user presses enter key (so, no need to click on Print button)
So, after above modifications, the user will enter the text press enter (this will print barcode) then scan (as focus is already in txtVerify). If everything is fine, new value can be entered.
To reset the screen, you can provide a 'Reset' button.
Glad to help! Please remember to accept the answer if you found it helpful.
Related
My requirement is to develop an application in power builder, which receives Scanned barcodes and decodes it
The application should also be able to reveal hidden ASCII codes in the scanned barcodes.
Like:-
ASCII Codes
TAB - 9
BS Backspace - 8
EOT End of Transmission - 4
FF Form Feed - 12
Etc.
When scanned codes arrives at datawindow, rich text input, single line edit it comes as one character at a time
So my logic would be is to take that character before it is written in Datawindow or rich text input and find its ascii value and if it is less the 32 (which means it is a hidden character)
I can give brackets around it and show in display screen. so that hidden characters are not missed out.
Eg Scanned code abcdefgh
Decoded code will be abc[09]def[12]gh
So I tried with EditChanged, itemchanged , KeyDown events but I am unable to get the character before it is written in datawindow. Because once it is been written in datawindow hidden characters will be missed out.
Is there any event in powerbuilder will give me the scannedcode after it has been scanned but before it has been written in data window or rich text control,
Something like PreviewTextInput Event, which will preview the text before writing it into the data window.
Sample barcode Image uploaded
Thanks and regards,
The Event ID pbm_dwnchanging might work for you. Try creating an event on the DataWindow control that uses pbm_dwnchanging - this appears to capture the characters as they're being entered, but before they're put into the edit control (like you would think pbm_dwnkey should).
// "prototype" in the window object's datawindow control declaration:
event onpbmdwnchanging pbm_dwnchanging
Here is the pbm_dwnchanging event extension's code - basically, it calls a method that builds the "representation" of the data being entered and logs it (i.e.: appends a Multi-line Edit control in the window).
event onpbmdwnchanging;
string dataRepresentation
// get the representation of the data
dataRepresentation = getDataRepresentation(data)
// log it to the window's MLE
addLogMessage("onpbmdwnchanging - row: " + string(row) + " data: '" +
dataRepresentation + "'")
return
end event
Lastly, the function that builds the "representation" of the data:
protected function string getDataRepresentation (string as_input);
string dataRep
char dataChars[]
string currentChar
long ll_datalength, ll_index
dataChars = as_input // cast the string into a character array
ll_datalength = upperbound(dataChars)
for ll_index = 1 to ll_datalength
currentChar = dataChars[ll_index]
if Asc(currentChar) < 32 then
// "hidden" character
dataRep += "[" + string(Asc(currentChar)) + "]"
else
dataRep += string(currentChar)
end if
next
return dataRep
end function
note: tested and works in PB 12.6
My Idea is not too hard. I have a button, a string called "progname", a TextBox and three Progressbars.
When I enter a number into the TextBox and press the button, the following code run's through.
Dim progname As String
progname = "Progressbar" & TextBox1.Text
Now I have a string called "progname" with relevant value.For an example "Progressbar2".
What I want to achieve is write something like:
progname.Value += 1
Which can't be done, as "Value" is not a Member of "String". How can I do this?
Overall what I want, is to be able to select one of the three progressbars by typing one of the numbers 1-3 into the TextBox and then change that ones porperties.
Yes you can.
A basic example is this, which searches your form for controls with the name matching your string. It then changes the type to a ProgressBar so you can access all the methods ..
Dim progbar As ProgressBar = CType(Me.Controls.Find(progName, False)(0), ProgressBar)
progbar.Value += 1
I need to create a button in Lotus Notes mail stationary which will insert a text and then the button is deleted from the message.
In the button I have:
res := #Prompt([OkCancelList]; "Is it OK?"; "Select result"; " ";"OK":"Failed":"");
#If(res ="OK";
#Command([EditGotoField]; "Body") + #Command([EditInsertText]; "Everything is fine);
#Command([EditGotoField]; "Body") + #Command([EditInsertText]; "Not so good mate"));
This part works fine, but I am not sure how to delete the button after click. Usually works #Command([EditClear]) but not in this case when I use #Command([EditGoToField]) in the formula.
I suppose i need to use GoToField again with the correct button identifier and then run EditClear, but I do not know where to find it, or if there is another way to do it... Ideas?
Thank you.
Assuming you have the button in field Body and nothing else that have to remain
then change your code to:
#Command([EditGotoField]; "Body");
#Command([EditSelectAll]);
res := #Prompt([OkCancelList]; "Is it OK?"; "Select result"; " ";"OK":"Failed":"");
#If(res ="OK";
#Command([EditInsertText]; "Everything is fine");
#Command([EditInsertText]; "Not so good mate"));
It selects the content of Body (including button) and replaces it by the new text.
Assuming your document is (or could be put into) edit mode, you could still have the button, but have the button in it's own paragraph (or table cell) with a hide-when formula of of MySpecialButtonPressed!="", and then include the line
FIELD MySpecialButtonPressed := #Now;
in the button code.
(Edit: changed test from =1 to !="", then changed the set value from 1 to #Now because Notes doesn't store Boolean values. Unless you're sending out millions of these, the cost of using dates instead of numbers less than the benefit of having more specific information in case you need it.)
Q1) I have a Entry widget and I want it to be per-initilized with a value and I want the user to have the open to erase that value and type in what ever value they want.
So for example:
Year: 2016 <----- By deafult 2016 is already inputted and visible
Is there a way I can do this?
Q2) Is there a way I can set a limit to the number of a same window that can be opened? For example: If i have a drop down menu which has a "help" option. Currently the way I have it set up, if I click the help once the help window will pop up, and if I click it again (while the first window is still open) another help window will pop up. How do I set it so that only 1 help window can be opened at a time?
Any help is greatly appreciated.
1) you can use a string variable
self.example = StringVar()
self.example.set("put what you want it to say at the start here")
#note put this before you make your entry
self.example_txt = Entry(self,textvariable = self.example)
self.example_txt.place(row = 1, column = 1)
#note iv purposely missed out class declaration ectra as i am assuming you already have that)
2) there is probably a better way to do this but you could use a global variable which is set to false when the help button is clicked and set back to true when help window closed
global valid
valid = True
#not put this at start of your program
def opennewindow():
global valid
if valid == True:
valid = False
#put code for opening new window here assuming you already have that code as
#you haven't asked for code for that
def closewindow():
global valid
valid = True
self.master.destroy()
To insert something into an entry widget you can use the insert method:
e1 = tk.Entry(...)
e1.insert(0, "hello, world")
To only allow a single help window, create the help window once and hide it. Then, make your help function merely show the window rather than create it. Or, have the function check to see if the window exists; if it doesn't, create it before making it visible.
I'm running into a bit of a problem, but I feel so close to solving it. I have a text file with Usernames and Passwords separated with a pipe:
;info.txt
user1|pass1
user2|pass2
user3|pass3
user4|pass4
user5|pass5
user6|pass6
user7|pass7
user8|pass8
user9|pass9
user10|pass10
and here's the code:
Gui, -SysMenu
Gui, Add, Button, , Log in
getUsers()
Gui, Add, Button, , Exit
Gui, Show
Return
getUsers()
{
userList := ""
loop
{
FileReadLine, line, info.txt, %A_Index%
if ErrorLevel
Break
getUsers := StrSplit(line, "|")
userList .= getUsers[1] "|"
}
Gui, Add, ListBox, h100 vChoice, %userList%
}
ButtonLogin:
MsgBox, You chose %Choice%.
Gui, Submit, NoHide
Return
ButtonExit:
ExitApp
Return
I used StrSplit() to separate the User from Pass and then delimit the Users to get them into proper format for the ListBox. Everything loads just fine, but when I select one from the list and hit "Log in," the first one doesn't give me any result then the correct results are delayed by one. Example:
Click user1 > You chose .
Click user5 > you chose user1.
Click user3 > you chose user5.
Also, if anyone has a better way of doing this, please let me know.
Ah, I figured it out. It was a problem with:
ButtonLogin:
MsgBox, You chose %Choice%.
Gui, Submit, NoHide
Return
The MsgBox was happening BEFORE Submit was going through. Fixed:
ButtonLogin:
Gui, Submit, NoHide
MsgBox, You chose %Choice%.
Return