跳到主要内容

3 篇博文 含有标签「C#」

查看所有标签

学生考勤系统

· 阅读需 3 分钟

别人作业啥的~~,不过还是学到了一些技巧

尚且还有一些问题没解决的

  • 作为阴影的窗口,不能设置 ShowInTaskBar = false, 设置后会消失,这个相对比较麻烦,没处理
  • 画阴影的函数还不是很完善,只能是类似的阴影

截图

登录页面

查询,操作页面

一些技巧

让窗口可拖动

是重写的WndProc,而不是传统的鼠标事件


// Let Windows drag this form for us
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0084 /*WM_NCHITTEST*/)
{
m.Result = (IntPtr)2; // HTCLIENT
return;
}
base.WndProc(ref m);
}

传统版本

// In form load

var lastPoint = new Point();
var _isDraging = false;
MouseDown += (sender, e) =>
{
_isDraging = true;
lastPoint = e.Location;
};
MouseMove += (sender, e) =>
{
if (! _isDraging)
return;

int ox = e.X - lastPoint.X;
int oy = e.Y - lastPoint.Y;
Location = new Point(Location.X + ox, Location.Y + oy);
};
MouseUp += (sender, e) => { _isDraging = false; };

实现类似的窗体阴影

是使用的一个类 Dropshadow.

最开始从这里 看到能实现阴影的方法,后来有查找了很多东西,修改成了 我自己的 Dropshadow 版本.调用方法

var f = new Dropshadow(this)
{
BorderRadius = 40,
ShadowColor = Color.Blue
};

f.RefreshShadow();

在 DataGridView 中使用 DateTimePicker

这个忘记了具体是在哪里找的了,使用 CalendarColumnCalendarCell 即可.在设计时可以直接选择.

圆角边框

[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
public static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // height of ellipse
int nHeightEllipse // width of ellipse
);

// in form load
Region = Region.FromHrgn(Win32.CreateRoundRectRgn(0, 0, Width, Height, 20, 20));

概述 getopt.h 的使用

· 阅读需 8 分钟

概述

c语言控制台编程时,经常都要接受命令行传递来的选项,而getopt是专门用来解析命令行选项的一套函数。

简单的说一下getopt,她已经有相当长的历史了,早期是在Unix中使用,现在已经移植到了个个不同的语言(Shell,Java,Php,.NET...),为接受命令行选项提供了很大的便利。同时也指定了一套传递选项和参数的标准。