小编Ale*_* P.的帖子

Delphi TFrame创建/销毁

如何创建(当我想要显示它)并在主TForm上销毁(当我想隐藏它时)帧?帧'align = alClient.

我试过这个:

表格:

unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, uFrame1, uFrame2;

type
  TFormMain = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    f1: TFrame1;
    f2: TFrame2;
  end;

var
  FormMain: TFormMain;

implementation

{$R *.dfm}

procedure TFormMain.FormCreate(Sender: TObject);
begin
  f1 := TFrame1.Create(Self);
  f1.Parent := Self;
end;

end.
Run Code Online (Sandbox Code Playgroud)

第一帧:

unit uFrame1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

type
  TFrame1 = class(TFrame) …
Run Code Online (Sandbox Code Playgroud)

delphi freepascal frame lazarus

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

文档在DocumentReady事件中没有准备好?

我正在使用Awesomium 1.7.0.5来加载页面,填充一些文本框并单击按钮.我正在尝试使用此主题中的示例来填充文本框:http://answers.awesomium.com/questions/857/webcontrol-type-in​​-webbrowser.html

这是我的代码(我正在使用WPF控件):

        private void WbAwsOnDocumentReady(object sender, UrlEventArgs urlEventArgs)
        {
            if (wbAws == null || !wbAws.IsLive)
              return;

            //Thread.Sleep(555);

            dynamic document = (JSObject)wbAws.ExecuteJavascriptWithResult("document");

            if (document == null)
              return;

            using (document)
            {
                dynamic textbox = document.getElementById("email");

                if (textbox == null)
                  return;

                using (textbox)
                {
                    textbox.value = "gaaffa"; 
                }

            }
        }
Run Code Online (Sandbox Code Playgroud)

它可以工作,但只能使用Thread.Sleep 0.1-0.5秒.否则,文档为空(非空)和/或文本框为空.我该怎么办?为什么在DocumentReadyEvent中没有准备好?

.net c# awesomium

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

停止shutil.make_archive 向自身添加存档

我在Appdir 里面有Releasedir

$ cd Release
$ tree
.
`-- App
    |-- App.exe
    ..........
Run Code Online (Sandbox Code Playgroud)

我试图App-1.0.zipRelease包含App所有内容的目录中创建。那是在解包之后App-1.0.zip我会得到这个App目录。

我试过了,shutil.make_archive但是当我这样做时

import shutil

shutil.make_archive('App-1.0', 'zip', '.')
Run Code Online (Sandbox Code Playgroud)

Release目录,我得到48字节App-1.0.zipApp-1.0.zip除了App目录。也就是说,它将这个未完成的档案添加到自己身上。

除了在临时目录中创建存档并移动之外,有没有办法避免这种情况?

我试图设置base_dir和使用App作为root_dir

shutil.make_archive('App-1.0', 'zip', 'App', 'App')
Run Code Online (Sandbox Code Playgroud)

但是我App在设置时遇到了未找到的错误base_dir

Traceback (most recent call last):
  File ".......archive.py", line 4, in <module>
    shutil.make_archive('App-1.0', 'zip', 'App', 'App')
  File "C:\Users\Alex\.virtualenvs\....-nAKWzegL\lib\shutil.py", line 800, …
Run Code Online (Sandbox Code Playgroud)

python archive shutil python-3.x

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

为什么复制如果更新不仅替换输出目录中的文件较旧?

当我向项目添加Access DB文件并将其设置为Copy for newer时,我发现了这个问题: 在此输入图像描述

我认为只有当输出目录中的文件比项目目录中的文件旧时才会将其复制到输出目录.

事实上,即使输出目录中的文件较新,它也会被复制:例如,当我编辑并通过我的程序保存它时.

我还使用另一种文件(.txt)在另一个项目中测试了它.

MSDN

如果要复制文件,只有在文件比输出目录中的同名现有文件更新时,才选择"如果更新则复制".

这是一个错误还是我做错了什么?

c# visual-studio-2010 visual-studio visual-studio-2012

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

Delphi如何更快地搜索二进制文件?

我有一个二进制文件(2.5 MB),我想找到这个字节序列的位置:CD 09 D9 F5.然后我想在这个位置后写一些数据,并用零覆盖旧数据(4 KB).

这是我现在的方式,但它有点慢.

ProcessFile(dataToWrite: string);
var
  fileContent: string;
  f: file of char;
  c: char;
  n, i, startIndex, endIndex: integer;
begin
  AssignFile(f, 'file.bin');
  reset(f);
  n := FileSize(f);
  while n > 0 do
  begin
    Read(f, c);
    fileContent := fileContent + c;
    dec(n);
  end;
  CloseFile(f);

  startindex := Pos(Char($CD)+Char($09)+Char($D9)+Char($F5), fileContent) + 4;
  endIndex := startIndex + 4088;

  Seek(f, startIndex);

  for i := 1 to length(dataToWrite) do
    Write(f, dataToWrite[i]);

  c := #0;
  while (i < endIndex) do
  begin
    Write(f, c); inc(i); …
Run Code Online (Sandbox Code Playgroud)

delphi binaryfiles delphi-7

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

如何在布局中的项目上使用 ColorOverlay?

我有RowLayout一些物品

RowLayout {
    anchors.fill: parent
    anchors.leftMargin: 3

    Image {
        id: icon
        source: imgSource
        sourceSize: Qt.size(parent.width, parent.height)
        smooth: true
    }

    Text {
        id: caption
        height: parent.height
        fontSizeMode: Text.Fit
        font.pointSize: textSize
        verticalAlignment: Text.AlignVCenter
        text: captionText
        color: "white"
    }
} 
Run Code Online (Sandbox Code Playgroud)

我想ColorOverlayImage这个布局中应用:

ColorOverlay {
    id: overlay
    anchors.fill: icon
    source: icon
    color: "#ff0000ff"
}
Run Code Online (Sandbox Code Playgroud)

但如果我把它放在ColorOverlay布局之外,那么我就不能使用anchors.fill: icon. 如果我把它变成一个孩子

    Image {
        id: icon
        source: imgSource
        sourceSize: Qt.size(parent.width, parent.height)
        smooth: true  
        ColorOverlay {
            id: overlay
            anchors.fill: icon
            source: …
Run Code Online (Sandbox Code Playgroud)

qt qml qt-quick qt5 qtquick2

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

为什么我的ObservableCollection序列化不起作用?

我正在尝试序列化和反序列化此ObservableCollection:

public class DataCollection : ObservableCollection<Data>
{
}

public class Data : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private bool? _enabled;

    public string Name { get; set; }
    public bool? Enabled 
    {
        get { return _enabled; }
        set { _enabled = value; NotifyPropertyChanged("Enabled"); }
    }

    public Data(string name, bool? enabled)
    {
        this.ScriptName = name;
        this.Enabled = enabled;
    }

    private void NotifyPropertyChanged(string property)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(property));
    }
}
Run Code Online (Sandbox Code Playgroud)

使用此类(如将对象的Observable collectin保存到XML文件的最简单方法什么?示例):

class UserPreferences …
Run Code Online (Sandbox Code Playgroud)

.net c# xml wpf xml-serialization

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

使用/进口Laravel外墙的正确方法是什么?

导入外墙命名空间的正确方法是什么(例如Hash::make)?

我需要使用导入use Illuminate\Support\Facades\Hash吗?

我看到有些人使用它们\Hash::make(来自命名空间文件,例如默认创建的控制器)或Hash::make(来自非命名空间的文件,例如路由).

此外IDE辅助生成的根命名空间外墙:

namespace {
exit("This file should not be included, only analyzed by your IDE");

class Hash extends \Illuminate\Support\Facades\Hash{        
    /** ... */
    public static function make($value, $options = array()){
        return \Illuminate\Hashing\BcryptHasher::make($value, $options);
    }
Run Code Online (Sandbox Code Playgroud)

但我不明白为什么它的工作原理如果这个类在Illuminate\Support\Facades\命名空间中,而不是在根命名空间中.

php namespaces laravel laravel-5 laravel-5.3

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

ANTLR if-else 歧义错误

我正在尝试为简单的编程语言创建 ANTLR 语法。

它有类似 C 的 if 语句:

program
    : statement* EOF
    ;

statement
    : block                                                                 # blockStatement
    | SEMI                                                                  # emptyStatement
    | assignment                                                            # assignmentStatement
    | declaration                                                           # variableDeclarationStatement
    | 'if' parExpression ifBody=statement ('else' elseBody=statement)?      # ifStatement
    ..........
    ;

block
    : '{' statement* '}'
    ;

expression
    : literal                                                           # literalExpression
    | Identifier                                                        # variableReference
    ..........
    ;

parExpression : '(' expression ')';

assignment : Identifier assignmentOp expression SEMI;

SEMI : ';';

Identifier : (LETTER | '_') (LETTER | DIGIT | …
Run Code Online (Sandbox Code Playgroud)

compiler-construction grammar antlr antlr4

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

Qt/Windows,可调整大小的无框窗口

我需要创建一个支持调整大小的无框架 Qt Windows 应用程序。

如果我使用

setWindowFlags(Qt::FramelessWindowHint);
Run Code Online (Sandbox Code Playgroud)

然后我只能从右下角调整大小(就像大小手柄一样,我猜 QMainWindow 以某种方式包含它?)。

有没有什么简单的方法可以让它像普通窗口一样从四面八方调整大小?也许是特定于平台的(Windows)?

c++ winapi qt

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