How do I get more than one keyboard input at a time in Small Basic - keyboard-events

I thought this would work, but didn't
GraphicsWindow.KeyDown = KeyDown
Sub KeyDown
If GraphicsWindow.LastKey = "W" And GraphicsWindow.LastKey = "Space" Then
Do Stuff
EndIf
EndSub
I need a solution to this so I can get more than one keyboard input at a time from a user

Here you go! This should do what you need!
GraphicsWindow.KeyDown = KeyDown
GraphicsWindow.KeyUp = KeyUp
While 1 = 1
Program.Delay(10)
If Key["Space"] = "True" And Key["Up"] Then
TextWindow.WriteLine("DOING STUFF!")
EndIf
EndWhile
Sub Keydown
LastKeyDown = GraphicsWindow.LastKey
Key[LastKeyDown] = "True"
EndSub
Sub KeyUp
LastKeyUp = GraphicsWindow.LastKey
Key[LastKeyUp] = "False"
EndSub

Related

WPF Radio Button showing mouse over colour incorrectly

I have three Radio Buttons in a toolbar as part of a tab. When the tab is opened the first button always displays the mouse over colour - it goes away when the user clicks anywhere on the tab, and back again next time the tab is selected. I have tried to set the focus on other elements, nothing seems to stop this behaviour and it's very confusing for the user - in the screenshot below 'Statements' is selected
Dim NotUsedRB As New RadioButton
With NotUsedRB
.Content = "Not Used"
.ToolTip = "This mailing address is not used"
.GroupName = "MailingRB"
.Name = "Mailing_NotUsedRB"
End With
RegisterControl(Customer_Grid, NotUsedRB)
vToolbar.Items.Add(NotUsedRB)
vToolbar.Items.Add(TS_Separator)
Dim StatementsRB As New RadioButton
With StatementsRB
.Content = "Statements"
.ToolTip = "Mailing address used for statements"
.GroupName = "MailingRB"
.Name = "Mailing_StatementsRB"
End With
RegisterControl(Customer_Grid, StatementsRB)
vToolbar.Items.Add(StatementsRB)
vToolbar.Items.Add(TS_Separator)
Dim FinesRB As New RadioButton
With FinesRB
.Content = "Fines"
.ToolTip = "Mailing address for violation fines"
.GroupName = "MailingRB"
.Name = "Mailing_FinesRB"
End With
RegisterControl(Customer_Grid, FinesRB)
vToolbar.Items.Add(FinesRB)
vToolbar.Items.Add(TS_Separator)
Turns out that setting .Focusable = False to all the Radio Buttons was the answer :-)

Remove "Add or Remove Buttons" in Rad Command Bar

I have a Rad Command Bar created with the code below:
RadCommandBar main = new RadCommandBar();
main.Dock = DockStyle.Top;
main.AutoSize = true;
main.Size = new System.Drawing.Size(874, 59);
CommandBarRowElement address = new CommandBarRowElement();
CommandBarStripElement strip = new CommandBarStripElement();
strip.FloatingForm = null;
strip.StretchHorizontally = true;
address.Strips.Add(strip);
CommandBarDropDownList addressEdit = new CommandBarDropDownList();
addressEdit.MaxSize = new System.Drawing.Size(0, 0);
addressEdit.VisibleInOverflowMenu = true;
addressEdit.StretchHorizontally = true;
main.Rows.Add(address);
parent.Controls.Add(main);
I'm having issue with hiding the "Add or Remove Buttons" of the strip element. Can someone point me to the right way to hide that menu?
You can use the following code:
strip.OverflowButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
It it better to set the Visibility to Collapsed, in order to collapse the whole item. Using Hidden will hide the item, but its space will be retained. More information is available here: Customize the overflow button

Immediately update DataGridViewCheckBoxCell

I am programmatically updating my WinForm DataGridView
Problem, DataGridViewCheckBoxCell doesn't get updated !!!
I was google, it seams like knowing case but whatever I've tried did not help yet.
private void InitializeFunctionsDataGrid()
{
System.Data.DataSet ds = func.GetFunctions();
this.FunctionsDataGrid.DataSource = ds.Tables[0];
this.FunctionsDataGrid.Columns["FunctionId"].Visible = false;
this.FunctionsDataGrid.Columns["DESCRIPTION"].Width = 370;
DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
column.Name = "enable";
column.HeaderText = "enable";
column.FalseValue = 0;
column.TrueValue = 1;
FunctionsDataGrid.Columns.Add(column);
foreach(DataGridViewRow row in FunctionsDataGrid.Rows)
{
(( DataGridViewCheckBoxCell)row.Cells["enable"]).Value = 1;
}
FunctionsDataGrid.CurrentCell = null;
}
enable is an unbound column. This means that you need to provide cell value yourself.
You can set the VirtualMode property to true and handle the CellValueNeeded event.
If you want to enable the user to check a cell then you need to handle the CellValuePushed event.
DataGridView samples that are part of the DataGridView FAQ has a specific example of an unbound checkbox column along with databound columns.
OK basically easiest way for me was to work with datasource.
I've add the column to the DataTable and fill it with data.
And then last thing this.FunctionsDataGrid.DataSource = ds.Tables[0];

Can VBA Forms have a Flow Layout?

I'm guessing this is impossible, but here goes.
Java and more recent .Net updates are capable of a Flow Layout - where a layout manager re-arranges the form controls to fit in the available space.
I've only seen VBA & WinForms using hard-coded absolute positions.
Has anyone encountered a flow-layout manager in this context?
Access 2007 and later versions implement this functionality via anchoring: Make controls stretch, shrink, or move as you resize a form
If you want to do it in earlier versions you can roll your own using the On Resize event of the form.
I have a form which is laid out like this. All of my controls are sequentially named based on their vertical position: txt_R1, txt_R2, txt_R3 etc...
When the Form loads, it looks like this:
When I update the combo box, the code below executes:
Dim s_tier As String
Dim s_rate As String
Dim s_lbl_Rate As String
Dim s_lbl_Tier As String
Dim s_obj As String
Me.TXT_Min.Visible = True
Me.LBL_MIN.Visible = True
Me.TXT_Min.Value = 0
Me.TXT_Scale.Visible = True
Me.lbl_Scale.Visible = True
Me.TXT_Scale.Value = 0
Me.txt_MinMax.Visible = True
Me.lbl_MinMax.Visible = True
Me.txt_MinMax.Value = 0
s_tier = "TXT_T"
s_rate = "TXT_R"
s_lbl_Rate = "LBL_R"
s_lbl_Tier = "LBL_T"
For i = 1 To numActive
'Tier Text Box
s_obj = s_tier & i
Me(s_obj).Visible = True
Me(s_obj).Value = "NULL"
'Tier Label
s_obj = s_lbl_Tier & i
Me(s_obj).Visible = True
'Rate Text Box
s_obj = s_rate & i
Me(s_obj).Visible = True
Me(s_obj).Value = "NULL"
'Rate Label
s_obj = s_lbl_Rate & i
Me(s_obj).Visible = True
Next i
'set last tier to infinite, since last tier typically goes on forever
s_obj = s_tier & numActive
Me(s_obj).Value = ChrW(&H221E)
Me(s_obj).FontSize = 16
'Make Test button visible and move to appropriate place
s_obj = s_lbl_Tier & (numActive + 1)
Me.Btn_Test.Top = Me(s_obj).Top
Me.Btn_Test.Left = Me(s_obj).Left
Me.Btn_Test.Visible = True
s_obj = s_tier & (numActive + 1)
'Make Test button visible and move to appropriate place
Me.btn_SQL.Top = Me(s_obj).Top
Me.btn_SQL.Left = Me(s_obj).Left
Me.btn_SQL.Visible = True
Me.Refresh
The refreshed form now looks like this if "1" is selected in the combo box:
... Or if "2" is selected in the combo box:
... Or if "3" is selected in the combo box:
The key to my method is to use the sequential naming convention as a way to exploit the
for i = 1 to numactive
piece of code. Once the loop ends, all of the static controls are visible. I can add 1 the numactive variable to determine where the first invisible control is, and anchor my 'floating' controls to that position.
This method can be tweaked to actually place any control into any position using offsets instead of the position of other controls. Let your imagination run wild!
WinForms of course has the FlowLayoutPanel and TableLayoutPanel..
There's an example of AutoLayout for Winforms on MSDN.

Use .net reactive in silverlight to generate multiple events

I have a method in a silverlight application. I want to start calling this method when an event occurs (mouse move), and continue to call this method every 1 second until a simple boolean condition changes. Is this possible ? I can't work out how to get the rx to generate multiple 'events' from the single event
Here's a method that I used to do this:
var isChecked = from f in Observable.FromEvent<RoutedEventHandler, RoutedEventArgs>(
h => new RoutedEventHandler(h),
h => checkBox1.Checked += h,
h => checkBox1.Checked -= h)
where checkBox1.IsChecked == true
select new Unit();
var xs = from click in Observable.FromEvent<RoutedEventHandler, RoutedEventArgs>(
h => new RoutedEventHandler(h),
h => button1.Click += h,
h => button1.Click -= h)
from ping in Observable.Interval(TimeSpan.FromSeconds(1.0)).TakeUntil(isChecked)
select ping;
_subscription = xs.ObserveOnDispatcher().Subscribe(v => label1.Content = v.ToString());
I created a button to begin the events on click. I created a check box that will stop the events when it is checked. This may not be exactly what you want but the events fire as you asked and you should be able to make modifications to suit from here.

Resources