kenlistian

勤学多思

  IT博客 :: 首页 :: 新随笔 ::  :: 聚合  :: 管理 ::
  138 随笔 :: 0 文章 :: 23 评论 :: 0 Trackbacks

2013年9月18日 #

   造成dispose不能正常卸掉.

   TT = Record

  a :String ;

  end;

最好是如下

TT=Record

   a:String[10];

  end;

这样的好处是可以new,dispose能正常释放.且add到list和读出正常.

posted @ 2013-09-18 09:23 kenlistian 阅读(101) | 评论 (0)编辑 收藏

2013年9月17日 #

vc6“Build”或者“Compile”菜单的时候,发现在输出窗口显示了以下信息:Error spawning 'vcspawn.exe'. The build could not be performed。然后熟悉的VC就不听你的使唤了!

添加(或者修改)环境变量ComSpec,设定其置为:c:\WINDOWS\system32\cmd.exe

重启Vc.

2.

vcspawn.exe在你的路径


F:\lylong\Bin>where vcspawn.exe
E:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\vcspawn.exe
F:\lylong\Bin>path
PATH=E:\WINNT\system32;E:\WINNT;E:\WINNT\System32\Wbem;F:\lylong\Bin;E:\PROGRA~1\ULTRAE~1;E:\cyg
win\bin;E:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;E:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;E:\Program Files\Microsoft Visual Studio\Common\Tools;E:\Program
Files\Microsoft Visual Studio\VC98\bin;E:\Program Files\SecureCRT 3.0;C:\ThinkPad;C:\IBMTools;C
:\MSSQL7\BINN;
F:\lylong\Bin>set C
ComSpec=E:\WINNT\system32\cmd.exe

posted @ 2013-09-17 09:20 kenlistian 阅读(120) | 评论 (0)编辑 收藏

2013年5月17日 #

int[,] arrayInt = new int[,]={{1,2,3},{2,3,3}};

arrayInt.GetLength(0);  //获得行

arrayInt.GetLength(1);  //获得列

posted @ 2013-05-17 17:54 kenlistian 阅读(92) | 评论 (0)编辑 收藏

2013年5月15日 #

 

//传入一个委托值.(函数地址吧!)
private void CallMethod<T>(Func<T, int> func, T item) 
{
    try
    {
        func(item);
    }
    catch (Exception e)
    {
        Log(e);
    }
    finally
    {
        DoOther();
    }
}

2.call:

private void button1_Click(object sender, EventArgs e)
{
    CallMethod(new Func<string, int>(MethodTest), "Hello");
}


private int MethodTest(string str)
{
    //Do();
    MessageBox.Show(str);
    return 0;
}
posted @ 2013-05-15 13:10 kenlistian 阅读(101) | 评论 (0)编辑 收藏

2013年5月12日 #


Application.AddMessageFilter 方法添加消息筛选器以便在向目标传送 Windows 消息时监视这些消息。
处理的是本身的消息事件.而不是全局.

如果要截取全局,需要用到Hook方法.

posted @ 2013-05-12 10:25 kenlistian 阅读(129) | 评论 (0)编辑 收藏

2013年5月10日 #

        private const int SWP_HIDEWINDOW = 0x80;
        private const int SWP_SHOWWINDOW = 0x40; 

        [DllImport("user32", EntryPoint = "SetWindowPos")]
        public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndlnsertAfter, int X, int Y, int cx, int cy, int flags); 
        [DllImport("User32.dll")]
        public static extern IntPtr FindWindowEx(IntPtr ph, IntPtr ch, String cn, String wn);
        [DllImport("User32.dll")]
        public static extern bool ShowWindow(IntPtr hWnd, long nCmdShow );

        private static void  HideTaskWindow(bool bHide)
        {
            if (bHide)
            {
                IntPtr handle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
                //ShowWindow(handle, 0);
                SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0,SWP_HIDEWINDOW); 
            }
            else
            {
                IntPtr handle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
                //ShowWindow(handle, 5);
                SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SWP_SHOWWINDOW);
            }            
        }
posted @ 2013-05-10 14:11 kenlistian 阅读(249) | 评论 (0)编辑 收藏

2013年5月9日 #

 

 [Linker Error] Unresolved external 'xxxxxx' referenced from F:\xxx\xxx\xxxx.OBJ


    出现这一错误的原因是链接程序没有找到函数xxxxx()的外部引用而引起的,经过查阅MSDN的资料后得知该函数需要“xxx.dll”的支持,而在BCB中却没有直接对该DLL提供相应的链接库。

     

   解决的步骤

  1. 复制文件xxx.dll到工程目录中
  2. 然后进入控制台并转入工程目录后,把dll convert to lib with bcb

  implib xxx.lib xxx.dll


  3. Add xxx.lb into your project ,and compiles again.,,then compile ok.

posted @ 2013-05-09 17:26 kenlistian 阅读(146) | 评论 (0)编辑 收藏

 

 

delphi

if (Sender is TButton)then
   b:=Sender as TButton

 

bcb

if (Sender->InheritsFrom(__classid(TButton)))
   b = dynamic_cast<TButton *>(Sender);

posted @ 2013-05-09 17:20 kenlistian 阅读(125) | 评论 (0)编辑 收藏

 

1.屏幕由于拖动闪动或者是切换界面时出现闪动时,直接对form的DoubleBuffered设置双缓冲刷新即可解决.

//form窗体类
  this.DoubleBuffered = true;  //减少屏幕闪动

 

2.对于拖动窗体造成窗体中的控件闪动,也可以调用user.dll的api函数来处理.

[DllImport("user32.dll")]
static extern bool LockWindowUpdate(IntPtr hWndLock);
 
//该api暂停某个控件的展现
//在控件绘制之前暂停展示,在绘制完毕之后再显示出来。


//例子:当缩放的时候解决闪烁问题:
// 解决后的现象是,整个form1只出现一次闪烁,没有了疯狂的刷新了。
void form1_ResizeBegin(object sender, EventArgs e)
{
        LockWindowUpdate(this.Handle);
} 
  
void form1_ResizeEnd(object sender, EventArgs e)
{
            LockWindowUpdate(IntPtr.Zero);
}

 

 

3.

A form that has a lot of controls takes a long time to paint. Especially the Button control in its default style is expensive. Once you get over 50 controls, it starts getting noticeable. The Form class paints its background first and leaves "holes" where the controls need to go. Those holes are usually white, black when you use the Opacity or TransparencyKey property. Then each control gets painted, filling in the holes. The visual effect is ugly and there's no ready solution for it in Windows Forms. Double-buffering can't solve it as it only works for a single control, not a composite set of controls. I discovered a new Windows style in the SDK header files, available for Windows XP and (presumably) Vista: WS_EX_COMPOSITED. With that style turned on for your form, Windows XP does double-buffering on the form and all its child controls.

source:http://social.msdn.microsoft.com/forums/en-US/winforms/thread/aaed00ce-4bc9-424e-8c05-c30213171c2c/

protected override CreateParams CreateParams 

{ 

get 

{ 

CreateParams cp = base.CreateParams; 

cp.ExStyle |= 0x02000000; 

return cp; 

} 

} 

 
posted @ 2013-05-09 14:16 kenlistian 阅读(356) | 评论 (0)编辑 收藏

      
//去焦点
btnSet.TabStop = false;

//设置按钮透明,进入后半透明
SetBtnStyle(btnSet);       

 private void SetBtnStyle(Button btn)
{
      btn.FlatStyle = FlatStyle.Flat;   //样式  
       btn.ForeColor = Color.Transparent;//前景  
       btn.BackColor = Color.Transparent;//去背景  
       btn.FlatAppearance.BorderSize = 0;//去边线 
       btn.FlatAppearance.MouseOverBackColor = Color.FromArgb(50, 40, 60, 82);
      btn.FlatAppearance.MouseDownBackColor = Color.FromArgb(50, 40, 60, 82);
}

 

 

对于image的stretch,一般在控件的sizemode属性中,对于devexpress的pictureEdit控件则如下设置:

 

 

pictureEdit1.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch;

form中的backimage,需要strectch时,则设置backgroupImageLayout属性为stretch.

internal static string LoadBackImage(XtraForm sender, string sfile,string sDefaultFile, bool bDirectLoad = false)
        {
            if (!bDirectLoad)
            {
                OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog();
                fd.Filter = "jpg文件(*.jpg)|*.jpg|png文件(*.png)|*.png";
                if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    sfile = fd.FileName;
            }

            if (string.IsNullOrEmpty(sfile))
            {//获得缺省的图片文件
                sfile = sDefaultFile;                
            }

            if (!string.IsNullOrEmpty(sfile))
            {
                Image im = Image.FromFile(sfile);
                sender.BackgroundImage = im;
                sender.BackgroundImageLayout = ImageLayout.Stretch;
            }
            else
            {
                sender.BackgroundImage = null;

            }
            return sfile;
        }
posted @ 2013-05-09 14:08 kenlistian 阅读(795) | 评论 (0)编辑 收藏

仅列出标题  下一页