Archive

Archive for the ‘C#’ Category

Jimmar's blog thingie

Aaaaaand I finally managed to start writing this tutorial .. sorry for the delay [was busy wasting my time and others’ too].

if you haven’t checked my previous 2 tutorials, you may need to do so to keep up, this tutorial will continue after my second one:

1 – AndEngine Simple Android Game Tutorial

2 – Simple AndEngine Game V1.5 [using pools]

This tutorial will cover:
– Moving Sprites with touch [follow your finger]
– Animating Sprites [AnimatedSprite]
– Enabling MultiTouch
– Simple Cooldown class
– Moving background [AutoParallaxBackground]

If you lost your project or modified it, you can download the one I provided at the end of the pools tutorial which I’ll base my tutorial on.

One final note, the Sprites I’m providing will be to support the hdpi resolution [480*800 to be precise] and may not [won’t] look good on other resolutions.

View original post 2,692 more words

Advertisements
Categories: C#

Formatpastcode numeric

Private Sub Command1_Click()
FormatPasteCode rtb.Text, 1
End Sub
Private Sub FormatPasteCode(str As String, currentpos As Integer)
Dim i As Integer
Dim oldPos As Integer
Dim str1 As String
i = currentpos
oldPos = currentpos
Do While i <= Len(str)
If i <> Len(str) Then
If Mid(str, i, 1) = ” ” Or Mid(str, i, 1) = vbTab Then
str1 = Mid(str, oldPos, i – oldPos)
If IsNumeric(str1) Then
ColorWord rtb, oldPos, i – oldPos, vbRed
End If
oldPos = i
ElseIf Mid(str, i, 1) = vbCr Then
str1 = Mid(str, oldPos, i – oldPos)
If IsNumeric(str1) Then
ColorWord rtb, oldPos, i – oldPos, vbRed
End If
oldPos = i + 1
End If
i = i + 1
Else
str1 = Mid(str, oldPos, i – oldPos)
If IsNumeric(str1) Then
ColorWord rtb, oldPos, i – oldPos, vbRed
End If
Exit Do
End If
Loop
End Sub

Private Sub ColorWord(rtb As RichTextBox, start As Integer, length As Integer, color As Long)
Dim oldPos As Integer
oldPos = rtb.SelStart
rtb.SelStart = start
rtb.SelLength = length
rtb.SelColor = color
End Sub

Private Sub Form_Resize()
rtb.Width = ScaleWidth – 800
rtb.Height = ScaleHeight – 800
End Sub

Categories: C#

Line numbers in RichTextBox VB6

Option Explicit

Private Declare Function SendMessage Lib “user32” Alias “SendMessageA” ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long

Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINEINDEX = &HBB

Private Sub GetLineNumber(rtb As RichTextBox)
Dim lines As Long
Dim i As Long
lines = SendMessage(rtb.hwnd, EM_GETLINECOUNT, 0&, 0&)
lblNumber.Caption = “”
For i = 1 To lines
lblNumber.Caption = lblNumber.Caption & CStr(i) & vbCrLf
Next i
End Sub

Private Sub GetCurrentLine(rtb As RichTextBox)
Dim lines As Long
Dim i, j As Long
Dim LN As Long
Dim curLine As Long

lines = SendMessage(rtb.hwnd, EM_GETLINECOUNT, 0&, 0&)
lblNumber.Caption = “”
For i = 1 To lines
If LN = SendMessage(rtb.hwnd, EM_LINEINDEX, i – 1, 0) Then Exit For
Next i
curLine = LN
For j = 1 To lines
If j = curLine Then
lblNumber.Caption = lblNumber.Caption & “* ” & CStr(j) & vbCrLf
Else
lblNumber.Caption = lblNumber.Caption & CStr(j) & vbCrLf
End If
Next j

End Sub
Private Sub rtb_Change()
GetCurrentLine rtb
End Sub

Private Sub UserControl_Initialize()
lblNumber.Height = rtb.Height
End Sub

Categories: C#

Làm sao để 1 control đang active ko bi mất active khi click 1 control khác

public partial class Form3 : Form,IMessageFilter
{
public Form3()
{
InitializeComponent();
Application.AddMessageFilter(this);
}

private const int WM_LBUTTONDOWN = 0x201;

public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_LBUTTONDOWN)
{
//button1 la nut ma ban click nhung ko cho active
if (m.HWnd == button1.Handle)
{
//Tao ham sendkey cua ban o day
return true;
}
}
return false;
}
}

Categories: C#

DataDings

DataTable dt = new DataTable();
dt.Columns.Add(“Code”, typeof(string));
dt.Columns.Add(“Name”, typeof(string));
dt.Rows.Add(“001”, “Mango”);
dt.Rows.Add(“002”, “Android”);
dt.Rows.Add(“003”, “Ginger bread”);
dt.Rows.Add(“004”, “Android 4.0”);
cboUser.DataSource = dt;
cboUser.DisplayMember = “Name”;
cboUser.ValueMember = “Code”;
txtCode.DataBindings.Add(“Text”, dt, “Code”);
txtName.DataBindings.Add(“Text”, dt, “Name”);

Categories: C#

Di chuyển con trỏ đến cuối trên DataGridViewTextBoxCell

private void dgvData_CellEnter(object sender, DataGridViewCellEventArgs e)
{
DataGridView dgv = (DataGridView)sender;
DataGridViewTextBoxCell textBoxCell = dgv.CurrentCell as DataGridViewTextBoxCell;
if (textBoxCell != null)
{
dgv.BeginEdit(false);
}
}

Categories: C#

Code to make keyboard

Show Recent Messages (F3)

Huynh Thanh Du: const int WS_EX_NOACTIVATE = 0x08000000;

protected override CreateParams CreateParams
{
get
{
CreateParams param = base.CreateParams;
param.ExStyle |= WS_EX_NOACTIVATE;
return param;
}
}

private void button1_Click(object sender, EventArgs e)
{
SendKeys.Send(“a”);
}

Categories: C#