小编Kos*_*mos的帖子

当浏览器窗口最大化后恢复时,为什么我的高度修复代码工作错误?

<!DOCTYPE html>
<html style = 'height: 100%;'>
    <head>
        <title>test manual height calculations</title>
    </head> 

    <script type = 'text/javascript'>
        window.onresize = fixHeighs;

        function endsWith(str, suffix)
        {
            if (!str)
                return false;

            return str.indexOf(suffix, str.length - suffix.length) !== -1;
        }

        function fixHeighs(start_elem)
        {
            if (start_elem && start_elem.target) // if this is event, then make var null
                start_elem = null;            

            var curr_elem = start_elem ? start_elem : document.body; // determine what element we should check now
            var neededHeight = curr_elem.getAttribute("data-neededHeight"); // get data-neededHeight attribute

            if …
Run Code Online (Sandbox Code Playgroud)

html javascript css height

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

如何捕获输入的类型 = 'text' 清除事件?

<input type='text' onchange="reportAnswer(1, this.value);" onkeyup="this.onchange();" onpaste="this.onchange();" oncut="this.onchange();" onclear = "this.onchange();" />

在此处输入图片说明

如何捕捉这种变化?这是IE11。

PS我添加了onclear处理程序,因为没有想法该怎么做。

html javascript textbox input

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

在C++中是否可以从主线程中执行辅助线程中运行的函数?

例如,我有一个主线程,创建了很多类等.我有一个网络部分,即在单独的线程中等待客户端数据.这个"服务员"应该从主线程中创建的类中运行一些函数,这个函数应该在主线程中执行.

我怎么能这样做?如果我SomeClass::SomeMethod(some_args);从服务员这样调用所需的方法,当然,它们在辅助线程中执行.

会有这样的事情: SomeClass::Invoke(function_pointer);所以,function_pointer指向的函数会在主线程中执行吗?我需要一个关于Windows操作系统的建议.

c++ multithreading

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

在父类中声明虚函数时,为什么会出现未解析的外部错误?

我有这个父类:

enum UI_STATE
{
    UI_STATE_SPLASH_SCREEN,
    UI_STATE_LOGIN_SCREEN,
    UI_STATE_CHARACTER_CREATION_SCREEN,
    UI_STATE_CHARACTER_CHOOSE_SCREEN,
    UI_STATE_LOADING_SCREEN,
    UI_STATE_GAMEPLAY,
    UI_STATE_EXIT_REQUESTED,
    UI_STATE_UNKNOWN
};

[event_source(native)]
class UserInterface
{
protected:
    MyGUI::Gui *mGUI;

public:
    static UserInterface *Instance;
    UI_STATE UI_CURRENT_STATE;

public:
    UserInterface()
    {
        MyGUI::OgrePlatform* mPlatform = new MyGUI::OgrePlatform();
        mPlatform->initialise(BaseObjects::mWindow, BaseObjects::mSceneMgr);
        mGUI = new MyGUI::Gui();
        mGUI->initialise();

        UI_CURRENT_STATE = UI_STATE_UNKNOWN;
    }

    ~UserInterface()
    {
        mGUI->destroyAllChildWidget();
        mGUI->shutdown();

        delete mGUI;
        mGUI = NULL;

        delete Instance;
        Instance = NULL;
    }

    virtual void update();
    virtual void GAMEPLAY_SCREEN_ShowTargetBox();
    virtual void GAMEPLAY_SCREEN_HideTargetBox();

...//some other methods
}

UserInterface *UserInterface::Instance = NULL;
Run Code Online (Sandbox Code Playgroud)

还有两个子类,其中一个是覆盖这3个虚函数,第二个对这3个函数什么都不做.

孩子1:

#ifndef …
Run Code Online (Sandbox Code Playgroud)

c++ virtual class function parent

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

为什么重写ToString()时,当项目添加到ComboBox时,不返回我想要的内容?

public partial class TestConrol : UserControl
{
    public TestConrol()
    {
        InitializeComponent();
    }

    public override string ToString()
    {
        return "asd";
    }
}

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        TestConrol tc1 = new TestConrol();
        comboBox1.Items.Add(tc1);

        TestConrol tc2 = new TestConrol();
        comboBox1.Items.Add(tc2);
    }
}
Run Code Online (Sandbox Code Playgroud)

当表单加载时,我看到combobox有两个空名称的项目,而不是"asd":/
但如果我在公共类中重写ToString(),而不是从任何东西派生,这个工作:

public class TestClass
{
    public override string ToString()
    {
        return "bla bla bla";
    }
}

public partial class Form1 : Form
{
    public Form1() …
Run Code Online (Sandbox Code Playgroud)

c# combobox overriding tostring

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

如何使 ColorDialog 允许设置所选颜色的透明度?

我没有看到任何可用的字段。我尝试了这一切:

        ColorDialog cd = new ColorDialog();
        cd.AnyColor = true;
        cd.AllowFullOpen = true;
        cd.SolidColorOnly = false;   
Run Code Online (Sandbox Code Playgroud)

但它可能还有其他作用。

如果使用 win 表单控件无法做到这一点,也许我可以在 WPFHost 元素中使用 WPF 颜色选择器?

.net c# color-picker winforms

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

是否可以使用C#DllImport从DLL导入非托管类或结构?

正如msdn http://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx所说"平台调用服务(PInvoke)允许托管代码调用DLL中实现的非托管函数. "

我想从我在c ++中创建的DLL导入一些类
是否可能以及如何?

例如,我在DLL中有一些结构:

struct __declspec(dllexport) DLLVector3
{
    float x, y, z;
};

struct __declspec(dllexport) DLLQuaternion
{
    float x, y, z, w;
};

class __declspec(dllexport) DLLCharacter
{
public:
    DLLVector3 position;
    DLLQuaternion orientation;

    DLLCharacter()
    {

    }

    ~DLLCharacter()
    {

    }

    void setPosition(PxVec3 pos)
    {
        position.x = pos.x;
        position.y = pos.y;
        position.z = pos.z;
    }

    void setOrientation(PxQuat or)
    {
        orientation.x = or.x;
        orientation.y = or.y;
        orientation.z = or.z;
        orientation.w = or.w;
    }
};

struct __declspec(dllexport) PhysicalObject
{
    DLLCharacter *character; …
Run Code Online (Sandbox Code Playgroud)

c# c++ dll class dllimport

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

如何得到类似的结果,如同Thread.Sleep支持双值?

有时我需要睡眠非整数毫秒,但无法找到一种方法.例如,如果我想睡半毫秒,我想这样做:

Thread.Sleep(0.5);
Run Code Online (Sandbox Code Playgroud)

但不能,因为Sleep只支持整数.

c# double multithreading sleep milliseconds

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

如何在不重新插入的情况下刷新ListBox中的项目文本?

我有类TestClass已经ToString重写(它返回Name场).我有TestClass添加的实例,ListBox在某些时候我需要更改Name其中一个实例,然后我可以刷新它的文本ListBox

using System;
using System.Windows.Forms;

namespace TestListBox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            listBox1.Items.Add(new TestClass("asd"));
            listBox1.Items.Add(new TestClass("dsa"));
            listBox1.Items.Add(new TestClass("wqe"));
            listBox1.Items.Add(new TestClass("ewq"));
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ((TestClass)listBox1.Items[0]).Name = "123";
            listBox1.Refresh(); // doesn't help
            listBox1.Update(); // same of course
        }
    }

    public class TestClass
    {
        public string Name;

        public TestClass(string …
Run Code Online (Sandbox Code Playgroud)

.net c# listbox tostring

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

当字段名称是“short”等保留关键字时,如何使用 Newtonsoft 反序列化 JSON 对象?

我有一些 JSON 对象:

"opf": {
                "type": "2014",
                "code": "12247",
                "full": "????????? ??????????? ????????",
                "short": "???"
            }
Run Code Online (Sandbox Code Playgroud)

我希望它将它反序列化到我的班级中:

class SuggestionInfoDataOpf
{
    public string code;
    public string full;
    public string short; //ERROR. Of course I can't declare this field
    public string type;
}
Run Code Online (Sandbox Code Playgroud)

怎么办?.. 我想像这样反序列化它:Newtonsoft.Json.JsonConvert.DeserializeObject<SuggestionInfoDataOpf>(json_str);,但字段名称应该匹配。

.net c# reserved-words json.net json-deserialization

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