kenlistian

勤学多思

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

#

 

 [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 阅读(390) | 评论 (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 阅读(361) | 评论 (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 阅读(2264) | 评论 (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 阅读(2863) | 评论 (0)编辑 收藏

1.是微软自带.在system32中.卸载制作中需要添加该程序.带参数 /x {xxxx-xxxx-xxxx...}为卸载.

其中x为卸载.

{}中包含的序列号,是打包的GUID值,它是productCode值,在vs2010中的工程文件的productCode值,直接复制过来.

把msiexe做一个快捷键在程序组中,在其属性的自带参数中输入 /x {产品GUID序列号}.

 

详情可见:http://www.docin.com/p-345895729.html

posted @ 2013-05-08 14:45 kenlistian 阅读(341) | 评论 (0)编辑 收藏

 
 
设置treelist控件中的所有只读状态.
foreach(TreeListColumn  col in treeList.Columns)
{
   col.OptionsColumn.AllowEdit = false;
   col.OptionsColumn.ReadOnly = true;
}
posted @ 2013-05-06 19:14 kenlistian 阅读(311) | 评论 (0)编辑 收藏

 

 

<smart2000>

  <superPin></superPin>

   <modules>

       <module id = "0">

         <item1></itme1>

         <item1></itme1>

      </module>

       <module id = "1">

          <item1></itme1>

         <item1></itme1>

      </module>

      ...

  </moudules>

</smart2000>

 

 

1.Modules”节点的值没有固定,在这里就直接写入,声明存在这个节点,不指定“Modules”节点里的格式。

public static XElement GenerateXmlFile(string appId)

 XElement myXDoc = new XElement(
                   new XElement("Smart2000",
                           new XElement("SuperPin", superPin),
                           new XElement("Modules")
                           );

}

 

2.指定Modules的格式:

public static XElement GenerateXmlFile(string appId)

 XElement myXDoc = new XElement(
                   new XElement("Smart2000",
                           new XElement("SuperPin", superPin),
                           new XElement("Modules",
                                   new XElement("Modules",
                                     new XAttribute("ID", "0"),
                                     new XAttribute("enable", "true"),
                                     new XAttribute("name", "Module" + 0),
                                     new XAttribute("Data", "")
                                       )

            )
              );

}

 

 

 

3. 插入嵌套节点

  

       //先加载XElement根节点
        XElment myXDoc = XElment.Load("@xxx.xml");



        public static XElement AddNode(XElement myXDoc, int num, string name, string data)
        {
            XElement xele = myXDoc.Element("Modules");  //在xml文件里取出该节点
              XElement x = xele.Element("Module");         //在该节点下取到第一行初始化的数据

             if (Convert.ToString(x.Attribute("id").Value) == num)
            {
                xele.RemoveAll();//删除该节点的全部内容
             }


            xele.Add(new XElement("Module",
                  new XAttribute("id", num),
                                 new XAttribute("enable", "true"),
                                 new XAttribute("name", name),
                                 new XAttribute("Data", data)));
            return myXDoc;
        }

估计上面有些小问题,但是采取获取某个XElment之下的XElment然后调用Add()是通用方法.一般而言,先删除该节点下所有的,再加入.反复循环调用AddNode,即可实现插入Modules下的多个Module.

 

4.AddNode

   

 

private static void ModifyXmlElement(string xmlpath, string strElement)  
{  
    XElement xe = XElement.Load(xmlpath);  

    IEnumerable<XElement> element = from e in xe.Elements("Book")  
                                   where e.Attribute("BookID").Value == strElement  
                                    select e;  
    ///修改元素
    if (element.Count() > 0)  
    {  
        XElement firstelement = element.First();  
        ///设置新的属性
         firstelement.SetAttributeValue("BookID", "new004");  
       
       ///替换成新的节点
         firstelement.ReplaceNodes(  
             new XElement("BookNo", "new0004"),  
             new XElement("BookName", "Book new0004"),  
             new XElement("BookPrice", "45"),  
             new XElement("BookRemark", "This is a book new0004")  
        );  
    
       //上面一段,可以改为先删除,再直接添加该节点更方便
       //对上面进行先屏蔽
        firstelement.RemoveAll();
    } 
    
    firstelement.Add(new XElement("BookNo","new004"),
                              new XElement("BookName", "book new0004"),
                              new XElement("BookPrice", "45"),
                             new XElement("BookRemark", "this is a book new004")
               );
    
  
    xe.Save(xmlpath);  

}

 

 

 

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

 

1.直接调用主屏宽度,高度

System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width//显示器的宽度
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height//显示器高度

 

2.

Point pt;
Rectangle rect = System.Windows.Forms.Screen.GetBounds(pt);

 

3.

//在屏幕的右下角显示窗体

//这个区域不包括任务栏的

Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);

//这个区域包括任务栏,就是屏幕显示的物理范围

Rectangle ScreenArea = System.Windows.Forms.Screen.GetBounds(this);

int width1 = ScreenArea.Width; //屏幕宽度
int height1 = ScreenArea.Height; //屏幕高度
this.Location = new System.Drawing.Point(width1 - 窗体宽度, height1 - 窗体高度);  //指定窗体显示在右下角

//在母窗体的中间显示子窗体的位置计算

waitForm.Location = new Point((this.Location.X + (this.Width - waitForm.Width) / 2),
                                                (this.Location.Y + (this.Height - waitForm.Height) / 2));

posted @ 2013-04-30 23:57 kenlistian 阅读(201) | 评论 (0)编辑 收藏

二者在通过Load方法加载XML时:

 

XDocument.Load()    加载整个XML文档  包括根节点

XElement.Load()       不加载XML的根节点.

 

 

XElement.Load()

    File.WriteAllText("Test.xml", @"<Root>  

     <Child1>1</Child1> 

     <Child2>2</Child2> 

      <Child3>3</Child3> 

      </Root>"); 

 

  1. Console.WriteLine("Querying tree loaded with XElement.Load");  
  2. Console.WriteLine("----");  
  3. XElement doc = XElement.Load("Test.xml");  
  4. IEnumerable<XElement> childList =    from el in doc.Elements()  
  5.     select el;  
  6. foreach (XElement e in childList)  
  7.     Console.WriteLine(e); 

 

Querying tree loaded with XElement.Load  

  1. ----  
  2. <Child1>1</Child1>  
  3. <Child2>2</Child2>  
  4. <Child3>3</Child3> 

 

XDocument.Load()

 

  1. File.WriteAllText("Test.xml", @"<Root>  
  2.     <Child1>1</Child1>  
  3.     <Child2>2</Child2>  
  4.     <Child3>3</Child3>  
  5. </Root>");  
  6. Console.WriteLine("Querying tree loaded with XDocument.Load");  
  7. Console.WriteLine("----");  
  8. XDocument doc = XDocument.Load("Test.xml");  
  9. IEnumerable<XElement> childList =   from el in doc.Elements()   select el;  
  10. foreach (XElement e in childList)  
  11.     Console.WriteLine(e); 

结果:

 

  1. Querying tree loaded with XDocument.Load  
  2. ----  
  3. <Root>  
  4.   <Child1>1</Child1>  
  5.   <Child2>2</Child2>  
  6.   <Child3>3</Child3>  
  7. </Root> 
posted @ 2013-04-30 22:44 kenlistian 阅读(502) | 评论 (0)编辑 收藏

复制后,做一个reg文件,运行.

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\{00020404-0000-0000-C000-000000000046}]
@="IEnumVARIANT"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\{00020404-0000-0000-C000-000000000046}\NumMethods]
@="7"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\{00020404-0000-0000-C000-000000000046}\ProxyStubClsid]
@="{00020421-0000-0000-C000-000000000046}"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\{00020404-0000-0000-C000-000000000046}\ProxyStubClsid32]
@="{00020421-0000-0000-C000-000000000046}"

posted @ 2013-04-30 18:58 kenlistian 阅读(138) | 评论 (0)编辑 收藏

仅列出标题
共42页: First 25 26 27 28 29 30 31 32 33 Last