问题列表 - 第27181页

Windows.Forms.MessageBox在页面.aspx中

首先抱歉英语.我最近发现Windows.Forms中的MessageBox可以在网页中使用,但是在显示它时会出现问题,它不是模态的.有没有办法让它莫代尔?

谢谢你的帮助.

c# asp.net visual-studio

2
推荐指数
1
解决办法
282
查看次数

Clojure中宏中关键字的奇怪行为

在宏扩展时评估关键字访问在Clojure中的表现时,我有点困惑.

以下工作正如我所料:

(def m {:a 1})
(:a m)
=> 1 
Run Code Online (Sandbox Code Playgroud)

但是,相同的关键字访问似乎不适用于宏:

(def m {:a 1})
(defmacro get-a [x] (:a x))
(get-a m)
=> nil
Run Code Online (Sandbox Code Playgroud)

知道这里发生了什么吗?

macros clojure map keyword

4
推荐指数
1
解决办法
203
查看次数

适用于C或C++的类似SWT的GUI工具包

你知道任何跨平台的GUI工具包,比如swt for C(在每个操作系统中使用默认小部件= eclipse.org/swt上的正确图片)?有一个名为DWT的D语言的swt实现,但我需要它用于C或C++.谢谢.

c c++ user-interface swt cross-platform

3
推荐指数
1
解决办法
2461
查看次数

有没有更好的方法来使用Auth更改cakephp中的用户密码?

我自己学习cakephp.我试图创建一个带有changepassword功能的用户控制器.它有效,但我不确定这是否是最好的方法,我无法在这方面搜索有用的教程.这是我的代码:

class UsersController extends AppController {

    var $name = 'Users';

    function login() {
    }

    function logout() {
        $this->redirect($this->Auth->logout());
    }

    function changepassword() {
        $session=$this->Session->read();
        $id=$session['Auth']['User']['id'];
        $user=$this->User->find('first',array('conditions' => array('id' => $id)));
        $this->set('user',$user);
        if (!empty($this->data)) {
            if ($this->Auth->password($this->data['User']['password'])==$user['User']['password']) {
                if ($this->data['User']['passwordn']==$this->data['User']['password2']) {
                // Passwords match, continue processing
                $data=$this->data;
                $this->data=$user;
                $this->data['User']['password']=$this->Auth->password($data['User']['passwordn']);
                $this->User->id=$id;
                $this->User->save($this->data);
                $this->Session->setFlash('Password changed.');
                $this->redirect(array('controller'=>'Toners','action' => 'index'));
                } else {
                    $this->Session->setFlash('New passwords differ.');
                    }
            } else {
                $this->Session->setFlash('Typed passwords did not match.');
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

password是旧密码,passwordn是新密码,password2是新密码.还有其他更多的coomon方式在蛋糕中做到吗?

cakephp

14
推荐指数
2
解决办法
2万
查看次数

如何支持包含自定义类型的QVariant对象的比较?

根据Qt文档,QVariant::operator==如果变体包含自定义类型,则无法正常工作:

bool QVariant :: operator ==(const QVariant&v)const

将此QVariant与v进行比较,如果它们相等则返回true; 否则返回false.

在自定义类型的情况下,不调用它们的相等运算符.而是比较值的地址.

你怎么能让这个为你的自定义类型表现得有意义?在我的例子中,我将枚举值存储在QVariant中,例如

在标题中:

enum MyEnum { Foo, Bar };

Q_DECLARE_METATYPE(MyEnum);
Run Code Online (Sandbox Code Playgroud)

功能中的某个地方:

QVariant var1 = QVariant::fromValue<MyEnum>(Foo);
QVariant var2 = QVariant::fromValue<MyEnum>(Foo);
assert(var1 == var2); // Fails!
Run Code Online (Sandbox Code Playgroud)

为了使这个断言成为现实,我需要做些什么呢?

我理解为什么它不起作用 - 每个变体都存储枚举值的单独副本,因此它们具有不同的地址.我想知道如何改变我在变体中存储这些值的方法,以便这不是一个问题,或者它们都引用相同的底层变量.

它不认为我可以绕过需要平等比较才能工作.上下文是我使用此枚举作为a中项目的UserData QComboBox,我希望能够QComboBox::findData用于定位与特定枚举值对应的项索引.

c++ qt qvariant

22
推荐指数
1
解决办法
5019
查看次数

获取当前目录的跨平台方式是什么?

我需要一种跨平台的方式来获取当前的工作目录(是的,getcwd做我想要的).我认为这可能会成功:

#ifdef _WIN32
    #include <direct.h>
    #define getcwd _getcwd // stupid MSFT "deprecation" warning
#elif
    #include <unistd.h>
#endif
#include <string>
#include <iostream>
using namespace std;

int main()
{
    string s_cwd(getcwd(NULL,0));
    cout << "CWD is: " << s_cwd << endl;
}
Run Code Online (Sandbox Code Playgroud)

我读到了这个:

应该没有内存泄漏,它也可以在Mac上运行,对吗?

更新:我担心这里仍然存在错误(我试图避免创建一个具有确定长度的char数组,因为没有正确的方法来获得getcwd的合适长度):

char* a_cwd = getcwd(NULL,0);
string s_cwd(a_cwd);
free(a_cwd); // or delete a_cwd? 
Run Code Online (Sandbox Code Playgroud)

c++ cross-platform getcwd

18
推荐指数
2
解决办法
2万
查看次数

网格中n个项目的平衡布局

我有一个要在网格中显示的n个徽标列表,每行最多3个.什么算法决定每行显示多少,以便每行的徽标数尽可能平衡而不使用超过最小可能行数?

例如:

 n -> number in each row
 1 -> 1
 2 -> 2
 3 -> 3
 4 -> 2, 2
 5 -> 3, 2
 6 -> 3, 3
 7 -> 3, 2, 2
 8 -> 3, 3, 2
 9 -> 3, 3, 3
10 -> 3, 3, 2, 2
Run Code Online (Sandbox Code Playgroud)

algorithm math

3
推荐指数
2
解决办法
685
查看次数

Internet Explorer的数组indexOf实现

有很多关于如何将indexOf实现引入Array原型的解决方案,以便它可以在Internet Explorer下工作,但是我偶然发现了一个似乎无法在我看到的任何地方解决的问题.

使用在MDC上非常同意的实现,我有以下代码现在有问题:

// indexOf support for IE (from MDC)
if (!Array.prototype.indexOf)
{
    Array.prototype.indexOf = function(elt /*, from*/)   
    {
        var len = this.length >>> 0;

        var from = Number(arguments[1]) || 0;
        from = (from < 0) ? Math.ceil(from) : Math.floor(from);
        if (from < 0)
            from += len;

        for (; from < len; from++)
        {
            if (from in this && this[from] === elt)  
                return from;
        }
        return -1;
    };
}

var i = [1,2,3,4];

for (j in …
Run Code Online (Sandbox Code Playgroud)

javascript arrays internet-explorer indexof

3
推荐指数
1
解决办法
3287
查看次数

使用ASP.NET网站进行持续部署?

我在C#/ ASP.NET中有一个目前正在开发的网站.当我们正在制作时,我希望在一天中经常发布,因为我们修复了错误并添加了功能(例如:http://toni.org/2010/05/19/in-praise-of -continuous-deployment-the-wordpress-com-story /).

如果您上传新版本的网站甚至更改单个文件,它会启动当前登录的用户并使其从任何表单等开始.是否有秘密能够在不干扰.NET站点用户的情况下进行部署?

.net c# asp.net session-state continuous-deployment

14
推荐指数
2
解决办法
1886
查看次数

验证字符串

我对正则表达式不太好......

我需要一个JavaScript正则表达式,它将执行以下操作:

  1. 字符串可以包含字母(大写小写),但不包含标点,例如éàïç...
  2. 该字符串可以在字符串中的任何位置包含数字(0..9),第一个位置除外.
  3. 该字符串可以包含下划线(_).

有效字符串:

  • FOO
  • foo1
  • foo_bar这样的名称
  • Foobar的

无效的字符串:

  • 1foo - >数字作为第一个字符
  • foo bar - >空间
  • föo - >标点符号ö

非常感谢!

javascript regex

1
推荐指数
1
解决办法
226
查看次数