|
Hi Richard. I think I misunderstood what you were looking to do. I'm glad you got the information you needed from Baris' post.
|
|
|
|
|
DateTime dt = DateTime.Now
gives me american date and not the british format d/m/y
i need the d/m/y
please
|
|
|
|
|
Internal representation of the DateTime object is not culture specific. It's the way you format it in ToString method.
DateTime.Now.ToString("dd/MM/yyyy");
note the capital MM if you put mm you will get minutes not the current month.
|
|
|
|
|
fantastic, i also noted in control panel (XP) a setting with American Language but I never knew about the ToString parameter very useful
|
|
|
|
|
This is also useful when using String.Format or Console.WriteLine . See the DateTimeFormatInfo documentation for more information, as well as my article, Custom String Formatting in .NET[^] for much more information, as well as links to other resources in the .NET Framework SDK.
Formatting strings properly in .NET is good to know.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
did you see my code about the error today a copy of my Tabpage class wonder if you have any thoughts
|
|
|
|
|
Also, read the docs for the CultureInfo class. If you need to convert dates and times from one culture to another, you can use the current CultureInfo as well as a specified culture and use their Calendar property to help convert. Also, if you are creating international applications, it's better to use DateTime.UtcNow to get the coordinated universal time.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there a way to get the scrollinfo of the TreeView?
I have tried PInvoke but doens't seem to work. Anyone sheds the light?
below are my codes
using System.Runtime.InteropServices;
public struct SCROLLINFO
{
uint cbSize;
uint fMask;
int nMin;
int nMax;
uint nPage;
int nPos;
int nTrackPos;
}
[DllImport("user32")] public static extern int GetScrollInfo(IntPtr hwnd, int n, ref SCROLLINFO lpScrollInfo);
//calling part
const int SB_VERT = 1;
SCROLLINFO si = new SCROLLINFO();
GetScrollInfo(this.tvStat.Handle, SB_VERT, ref si);
//the si return is all zeros. Doesn't work apparently
thanx
<B>Sonork 100.41263:Anthony_Yio
Life is about experiencing ... </B>
|
|
|
|
|
Before calling GetScrollInfo you must set the cbSize and fMask fields of the structure, which is also documented for the GetScrollInfo API and is common among many APIs that take structs as params so that they know the size of the struct, which makes the API more robust.
To do this, use the static Marshal.SizeOf method from the System.Runtime.InteropServices namespace.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I see, will try that, thanks.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
As per the subject, does anyone have even the faintest idea, using C#, of how I make a thumbnail screenshot of a webpage programatically? There are one or two ActiveX components out there that do this, and they render it exactly as IE would, which leads me to believe that it's some kind of functionality in IE. Perhaps it's somehow loading the website into an invisible browser window and taking a screenshot that way? I need to work this out for at least two or three tasks I'd like to implement solutions for. Please note that this has to be able to be completely automatic and doable from nothing more than a given URL.
NATHAN RIDLEY
Web Application Developer
email: nathan @ netlab.com.au
[remove the spaces before and after the @ symbol]
|
|
|
|
|
|
Thanks Mike, looks like it could exactly what I'm after!
NATHAN RIDLEY
Web Application Developer
email: nathan @ netlab.com.au
[remove the spaces before and after the @ symbol]
|
|
|
|
|
I'm trying to set the text of an item of a TreeView to bold. When i set the node font, the node continues to use the same width space for drawing the text as where the font was "plain", so the label is trunked at the end. There's a way to update correctly the space of the node?
i've used this code before adding the node to the Nodes collection:
<br />
TreeNode node = new TreeNode("Test", 0, 0);<br />
node.NodeFont = new Font(treeView.Font, FontStyle.Bold);<br />
<br />
treeView.Nodes.Add(node);<br />
|
|
|
|
|
Yes there is a workaround:
node.Font = new Font(someotherfont..);<br />
node.Text = node.Text;
I know it looks silly, but it's the only workaround I found to force the treeview to recalculate the size of text with the new font/style etc.
|
|
|
|
|
This makes sense, since setting the Text property actually causes the class to send the TVM_SETITEM message to the underlying Tree-View common control with the TVIF_TEXT flag to set the text. If you set the text first, the underlying tree view probably isn't sent the text mask and hence the text is not sent. This would best be called a bug, but why it is necessary does make sense if you understand how the TreeView class works (i.e., it encapsulates its respective common control, as do most controls in Windows Forms).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i cant see any differencies using that workaround. However i'm setting the new font before adding the node to the treeview, so the text area'd must be already recalculated, or not?
|
|
|
|
|
when i go into designer i get lots of errors but when i run the project all is well
errors say 'operation is not valid due to the current state of the object'
86 errors in total any ideas. my friend Heath is helping me lots so this is for him but appreciate any help between now and then as he is in the usa fast asleep
|
|
|
|
|
here is some code from the page
using System;
using System.Windows.Forms;
using System.Drawing;
using DGIBO;
using System.Data;
using Patriot;
using System.ComponentModel;
namespace Patriot
{
///
/// Summary description for HeatingPage.
///
public class LoftPage:TabPage
{
private System.ComponentModel.Container components = null;
public LoftPage()
{
InitializeComponent();
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region private fields
Job job;
#region p group1
private GroupBox groupBox1;
private TextBox txtJobNo;
private Label lblJobNo;
private Label lblWksOrderNo;
private TextBox txtWksOrderNo;
private Label lblApprovalNo;
private TextBox txtApprovalNo;
private Label lblGuarantee;
private ComboBox ddlGuarantee;
private Label lblMaterial;
private ComboBox ddlMaterial;
private Label lblSqrMeters;
private TextBox txtSqrMeters;
private Label lblSalePoints;
private TextBox txtSalePoints;
private Label lblScheme;
private ComboBox ddlScheme;
private Label lblPhase;
private ComboBox ddlPhase;
#endregion
#region p group2
// group 2
//
private GroupBox groupBox2;
private DataGrid dtgInvoice;
private DataGrid dtgAddWork;
private DataGrid dtgAddPoints;
private Label lblDeposit;
private TextBox txtDeposit;
#endregion
#region p group3
private GroupBox groupBox3;
private Label lblCrew;
private ComboBox ddlCrew;
private Label lblNo1;
private ComboBox ddlNo1;
private Label lblNo2;
private ComboBox ddlNo2;
private Label lblNo3;
private ComboBox ddlNo3;
private Label lblNotes;
private TextBox txtNotes;
private Label lblJobOrder;
private TextBox txtJobOrder;
private Label lblDateBooked;
private TextBox txtDateBooked;
private Label lblDayBooked;
private TextBox txtDayBooked;
private Label lblWeekNo;
private TextBox txtWeekNo;
private Label lblInstalledDate;
private TextBox txtInstalledDate;
private Label lblInstalledWeek;
private TextBox txtInstalledWeek;
private Label lblHours;
private TextBox txtHours;
private Label lblPointsDone;
private TextBox txtPointsDone;
private Button btnCancelBooking;
private Button btnSameAsBkd;
private Label lblBkdRemedial;
private TextBox txtBkdRemedial;
private Label lblRemedialDate;
private TextBox txtRemedialDate;
#endregion
#region p group4
private GroupBox groupBox4;
private Label lblCancelledDate;
private TextBox txtCancelledDate;
private Label lblCancelledWeek;
private TextBox txtCancelledWeek;
private Label lblDeductWeek;
private TextBox txtDeductWeek;
private Label lblReason;
private ComboBox ddlReason;
private TextBox txtReason;
private Button btnInvoice;
private CheckBox chkInvoice;
private Button btnCancel;
private Button btnPrintT;
private CheckBox chkPrintT;
private Button btnThisWeek;
#endregion
#region p group5
private GroupBox groupBox5;
private DataGrid dtgMaterial;
#endregion
#endregion
private void InitializeComponent()
{
this.SuspendLayout();
BackColor = System.Drawing.Color.Aquamarine;
ForeColor = System.Drawing.SystemColors.MenuText;
Location = new System.Drawing.Point(4, 22);
TabIndex = 0;
Text = "";
ToolTipText = "";
#region Group1 new controls
groupBox1 = new System.Windows.Forms.GroupBox();
groupBox1.SuspendLayout();
txtJobNo = new TextBox();
lblJobNo = new Label();
lblWksOrderNo = new Label();
txtWksOrderNo = new TextBox();
lblApprovalNo = new Label();
txtApprovalNo = new TextBox();
lblGuarantee = new Label();
ddlGuarantee = new ComboBox();
lblMaterial = new Label();
ddlMaterial = new ComboBox();
lblSqrMeters = new Label();
txtSqrMeters = new TextBox();
lblSalePoints = new Label();
txtSalePoints = new TextBox();
lblScheme = new Label();
ddlScheme = new ComboBox();
lblPhase = new Label();
ddlPhase = new ComboBox();
Controls.Add(this.groupBox1);
this.groupBox1.Controls.Add(this.lblJobNo);
this.groupBox1.Controls.Add(this.txtJobNo);
this.groupBox1.Controls.Add(lblWksOrderNo);
this.groupBox1.Controls.Add(txtWksOrderNo);
this.groupBox1.Controls.Add(lblApprovalNo);
this.groupBox1.Controls.Add(txtApprovalNo);
this.groupBox1.Controls.Add(lblGuarantee);
this.groupBox1.Controls.Add(ddlGuarantee);
this.groupBox1.Controls.Add(lblMaterial);
this.groupBox1.Controls.Add(ddlMaterial);
this.groupBox1.Controls.Add(lblSqrMeters);
this.groupBox1.Controls.Add(txtSqrMeters);
this.groupBox1.Controls.Add(lblSalePoints);
this.groupBox1.Controls.Add(txtSalePoints);
this.groupBox1.Controls.Add(lblScheme);
this.groupBox1.Controls.Add(ddlScheme);
this.groupBox1.Controls.Add(lblPhase);
this.groupBox1.Controls.Add(ddlPhase);
this.groupBox1.Location = new Point(8,8);
this.groupBox1.Size = new System.Drawing.Size(1008, 88);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//this.groupBox1.BackColor = Color.PaleGoldenrod;
//
// lblJobNo
//
this.lblJobNo.Location = new System.Drawing.Point(16, 24);
this.lblJobNo.Name = "lblJobNo";
this.lblJobNo.Size = new System.Drawing.Size(56, 23);
this.lblJobNo.TabIndex = 1;
this.lblJobNo.Text = "Job No:";
//
// txtJobNo
//
this.txtJobNo.Location = new System.Drawing.Point(80, 24);
this.txtJobNo.Size = new System.Drawing.Size(100, 20);
this.txtJobNo.TabIndex = 2;
this.txtJobNo.Text = "";
//this.txtJobNo.Validating += new System.ComponentModel.CancelEventHandler(this.txtJobNo_Validating);
//
// lblWksOrderNo
//
this.lblWksOrderNo.Location = new System.Drawing.Point(192, 24);
this.lblWksOrderNo.Size = new System.Drawing.Size(80, 23);
this.lblWksOrderNo.TabIndex = 3;
this.lblWksOrderNo.Text = "Wks Order No:";
//
// txtWksOrderNo
//
this.txtWksOrderNo.Location = new System.Drawing.Point(272, 24);
this.txtWksOrderNo.Size = new System.Drawing.Size(100, 20);
this.txtWksOrderNo.TabIndex = 4;
this.txtWksOrderNo.Text = "";
//
// lblApprovalNo
//
this.lblApprovalNo.Location = new System.Drawing.Point(376, 24);
this.lblApprovalNo.Size = new System.Drawing.Size(80, 23);
this.lblApprovalNo.TabIndex = 5;
this.lblApprovalNo.Text = "Approval No:";
//
// txtApprovalNo
//
this.txtApprovalNo.Location = new System.Drawing.Point(464, 24);
this.txtApprovalNo.Size = new System.Drawing.Size(100, 20);
this.txtApprovalNo.TabIndex = 6;
this.txtApprovalNo.Text = "";
//
// lblGuarantee
//
this.lblGuarantee.Location = new System.Drawing.Point(576, 24);
this.lblGuarantee.Size = new System.Drawing.Size(104, 23);
this.lblGuarantee.TabIndex = 7;
this.lblGuarantee.Text = "Guarantee Type:";
//
// ddlGuarantee
//
this.ddlGuarantee.Location = new System.Drawing.Point(696, 24);
this.ddlGuarantee.Size = new System.Drawing.Size(121, 21);
this.ddlGuarantee.TabIndex = 8;
//
// lblMaterial
//
this.lblMaterial.Location = new System.Drawing.Point(16, 56);
this.lblMaterial.Size = new System.Drawing.Size(56, 23);
this.lblMaterial.TabIndex = 9;
this.lblMaterial.Text = "Material:";
//
// ddlMaterial
//
this.ddlMaterial.Location = new System.Drawing.Point(80, 56);
this.ddlMaterial.Size = new System.Drawing.Size(208, 21);
this.ddlMaterial.TabIndex = 10;
//
// lblSqrMeters
//
this.lblSqrMeters.Location = new System.Drawing.Point(304, 56);
this.lblSqrMeters.Size = new System.Drawing.Size(72, 23);
this.lblSqrMeters.TabIndex = 11;
this.lblSqrMeters.Text = "Sqr Meters:";
//
// txtSqrMeters
//
this.txtSqrMeters.Location = new System.Drawing.Point(368, 56);
this.txtSqrMeters.Size = new System.Drawing.Size(56, 20);
this.txtSqrMeters.TabIndex = 13;
this.txtSqrMeters.Text = "";
//
// lblSalePoints
//
this.lblSalePoints.Location = new System.Drawing.Point(432, 56);
this.lblSalePoints.Size = new System.Drawing.Size(72, 23);
this.lblSalePoints.TabIndex = 14;
this.lblSalePoints.Text = "Sale points:";
//
// txtSalePoints
//
this.txtSalePoints.Location = new System.Drawing.Point(512, 56);
this.txtSalePoints.Size = new System.Drawing.Size(48, 20);
this.txtSalePoints.TabIndex = 15;
this.txtSalePoints.Text = "";
//
// lblScheme
//
this.lblScheme.Location = new System.Drawing.Point(576, 56);
this.lblScheme.Size = new System.Drawing.Size(56, 23);
this.lblScheme.TabIndex = 16;
this.lblScheme.Text = "Scheme:";
//
//ddlScheme
//
this.ddlScheme.Location = new System.Drawing.Point(656,56);
this.ddlScheme.Size = new System.Drawing.Size(144,21);
this.ddlScheme.TabIndex = 17;
this.ddlScheme.Text = "";
// fill data
Schemes(this.ddlScheme);
this.ddlScheme.SelectionChangeCommitted +=new EventHandler(ddlScheme_SelectionChangeCommitted);
//
// lblPhase
//
this.lblPhase.Location = new System.Drawing.Point(816, 56);
this.lblPhase.Size = new System.Drawing.Size(48, 23);
this.lblPhase.TabIndex = 18;
this.lblPhase.Text = "Phase:";
this.ddlPhase.SelectionChangeCommitted +=new EventHandler(ddlPhase_SelectionChangeCommitted);
//
//ddlPhase
//
this.ddlPhase.Location = new System.Drawing.Point(880,56);
this.ddlPhase.Size = new System.Drawing.Size(121,21);
this.ddlPhase.TabIndex = 19;
this.ddlPhase.Text = "";
this.groupBox1.ResumeLayout(false);
#endregion
#region Group2 new controls
this.groupBox2 = new System.Windows.Forms.GroupBox();
//suspend layout then call resume to set prpoerties of containers
this.groupBox2.SuspendLayout();
this.lblDeposit = new Label();
this.txtDeposit = new TextBox();
this.dtgInvoice = new DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dtgInvoice)).BeginInit();
this.dtgAddWork = new DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dtgAddWork)).BeginInit();
this.dtgAddPoints = new DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dtgAddPoints)).BeginInit();
Controls.Add(this.groupBox2);
this.groupBox2.Controls.Add(this.lblDeposit);
this.groupBox2.Controls.Add(this.txtDeposit);
this.groupBox2.Controls.Add(this.dtgInvoice);
this.groupBox2.Controls.Add(this.dtgAddWork);
this.groupBox2.Controls.Add(this.dtgAddPoints);
this.groupBox2.Location = new Point(8,104);
this.groupBox2.Size = new System.Drawing.Size(824, 240);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
//
//dtgInvoice
//
dtgInvoice.BorderStyle = BorderStyle.FixedSingle;
dtgInvoice.CaptionText = "Invoice";
dtgInvoice.FlatMode = true;
dtgInvoice.HeaderForeColor = SystemColors.ControlText;
dtgInvoice.Location = new Point(8,12);
dtgInvoice.Size = new Size(312,184);
dtgInvoice.TabIndex = 0;
//
//dtgAddWork
//
dtgAddWork.BorderStyle = BorderStyle.FixedSingle;
dtgAddWork.CaptionText = "Additional Work";
dtgAddWork.FlatMode = true;
dtgAddWork.HeaderForeColor = SystemColors.ControlText;
dtgAddWork.Location = new Point(328,12);
dtgAddWork.Size = new Size(312,216);
dtgAddWork.TabIndex = 1;
//
//dtgAddPoints
//
dtgAddPoints.BorderStyle = BorderStyle.FixedSingle;
dtgAddPoints.CaptionText = "Additional Points";
dtgAddPoints.FlatMode = true;
dtgAddPoints.HeaderForeColor = SystemColors.ControlText;
dtgAddPoints.Location = new Point(648,12);
dtgAddPoints.Size = new Size(168,216);
dtgAddPoints.TabIndex = 2;
//
// lblDeposit
//
this.lblDeposit.Location = new System.Drawing.Point(8,208);
this.lblDeposit.Size = new System.Drawing.Size(56, 23);
this.lblDeposit.TabIndex = 3;
this.lblDeposit.Text = "Deposit:";
//
// txtDeposit
//
this.txtDeposit.Location = new System.Drawing.Point(72,203);
this.txtDeposit.Size = new System.Drawing.Size(100, 20);
this.txtDeposit.TabIndex = 3;
this.txtDeposit.Text = "";
this.groupBox2.ResumeLayout(false);
#endregion
#region Group 3
this.groupBox3 = new System.Windows.Forms.GroupBox();
//suspend layout then call resume to set prpoerties of containers
this.groupBox3.SuspendLayout();
groupBox3 = new GroupBox();
lblCrew = new Label();
ddlCrew = new ComboBox();
lblNo1 = new Label();
ddlNo1 = new ComboBox();
lblNo2 = new Label();
ddlNo2 = new ComboBox();
lblNo3 = new Label();
ddlNo3 = new ComboBox();
lblNotes = new Label();
txtNotes = new TextBox();
lblJobOrder = new Label();
txtJobOrder = new TextBox();
lblDateBooked = new Label();
txtDateBooked = new TextBox();
lblDayBooked = new Label();
txtDayBooked = new TextBox();
lblWeekNo = new Label();
txtWeekNo = new TextBox();
lblInstalledDate = new Label();
txtInstalledDate = new TextBox();
lblInstalledWeek = new Label();
txtInstalledWeek = new TextBox();
lblHours = new Label();
txtHours = new TextBox();
lblPointsDone = new Label();
txtPointsDone = new TextBox();
btnCancelBooking = new Button();
btnSameAsBkd = new Button();
lblBkdRemedial = new Label();
txtBkdRemedial = new TextBox();
lblRemedialDate = new Label();
txtRemedialDate = new TextBox();
Controls.Add(this.groupBox3);
this.groupBox3.Controls.Add(this.lblCrew);
this.groupBox3.Controls.Add(this.ddlCrew);
this.groupBox3.Controls.Add(this.lblNo1);
this.groupBox3.Controls.Add(this.ddlNo1);
this.groupBox3.Controls.Add(this.lblNo2);
this.groupBox3.Controls.Add(this.ddlNo2);
this.groupBox3.Controls.Add(this.lblNo3);
this.groupBox3.Controls.Add(this.ddlNo3);
this.groupBox3.Controls.Add(this.lblNotes);
this.groupBox3.Controls.Add(this.txtNotes);
this.groupBox3.Controls.Add(this.lblJobOrder);
this.groupBox3.Controls.Add(this.txtJobOrder);
this.groupBox3.Controls.Add(this.lblDateBooked);
this.groupBox3.Controls.Add(this.txtDateBooked);
this.groupBox3.Controls.Add(this.lblDayBooked);
this.groupBox3.Controls.Add(this.txtDayBooked);
this.groupBox3.Controls.Add(this.lblWeekNo);
this.groupBox3.Controls.Add(this.txtWeekNo);
this.groupBox3.Controls.Add(this.lblInstalledDate);
this.groupBox3.Controls.Add(this.txtInstalledDate);
this.groupBox3.Controls.Add(this.lblInstalledWeek);
this.groupBox3.Controls.Add(this.txtInstalledWeek);
this.groupBox3.Controls.Add(this.lblHours);
this.groupBox3.Controls.Add(this.txtHours);
this.groupBox3.Controls.Add(this.lblPointsDone);
this.groupBox3.Controls.Add(this.txtPointsDone);
this.groupBox3.Controls.Add(this.btnCancelBooking);
this.groupBox3.Controls.Add(this.btnSameAsBkd);
this.groupBox3.Controls.Add(this.lblBkdRemedial);
this.groupBox3.Controls.Add(this.txtBkdRemedial);
this.groupBox3.Controls.Add(this.lblRemedialDate);
this.groupBox3.Controls.Add(this.txtRemedialDate);
//
//gpBox3
//
this.groupBox3.Location = new Point(8,352);
this.groupBox3.Size = new System.Drawing.Size(616,256);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
//
// lblCrew
//
this.lblCrew.Location = new System.Drawing.Point(8,24);
this.lblCrew.Size = new System.Drawing.Size(40, 23);
this.lblCrew.TabIndex = 0;
this.lblCrew.Text = "Crew:";
//
//ddlCrew
//
this.ddlCrew.Location = new System.Drawing.Point(48,24);
this.ddlCrew.Size = new System.Drawing.Size(80,21);
this.ddlCrew.TabIndex = 1;
this.ddlCrew.Text = "";
//
// lblNo1
//
this.lblNo1.Location = new System.Drawing.Point(8,56);
this.lblNo1.Size = new System.Drawing.Size(32, 23);
this.lblNo1.TabIndex = 2;
this.lblNo1.Text = "No1:";
//
//ddlNo1
//
this.ddlNo1.Location = new System.Drawing.Point(48,56);
this.ddlNo1.Size = new System.Drawing.Size(136,21);
this.ddlNo1.TabIndex = 3;
this.ddlNo1.Text = "";
//
// lblNo2
//
this.lblNo2.Location = new System.Drawing.Point(8,88);
this.lblNo2.Size = new System.Drawing.Size(32, 23);
this.lblNo2.TabIndex = 4;
this.lblNo2.Text = "No2:";
//
//ddlNo2
//
this.ddlNo2.Location = new System.Drawing.Point(48,88);
this.ddlNo2.Size = new System.Drawing.Size(136,21);
this.ddlNo2.TabIndex = 5;
this.ddlNo2.Text = "";
//
// lblNo3
//
this.lblNo3.Location = new System.Drawing.Point(8,120);
this.lblNo3.Size = new System.Drawing.Size(32, 23);
this.lblNo3.TabIndex = 6;
this.lblNo3.Text = "No3:";
//
//ddlNo3
//
this.ddlNo3.Location = new System.Drawing.Point(48,120);
this.ddlNo3.Size = new System.Drawing.Size(136,21);
this.ddlNo3.TabIndex = 7;
this.ddlNo3.Text = "";
//
// lblNotes
//
this.lblNotes.Location = new System.Drawing.Point(8, 152);
this.lblNotes.Size = new System.Drawing.Size(72, 23);
this.lblNotes.TabIndex = 8;
this.lblNotes.Text = "Crew Notes:";
//
// txtNotes
//
this.txtNotes.Location = new System.Drawing.Point(96, 152);
this.txtNotes.Size = new System.Drawing.Size(312, 72);
this.txtNotes.Multiline = true;
this.txtNotes.TabIndex = 9;
this.txtNotes.Text = "";
//
// lblJobOrder
//
this.lblJobOrder.Location = new System.Drawing.Point(200,24);
this.lblJobOrder.Size = new System.Drawing.Size(80, 23);
this.lblJobOrder.TabIndex = 10;
this.lblJobOrder.Text = "Job Order:";
//
// txtJobOrder
//
this.txtJobOrder.Location = new System.Drawing.Point(288,24);
this.txtJobOrder.Size = new System.Drawing.Size(40,20);
this.txtJobOrder.TabIndex = 11;
this.txtJobOrder.Text = "";
//
// lblDateBooked
//
this.lblDateBooked.Location = new System.Drawing.Point(200,56);
this.lblDateBooked.Size = new System.Drawing.Size(80, 23);
this.lblDateBooked.TabIndex = 12;
this.lblDateBooked.Text = "Date Booked:";
//
// txtDateBooked
//
this.txtDateBooked.Location = new System.Drawing.Point(288,56);
this.txtDateBooked.Size = new System.Drawing.Size(72,20);
this.txtDateBooked.TabIndex = 13;
this.txtDateBooked.Text = "";
this.txtDateBooked.Leave += new EventHandler(txtDateBooked_Leave);
//
// lblDayBooked
//
this.lblDayBooked.Location = new System.Drawing.Point(200,88);
this.lblDayBooked.Size = new System.Drawing.Size(80, 23);
this.lblDayBooked.TabIndex = 14;
this.lblDayBooked.Text = "Day Booked:";
//
// txtDayBooked
//
this.txtDayBooked.Location = new System.Drawing.Point(288,88);
this.txtDayBooked.Size = new System.Drawing.Size(72,20);
this.txtDayBooked.TabIndex = 15;
this.txtDayBooked.Text = "";
//
// lblWeekNo
//
this.lblWeekNo.Location = new System.Drawing.Point(200,120);
this.lblWeekNo.Size = new System.Drawing.Size(80, 23);
this.lblWeekNo.TabIndex = 16;
this.lblWeekNo.Text = "Week No:";
//
// txtWeekNo
//
this.txtWeekNo.Location = new System.Drawing.Point(288,120);
this.txtWeekNo.Size = new System.Drawing.Size(32,20);
this.txtWeekNo.TabIndex = 17;
this.txtWeekNo.Text = "";
//
// lblInstalledDate
//
this.lblInstalledDate.Location = new System.Drawing.Point(368,24);
this.lblInstalledDate.Size = new System.Drawing.Size(80, 23);
this.lblInstalledDate.TabIndex = 18;
this.lblInstalledDate.Text = "Installed Date:";
//
// txtInstalledDate
//
this.txtInstalledDate.Location = new System.Drawing.Point(456,24);
this.txtInstalledDate.Size = new System.Drawing.Size(72,20);
this.txtInstalledDate.TabIndex = 19;
this.txtInstalledDate.Text = "";
this.txtInstalledDate.Leave +=new EventHandler(txtInstalledDate_Leave);
//
// lblInstalledWeek
//
this.lblInstalledWeek.Location = new System.Drawing.Point(368,56);
this.lblInstalledWeek.Size = new System.Drawing.Size(88, 23);
this.lblInstalledWeek.TabIndex = 20;
this.lblInstalledWeek.Text = "Installed Week:";
//
// txtInstalledWeek
//
this.txtInstalledWeek.Location = new System.Drawing.Point(456,56);
this.txtInstalledWeek.Size = new System.Drawing.Size(32,20);
this.txtInstalledWeek.TabIndex = 21;
this.txtInstalledWeek.Text = "";
//
// lblHours
//
this.lblHours.Location = new System.Drawing.Point(368,88);
this.lblHours.Size = new System.Drawing.Size(80, 23);
this.lblHours.TabIndex = 22;
this.lblHours.Text = "Hours:";
//
// txtHours
//
this.txtHours.Location = new System.Drawing.Point(456,88);
this.txtHours.Size = new System.Drawing.Size(32,20);
this.txtHours.TabIndex = 23;
this.txtHours.Text = "";
//
// lblPointsDone
//
this.lblPointsDone.Location = new System.Drawing.Point(368,120);
this.lblPointsDone.Size = new System.Drawing.Size(80, 23);
this.lblPointsDone.TabIndex = 24;
this.lblPointsDone.Text = "Points Done:";
//
// txtPointsDone
//
this.txtPointsDone.Location = new System.Drawing.Point(456,120);
this.txtPointsDone.Size = new System.Drawing.Size(72,20);
this.txtPointsDone.TabIndex = 25;
this.txtPointsDone.Text = "";
//
//btnCancelBooking
//
this.btnCancelBooking.Location = new Point(536,24);
this.btnCancelBooking.Size = new Size(75,40);
this.btnCancelBooking.BackColor = Color.Red;
this.btnCancelBooking.TabIndex = 26;
this.btnCancelBooking.Text = "Cancel Booking";
//
//btnSameAsBkd
//
this.btnSameAsBkd.Location = new Point(536,72);
this.btnSameAsBkd.Size = new Size(75,40);
this.btnSameAsBkd.TabIndex = 27;
this.btnSameAsBkd.Text = "Same As Booked";
//
// lblBkdRemedial
//
this.lblBkdRemedial.Location = new System.Drawing.Point(448,152);
this.lblBkdRemedial.Size = new System.Drawing.Size(88, 23);
this.lblBkdRemedial.TabIndex = 28;
this.lblBkdRemedial.Text = "Bkd Remedial:";
//
// txtBkdRemedial
//
this.txtBkdRemedial.Location = new System.Drawing.Point(536,152);
this.txtBkdRemedial.Size = new System.Drawing.Size(72,20);
this.txtBkdRemedial.TabIndex = 29;
this.txtBkdRemedial.Text = "";
//
// lblRemedialDate
//
this.lblRemedialDate.Location = new System.Drawing.Point(448,176);
this.lblRemedialDate.Size = new System.Drawing.Size(88, 23);
this.lblRemedialDate.TabIndex = 30;
this.lblRemedialDate.Text = "Remedial Date:";
//
// txtRemedialDate
//
this.txtRemedialDate.Location = new System.Drawing.Point(536,176);
this.txtRemedialDate.Size = new System.Drawing.Size(72,20);
this.txtRemedialDate.TabIndex = 31;
this.txtRemedialDate.Text = "";
this.groupBox3.ResumeLayout(false);
#endregion
#region Group 4 new controls
groupBox4 = new System.Windows.Forms.GroupBox();
groupBox4.SuspendLayout();
lblCancelledDate = new Label();
txtCancelledDate = new TextBox();
lblCancelledWeek = new Label();
txtCancelledWeek = new TextBox();
lblDeductWeek = new Label();
txtDeductWeek = new TextBox();
lblReason = new Label();
ddlReason = new ComboBox();
txtReason = new TextBox();
btnInvoice = new Button();
chkInvoice = new CheckBox();
btnCancel = new Button();
btnPrintT = new Button();
chkPrintT = new CheckBox();
btnThisWeek = new Button();
Controls.Add(this.groupBox4);
this.groupBox4.Controls.Add(lblCancelledDate);
this.groupBox4.Controls.Add(txtCancelledDate);
this.groupBox4.Controls.Add(lblCancelledWeek);
this.groupBox4.Controls.Add(txtCancelledWeek);
this.groupBox4.Controls.Add(lblDeductWeek);
this.groupBox4.Controls.Add(txtDeductWeek);
this.groupBox4.Controls.Add(lblReason);
this.groupBox4.Controls.Add(ddlReason);
this.groupBox4.Controls.Add(txtReason);
this.groupBox4.Controls.Add(btnInvoice);
this.groupBox4.Controls.Add(chkInvoice);
this.groupBox4.Controls.Add(btnCancel);
this.groupBox4.Controls.Add(btnPrintT);
this.groupBox4.Controls.Add(chkPrintT);
this.groupBox4.Controls.Add(btnThisWeek);
this.groupBox4.Location = new Point(630,352);
this.groupBox4.Size = new System.Drawing.Size(200,264);
this.groupBox4.TabIndex = 3;
this.groupBox4.TabStop = false;
//
// lblCancelledDate
//
this.lblCancelledDate.Location = new System.Drawing.Point(8, 24);
this.lblCancelledDate.Size = new System.Drawing.Size(88, 23);
this.lblCancelledDate.TabIndex = 0;
this.lblCancelledDate.Text = "Cancelled Date:";
//
// txtCancelledDate
//
this.txtCancelledDate.Location = new System.Drawing.Point(104, 24);
this.txtCancelledDate.Size = new System.Drawing.Size(88, 20);
this.txtCancelledDate.TabIndex = 1;
this.txtCancelledDate.Text = "";
this.txtCancelledDate.Leave +=new EventHandler(txtCancelledDate_Leave);
//
// lblCancelledWeek
//
this.lblCancelledWeek.Location = new System.Drawing.Point(8, 56);
this.lblCancelledWeek.Size = new System.Drawing.Size(96, 23);
this.lblCancelledWeek.TabIndex = 2;
this.lblCancelledWeek.Text = "Cancelled Week:";
//
// txtCancelledWeek
//
this.txtCancelledWeek.Location = new System.Drawing.Point(104, 56);
this.txtCancelledWeek.Size = new System.Drawing.Size(32, 20);
this.txtCancelledWeek.TabIndex = 3;
this.txtCancelledWeek.Text = "";
//
// lblDeductWeek
//
this.lblDeductWeek.Location = new System.Drawing.Point(8, 88);
this.lblDeductWeek.Size = new System.Drawing.Size(80, 23);
this.lblDeductWeek.TabIndex = 4;
this.lblDeductWeek.Text = "Deduct Week:";
//
// txtDeductWeek
//
this.txtDeductWeek.Location = new System.Drawing.Point(104, 88);
this.txtDeductWeek.Size = new System.Drawing.Size(32, 20);
this.txtDeductWeek.TabIndex = 5;
this.txtDeductWeek.Text = "";
//
// lblReason
//
this.lblReason.Location = new System.Drawing.Point(8,120);
this.lblReason.Size = new System.Drawing.Size(80, 23);
this.lblReason.TabIndex = 6;
this.lblReason.Text = "Reason:";
//
// ddlReason
//
this.ddlReason.Location = new System.Drawing.Point(104,120);
this.ddlReason.Size = new System.Drawing.Size(85, 21);
this.ddlReason.TabIndex = 7;
this.ddlReason.Text = "";
//
// txtReason
//
this.txtReason.Location = new System.Drawing.Point(8,144);
this.txtReason.Size = new System.Drawing.Size(184, 20);
this.txtReason.TabIndex = 8;
this.txtReason.Text = "";
//
// btnInvoice
//
this.btnInvoice.Location = new System.Drawing.Point(8, 176);
this.btnInvoice.Size = new System.Drawing.Size(72, 32);
this.btnInvoice.TabIndex = 9;
this.btnInvoice.Text = "Invoice Only";
//
// chkInvoice
//
this.chkInvoice.Location = new System.Drawing.Point(88, 184);
this.chkInvoice.Size = new System.Drawing.Size(16, 24);
this.chkInvoice.TabIndex = 10;
//
//btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(112,176);
this.btnCancel.Size = new System.Drawing.Size(72,32);
this.btnCancel.BackColor = Color.Red;
this.btnCancel.TabIndex = 11;
this.btnCancel.Text = "Cancel";
//
// btnPrintT
//
this.btnPrintT.Location = new System.Drawing.Point(8, 224);
this.btnPrintT.Size = new System.Drawing.Size(72, 32);
this.btnPrintT.TabIndex = 12;
this.btnPrintT.Text = "Print T Card:";
//
//chkPrintT
//
this.chkPrintT.Location = new System.Drawing.Point(88,232);
this.chkPrintT.Size = new System.Drawing.Size(16,24);
this.chkPrintT.TabIndex = 13;
//
// btnThisWeek
//
this.btnThisWeek.Location = new System.Drawing.Point(112,224);
this.btnThisWeek.Size = new System.Drawing.Size(72, 32);
this.btnThisWeek.TabIndex = 14;
this.btnThisWeek.Text = "This Week:";
this.groupBox4.ResumeLayout(false);
#endregion
#region Group 5 controls
this.groupBox5 = new System.Windows.Forms.GroupBox();
//suspend layout then call resume to set prpoerties of containers
this.groupBox5.SuspendLayout();
this.dtgMaterial = new DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dtgMaterial)).BeginInit();
Controls.Add(this.groupBox5);
this.groupBox5.Controls.Add(this.dtgMaterial);
this.groupBox5.Location = new Point(833,104);
this.groupBox5.Size = new System.Drawing.Size(176, 488);
this.groupBox5.TabIndex = 4;
this.groupBox5.TabStop = false;
//
//dtgMaterial
//
dtgMaterial.BorderStyle = BorderStyle.FixedSingle;
dtgMaterial.CaptionText = "Material Used";
dtgMaterial.FlatMode = true;
dtgMaterial.HeaderForeColor = SystemColors.ControlText;
dtgMaterial.Location = new Point(0,12);
dtgMaterial.Size = new Size(176,488);
dtgMaterial.TabIndex = 0;
this.groupBox5.ResumeLayout(false);
#endregion
this.ResumeLayout(false);
}
#region events
//private void
private void txtDateBooked_Leave(object sender,EventArgs e)
{
this.txtWeekNo.Text = DateEx.WeekNumber(Convert.ToDateTime(txtDateBooked.Text)).ToString();
this.txtDayBooked.Text = DateEx.DayOfWeek(Convert.ToDateTime(txtDateBooked.Text));
}
private void txtInstalledDate_Leave(object sender,EventArgs e)
{
this.txtInstalledWeek.Text = DateEx.WeekNumber(Convert.ToDateTime(txtInstalledDate.Text)).ToString();
}
private void txtCancelledDate_Leave(object sender,EventArgs e)
{
this.txtCancelledWeek.Text = DateEx.WeekNumber(Convert.ToDateTime(txtCancelledDate.Text)).ToString();
}
private void ddlScheme_SelectionChangeCommitted(object sender,EventArgs e)
{
Phases(this.ddlPhase,this.ddlScheme);
LoadInvoice(this.dtgInvoice,this.ddlPhase);
AddCustomDatagridStyle(this.dtgInvoice);
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.dtgInvoice.DataSource];
((DataView)cm.List).AllowNew = false;
}
private void ddlPhase_SelectionChangeCommitted(object sender,EventArgs e)
{
LoadInvoice(this.dtgInvoice,this.ddlPhase);
AddCustomDatagridStyle(this.dtgInvoice);
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.dtgInvoice.DataSource];
((DataView)cm.List).AllowNew = false;
}
#endregion
#region load drop downs
private void Schemes(ComboBox schemeName)
{
job = new DGIBO.Job();
DataTable list = job.LoadSchemes();
schemeName.Text = "Select";
schemeName.DataSource = list;
schemeName.DisplayMember = "SchemeName";
schemeName.ValueMember = "SchemeID";
}
private void Phases(ComboBox phaseName,ComboBox schemeName)
{
job = new DGIBO.Job();
DataTable list = job.LoadPhases(Convert.ToInt32(schemeName.SelectedValue.ToString()));
phaseName.DataSource = list;
phaseName.DisplayMember = "PhaseName";
phaseName.ValueMember = "PhaseID";
}
private void LoadInvoice(DataGrid invoiceJob,ComboBox phaseName)
{
job = new Job();
DataTable list = job.LoadPhasePayers(Convert.ToInt32(phaseName.SelectedValue.ToString()));
invoiceJob.DataSource = list;
}
#endregion
#region custom grid
private void AddCustomDatagridStyle(DataGrid myGrid)
{
//used for the invoice controls
//myGrid.RowHeadersVisible = false;
//myGrid.RowHeaderWidth = -50;
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.RowHeadersVisible = false;
ts1.MappingName = null;
DataGridColumnStyle textCol = new DataGridTextBoxColumn();
textCol.MappingName = "Payer";
textCol.HeaderText = "Payer";
textCol.Width = 140;
textCol.ReadOnly = true;
ts1.GridColumnStyles.Add(textCol);
DataGridColumnStyle textCol2 = new DataGridTextBoxColumn();
textCol2.MappingName = "Net";
textCol2.HeaderText = "Net";
textCol2.Width = 55;
textCol2.ReadOnly = false;
textCol2.Alignment = HorizontalAlignment.Center;
ts1.GridColumnStyles.Add(textCol2);
DataGridColumnStyle textCol3 = new DataGridTextBoxColumn();
textCol3.MappingName = "VAT";
textCol3.HeaderText = "VAT %";
textCol3.Width = 55;
textCol3.ReadOnly = true;
textCol3.Alignment = HorizontalAlignment.Center;
ts1.GridColumnStyles.Add(textCol3);
DataGridColumnStyle textCol4 = new DataGridTextBoxColumn();
textCol4.MappingName = "Gross";
textCol4.HeaderText = "Gross";
textCol4.Width = 55;
textCol4.ReadOnly = false;
textCol4.Alignment = HorizontalAlignment.Center;
ts1.GridColumnStyles.Add(textCol4);
myGrid.TableStyles.Add(ts1);
}
#endregion
}
}
|
|
|
|
|
This is a simple problem. You treat each tab page as a separate class and add them to your TabControl . Expose what properties you need to from each tab page so that the TabControl can access them. A better OO design is to pass each tab page an object (such as a DataSet or whatever is appropriate so that each tab page can assign its own properties to its controls), which is best done by deriving from another base class that derives from TabPage . You need to create a good OO design.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've been porting code to C# while using Managed DirectX 9.0b. To access memory surfaces directly i used the Surface.Lock() method, which should return an Array, but returns a byte[,]. Annoyingly, the size of this array is the size of the surface in pixels, not in bytes. E.g. working with a 100X100 pixels surface with 16bits per pixel, the method returns a byte[100,100] (half the size). Using the array position as a pointer, and navigating it manualy using SurfaceDescription.Pitch didn't help either. If you had the patience to read this, read the code:
<br />
int stride = back.SurfaceDescription.Pitch;<br />
byte[,] barr = back.Lock (Microsoft.DirectX.DirectDraw.LockFlags.SurfaceMemoryPointer );<br />
unsafe<br />
{<br />
fixed (byte* pbdata = barr)<br />
{<br />
for (int j=0; j<100; j++)<br />
{<br />
for (int i=0; i<100; i++)<br />
{<br />
*(pbdata+j*stride+2*i+1) = 0xF8;<br />
}<br />
}<br />
}<br />
}<br />
back.Unlock(barr);<br />
this should paint my surface red, but it only paints half of it red.
What am I doing wrong?
|
|
|
|
|
There used to be a bug regarding this that didn't actually lock all of the surface memory. Not sure if they've fixed it or not...
ok, that said, the Pitch property is the distance *in bytes* to the next line of the raster. So one "line" in the raster is actually Pitch bytes long. Hence, one pixel is (Pitch/width) bytes long. Methinks you're addressing the wrong chunk of memory as a result.
Jeremy Kimball
magnae clunes mihi placent, nec possum de hac re mentiri.
(Large buttocks are pleasing to me, nor am I able to lie concerning this matter)
|
|
|
|
|
Thanks, u'r absolutely right about the pitch. sorry that my code is ugly that way (the "j" index came before the "i" somehow). but i think i've tried what you've suggested:
<br />
for (int line_no=0; line_no<100; line_no++)<br />
for (int column_no=0; column_no<100; column_no++)<br />
*(pbdata+line_no*Pitch+2*column_no+1) = 0xF8;<br />
Do I understand what you mean, or am i missing something?
You say the bug is not locking the whole surface memory? in desperation i've tried to access bytes seemingly outside my surface (like: line_no = 120); to my surprise nothing crashed (as if i've accessed something legal), but the app seemed to be in a deadlock (so maybe it was not locked)
|
|
|
|
|
this is my screen capture code:
Bitmap bmp = new Bitmap(800,600);
public static Bitmap GetDesktopImage()
{
IntPtr hBitmap;
IntPtr hDC = GetDC(GetDesktopWindow());
IntPtr hMemDC = CreateCompatibleDC(hDC);
hBitmap = CreateCompatibleBitmap(hDC, size.cx, size.cy);
IntPtr hOld = (IntPtr) SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC, 0, 0,size.cx,size.cy, hDC, 0,SRCCOPY);
SelectObject(hMemDC, hOld);
DeleteDC(hMemDC);
ReleaseDC(GetDesktopWindow(), hDC);
bmp = System.Drawing.Image.FromHbitmap(hBitmap);//<-here
DeleteObject(hBitmap);
GC.Collect();
return bmp;
}
at the arrow place,get a bitmap instance. i think the bitmap is true color depth.
Here is my question:
1.After BitBlt method, can i get a 256 color bitmap instance directly instead of a true color bitmap ?
2.if i have to get a true color bitmap, How to convert it into a 256/16/2 color bitmap quickly ?
|
|
|
|
|
First, don't assume the desktop is 800x600. Use either SystemInformation.VirtualScreen or Screen.WorkingArea to get the Rectangle to use to size the Bitmap .
Second, you can create a 256-color bitmap by using the Bitmap.Bitmap(int, int, PixelFormat) constructor. Then create a new Graphics object for that bitmap and use GetHdc to get the DC which you could paint into. Make sure you call ReleaseHdc and then dispose your Graphics object, but do not call GC.Collect - just call Graphics.Dispose on anything you create. Calling GC.Collect can be very expensive and - if you dispose things correctly (in order to free native resources, which GC.Collect won't do) - is unnecessary.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|