分类目录
文章索引模板

Category: Dev

OnExplicitShutdown OnStartup - 一月 22, 2010 by yippee

protected override void OnStartup(StartupEventArgs e)
    {
       Window testWindow = new Window();
       testWindow.ShowDialog();
       testWindow.Close();
       // THE CODE BELOW WILL NOT SHOW THE NEXT WINDOW
       Window testWindow2 = new Window();
       testWindow2.ShowDialog();
       testWindow2.Close();
    }
同一个程序里面启动多个WINDOWS
第二个立即返回了
改成 OnExplicitShutdown

OnLastWindowClose


应用程序在最后一个窗体关闭时,或调用Shutdown方法时才会关闭


l         OnMainWindowClose


An application shuts down when either the main window closes, or Shutdown is called.


应用程序在主窗体关闭时,或调用Shutdown方法时才会关闭


l         OnExplicitShutdown


应用程序只有在调用Shutdown方法时才会关闭。

Very long delay before MediaOpened event raised on MediaElement
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8d168db2-5496-4f8f-ace5-abc6e5902d43/



Life Is Art – 博客园
http://www.cnblogs.com/RMay/



Life Is Art – 博客园
http://www.cnblogs.com/RMay/



WPF ShowDialog returns null immediatly on second call … – Stack Overflow
http://stackoverflow.com/questions/1243833/wpf-showdialog-returns-null-immediatly-on-second-call
protected override void OnStartup(StartupEventArgs e)
    {
       Window testWindow = new Window();
       testWindow.ShowDialog();
       testWindow.Close();
       // THE CODE BELOW WILL NOT SHOW THE NEXT WINDOW
       Window testWindow2 = new Window();
       testWindow2.ShowDialog();
       testWindow2.Close();
    }


引用 4.WPF应用程序管理 – 一个半天的日志 – 网易博客
http://blog.163.com/wangzhenguo2005@126/blog/static/371405262009102322715437/



分享:WPF编程体验,先启动登录==>后启动主程序的运行机制实现
http://topic.csdn.net/u/20080531/13/7b636858-ed76-43f6-b243-2921bfd16a48.html



分享:WPF编程体验,先启动登录==>后启动主程序的运行机制实现
http://topic.csdn.net/u/20080531/13/7b636858-ed76-43f6-b243-2921bfd16a48.html



WPF SDK研究 之 AppModel – 包建强的开源地带 – 博客园
http://www.cnblogs.com/jax/articles/1142889.html


 


Hiding a window triggering the Closing event?
http://social.msdn.microsoft.com/Forums/zh-HK/wpf/thread/0f7ffa69-4b43-421d-894b-aa5d6ef7b678
      private void SearchForm_Closing(object sender, CancelEventArgs args)
      {
          Save();  // Doing something
          args.Cancel = true;
          // Trying to hide
          Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (DispatcherOperationCallback)delegate(object o)
          {
             Hide();
             return null;
          }, null);
      }


Window.DialogResult Property (System.Windows)
http://msdn.microsoft.com/en-us/library/system.windows.window.dialogresult.aspx



SecurityException when running a Windows Application – .NET Development – Windows Tech
http://windows-tech.info/13/881f8bcfd0bfd5a2.php



Using DB on multiple forms – .NET Development – Windows Tech
http://windows-tech.info/13/a9c04603728f1ad2.php



 

标签:,
java led dll - 十二月 25, 2009 by yippee

java 操作 dll JNative LEd – zjutsoft的专栏 – CSDN博客
http://blog.csdn.net/zjutsoft/archive/2009/09/10/4538943.aspx



java 操作 LED DLL 动态链接库 JNaitive – zjutsoft – JavaEye技术网站
http://zjutsoft.javaeye.com/blog/466250



java 操作 LED DLL 动态链接库 JNaitive
http://fuckb.net/article?v=2&u=java-operation-led-dll-dynamic-link-library-jnaitive#java%20%E6%93%8D%E4%BD%9C%20LED%20DLL%20%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93%20JNaitive
java 操作 LED DLL 动态链接库 JNaitive.主要是操作LDE。 java 来操作dll动态链接库。
包含 四个文件 JNative.jar. 动态链接库BxADLL.dll.
需要放到 c:\windows\system32目录下面的。 JNativeCpp.dll
源代码:
import org.xvolks.jnative.JNative;
import org.xvolks.jnative.Type;
import org.xvolks.jnative.exceptions.NativeException;
import org.xvolks.jnative.pointers.Pointer;
import org.xvolks.jnative.pointers.memory.HeapMemoryBlock;
import org.xvolks.jnative.pointers.memory.MemoryBlockFactory;
import org.xvolks.jnative.misc.basicStructures.INT64;
import org.xvolks.jnative.misc.basicStructures.LONG;
import org.xvolks.jnative.misc.basicStructures.HWND;
import org.xvolks.jnative.misc.basicStructures.LPARAM;
import org.xvolks.jnative.misc.basicStructures.HANDLE;
import org.xvolks.jnative.util.Callback;
public class catchDLL2 {
private static JNative v = null;
/**
* 加载的DLL
*/
private static final String DLL_LIB = “BxADLL.dll”;
// 强制关机
static void SetScreenState(int a){
int i=0;
try{
v = new JNative(DLL_LIB, “SetScreenState”);
Pointer p = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
v.setParameter(i++,1);
v.setParameter(i++,a);
p.setStringAt(0,”ScreenStateData1″);
v.setParameter(i++,p);
v.invoke();
}catch(Exception e){
e.printStackTrace();
}
}
//设置亮度
static void SetScreenLight(int a){
int i=0;
try{
v = new JNative(DLL_LIB, “SetScreenLight”);
Pointer p = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
v.setParameter(i++,1);
v.setParameter(i++,a);
p.setStringAt(0,”ScreenLight1″);
v.setParameter(i++,p);
v.invoke();
}catch(Exception e){
e.printStackTrace();
}
}
//设置显示屏参数
static void SetScreenParameter() throws NativeException, IllegalAccessException{
int i = 0;
v = new JNative(DLL_LIB, “SetScreenParameter”);
Pointer p3 = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
p3.setStringAt(0,”ParametetData1″);
//设置参数
v.setParameter(i++,1);
v.setParameter(i++,64);
v.setParameter(i++,32);
v.setParameter(i++,2);
v.setParameter(i++,2);
v.setParameter(i++,0);
v.setParameter(i++,0);
v.setParameter(i++,p3);
//设置返回值类型
//v.setRetVal(Type.INT);
v.invoke();
}
//发送命令 参数是包含命令的文件
static int SendDataToComm(String pchar,int i){
int ret=1;
try{
v = new JNative(DLL_LIB, “SendDataToComm”);
System.out.println(v.getDLLName());
Pointer p = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
Pointer p2 = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
//设置参数
v.setParameter(0,1);
v.setParameter(1,i);
v.setParameter(2,64);
v.setParameter(3,32);
v.setParameter(4,2);
p.setStringAt(0,”Com1″);
v.setParameter(5,p);
v.setParameter(6,57600);
p2.setStringAt(0,pchar);
v.setParameter(7,p2);
//设置返回值类型
v.setRetVal(Type.LONG);
v.invoke();
//System.out.println(“LED设备=”+p2.getAsString());
ret = Integer.parseInt(v.getRetVal());
}catch(Exception e){
e.printStackTrace();
}
return ret;
}
//取得发送全部显示屏数据的数据头信息,在添加显示区域信息前添加。
static void GetAllDataHead(){
try{
int i = 0;
v = new JNative(DLL_LIB, “GetAllDataHead”);
/*Pointer p = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
p.setStringAt(0,”SendAllDataHead1″);*/
//设置参数===================
//显示屏屏号
v.setParameter(i++,1);
//显示屏中区域的个数
v.setParameter(i++,2);
//字幕区域的宽度
v.setParameter(i++,64);
//字幕区域的高度
v.setParameter(i++,32);
//显示屏类型
v.setParameter(i++,2);
//字幕区域信息保存的文件名;
v.setParameter(i++,”SendAllDataHead1″);
//设置返回值类型
//v.setRetVal(Type.INT);
v.invoke();
}catch(Exception e){
e.printStackTrace();
}
}
//合并显示区域信息文件
static void UnionAreaDataToFile(int a,int b,String file,int c){
try{
int i = 0;
v = new JNative(DLL_LIB, “UnionAreaDataToFile”);
/*Pointer p = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
Pointer p1 = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
p.setStringAt(0,file);
p1.setStringAt(0,”SendAllData1″);*/
//设置参数===================
//pSourceFile是否是区域文件;1:区域文件;0:非区域文件;
v.setParameter(i++,a);
//区域序号;从1开始;
v.setParameter(i++,b);
//预合并信息文件名称
v.setParameter(i++,file);
//合并目标文件名称。
v.setParameter(i++,”SendAllData1″);
//0:在原文件下添加合并信息文件;1:删除原文件信息,重新创建合并信息文件
v.setParameter(i++,c);
//设置返回值类型
//v.setRetVal(Type.INT);
v.invoke();
}catch(Exception e){
e.printStackTrace();
}
}
//转换 字幕区域显示信息 SendDataTitle1 D1
static void SetScreenTitle(int nAreaOrdID,int x,int y,int hight,int big,String pTitle,int nStunt,int nRunSpeed,int nShowTime){
try{
int i = 0;
v = new JNative(DLL_LIB, “SetScreenTitle”);
Pointer p = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
//Pointer p1 = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
Pointer p2 = new Pointer(MemoryBlockFactory.createMemoryBlock(100));
p.setStringAt(0,”宋体”);
//p1.setStringAt(0,pTitle);
p2.setStringAt(0,”SendDataTitle1″);
//设置参数===================
//区域序号
v.setParameter(i++,nAreaOrdID);
//字幕区域的横坐标
v.setParameter(i++,x);
//字幕区域的纵坐标
v.setParameter(i++,y);
//字幕区域的长度
v.setParameter(i++,64);
//字幕区域的高度
v.setParameter(i++,hight);
//显示屏类型
v.setParameter(i++,2);
//点阵类型
v.setParameter(i++,1);
//字幕区域显示字体
v.setParameter(i++,p);
//字幕区域显示字号
v.setParameter(i++,big);
//字幕区域显示颜色; 1:红色;2:绿色;3:黄色
v.setParameter(i++,1);
//粗体;1:粗体;0正常
v.setParameter(i++,0);
//斜体;1:斜体;0正常
v.setParameter(i++,0);
//下划线;1:下划线;0正常
v.setParameter(i++,0);
//字幕区域显示的字幕滚动信息
v.setParameter(i++,pTitle);
//字幕区域显示特技;具体特技特征字见注1;
v.setParameter(i++,nStunt);
//字幕区域信息运行速度
v.setParameter(i++,nRunSpeed);
//字幕区域信息停留时间
v.setParameter(i++,nShowTime);
//字幕区域信息保存的文件名;
v.setParameter(i++,p2);
//设置返回值类型
//v.setRetVal(Type.INT);
v.invoke();
}catch(Exception e){
e.printStackTrace();
}
}
//设置亮度
static void setLight(int a){
//设置亮度 SetScreenLight(1–15) ScreenLight1
SetScreenLight(a);
int ret=SendDataToComm(“ScreenLight1″,0xc8);
if(ret==1) System.out.println(“亮度设置发送成功”);
else System.out.println(“亮度设置发送失败”);
}
//强制开关机
static void setState(int a){
//强制开关机 SetScreenState(1表示开机 0表示关闭); ScreenStateData1
SetScreenState(a);
int opendown=SendDataToComm(“ScreenStateData1″,0xC4);
if(opendown==1) System.out.println(“开关机发送成功”);
else System.out.println(“开关机发送失败”);
}
//设置屏参
static void setParameter() throws NativeException, IllegalAccessException{
//设置显示屏参数 SetScreenParameter(); ParametetData1
SetScreenParameter();
int par=SendDataToComm(“ParametetData1″,0xC1);
if(par==1) System.out.println(“显示屏参数发送成功”);
else System.out.println(“显示屏参数发送失败”);
}
// UnionAreaDataToFile 1:区域文件;0:非区域文件; 区域序号;从1开始;
//0:在原文件下添加合并信息文件;1:删除原文件信息,重新创建合并信息文件
//发送字幕 message1显示上面 message2显示下面
public static void SendMessage(String message1,String message2){
GetAllDataHead();
UnionAreaDataToFile(0,0,”SendAllDataHead1″,1);
//16是字幕显示高度 12是字体大小
SetScreenTitle(1,0,0,16,12,message1,1,1,2);
UnionAreaDataToFile(1,1,”SendDataTitle1″,0);
SetScreenTitle(2,0,16,16,12,message2,1,1,2);
UnionAreaDataToFile(1,2,”SendDataTitle1″,0);
//设置字幕 SetScreenTitle(); SendDataTitle1
//SetScreenTitle();
int title=SendDataToComm(“SendAllData1″,0xD1);
if(title==1) System.out.println(“向显示屏发送数据成功”);
else System.out.println(“向显示屏发送数据失败”);
}
// 发送字幕 message1显示上面 全屏显示
public static void SendOne(String message1){
GetAllDataHead();
UnionAreaDataToFile(0,0,”SendAllDataHead1″,1);
SetScreenTitle(1,0,0,32,24,message1,1,1,2);
UnionAreaDataToFile(1,1,”SendDataTitle1″,0);
//设置字幕 SetScreenTitle(); SendDataTitle1
//SetScreenTitle();
int title=SendDataToComm(“SendAllData1″,0xD1);
if(title==1) System.out.println(“向显示屏发送数据成功”);
else System.out.println(“向显示屏发送数据失败”);
}
public static void main(String[] args) {
try{
//1~15 亮度增加
//setLight(1);
//0关机 1 开机
//setState(1);
//设置屏参
//setParameter();
SendMessage(“浙A-T56865″,”杭州威玛计算机系统有限公司”);
//SendOne(“中国你好”);
}catch(Exception ne){
System.err.println(“listAllDevice NativeException!”);
//releaseCard();
ne.printStackTrace();
}
}
}


 

标签:,
c#路径图片缩略 - 十月 23, 2009 by yippee

try


{


    // Create an Image object from a file.


    // PhotoTextBox.Text is the full path of your image


    using (Image photoImg = Image.FromFile(PhotoTextBox.Text))


    {


        // Create a Thumbnail from image with size 50×40.


        // Change 50 and 40 with whatever size you want


        using (Image thumbPhoto = photoImg.GetThumbnailImage(50, 40, null, new System.IntPtr()))


        {


            // The below code converts an Image object to a byte array


            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())


            {


                thumbPhoto.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);


                imgBytes = ms.ToArray();


            }


        }


    }


}


catch (Exception exp)


{


    MessageBox.Show(“Select a valid photo!”);


    PhotoTextBox.Select();


    return;


}        


C#中让ListBox支持文件路径的拖放
有时,我们程序,需要加载一个文件列表,这个列表,通常用ListBox来存放,为了方便操作,让listBox支持拖放入文件的路径,是个非常好的功能,在.NET里面实现这个功能,是非常方便,只需要3个步骤:


将 ListBox 的 AllowDrop 属性设为 true
在 ListBox 的 DragOver 和 DragEnter 事件中处理
void ListBox1DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}


void ListBox1DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
上面的 e.Effect 可以根据实际情况,调节不同的值,不过,如果不确定,就用默认的All


3. 处理拖放事件


void ListBox1DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
String[] files = (String[])e.Data.GetData(DataFormats.FileDrop);
foreach (String s in files)
{
(sender as ListBox).Items.Add(s);
}
}

标签:,
CreateToolhelp32Snapshot dump fail - 十月 23, 2009 by yippee

 // TODO: 在此添加控件通知处理程序代码
HANDLE Hand  = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 2256);
MODULEENTRY32 lppe;
memset(&lppe,0,sizeof(MODULEENTRY32));
 lppe.dwSize = sizeof(MODULEENTRY32);
BOOL  found = Module32First(Hand, &lppe);
CFile myFile;


if ( myFile.Open( _T(“r:\\myfilef.dat”), CFile::modeCreate |  
 CFile::modeReadWrite, NULL ) )
{
 /*myFile.Write( szBuffer, sizeof( szBuffer ) );
 myFile.Flush();
 myFile.Seek( 0, CFile::begin );
 nActual = myFile.Read( szBuffer, sizeof( szBuffer ) ); */


 while(found)
 {
 DWORD Add1 = DWORD(lppe.modBaseAddr);
DWORD Add2  = Add1 + lppe.modBaseSize;
DWORD index  = DWORD(lppe.modBaseAddr);
 
  {
  
   myFile.Write(lppe.modBaseAddr,  lppe.modBaseSize-4);
  
  }
   found = Module32Next(Hand, &lppe);
 }
  CloseHandle(Hand); // 释放快照句柄
失败··


时间:2008-09-19 08:57来源:中国网管联盟作者:bitsCN编辑字体:[大 中 小]


有时,有些软件有保护,看不到他程序内部是怎么一个样,如果想简单的把他的内存保存下来!
我写了一个简单的函数,调用一下就可以把DLL和EXE的内存里的信息全部导到文件里!到时再慢慢查吧!
 


uses
 TlHelp32; bitscn_com



procedure GetDLLMemToFile;
var
  PID: Dword;
  Hand: THandle;
  lppe: TModuleEntry32;
  found: boolean;
  File111: TFileStream;
  dd, Add1, Add2, index: dword;
begin
  Hand := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessID);
  lppe.dwSize := SizeOf(lppe);
  found := Module32First(Hand, lppe);
  while found do
  begin
    File111 := TFileStream.Create(‘debug\’ + extractfilename(lppe.szExePath), $FFFF); bitscn.com


    Add1 := dword(lppe.modBaseAddr);
    Add2 := Add1 + lppe.modBaseSize;
    index := dword(lppe.modBaseAddr);
    while true do
    begin
      dd := Pdword(index)^;
      File111.WriteBuffer(dd, 4);
      inc(index, 4);
      if index >= Add2 – 4 then break;
    end; feedom.net


    File111.Destroy;      found := Module32Next(Hand, lppe);
  end;
  CloseHandle(Hand); // 释放快照句柄
end;

标签:, ,
wpf显示GIF - 九月 19, 2009 by yippee

wpf显示GIF


第三方控件
用浏览器控件
HOST WINFORM的PICTUREBOX
用MEDIAELEMENT
读取GIF文件自己解码显示
调用解码类一个图片一个图片解析出来定时器
//Create a Bitmpap Object.
    Bitmap animatedImage = new Bitmap(“SampleAnimation.gif”);
    bool currentlyAnimating = false;
                    
    //This method begins the animation.
    public void AnimateImage()
    {
        if (!currentlyAnimating)
        {
                    
            //Begin the animation only once.
            ImageAnimator.Animate(animatedImage, new EventHandler(this.OnFrameChanged));
            currentlyAnimating = true;
        }
    }


    private void OnFrameChanged(object o, EventArgs e)
    {
                    
        //Force a call to the Paint event handler.
        this.Invalidate();
    }


    protected override void OnPaint(PaintEventArgs e)
    {
                    
        //Begin the animation.
        AnimateImage();
                    
        //Get the next frame ready for rendering.
        ImageAnimator.UpdateFrames();
                    
        //Draw the next frame in the animation.
        e.Graphics.DrawImage(this.animatedImage, new Point(0, 0));
    }


    public static void Main()
    {
        Application.Run(new animateImage());
    }



.Victor’s BLOG: GIF文件格式详解
http://blog.zhongmoo.cn/2009/05/gif.html



WPF中不支持gif的问题 — Windows Live
http://kimiya25.spaces.live.com/Blog/cns!27A083D4FD9435E9!1308.entry



Disabled Images in WPF – Andrew Smith – Infragistics Community
http://blogs.infragistics.com/blogs/andrew_smith/archive/2008/03/30/disabled-images-in-wpf.aspx



GifBitmapDecoder 类 (System.Windows.Media.Imaging)
http://msdn.microsoft.com/zh-cn/library/system.windows.media.imaging.gifbitmapdecoder.aspx
Stream imageStreamSource = new FileStream(“tulipfarm.gif”, FileMode.Open, FileAccess.Read, FileShare.Read); GifBitmapDecoder decoder = new GifBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);


ImageAnimator.Animate 方法 (System.Drawing)
http://msdn.microsoft.com/zh-tw/library/system.drawing.imageanimator.animate(VS.80).aspx



怎样让我的动画真真的动起来?
http://social.msdn.microsoft.com/forums/zh-TW/232/thread/5ac14de8-c2e1-4076-932a-e9de4b0cebf5/



My animated .gif control for WPF – Pragmatic TSQL Programmer
http://www.solidrockstable.com/blogs/PragmaticTSQL/Lists/Posts/Post.aspx?ID=37



How do I get an animated gif to work in WPF? – Stack Overflow
http://stackoverflow.com/questions/210922/how-do-i-get-an-animated-gif-to-work-in-wpf



Creating Animated GIF files in WPF
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6ef358a7-d1ac-4267-91d9-166024aad8ca



CodeProject: Another approach to animated GIF in WPF, with transparency. Free source code and programming help
http://www.codeproject.com/KB/WPF/animatedgifinwpf.aspx



CodeProject: GIF animation in WPF. Free source code and programming help
http://www.codeproject.com/KB/WPF/wpfgifanimator.aspx



[WPF疑难]在WPF中显示动态GIF – this.Study(DateTime.Now) – 博客园
http://www.cnblogs.com/zhouyinhui/archive/2007/12/23/1011555.html



WPF support gif — Windows Live
http://kimiya25.spaces.live.com/Blog/cns!27A083D4FD9435E9!1311.entry



[WPF疑难]在WPF中显示动态GIF_软件_科技时代_新浪网
http://tech.sina.com.cn/s/s/2008-05-20/0751665803.shtml



当WPF遇到了gif_福娃居
http://hi.baidu.com/mych/blog/item/1eb14f545f12a752564e00be.html



How do I get an animated gif to work in WPF? – Stack Overflow
http://stackoverflow.com/questions/210922/how-do-i-get-an-animated-gif-to-work-in-wpf



用C#的winform显示gif动画 – 软件使用 – 欢迎来到海青论坛 – Powered by Discuz!
http://youth.dlmu.edu.cn/bbs/viewthread.php?tid=29151



 

标签:,
CopyFromScreen截屏 - 九月 14, 2009 by yippee

CopyFromScreen截屏


传统截屏
#region 导入函数
      
        [DllImport("gdi32.dll")]
        private static extern IntPtr CreateDC(string lpszDriver, string lpszDrivse, string lpszOutput, Int32 lpInitData);


        [DllImport("gdi32.dll")]
        private static extern IntPtr CreateCompatibleDC(IntPtr hdc);


        [DllImport("gdi32.dll")]
        private static extern int GetDeviceCaps(IntPtr hdc, Int32 nIndex);


        [DllImport("gdi32.dll")]
        private static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);


        [DllImport("gdi32.dll")]
        private static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);


        [DllImport("gdi32.dll")]
        private static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest,
                 int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, UInt32 dwRop);


        [DllImport("gdi32.dll")]
        private static extern int DeleteDC(IntPtr hdc);


        #endregion


 现在截屏简单多了


 Console.WriteLine(DateTime.Now.Millisecond.ToString());
            System.Drawing.Bitmap photo = new System.Drawing.Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(photo);
            graphic.CopyFromScreen(0, 0, 0, 0, new System.Drawing.Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));
            photo.Save(@”r:\aa.jpg”, System.Drawing.Imaging.ImageFormat.Jpeg);
            Console.WriteLine(DateTime.Now.Millisecond.ToString());


CopyFromScreen 方法对于将一个图像放置于另一个图像顶部非常有用。若要指定源颜色和目标颜色的混合方式,请使用 CopyFromScreen 方法之一,该方法采用 CopyPixelOperation 参数。

标签:,
wpf内嵌资源 - 九月 7, 2009 by yippee

做个模拟时钟,搞了几个图片,然后不想放在外部,想内嵌,结果发现一个内嵌,不知道微软为什么搞那么多东东。

项目属性里面有个资源;然后文件属性有个编译选项,并且选择项还不少。

Resources in Windows Presentation Foundation applications
http://nerddawg.blogspot.com/2005/11/resources-in-windows-presentation.html


wpf/silverlight文章推荐阅读 – Clingingboy – 博客园
http://www.cnblogs.com/Clingingboy/archive/2008/06/25/1230047.html



WPF应用程序使用资源及多语言设置学习-2 – 一直半解 – 博客园
http://www.cnblogs.com/xwing/archive/2009/05/31/1493256.html



嵌入式资源 – Q.yuhen
http://www.rainsts.net/article.asp?id=98
直接使用 Assembly.GetManifestResourceStream方法来读取资源数据流。其中资源名为


Namespace + FolderName + Filename
Stream strm = Assembly.GetExecutingAssembly().GetManifestResourceStream(“MyNameSpace.Images.logo.bmp”);
Image image = new Bitmap(strm);
pictureBox1.Image = image;


Resource – 技术文章 – 梦路论坛 silverlight 3| silverlight 3源代码| silverlight 游戏 | – Powered by Discuz!
http://www.wakeway.com/thread-2-1-1.html



Silverlight常见问题答疑1 —- Silverlight如何定位图片 – 春夏秋冬 – 博客园
http://www.cnblogs.com/nineflowers/archive/2009/05/24/1488527.html



[100分] 问关于uri使用某个dll image 资源的问题?急,在线等…..分不够可以再加多少都可以
http://topic.csdn.net/u/20070906/15/a01619d6-f595-4fd8-ae3d-d77e9f1121c5.html
我在一个dll(类ImageControl)中添加了一个on.gif的资源,然后在application对其进行引用。下面是一个按钮的click事件:


private void button1_Click(object sender, RoutedEventArgs e)
{
  image1.Source = new BitmapImage(new Uri(“Pack://application:,,,/ImageControl;component/on.gif”));
}


最初我也各楼主一样只写了new Uri(“/ImageControl;component/on.gif”),运行时报错说找不到资源,但后来经过查找在前面加上了Pack://application:,,,后就可以了。



relative filepath for BitmapImage UriSource in Feb CTP
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/856f77cc-d4bb-463e-b9aa-f293804e9325



image uri source
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/faa43454-ee54-46ab-ad01-64e8897b8f7b



Writing Custom GPU-based Effects for WPF – WindowsClient.net
http://windowsclient.net/wpf/wpf35/wpf-35sp1-custom-gpu-effects.aspx



Loading an image from inside a WPF dll from control code — Windows Live
http://rrelyea.spaces.live.com/blog/cns!167AD7A5AB58D5FE!1612.entry



WPF学习之资源-Resources – Memory – 博客园
http://www.cnblogs.com/Memory/archive/2008/12/11/1352887.html



闲话WPF之十六(WPF中的资源 [2]) – C++ .NET WPF Android – 博客园
http://www.cnblogs.com/yilinglai/archive/2006/12/30/608237.html



在 WPF 中创建可换肤的用户界面-开发频道-IT技术-天极网
http://dev.yesky.com/365/7616365_3.shtml



11.1.1 添加资源 – 51CTO.COM
http://book.51cto.com/art/200908/145394.htm



WPF image resources – Stack Overflow
http://stackoverflow.com/questions/347614/wpf-image-resources



Windows Presentation Foundation Application Resource, Content, and Data Files
http://msdn.microsoft.com/en-us/library/aa970494.aspx



MCS Blogs – Using an embedded resource Image from code in a WPF application.
http://www.malluf.com/dnn/MCSBlogs/tabid/57/EntryID/1/Default.aspx



How to embed an image resource in a control library — Windows Live
http://wpfxaml.spaces.live.com/blog/cns!97DD5FD32788695B!154.entry
component


hardcodet.net » Linked Images in WPF Projects – Bad Idea?
http://www.hardcodet.net/2009/08/linked-images-in-wpf-projects-cause-issues



Embedding Bitmaps inside XAML « WPF, .NET & Other stuff
http://coldhour.info/browse.php?b=5&u=Oi8vc2hhcnBpbnNpZ2h0cy53b3JkcHJlc3MuY29tLzIwMDcvMTAvMDgvZW1iZWRkaW5nLWJpdG1hcHMtaW5zaWRlLXhhbWwv



dasz.at – Benutzbare Technologie» Blog Archive » WPF: Embedding Images in the Assembly
http://dasz.at/index.php/2008/01/wpf-embedding-images-in-the-assembly/



最后还是文件编译为内嵌资源
Stream strm = Assembly.GetExecutingAssembly().GetManifestResourceStream(strpics[i]);
                    PngBitmapDecoder bitmapDecoder = new PngBitmapDecoder(strm, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                    ImageSource imageSource = bitmapDecoder.Frames[0];


                    imghms[i].Source = imageSource;

标签:,
Wpf模拟时钟代码实现analogicclock - 九月 5, 2009 by yippee

WPF画个时钟真是方便,可是我碰到得问题是,我得用代码实现。这下可真是够麻烦。
得把XAML的代码一行行用C#写。
然后把DATABIND改为定时器··
还没搞清楚DATABIND机制···
搞了半天终于OK了。

制作简单的WPF时钟 – 大可山博客[GDI+,WPF, .Net图形图像] – CSDN博客
http://blog.csdn.net/johnsuna/archive/2007/10/26/1845605.aspx



3D Digital Clock for WPF – Home
http://solnick.codeplex.com/



CodeProject: Creating a look-less custom control in WPF. Free source code and programming help
http://www.codeproject.com/KB/WPF/WPFCustomControl.aspx



CodeProject: A WPF Digital Clock. Free source code and programming help
http://www.codeproject.com/KB/WPF/digitalclock.aspx



WPF: A ControlTemplate for an Analog Clock | Sahil Malik – blah.winsmarts.com
http://blah.winsmarts.com/2007-3-WPF__A_ControlTemplate_for_an_Analog_Clock.aspx



The Joy Of Programming: Simple WPF Clock using Microsoft Expression Blend
http://proxycrowd.com/browse.php?b=5&u=Oi8vam9iaWpveS5ibG9nc3BvdC5jb20vMjAwNy8wMy9zaW1wbGUtd3BmLWNsb2NrLXVzaW5nLW1pY3Jvc29mdC5odG1s



Implementing an analogic clock in WPF – Orlando Perri
http://blogs.windowsclient.net/orlando_perri/archive/2009/07/29/implementing-an-analogic-clock-in-wpf.aspx



Aaltra blog – Create analog clock in WPF
http://blog.aaltra.eu/en/tech/createanalogclockinwpf



3D Digital Clock for WPF – Home
http://solnick.codeplex.com/



CodeProject: Analog Clock in WPF. Free source code and programming help
http://www.codeproject.com/KB/WPF/WpfClock.aspx



Analog Clock Widget
http://www.c-sharpcorner.com/UploadFile/dpatra/105202009092936AM/1.aspx



Tutorial: Create a Win32 Application Hosting WPF Content
http://msdn.microsoft.com/en-us/library/aa970266.aspx



Analog Clock – C# version
http://geekswithblogs.net/rebelgeekz/archive/2004/02/12/2078.aspx



WPF 2D Transformations — CodeGuru.com
http://www.codeguru.com/csharp/csharp/cs_misc/userinterface/article.php/c12221


 


http://www.galasoft.ch/mydotnet/articles/resources/article-2006102701/Page1.xaml.cs.txt



WPF自定义控件 —— 复合控件(中国象棋联机版) – 咖喱块 – 博客园
http://www.cnblogs.com/Curry/archive/2009/05/06/1450383.html



WPF自定义控件 —— 复合控件(中国象棋联机版) – 咖喱块 – 博客园
http://www.cnblogs.com/Curry/archive/2009/05/06/1450383.html



21.2.2 使用代码创建动画(1) – 51CTO.COM
http://book.51cto.com/art/200908/145521.htm



WPF 深入研究 之 Control 控件 – 包建强的开源地带 – 博客园
http://www.cnblogs.com/Jax/archive/2009/02/11/1194218.html



WPF學習日誌 ~2008年3月號~ – 精華區 – VB2005討論板 – VB研究小站討論區 – Powered by Discuz!
http://www.ncis.com.tw/ncis_bbs/viewthread.php?tid=1457



SerialSeb: WPF Tips’n'Tricks #8: Use your code-behind for binding
http://ih8filters.com/browse.php?b=5&u=Oi8vc2VyaWFsc2ViLmJsb2dzcG90LmNvbS8yMDA3LzEwL3dwZi10aXBzLTgtdXNlLXlvdXItY29kZS1iZWhpbmQtZm9yLmh0bWw%3D



July 2009 – Posts – Orlando Perri
http://blogs.windowsclient.net/orlando_perri/archive/2009/07.aspx



WiredPrairie: Coding Archives
http://www.wiredprairie.us/journal/coding/



Spinning Progress Control in WPF
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0875ebf8-bb77-45ea-a929-d40743a3bf03/



WPF: Synchronizing animations (part 1: Using built-in features)
http://www.galasoft.ch/mydotnet/articles/article-2007060701.aspx



 

标签:, , ,
Xml转义字符 - 九月 5, 2009 by yippee

又碰到转义字符,估计这个是LINUX下JAVA生成的XML,所以只有
。

没有办法,只好整理了弄下。
if (c == ‘&’) {
buf.Append (“&”);
并且XML每次还得先把&转换成&。如果LOADXML," 就成了:"&

http://cse-mjmcl.cse.bris.ac.uk/blog/2007/02/14/1171465494443.html
In c#: xml = Regex.Replace(xml, “&\\#x(?:0[0-8BCEF]|1[0-9A-F]);”, “”);
这人狠,直接干掉··

http://www.csharper.net/blog/escape_xml_string_characters_in_c_.aspx
xml = xml.Replace( “&”, “&” );
xml = xml.Replace( “<”, “<” );

但是好像不区分大小写?

XML文档中使用多个关键字,如果XML文档中使用这些关键字,则需要转义。这些字符如下:

l         “&”用替换“&amp”;

l         “<”用替换“&lt;”;

l         “>”用替换“&gt;”;

l         “””用替换“&quot;”;

l         空格用替换“&nbsp;”。

XML标准中还定义了其它一些转义符,用于显示一些特别字符,如各种货币的符号(英镑:&pound;)、商标符号(&#8482;)等。

Character Name  Entity Reference  Character Reference  Numeric Reference
Ampersand  &amp;  &  &#38;#38;
Left angle bracket  &lt;  <  &#38;#60;
Right angle bracket  &gt;  >  &#62;
Straight quotation mark  &quot;  ”  &#39;
Apostrophe  &apos;  ’  &#34;
http://support.microsoft.com/?scid=kb%3Ben-us%3B316063&x=7&y=9
微软直接搞了个private void ReplaceSpecialChars(long linenumber)

我干脆全部替换一遍:
string s = xn.InnerText;
s = Regex.Replace(s, “&#xD;&#xA;”, “\r\n”);
s = Regex.Replace(s, “&nbsp;”, ” “);
s = Regex.Replace(s, “&#xD;”, “\r\n”);
s = Regex.Replace(s, “&#xA;”, “\r\n”);
s = Regex.Replace(s, “&quot;”, “”");
s = Regex.Replace(s, “&lt;”, “<”);
s = Regex.Replace(s, “&gt;”, “>”);
s = Regex.Replace(s, “&apos;”, “\”);
s = Regex.Replace(s, “&amp;”, “&”);

虽然据说2、System.Text.Regex(Regular Expression正则表达式),大家都估计到它的效率不高,虽然它支持忽略大小写。
//另外还碰到个好玩的事情,如果外接了显示器,并且拖过去了程序,如果拔掉,这个程序就找不回来了。得右键菜单-移动,然后拖回来。

表显示了 XML 输出中转义的字符。除 UserData 元素(其中包含用户提供的非转义数据)外,其他所有元素和属性均发生转义。UserData 元素是调用 TraceData 方法的结果。

转义字符
& &amp;
< &lt;
> &gt;
&quot;
\ &apos;
0xD &#xD;
0xA &#xA;

找了找资料,发现很多也是手工转换:

标签:,
OPhone初步印象 - 九月 2, 2009 by yippee

今天转悠转悠,跑到了OPHONE网站去了。
首先去的是:http://www.mmarket.com/
然后进入了开发者社区:http://dev.chinamobile.com/cmdn/supesite/
里面的资料还有些,看了看OPHONE SDK的一点编程资料
从DEMO又调到了:http://www.ophonesdn.com/documentation/ophone/gettingstarted/hello_ophone.html
这是一个源码:
http://www.ophonesdn.com/documentation/ophone/samples/ophoneapps/HomeAPIDemo/src/oms/samples/home/HomeAPIDemoActivity.java.html

  • /**
  • * This demo implement 3 functions:
  • * 1. Add/Remove symbol to shortcut.
  • *    For example: In Feiton, if you received messages, you can show the
  • *    message count on the shortcut. While user read the message, remove
  • *    the symbol from Fetion shortcut.
  • * 2. Add shortcut on Home Screen.
  • *    If you install an application, you can use Home Screen API
  • *    to add shortcut on Home Screen.
  • *    If you want to delete the shortcut, you should delete it manually.
  • *    Long press the shortcut item, and select ’delete’ item.
  • * 3. Register a broadcast receiver, so you can know when the Home Screen
  • *    load complete or when the shortcut is added.
  • * For more detail, see the following demo code.
  • * */
  • 感觉还是太复杂了

  • TextPaint textPaint = new TextPaint();
  • textPaint.setColor(Color.WHITE);
  • textPaint.setAntiAlias(true);
  • textPaint.setTextAlign(Align.CENTER);
  • textPaint.setTextSize(14f);
  • textPaint.setFakeBoldText(true);
  • canvas.drawBitmap(bg, 0, 0, null);
  • canvas.drawText(Integer.toString(mUnreadMessageCount), bg
  • .getWidth() / 2, 14, textPaint);
  • 看来没有可视化界面编程,如果做复杂界面程序,估计是个痛苦的事情
    至于编程也是大同小异。
    也是NEW,然后设置属性,最后画出来
    不过CANVAS好像很强悍的样子
    画图,画文本

    标签:,
    令人抓狂的silverlight3开发环境构建 - 九月 1, 2009 by yippee

    令人抓狂的silverlight3开发环境构建


    想弄下silverlight 3 ,我已经安装了VS2008 SP1。
    到官网一看:东西不少
    Microsoft® Silverlight™ 3 Tools for Visual Studio 2008 SP1
    Microsoft® Silverlight™ 3 SDK
    Microsoft Silverlight 3 脱机文档


    不过SDK还不到10M。而2.0版本的却有
    Microsoft® Silverlight™ 2 软件开发工具包 55.8 MB



    安装了SDK,说我原有版本更高。这也是我登录MS网站提示我安装的。
    于是就卸载。然后安装了SDK


    再安装TOOLS,结果提示:
    Action: Downloading Items…


    [9/1/2009, 11:35:39] (IronSpigot::CompositeDownloaderT<class IronSpigot::RetryingDownloaderT<class IronSpigot::WinHttpDownloader,class IronSpigot::BitsDownloader,class IronSpigot::UrlMonDownloader,class IronSpigot::FileAuthenticity> >::PerformAction) Downloading http://go.microsoft.com/fwlink/ to R:\TEMP\Silverlight 3.0 Tools\Silverlight_Developer.exe
    [9/1/2009, 11:35:39] (IronSpigot::RetryingDownloaderT<class IronSpigot::WinHttpDownloader,class IronSpigot::BitsDownloader,class IronSpigot::UrlMonDownloader,class IronSpigot::FileAuthenticity>::UseHttp) Determine the protocol to use


    去下载了一个,安装了后继续:
    提示版本不对,只好卸载,再重新安装TOOLS


    亏我还是官网下载的:http://download.microsoft.com/download/0/D/7/0D76C405-E0E5-43CC-89D3-18243A4FCA86/Silverlight.3.0_Developer.exe
    下载SDK的时候看到的:
    在安装 Silverlight 3 SDK 前,请删除 Silverlight 3 SDK Beta。


    如果您已安装或计划安装 Microsoft Silverlight Tools for Visual Studio 2008,请直接跳过 Silverlight SDK 的安装。Microsoft Silverlight Tools 将安装 Silverlight 3 SDK。有关此方面的更多信息,请单击此处。


    若要生成 Silverlight 3 应用程序,您可以在此处安装 Silverlight 3 for Developers



    结果提示安装失败
    WINHTTP_CALLBACK_STATUS_REQUEST_ERROR error: error=12002, result= 2. Percentage downloaded=19
    [9/1/2009, 12:1:19] (IronSpigot::RetryingDownloaderT<class IronSpigot::WinHttpDownloader,class IronSpigot::BitsDownloader,class IronSpigot::UrlMonDownloader,class IronSpigot::FileAuthenticity>::PerformAction) Download failed at attempt 4 of 4 for http://go.microsoft.com/fwlink/?LinkID=150219 using http:
    [9/1/2009, 12:1:19] (IronSpigot::LogUtils::LogFinalResult) Final Result: Installation failed with error code: (0×80072EE2).


    [9/1/2009, 12:1:19] Action complete



    只好又重新手工下载··然后安装


    结果这个···
    居然还是要下载······
    我彻底无语了········


    ~~~~~~~~~
    1. 先打VS2008Sp1的包
    http://www.microsoft.com/downloadS/details.aspx?familyid=27673C47-B3B5-4C67-BD99-84E525B5CE61&displaylang=zh-cn


    2. 装 Silverlight3_Tools.exe
    http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=c22d6a7b-546f-4407-8ef6-d60c8ee221ed


    3. 装silverlight_sdk.exe


    http://www.microsoft.com/downloads/details.aspx?familyid=8D933343-038F-499C-986C-C3C7E87A60B3&displaylang=zh-cn


    1:安装VS2008


    下载地址:http://msdn.microsoft.com/en-us/vs2008/products/cc268305.aspx


     


    2:给VS2008打SP1补丁


    下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyID=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en



    3:安装VS2008专用SilverLight开发插件


    VS2008 SP1默认不安装Silverlight模版。需要手动下载Microsoft Silverlight Tools for Visual Studio 2008下载地址是:


    http://www.microsoft.com/downloads/details.aspx?FamilyID=50a9ec01-267b-4521-b7d7-c0dba8866434&DisplayLang=en


    有多种语言版本。


    下载前请按网页上的,提示卸载以前任何SL1.1或以前版本的 相关补丁。


    下载安装后,新建工程,会出现SilverLight模版选项,此时,VS2008也能和Microsoft Expression Blend 结合使用了。


    (图用的博客园一位同仁的)


    最后,注意安装顺序。


    (1),卸载Silverlight Runtime(客户端插件),经过个人测试,这步好像是必须的,不然第2步到最后会失败。如果失败,从第1步重来


    (2),安装Microsoft Silverlight Tools for Visual Studio 2008


    (3),然后安装Silverlight Runtime

    标签:, ,
    Wordpress的BBTHME主题修改HELLOFLASH为D13Slideshow - 八月 27, 2009 by yippee

    安装了BBTHEMS,介绍可以参考:http://blog.iibetter.com/?p=10140 Wordpress主题下载该主题采用了HELLOFLASH作为幻灯片插件:参考了:
    HelloFlash(WordPress幻灯片插件)的使用方法及注意事项
    http://paranimage.com/5-wordpress-slideshow-plugins-for-featured-posts/

    HelloFlash使用方法及注意事项
    然而还是时而好,时而坏,一怒之下,决定换个插件。

    上网看到:
    5款WordPress推荐文章幻灯片插件
    http://paranimage.com/5-wordpress-slideshow-plugins-for-featured-posts/
    好像第一个不错的样子:D13design提供的一个WordPress插件,以Javascript幻灯片动画的形式展示推荐内容。包含图片,标题和摘要。可选输出5篇或10篇,后台选择要输出哪些文章。幻灯片样式可设为循环播放,只播放一次或手动导航,以及其它一些方便的设置。下载后安装,似乎正常,可是配置页面总是显示不完整,提示如下:
    <b>Fatal error</b>:  Maximum execution time of 30 seconds exceeded in <b>D:\PhpNow\htdocs\wp\wp-includes\plugin.php</b> on line <b>385</b><br />
    看了看代码:
    global $post;
    foreach($myposts as $post) :
    setup_postdata($post); ?>
    <option value=”<?php echo(the_ID()); ?>” <?php if($post->ID==$temp){ echo(“selected”); } ?>><?php echo $post->ID; ?>: <?php the_title(); ?></option>
    <?php endforeach; ?>
    </select>

    看来是由于我的BLOG条目2000多条,太多了,导致超时了。

    找了找资料,改成:
    $querystr = “       SELECT *       FROM wp_posts       ORDER BY wp_posts.post_date DESC       LIMIT 0,20        “;
    global $wpdb;
    $pageposts = $wpdb->get_results($querystr);
    foreach ($pageposts as $topten)
    {
    $postid = $topten->ID;
    $title = $topten->post_title;
    ?>
    <option value=”<?php echo $topten->ID; ?>”
    <?php
    if($topten->ID==$temp){ echo(“selected”); } ?>>
    <?php echo $topten->ID; ?>:
    <?php echo $topten->post_title; ?>
    </option>      <?php }; ?>

    只显示前面20个终于正常了··参考资料:

    WordPress:Displaying Posts Using a Custom Select Query
    http://www.zzbaike.com/wiki/WordPress:Displaying_Posts_Using_a_Custom_Select_Query
    wordpress源代码分析之get_option()函数
    http://hi.baidu.com/seriouscool/blog/item/929fbbdd0a9a7adf8d1029e9.html
    http://wordpress.org/extend/plugins/d13slideshow/faq/
    如何为你的wordpress主题添加幻灯片展示

    标签:, ,
    20090624 sqlite insert or ignore - 八月 18, 2009 by yippee

     public override int Insert( HelpEntity e ) &leftsign;
                //构造sql
                string sql = "INSERT INTO [HelpEntity](Name,Nickname,Text,IsIncluded,Guid)VALUES(@Name,@Nickname,@Text,@IsIncluded,@Guid);select last_insert_rowid()";

                //参数构造
                SQLiteParameter[] parameters = &leftsign;
                    new SQLiteParameter("@Name",DbType.String),
                    new SQLiteParameter("@Nickname",DbType.String),
                    new SQLiteParameter("@Text",DbType.String),
                    new SQLiteParameter("@IsIncluded",DbType.Boolean),
                    new SQLiteParameter("@Guid",DbType.Guid),
                &rightsign;;

                //为参数赋值
                int i = 0;
                parameters[ i++ ].Value = e.Name;
                parameters[ i++ ].Value = e.Nickname;
                parameters[ i++ ].Value = e.Text;
                parameters[ i++ ].Value = e.IsIncluded;
                parameters[ i++ ].Value = e.Guid;

                //执行查询
                try &leftsign;
                    object obj = db.ExecuteScalar( CommandType.Text, sql, parameters );
                    if( obj != null )
                        return int.Parse( obj.ToString() );
                    return -1;
                &rightsign; catch( Exception exp ) &leftsign;
                    throw exp;
                &rightsign;
            &rightsign;

    ~
    Look at the sqlite.org: http://www.sqlite.org/lang_expr.html

    last_insert_rowid() Return the ROWID of the last row insert from this connection to the database.

    It returns last inserted rowid inside connection! You always do open and close connection while querying database. Iif you query \’last_insert_rowid()\’ you do tha same: open new connection and then you get 0.

    I know all that, but i have the same problem. I\’m using microsoft visual studio express C# with tableadapters. All queries are like: this.tableadapter.query(parameters).
    ~
    Change your SQL to:

    "insert into people (Name) values(@Name);
     SELECT last_insert_rowid() AS RecordID;";

    Then call ExecuteScalar() on it instead of ExecuteNonQuery() to get the rowid.

    Also your table definition should be:

    CREATE TABLE People (RecordID INTEGER PRIMARY KEY AUTOINCREMENT, Name VARCHAR);

    Robert
    ~
    ExecuteScalar方法返回的类型是object类型,这个方法返回sql语句执行后的第一行第一列的值,由于不知到sql语句到底是什么样的结构(有可能是int,有可能是char等等),所以ExecuteScalar方法返回一个最基本的类型object,这个类型是所有类型的基类,换句话说:可以转换为任意类型。

    ExecuteNonQuery方法是用来执行insert、delete、update语句的,由于这些语句执行后只有一个结果:“影响了**行”,所以ExecuteNonQuery方法返回的是影响的行数(int)。

    虽然SQL中列的name本身就是字符串类型,但是你通过dataReader["name"]这种方式访问这个字段,必须强制类型转换,因为dataReader["name"]就像一个数组,数组中的每个元素的类型都应该一样,所以dataReader[]这个数组中的元素类型也被定义为object类型,以方便转换。

    int.Parse(("select max(id) from [tb]").ToString())+1);

    select top 1 id from [tb] order by id desc

    select SCOPE_IDENTITY()

    I need something like: http://sqlite.phxsoftware.com/forums/p/1029/4441.aspx#4441

    INSERT INTO Timeline (name, ts)
    SELECT @name, @ts
    WHERE NOT EXISTS (SELECT 1 FROM Timeline WHERE name=@name AND ts = @ts);

    It works fine with insert. I was wondering if update can be added to the above statement.

    ~
    C:\\sqlite>sqlite3.exe testdb.db
    SQLite version 3.5.1
    Enter ".help" for instructions
    sqlite> create table people (lastname text, firstname text, salary double);
    sqlite> create unique index people_unique_1 on people (lastname, firstname);
    sqlite> insert or ignore into people values (\’smith\’, \’john\’, 44548.33);
    sqlite> select * from people;
    smith&line;john&line;44548.33
    sqlite> insert or ignore into people values (\’smith\’, \’john\’, 44548.33);
    sqlite> select * from people;
    smith&line;john&line;44548.33
    sqlite> insert or ignore into people values (\’smith\’, \’linda\’, 44548.33);
    sqlite> select * from people;
    smith&line;john&line;44548.33
    smith&line;linda&line;44548.33
    sqlite>

    标签:,
    20090623 treeview esc LabelEdit - 八月 18, 2009 by yippee

    treeview esc

    void treeType_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
            &leftsign;
                Console.WriteLine(e.Label);
                if (e.Label==null)
                &leftsign;
                    e.Node.EndEdit(true);
                    e.Node.Remove();
                &rightsign;

      CancelEdit  获取或设置指示是否已取消编辑的值。
      Label  获取与树节点关联的新文本。
      Node  获取包含待编辑文本的树节点。

    如果用户按 Esc 取消编辑或没有修改标签文本就按 Enter,此属性的值则为 nullNothingnullptrnull 引用(在 Visual Basic 中为 Nothing)。如果用户编辑标签文本,此属性的值则为新的标签文本。即使编辑的标签文本最后的值与其原始值相同,也是如此。

            ~
            I suggest that you set a flag in the BeforeLabelEdit event and reset the
    flag in AfterlabelEdit. In KeyDown if flag and KeyCode=vbEscape then you
    remove the Node.

    Another method is just to add the node with a default name and have the user
    to delete the node if he wants to. I believe this is more like the Windows
    style.

    Leif H

    我在treeView中新增节点,并把它处于可编辑状态。但如果我想用Esc键退出新增节点的编辑状态,并把它删除,就调用了treeview的 keydown事件。但如何在treeview的AfterLabelEdit中调用keydown事件呢?请高手指点!!!!!

    标签:,
    20090611 c# vc 流控 - 八月 18, 2009 by yippee

    flowcontrol

     这次碰到问题了

    一个据称无流控的终端

    最开始用C# SERIALPORT
    以为不是很轻而易举的事情
    结果一搞,成功率非常低
    发送五六次才成功一次

    然后改用VC,结果发现还是一样
    调来调去发现如果什么都不配置
    直接BUILDDCB,反而可以

    再用C#调用API,这下也可以了

    ········
    CString s;
        s.Format(L"%d,N,8,1",m_dwBaudRate);   
        BOOL b=BuildCommDCB(s,&dcb);   
        dcb.ByteSize = m_bByteSize;
        dcb.Parity = m_bParity;
        dcb.StopBits = m_bStopBits;
        fRetVal = SetCommState(m_hCom,&dcb);
     
        // Handshaking
        typedef enum
        &leftsign;
            EHandshakeUnknown        = -1,    // Unknown
            EHandshakeOff            =  0,    // No handshaking
            EHandshakeHardware        =  1,    // Hardware handshaking (RTS/CTS)
            EHandshakeSoftware        =  2    // Software handshaking (XON/XOFF)
        &rightsign;
        EHandshake;

        // Set the handshaking flags
        switch (m_FlowCtrl)
        &leftsign;
        case EHandshakeOff:
            dcb.fOutxCtsFlow = FALSE;                    // Disable CTS monitoring
            dcb.fOutxDsrFlow = FALSE;                    // Disable DSR monitoring
           
            dcb.fOutX = FALSE;                            // Disable XON/XOFF for transmission
            dcb.fInX = FALSE;                            // Disable XON/XOFF for receiving
            //dcb.fRtsControl = RTS_CONTROL_DISABLE;        // Disable RTS (Ready To Send)
            //dcb.fDtrControl = DTR_CONTROL_DISABLE;        // Disable DTR monitoring
            就是这两个
            break;

            fDtrControl
    The DTR (data-terminal-ready) flow control. This member can be one of the following values.

    Value Meaning
    DTR_CONTROL_DISABLE
    0×00
     Disables the DTR line when the device is opened and leaves it disabled.
     
    DTR_CONTROL_ENABLE
    0×01
     Enables the DTR line when the device is opened and leaves it on.
     
    DTR_CONTROL_HANDSHAKE
    0×02
     Enables DTR handshaking. If handshaking is enabled, it is an error for the application to adjust the line by using the EscapeCommFunction function.
     
    估计要用这段代码
    #  // 设置流控制方式  
    #         switch (nComShake)  
    #         &leftsign;  
    #         case 0:  
    #             // 无流量控制  
    #             dcb.fOutxCtsFlow = FALSE;  
    #             dcb.fOutxDsrFlow = FALSE;  
    #             dcb.fOutX = FALSE;  
    #             dcb.fInX = FALSE;  
    #             break;  
    #         case 1:  
    #             // RTS控制,监视CTS信号  
    #             dcb.fOutxCtsFlow = TRUE;  
    #             dcb.fOutxDsrFlow = FALSE;  
    #             dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;  
    #             dcb.fOutX = FALSE;  
    #             dcb.fInX = FALSE;  
    #             break;  
    #         case 2:  
    #             // DTR控制,监视CTS信号  
    #             dcb.fOutxCtsFlow = TRUE;  
    #             dcb.fOutxDsrFlow = FALSE;  
    #             dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;  
    #             dcb.fOutX = FALSE;  
    #             dcb.fInX = FALSE;  
    #             break;  
    #         case 3:  
    #             // RTS控制,监视DSR信号  
    #             dcb.fOutxCtsFlow = FALSE;  
    #             dcb.fOutxDsrFlow = TRUE;  
    #             dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;  
    #             dcb.fOutX = FALSE;  
    #             dcb.fInX = FALSE;  
    #             break;  
    #         case 4:  
    #             // DTR控制,监视DSR信号  
    #             dcb.fOutxCtsFlow = FALSE;  
    #             dcb.fOutxDsrFlow = TRUE;  
    #             dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;  
    #             dcb.fOutX = FALSE;  
    #             dcb.fInX = FALSE;  
    #             break;  
    #         case 5:  
    #             // XON/XOFF控制方式  
    #             dcb.fOutxCtsFlow = FALSE;  
    #             dcb.fOutxDsrFlow = FALSE;  
    #             dcb.fOutX = TRUE;  
    #             dcb.fInX = TRUE;  
    #             dcb.XonChar = 0×11;  
    #             dcb.XoffChar = 0×13;  
    #             dcb.XoffLim = 100;  
    #             dcb.XonLim = 100;  
    #             break;  
    #         &rightsign;   

    标签:,