首页 \ 问答 \ memo.lines.add的问题(problems with memo.lines.add)

memo.lines.add的问题(problems with memo.lines.add)

我正在尝试制作一个聊天应用程序,将消息发布到以下形式的备忘录中:

USERNAME-> Message

但它是这样贴在我的备忘录上的:

USERNAME

这是我的代码:

const
  cnMaxUserNameLen = 254;
var
  sUserName: string;
  dwUserNameLen: DWORD;
  text : string;
begin
  dwUserNameLen := cnMaxUserNameLen - 1;
  SetLength(sUserName, cnMaxUserNameLen);
  GetUserName(PChar(sUserName), dwUserNameLen);
  SetLength(sUserName, dwUserNameLen);

  text:= sUserName + '-> ' + edit1.Text;
  memo1.Lines.Add(text);

有关如何解决它的任何建议?


I am trying to make a chat application that will post a message into a memo in the form like this:

USERNAME-> Message

but it is posting to my memo like this:

USERNAME

Here is my code:

const
  cnMaxUserNameLen = 254;
var
  sUserName: string;
  dwUserNameLen: DWORD;
  text : string;
begin
  dwUserNameLen := cnMaxUserNameLen - 1;
  SetLength(sUserName, cnMaxUserNameLen);
  GetUserName(PChar(sUserName), dwUserNameLen);
  SetLength(sUserName, dwUserNameLen);

  text:= sUserName + '-> ' + edit1.Text;
  memo1.Lines.Add(text);

Any suggestions on how to fix it?


原文:https://stackoverflow.com/questions/8218628
更新时间:2022-02-21 15:02

最满意答案

好; 更复杂的答案:

public static IEnumerable<T> Intersect<T>(params IEnumerable<T>[] enums) {
    return Intersect<T>(null, enums);
}
public static IEnumerable<T> Intersect<T>(IComparer<T> comparer, params IEnumerable<T>[] enums) {
    if(enums == null) throw new ArgumentNullException("enums");
    if(enums.Length == 0) return Enumerable.Empty<T>();
    if(enums.Length == 1) return enums[0];
    if(comparer == null) comparer = Comparer<T>.Default;
    return IntersectImpl(comparer, enums);
}
public static IEnumerable<T> IntersectImpl<T>(IComparer<T> comparer, IEnumerable<T>[] enums) {
    IEnumerator<T>[] iters = new IEnumerator<T>[enums.Length];
    try {
        // create iterators and move as far as the first item
        for (int i = 0; i < enums.Length; i++) {
            if(!(iters[i] = enums[i].GetEnumerator()).MoveNext()) {
                yield break; // no data for one of the iterators
            }
        }
        bool first = true;
        T lastValue = default(T);
        do { // get the next item from the first sequence
            T value = iters[0].Current;
            if (!first && comparer.Compare(value, lastValue) == 0) continue; // dup in first source
            bool allTrue = true;
            for (int i = 1; i < iters.Length; i++) {
                var iter = iters[i];
                // if any sequence isn't there yet, progress it; if any sequence
                // ends, we're all done
                while (comparer.Compare(iter.Current, value) < 0) {
                    if (!iter.MoveNext()) goto alldone; // nasty, but
                }
                // if any sequence is now **past** value, then short-circuit
                if (comparer.Compare(iter.Current, value) > 0) {
                    allTrue = false;
                    break;
                }
            }
            // so all sequences have this value
            if (allTrue) yield return value;
            first = false;
            lastValue = value;
        } while (iters[0].MoveNext());
    alldone:
        ;
    } finally { // clean up all iterators
        for (int i = 0; i < iters.Length; i++) {
            if (iters[i] != null) {
                try { iters[i].Dispose(); }
                catch { }
            }
        }
    }
}

OK; more complex answer:

public static IEnumerable<T> Intersect<T>(params IEnumerable<T>[] enums) {
    return Intersect<T>(null, enums);
}
public static IEnumerable<T> Intersect<T>(IComparer<T> comparer, params IEnumerable<T>[] enums) {
    if(enums == null) throw new ArgumentNullException("enums");
    if(enums.Length == 0) return Enumerable.Empty<T>();
    if(enums.Length == 1) return enums[0];
    if(comparer == null) comparer = Comparer<T>.Default;
    return IntersectImpl(comparer, enums);
}
public static IEnumerable<T> IntersectImpl<T>(IComparer<T> comparer, IEnumerable<T>[] enums) {
    IEnumerator<T>[] iters = new IEnumerator<T>[enums.Length];
    try {
        // create iterators and move as far as the first item
        for (int i = 0; i < enums.Length; i++) {
            if(!(iters[i] = enums[i].GetEnumerator()).MoveNext()) {
                yield break; // no data for one of the iterators
            }
        }
        bool first = true;
        T lastValue = default(T);
        do { // get the next item from the first sequence
            T value = iters[0].Current;
            if (!first && comparer.Compare(value, lastValue) == 0) continue; // dup in first source
            bool allTrue = true;
            for (int i = 1; i < iters.Length; i++) {
                var iter = iters[i];
                // if any sequence isn't there yet, progress it; if any sequence
                // ends, we're all done
                while (comparer.Compare(iter.Current, value) < 0) {
                    if (!iter.MoveNext()) goto alldone; // nasty, but
                }
                // if any sequence is now **past** value, then short-circuit
                if (comparer.Compare(iter.Current, value) > 0) {
                    allTrue = false;
                    break;
                }
            }
            // so all sequences have this value
            if (allTrue) yield return value;
            first = false;
            lastValue = value;
        } while (iters[0].MoveNext());
    alldone:
        ;
    } finally { // clean up all iterators
        for (int i = 0; i < iters.Length; i++) {
            if (iters[i] != null) {
                try { iters[i].Dispose(); }
                catch { }
            }
        }
    }
}

相关问答

更多
  • 以下是我可以按照个人喜好的降序排列的选项。 使用静态检查而不是运行时检查。 这样就不必枚举列表来进行检查。 该选项具有极其昂贵的限制。 我自己也无法访问静态检查程序,就像我希望的那样。 所以,你可以...... 在未来日期的预留中更改方法的定义以使其正常工作,以便不需要检查。 喜欢这个: void ProcessSchedules(IEnumerable schedules) { Contract.Requires(schedul ...
  • 以下想法如何: 创建优先级队列 通过每个文件迭代f 排队对(nextNumberIn(f),f)使用第一个值作为优先级键 而队列不为空 排队头(m,f) 输出m 如果f没有耗尽 入队(nextNumberIn(f),f) 由于可以在对数时间内对优先级队列添加元素,所以项2是O(N×log N) 。 由于while循环的(几乎全部)迭代添加了一个元素,整个while循环是O(M×log N) ,其中M是要排序的数字的总数。 假设所有文件都有非空序列,我们有M> N ,因此整个算法应该是O(M×log N) 。 ...
  • players.transpose.map {|a| a.join(" ")} players.transpose.map {|a| a.join(" ")}
  • 由于intersect1d每次排序数组,因此效率很低。 在这里,您必须将交叉点和每个样本扫描在一起以构建新的交叉点,这可以在线性时间内完成,从而保持顺序。 这种任务通常必须通过低级别例程手动调整。 这里有一种方法可以用numba做到这一点: from numba import njit import numpy as np @njit def drop_missing(intersect,sample): i=j=k=0 new_intersect=np.empty_like(inters ...
  • 好; 更复杂的答案: public static IEnumerable Intersect(params IEnumerable[] enums) { return Intersect(null, enums); } public static IEnumerable Intersect(IComparer comparer, params IEnumerable[] enums) { if(enums == null) throw new ...
  • 如果您创建一个序列相等比较器,如下所示: class SequenceEqualityComparer : IEqualityComparer> { public bool Equals(IEnumerable a, IEnumerable b) { if (a == null) return b == null; if (b == null) return false; return a.Sequenc ...
  • 显然,你的模型的设置方式( Menu has_many categories , Category has_many dishes ),如果你要在同一个视图中显示所有这些信息,你没有别的办法,而只是循环遍历它们并显示所需的数据你的观点很好,恕我直言。 我没有看到任何问题。 只需一个提示,在循环关联模型的数据时,您只需要注意始终为关联的模型属性提供数据,否则您可能会获得undefined method 'method_name' for nil:NilClass一些的undefined method 'met ...
  • 2个平面的交点是一条线。 3个平面的交点是3D空间中的一个点。 因此,在所有平面中,选择任意3个平面并找到它们的交点。 所有其他平面(如果它们确实在同一点交叉)也将在此点相交。 这就是你要找的地方! The intersection of 2 planes is a line. The intersection of 3 planes is a point in the 3D space. So, of all the planes, select any 3 planes and find their p ...
  • 只需使用std::set_intersection()几次。 我认为你需要两个临时矢量来交替使用来存储结果。 如果你想只使用每个向量的一次传递,你只需使用它的通用版本,可能保留当前最小值的优先级队列。 Just use std::set_intersection() a couple of time. I think you'd need two temporary vectors used alternatingly to store the results. If you want to do it w ...
  • 第一个挑战是使功能正确。 一旦它是正确的,我们可以担心速度。 有一些东西可以绊倒像这样的函数: 为NaN 糟糕的限制 重复的数字 只有1个输入数组(或者根本没有) 您的原始函数可以处理重复的数字,例如[[9,9,9,9],[9,9,9]],但如果任何值是NaN,则会陷入无限循环,并处理0的限制为如果没有任何限制。 这是我的(Mk3)尝试: function intersection( arrs, limit ) { var result = [], posns = []; var j, v, ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)