小编aki*_*kif的帖子

将图标放在表单中的input元素内

如何在表单的输入元素中放置一个图标?

具有三个输入的Web表单的屏幕截图,其中包含图标

现场版:潮汐力主题

css forms icons element input

249
推荐指数
12
解决办法
55万
查看次数

将XmlDocument转换为String

以下是我目前正在将XMLDocument转换为String的方法

StringWriter stringWriter = new StringWriter();
XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);

xmlDoc.WriteTo(xmlTextWriter);

return stringWriter.ToString();
Run Code Online (Sandbox Code Playgroud)

这种方法的问题是如果我有"((引用)我在属性中)它会逃脱它们.

例如:

<Campaign name="ABC">
</Campaign>
Run Code Online (Sandbox Code Playgroud)

以上是预期的XML.但它回来了

<Campaign name=\"ABC\">
</Campaign>
Run Code Online (Sandbox Code Playgroud)

我可以做String.Replace"\"但是这个方法好吗?有没有什么副作用?如果XML本身包含"\",它会正常工作吗?

c# string quotes xmldocument escaping

206
推荐指数
4
解决办法
24万
查看次数

C++重定义头文件(winsock2.h)

如何防止包含两次头文件?问题是我包括了MyClass.h中然后我将MyClass.h包含在许多文件中,因此它包含多次并发生重定义错误.怎么预防?

我正在使用#pragma而不是包含警卫,我想这很好.

MyClass.h:

// MyClass.h
#pragma once

#include <winsock2.h>

class MyClass
{

// methods
public:
 MyClass(unsigned short port);
 virtual ~MyClass(void);
};
Run Code Online (Sandbox Code Playgroud)

编辑:我得到的错误很少

c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(460) : see previous definition of 'AF_IPX'
c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(124) : warning C4005: 'AF_MAX' : macro redefinition
        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(479) : see previous definition of 'AF_MAX'
c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(163) : warning C4005: 'SO_DONTLINGER' : macro redefinition
        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(402) : …
Run Code Online (Sandbox Code Playgroud)

c++ header redefinition

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

在C++中使用指向动态分配对象的指针向量时,如何避免内存泄漏?

我正在使用一个指向对象的向量.这些对象派生自基类,并且正在动态分配和存储.

例如,我有类似的东西:

vector<Enemy*> Enemies;
Run Code Online (Sandbox Code Playgroud)

我将从Enemy类派生,然后为派生类动态分配内存,如下所示:

enemies.push_back(new Monster());
Run Code Online (Sandbox Code Playgroud)

为了避免内存泄漏和其他问题,我需要注意哪些事项?

c++ pointers stl vector derived

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

预编译标题

我有一个示例项目(不是我的)在Visual C++ 6中.我正在尝试将其转换为Visual Studio 2008.

旧项目使用预编译头.现在的问题是:

  1. 什么是预编译头文件?

  2. 由于旧项目使用预编译头.我还将在Visual Studio 2008(新项目)中使用它们.但我得到的错误是"你忘了包含stdafx.h",为了解决这个问题,我在每个源文件中加入了"stdafx.h".这非常有效.但是旧项目在每个文件中都没有包含"stdafx.h"?那么如何选择退出在每个源文件中包含"stdafx.h".因为不是每个源文件都需要"stdafx.h"中定义的包含文件,所以只有少数文件.怎么做的?

编辑: 如何使用预先设定的标题来解释某些文件?

visual-c++-6 precompiled-headers visual-studio-2008

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

DateTime比较精度

我正在进行DateTime比较,但我不想在秒,毫秒和刻度级别进行比较.什么是最优雅的方式?

如果我只是比较DateTime,那么由于滴答差异,它们很少相等.

c# comparison datetime

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

CreateProcess不传递命令行参数

您好我有以下代码,但它没有按预期工作,无法弄清楚问题是什么.

基本上,我正在执行一个进程(一个.NET进程)并传递它的命令行参数,它由CreateProcess()成功执行但CreateProcess()没有传递命令行参数

我在这做错了什么?

int main(int argc, char* argv[])
{
    PROCESS_INFORMATION ProcessInfo; //This is what we get as an [out] parameter

    STARTUPINFO StartupInfo; //This is an [in] parameter

    ZeroMemory(&StartupInfo, sizeof(StartupInfo));
    StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field

    LPTSTR cmdArgs = "name@example.com";

    if(CreateProcess("D:\\email\\smtp.exe", cmdArgs, 
        NULL,NULL,FALSE,0,NULL,
        NULL,&StartupInfo,&ProcessInfo))
    { 
        WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
        CloseHandle(ProcessInfo.hThread);
        CloseHandle(ProcessInfo.hProcess);

        printf("Yohoo!");
    }  
    else
    {
        printf("The process could not be started...");
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编辑:嘿,还有一件事,如果我这样通过我cmdArgs:

// a space as the first character
LPTSTR cmdArgs = " name@example.com";
Run Code Online (Sandbox Code Playgroud)

然后我得到错误,然后CreateProcess返回 …

c++ winapi createprocess

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

FILETIME到__int64

FILETIME结构转换为什么的正确方法是什么__int64?你能告诉我吗?

c++ int64

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

打开其他程序的配置文件

我有一个程序A,它还有一个app.config文件,我在其中添加了一些密钥,如服务器地址,用户名和密码,用于连接服务器.它是一个控制台应用程序.现在我想制作一个我已经完成的UI.在那个UI中,我想修改程序A的app.config的内容.我怎么做?

这是我尝试的,我将UI(基本上是.exe)复制到程序A的目录,app.config也驻留在该目录中.然后在UI中,我使用ConfigurationManager类的OpenExeConfiguration方法,并将程序A的文件名作为参数传递.但它抛出类型System.Configuration.ConfigurationErrorsException的异常.

所以我认为我的方法不正确.我该怎么办?

编辑:哦,我忘了告诉我正在使用C#,.NET 3.5和VS 2008(如果有帮助:D)

.net c# configurationmanager app-config

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

通过C#启动的PowerPoint不会退出

嘿,我是从C#WinForms应用程序自动化PowerPoint和Excel; 我所做的是从PowerPoint中读取幻灯片并将其保存在Excel中,然后退出这两个应用程序.Excel已成功退出,但PowerPoints未退出.问题是,当我第一次转换它不退出时,但当我再次转换时它确实.

这是我的代码

try
{
    PowerPoint.Application ppApp;
    PowerPoint.Presentation ppPres;
    List<Company> companies = new List<Company>();

    ppApp = new PowerPoint.Application();
    ppApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
    ppApp.WindowState = Microsoft.Office.Interop.PowerPoint.PpWindowState.ppWindowMinimized;

    ppPres = ppApp.Presentations.Open(fileTxtBox.Text,
                                      Microsoft.Office.Core.MsoTriState.msoFalse,
                                      Microsoft.Office.Core.MsoTriState.msoFalse,
                                      Microsoft.Office.Core.MsoTriState.msoTrue);

    int slides = ppPres.Slides.Count;

    for (int slide = 1; slide <= slides; slide++)
    {
        int rows = 1;
        PowerPoint.Cell cell;
        int shape = 1;

        for (; shape < ppPres.Slides[slide].Shapes.Count; shape++)
        {
            if (ppPres.Slides[slide].Shapes[shape].HasTable == Microsoft.Office.Core.MsoTriState.msoTrue)
            {
                cell = ppPres.Slides[slide].Shapes[shape].Table.Cell(1, 1);

                if (cell.Shape.TextFrame.TextRange.Text.Trim().ToLower().Contains("realized"))
                {
                    rows = ppPres.Slides[slide].Shapes[shape].Table.Rows.Count;
                    break;
                }
            }
        } …
Run Code Online (Sandbox Code Playgroud)

c# com powerpoint

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