问题列表 - 第38071页

放大WPF的方法

我需要实现与Office 2010相同的缩放功能.

内容可以是任何UI元素,包括第三方网格(可能是telerik)

我知道4种实现缩放的方法.

在这种情况下实现缩放的最佳方式(性能)是什么?

wpf zoom

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

直接从C++ 0x lambda调用者返回

我刚刚重写了以下C89代码,它从当前函数返回:

// make sure the inode isn't open
{
    size_t i;
    for (i = 0; i < ARRAY_LEN(g_cpfs->htab); ++i)
    {
        struct Handle const *const handle = &g_cpfs->htab[i];
        if (handle_valid(handle))
        {
            if (handle->ino == (*inode)->ino)
            {
                log_info("Inode "INO_FMT" is still open, delaying removal.",
                        (*inode)->ino);
                return true;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

使用此C++ 0x STL/lambda混合:

std::for_each(g_cpfs->htab.begin(), g_cpfs->htab.end(), [inode](Handle const &handle) {
    if (handle.valid()) {
        if (handle.ino == inode->ino) {
            log_info("Inode "INO_FMT" is still open, delaying removal.", inode->ino);
            return true;
        }
    }});
Run Code Online (Sandbox Code Playgroud)

哪个产生:

1> …

c++ lambda return-type c++11

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

明确的模板专业化问题

template <class T>
class Test
{
public:
    template<class U> void f(); //generic function

    template<> void f<char>(); //Specialization for char.
};

template <class T>
template<class U> 
void Test<T>::f()   //Definition of generic function
{
}

template<>
template<> void Test<char>::f<char>(){}  //Definition of specialization.

int main()
{
    Test<char> ob1;
    ob1.f<char>(); //Works fine.

    Test<int> ob2;
    ob2.f<char>();  //Produces linker error.
}
Run Code Online (Sandbox Code Playgroud)

链接器错误是

error LNK2019: unresolved external symbol "public: void __thiscall
Test<int>::f<char>(void)"
Run Code Online (Sandbox Code Playgroud)

我的要求是:我应该能够将任何类型传递给Test类,并将任何类型传递给函数f().我应该可以使用下面所有类型的组合.

  Test   f()
  --------------
  int    char
  char   int
  int    int
Run Code Online (Sandbox Code Playgroud)

我可以通过定义下面的另一个函数来解决错误.

template<>
template<> void Test<int>::f<char>(){} …
Run Code Online (Sandbox Code Playgroud)

c++

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

从String.GetHashCode解密哈希字符串?

来自MSDN的示例代码 http://msdn.microsoft.com/en-us/library/system.string.gethashcode.aspx

"abc"的哈希码是:536991770

但是如何将"536991770"转换回"abc"?

c#

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

如何在Linux中生成真正的随机数(非伪)

在Linux(C/C++代码)中创建安全随机数的(最佳)方法是什么,比一般rand()结果更随机,而不是伪作为OpenSSL BN_rand?

在Windows中,我发现这CryptGenRandom()是一个不错的选择.Linux中有没有相同的东西?

先感谢您.

c++ linux security random

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

如何用汇编语言检查EIP值?

我想用汇编语言获取EIP寄存器的当前值.那可能吗?

x86 assembly

34
推荐指数
3
解决办法
3万
查看次数

是否可以在整个类上添加@Secured或@PreAuthorized注释

保护整个控制器类而不是每个方法似乎是合乎逻辑的.我可以这样做:

@Controller
@Secured("ROLE_USER")
public class accountPages {
   //Controllers
}
Run Code Online (Sandbox Code Playgroud)

java spring-mvc spring-security

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

如何使用纯CSS对表单中的标签和字段进行样式设置并获得正确的对齐?

我要求作为最后的努力来遵守我的良心并用CSS做到这一点.我想使用CSS来布局这个简单的表单,但我花了两个小时试图获得它并且总是最终出现对齐问题.我用十分钟就用它做了.

我需要右对齐标签,名称行分为两部分,标签与输入文本正确垂直对齐,以及输入的所有右边缘排成一行.在CSS中做什么需要做什么?

替代文字

编辑:添加我的CSS,看看我哪里出错了.

这就是我用CSS获得的:

.form_row {
    width: 500px;
}
.form_row label {
    text-align: right;
    width: 150px;
    float: left;
    margin-top: 6px;
    padding-right: 6px;
}
#id_first_name, #id_last_name {
    width: 130px;
}
#id_email, #id_password {
    width: 300px;
}
Run Code Online (Sandbox Code Playgroud)

标记:

<div class="form_row">
    <label for="id_first_name">Name:</label>
    <input id="id_first_name" type="text" name="first_name" />
    <input id="id_first_name" type="text" name="last_name" />
</div>
<div class="form_row">
    <label for="id_email">Email:</label>
    <input type="text" name="email" id="id_email"/>
</div>
<div class="form_row">
    <label for="id_password">Password:</label>
    <input id="id_password" type="password" name="password" />
</div>
Run Code Online (Sandbox Code Playgroud)

结果如下:

替代文字

css forms tablelayout

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

Rails 3:Google Apps/Heroku的SMTP设置

以下是setup_mail.rb中Google Apps的smtp设置.

  :address              => "smtp.gmail.com",  
  :port                 => 587,                 
  :domain               => 'mysite.co',  
  :user_name            => 'noreply@mysite.co',      
  :password             => 'password',      
  :authentication       => 'plain',             
  :enable_starttls_auto => true
Run Code Online (Sandbox Code Playgroud)

我的开发日志详细显示了生成的电子邮件并发送到正确的电子邮件地址......但它们没有到达.我只能认为上面的设置一定有问题.你能看出问题所在吗?

一旦解决了这个问题,我有什么问题可以让它在Heroku上运行吗?


注意:以上是记录弃用警告:

DEPRECATION WARNING: Giving a hash to body is deprecated, please use instance va
riables instead. (called from process at C:/Sanj/Ruby192/lib/ruby/gems/1.9.1/gem
s/actionmailer-3.0.0/lib/action_mailer/old_api.rb:77)
Run Code Online (Sandbox Code Playgroud)

smtp ruby-on-rails actionmailer heroku ruby-on-rails-3

6
推荐指数
3
解决办法
9853
查看次数

模板化代码如何在C++中找到类型为模板参数的字符串的长度?

考虑以下代码:

template <typename T>
class String
{
public:
    ...
 String(T* initStr)
 {
  size_t initStrLen;
  if (initStr != NULL)
  {
   printf_s("%s\n", typeid(T) == typeid(char) ? "char" : "wchar_t");

   if (typeid(T) == typeid(char))
   {
    strlen((T*)initStr);
   }
   else if (typeid(T) == typeid(wchar_t))
   {
    wcslen((T*)initStr);
   }
  }
 }  
    ...
};
Run Code Online (Sandbox Code Playgroud)

当我编译代码时,我收到此错误消息:

...\main.cpp(32):错误C2664:'strlen':无法将参数1从'wchar_t*'转换为'const char*'

然后我尝试使用函数指针:

typedef size_t (*STRLEN)(void*);
STRLEN _strlen;
_strlen = reinterpret_cast<STRLEN> (typeid(*initStr) == typeid(char) ? strlen : wcslen);
Run Code Online (Sandbox Code Playgroud)

并且编译器再次发出错误,这次:

...\main.cpp(28):错误C2446:':':没有从'size_t(__ cdecl*)(const wchar_t*)'转换为'size_t(__ cdecl*)(const char*)'

我的问题是,我如何使用这些功能strlenwcslen模板?

c++ templates

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