程序设计

专业和发烧友程序员的问答

18
在WPF中将窗口移到最前面
如何将WPF应用程序带到桌面前端?到目前为止,我已经尝试过: SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true); SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetForegroundWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle); 没有一个人在做这项工作(Marshal.GetLastWin32Error()就是说这些操作已成功完成,并且每个定义的P / Invoke属性都具有SetLastError=true)。 如果我创建一个新的空白WPF应用程序,并SwitchToThisWindow使用一个计时器调用,它将完全按预期工作,因此我不确定为什么在我的原始情况下它不起作用。 编辑:我正在与全局热键一起执行此操作。
214 c#  .net  wpf  winapi  pinvoke 

3
MongoDB:在一个字段上更新每个文档
我有一个foo假设收集的名字。 的每个实例foo都有一个名为lastLookedAt的字段,这是从纪元开始的UNIX时间戳。我希望能够通过MongoDB客户端,并将所有现有文档(其中约20,000个)的时间戳设置为当前时间戳。 处理此问题的最佳方法是什么?
214 mongodb 

7
如何使用PHP从JSON提取数据?
这旨在作为一般参考问题和答案,涵盖许多永无止境的“如何访问JSON中的数据?” 问题。它在这里处理在PHP中解码JSON和访问结果的广泛基础知识。 我有JSON: { "type": "donut", "name": "Cake", "toppings": [ { "id": "5002", "type": "Glazed" }, { "id": "5006", "type": "Chocolate with Sprinkles" }, { "id": "5004", "type": "Maple" } ] } 如何在PHP中对此进行解码并访问结果数据?
214 php  json 

5
UI线程上的任务继续
是否有一种“标准”方法来指定任务继续应该在创建初始任务的线程上运行? 目前,我有下面的代码-它正在工作,但是跟踪调度程序并创建第二个Action似乎是不必要的开销。 dispatcher = Dispatcher.CurrentDispatcher; Task task = Task.Factory.StartNew(() => { DoLongRunningWork(); }); Task UITask= task.ContinueWith(() => { dispatcher.Invoke(new Action(() => { this.TextBlock1.Text = "Complete"; } });
214 c#  .net  wpf  multithreading  task 


19
Android 4.4(KitKat)上的Android Gallery为Intent返回不同的URI。ACTION_GET_CONTENT
在KitKat之前(或在新Gallery之前)Intent.ACTION_GET_CONTENT返回了这样的URI 内容:// media / external / images / media / 3951。 使用ContentResolver和查询 MediaStore.Images.Media.DATA返回文件URL。 但是,在KitKat中,图库会返回URI(通过“ Last”),如下所示: 内容://com.android.providers.media.documents/document/image:3951 我该如何处理?

11
如何将一个反应成分传递到另一个反应成分中以超越第一成分的含量?
有没有办法将一个组件传递到另一个React组件?我想创建一个模型react组件,并传入另一个react组件以包含该内容。 编辑:这是一个reactJS codepen,说明了我正在尝试做的事情。http://codepen.io/aallbrig/pen/bEhjo 的HTML <div id="my-component"> <p>Hi!</p> </div> ReactJS /**@jsx React.DOM*/ var BasicTransclusion = React.createClass({ render: function() { // Below 'Added title' should be the child content of <p>Hi!</p> return ( <div> <p> Added title </p> {this.props.children} </div> ) } }); React.renderComponent(BasicTransclusion(), document.getElementById('my-component'));

18
JavaScript的String.indexOf()是否有允许正则表达式的版本?
在javascript中,是否有等效的String.indexOf()接受正则表达式而不是第一个第一个参数的字符串,同时仍允许第二个参数? 我需要做类似的事情 str.indexOf(/[abc]/ , i); 和 str.lastIndexOf(/[abc]/ , i); 虽然String.search()将regexp作为参数,但不允许我指定第二个参数! 编辑: 事实证明,这比我最初想象的要难,所以我编写了一个小的测试函数来测试所有提供的解决方案...假定regexIndexOf和regexLastIndexOf已添加到String对象。 function test (str) { var i = str.length +2; while (i--) { if (str.indexOf('a',i) != str.regexIndexOf(/a/,i)) alert (['failed regexIndexOf ' , str,i , str.indexOf('a',i) , str.regexIndexOf(/a/,i)]) ; if (str.lastIndexOf('a',i) != str.regexLastIndexOf(/a/,i) ) alert (['failed regexLastIndexOf ' , str,i,str.lastIndexOf('a',i) …



10
“ for line in…”导致UnicodeDecodeError:'utf-8'编解码器无法解码字节
这是我的代码, for line in open('u.item'): #read each line 每当我运行此代码时,都会出现以下错误: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 2892: invalid continuation byte 我试图解决这个问题,并在open()中添加了一个额外的参数,代码看起来像; for line in open('u.item', encoding='utf-8'): #read each line 但是,它再次给出相同的错误。那我该怎么办!请帮忙。

16
TypeError:调用jQuery函数时$不是函数
我在使用jQuery包装器的WordPress插件中有一个简单的jQuery脚本,如下所示: $(document).ready(function(){ // jQuery code is in here }); 我从WordPress仪表板内部调用此脚本,并在jQuery框架加载后将其加载。 当我在Firebug中检查页面时,我一直不断收到错误消息: TypeError:$不是函数 $(document).ready(function(){ 我是否应该将脚本包装在此函数中: (function($){ // jQuery code is in here })(jQuery); 我已经有很多次此错误,并且不确定如何处理。 任何帮助将不胜感激。

8
如何在MySQL中将BLOB转换为TEXT?
我有很多记录,其中文本已存储在MySQL的Blob中。为了便于处理,我想将数据库中的格式更改为TEXT ...任何想法如何轻松进行更改以免打断数据-我想它将需要正确编码?
214 sql  mysql  blobs 


25
从数据库表生成类
如何从SQL Server表对象生成类? 我不是在谈论使用一些ORM。我只需要创建实体(简单类)。就像是: public class Person { public string Name { get;set; } public string Phone { get;set; } } 给定一些表,如: +----+-------+----------------+ | ID | Name | Phone | +----+-------+----------------+ | 1 | Alice | (555) 555-5550 | | 2 | Bob | (555) 555-5551 | | 3 | Cathy …
214 c#  sql  sql-server  tsql 

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.